Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
state.qc File Reference
Include dependency graph for state.qc:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void accuracy_free (entity this)
void accuracy_init (entity this)
 init/free
void anticheat_init (entity this)
void anticheat_report_to_eventlog (entity this)
void bot_clientconnect (entity this)
void bot_clientdisconnect (entity this)
void ClientData_Attach (entity this)
void ClientData_Detach (entity this)
void ClientState_attach (entity this)
void ClientState_detach (entity this)
void DecodeLevelParms (entity this)
void entcs_attach (entity this)
void entcs_detach (entity this)
void Inventory_clear (PlayerState this)
void Inventory_delete (entity this)
void Inventory_new (PlayerState this)
void InventoryStorage_attach (PlayerState this)
void InventoryStorage_delete (PlayerState this)
void PlayerScore_Attach (entity this)
void PlayerScore_Detach (entity this)
void PlayerState_attach (entity this)
void PlayerState_detach (entity this)
void W_HitPlotClose (entity this)
void W_HitPlotOpen (entity this)

Function Documentation

◆ accuracy_free()

void accuracy_free ( entity this)

Definition at line 58 of file accuracy.qc.

59{
60 delete(CS(e).accuracy);
61}
ClientState CS(Client this)
Definition state.qh:47

References CS(), and entity().

Referenced by ClientState_detach().

◆ accuracy_init()

void accuracy_init ( entity this)

init/free

Definition at line 50 of file accuracy.qc.

51{
52 entity a = CS(e).accuracy = new_pure(accuracy);
53 a.owner = e;
54 a.drawonlytoclient = e;
55 Net_LinkEntity(a, false, 0, accuracy_send);
56}
bool accuracy_send(entity this, entity to, int sf)
Definition accuracy.qc:26
entity accuracy
Definition accuracy.qh:26
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
void Net_LinkEntity(entity e, bool docull, float dt, bool(entity this, entity to, int sendflags) sendfunc)
Definition net.qh:123
#define new_pure(class)
purely logical entities (not linked to the area grid)
Definition oo.qh:67

References accuracy, accuracy_send(), CS(), entity(), Net_LinkEntity(), and new_pure.

Referenced by ClientState_attach().

◆ anticheat_init()

void anticheat_init ( entity this)

Definition at line 256 of file anticheat.qc.

257{
258 CS(this).anticheat_speedhack_offset = 0;
259 CS(this).anticheat_jointime = servertime;
260}
float servertime
Definition net.qh:348

References CS(), entity(), and servertime.

Referenced by ClientState_attach().

◆ anticheat_report_to_eventlog()

void anticheat_report_to_eventlog ( entity this)

Definition at line 211 of file anticheat.qc.

211 {
213 return;
214 GameLogEcho(strcat(":anticheat:_time:", ftos(this.playerid), ":", ftos(servertime - CS(this).anticheat_jointime)));
215#define ANTICHEAT_REPORT_ONE(name, f, tmin, mi, ma) \
216 GameLogEcho(strcat(":anticheat:", name, ":", anticheat_display(f, servertime - CS(this).anticheat_jointime, tmin, mi, ma)))
218#undef ANTICHEAT_REPORT_ONE
219}
float anticheat_jointime
Definition anticheat.qc:13
#define ANTICHEAT_REPORT_ONE(name, f, tmin, mi, ma)
#define ANTICHEATS(ANTICHEAT)
Definition anticheat.qc:191
void GameLogEcho(string s)
Definition gamelog.qc:15
bool autocvar_sv_eventlog
Definition gamelog.qh:3
string ftos(float f)
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))
int playerid
Definition client.qh:82

References anticheat_jointime, ANTICHEAT_REPORT_ONE, ANTICHEATS, autocvar_sv_eventlog, CS(), entity(), ftos(), GameLogEcho(), playerid, servertime, and strcat().

Referenced by ClientState_detach(), and GameCommand_anticheat().

◆ bot_clientconnect()

void bot_clientconnect ( entity this)

Definition at line 469 of file bot.qc.

470{
471 if (!IS_BOT_CLIENT(this)) return;
473 this.bot_nextthink = time - random();
474 this.isbot = true;
475 this.createdtime = this.bot_nextthink;
476
477 if(!this.bot_config_loaded) // This is needed so team overrider doesn't break between matches
478 {
481 }
482
483 havocbot_setupbot(this);
484}
float isbot
Definition api.qh:49
void bot_setclientfields(entity this)
Definition bot.qc:39
void bot_setnameandstuff(entity this)
Definition bot.qc:163
float createdtime
Definition bot.qh:61
float bot_config_loaded
Definition bot.qh:74
float bot_nextthink
Definition bot.qh:59
float bot_preferredcolors
Definition bot.qh:62
float time
clientcolors
Definition ent_cs.qc:147
void havocbot_setupbot(entity this)
Definition havocbot.qc:1764
float random(void)
#define IS_BOT_CLIENT(v)
want: (IS_CLIENT(v) && !IS_REAL_CLIENT(v))
Definition utils.qh:15

References bot_config_loaded, bot_nextthink, bot_preferredcolors, bot_setclientfields(), bot_setnameandstuff(), clientcolors, createdtime, entity(), havocbot_setupbot(), IS_BOT_CLIENT, isbot, random(), and time.

Referenced by ClientConnect().

◆ bot_clientdisconnect()

void bot_clientdisconnect ( entity this)

Definition at line 454 of file bot.qc.

455{
456 if (!IS_BOT_CLIENT(this))
457 return;
458 bot_clearqueue(this);
459 strfree(this.cleanname);
463 if(this.bot_cmd_current)
464 delete(this.bot_cmd_current);
465 if(bot_waypoint_queue_owner == this)
467}
string cleanname
Definition api.qh:45
string netname_freeme
Definition bot.qh:55
string playermodel_freeme
Definition bot.qh:56
string playerskin_freeme
Definition bot.qh:57
void bot_clearqueue(entity bot)
Definition scripting.qc:21
entity bot_waypoint_queue_owner
Definition navigation.qh:85
#define NULL
Definition post.qh:14
entity bot_cmd_current
Definition scripting.qh:60
#define strfree(this)
Definition string.qh:59

References bot_clearqueue(), bot_cmd_current, bot_waypoint_queue_owner, cleanname, entity(), IS_BOT_CLIENT, netname_freeme, NULL, playermodel_freeme, playerskin_freeme, and strfree.

Referenced by ClientState_detach().

◆ ClientData_Attach()

void ClientData_Attach ( entity this)

Definition at line 172 of file client.qc.

173{
175 CS(this).clientdata.drawonlytoclient = this;
176 CS(this).clientdata.owner = this;
177}
bool ClientData_Send(entity this, entity to, int sf)
Definition client.qc:128
entity clientdata
Definition client.qh:64

References clientdata, ClientData_Send(), CS(), entity(), Net_LinkEntity(), and new_pure.

Referenced by ClientState_attach().

◆ ClientData_Detach()

void ClientData_Detach ( entity this)

Definition at line 179 of file client.qc.

180{
181 delete(CS(this).clientdata);
182 CS(this).clientdata = NULL;
183}

References CS(), entity(), and NULL.

Referenced by ClientState_detach().

◆ ClientState_attach()

void ClientState_attach ( entity this)

Definition at line 46 of file state.qc.

47{
48 this._cs = NEW(ClientState, this);
49
50 // TODO: fold all of these into ClientState
51
52 DecodeLevelParms(this);
53
57 accuracy_init(this);
58 entcs_attach(this);
59 anticheat_init(this);
60 W_HitPlotOpen(this);
63}
Purpose: common client state, usable on client and server Client: singleton representing the viewed p...
Definition state.qh:29
#define NEW(cname,...)
Definition oo.qh:117
void PlayerStats_PlayerBasic_CheckUpdate(entity joiningplayer)
void accuracy_init(entity this)
init/free
Definition accuracy.qc:50
void anticheat_init(entity this)
Definition anticheat.qc:256
void PlayerScore_Attach(entity this)
Definition scores.qc:334
void InventoryStorage_attach(PlayerState this)
void entcs_attach(entity this)
Definition ent_cs.qc:251
void ClientData_Attach(entity this)
Definition client.qc:172
void DecodeLevelParms(entity this)
Definition client.qc:984
void W_HitPlotOpen(entity this)
Definition hitplot.qc:82
ClientState _cs
Definition state.qh:42
void StatusEffectsStorage_attach(entity e)

References _cs, accuracy_init(), anticheat_init(), ClientData_Attach(), DecodeLevelParms(), entcs_attach(), entity(), InventoryStorage_attach(), NEW, PlayerScore_Attach(), PlayerStats_PlayerBasic_CheckUpdate(), StatusEffectsStorage_attach(), and W_HitPlotOpen().

Referenced by Client::Client().

◆ ClientState_detach()

void ClientState_detach ( entity this)

Definition at line 73 of file state.qc.

74{
75 GetCvars(this, CS_CVAR(this), -1); // free cvars TODO: is this still needed now that it's stored on the clientstate entity?
76 accuracy_free(this); // TODO: needs to be before CS() is deleted!
77 PlayerScore_Detach(this); // what ^they^ said
78 W_HitPlotClose(this);
80 entcs_detach(this);
83 delete(CS(this));
84 this._cs = NULL;
85
87
89}
void GetCvars(entity this, entity store, int f)
void accuracy_free(entity this)
Definition accuracy.qc:58
void ClientData_Detach(entity this)
Definition client.qc:179
void InventoryStorage_delete(PlayerState this)
void PlayerScore_Detach(entity this)
Definition scores.qc:344
void W_HitPlotClose(entity this)
Definition hitplot.qc:92
void bot_clientdisconnect(entity this)
Definition bot.qc:454
void anticheat_report_to_eventlog(entity this)
Definition anticheat.qc:211
void entcs_detach(entity this)
Definition ent_cs.qc:268
#define CS_CVAR(this)
Definition state.qh:51
void StatusEffectsStorage_delete(entity e)

References _cs, accuracy_free(), anticheat_report_to_eventlog(), bot_clientdisconnect(), ClientData_Detach(), CS(), CS_CVAR, entcs_detach(), entity(), GetCvars(), InventoryStorage_delete(), NULL, PlayerScore_Detach(), StatusEffectsStorage_delete(), and W_HitPlotClose().

Referenced by ClientDisconnect().

◆ DecodeLevelParms()

void DecodeLevelParms ( entity this)

Definition at line 984 of file client.qc.

985{
986 // load parms
987 CS(this).parm_idlesince = parm1;
988 if (CS(this).parm_idlesince == -(86400 * 366))
989 CS(this).parm_idlesince = time;
990
991 // whatever happens, allow 60 seconds of idling directly after connect for map loading
992 CS(this).parm_idlesince = max(CS(this).parm_idlesince, time - autocvar_sv_maxidle + 60);
993
995}
#define MUTATOR_CALLHOOK(id,...)
Definition base.qh:143
float max(float f,...)
float parm1
Definition progsdefs.qc:45
float autocvar_sv_maxidle
Definition client.qh:37

References autocvar_sv_maxidle, CS(), DecodeLevelParms(), entity(), max(), MUTATOR_CALLHOOK, parm1, and time.

Referenced by ClientState_attach(), DecodeLevelParms(), and MUTATOR_HOOKABLE().

◆ entcs_attach()

void entcs_attach ( entity this)

Definition at line 251 of file ent_cs.qc.

252 {
253 entity e = CS(player).entcs = new_pure(entcs_sender);
254 e.owner = player;
256 e.nextthink = time;
257 Net_LinkEntity(e, false, 0, entcs_send);
258 // NOTE: the following code block has been disabled as a workaround for https://gitlab.com/xonotic/xonotic-data.pk3dir/-/issues/1824
259#if 0
260 if (!IS_REAL_CLIENT(player)) return;
261 FOREACH_CLIENT(true, {
262 assert(CS(it).entcs);
263 _entcs_send(CS(it).entcs, msg_entity = player, BITS(23), MSG_ONE);
264 });
265#endif
266 }
#define BITS(n)
Definition bits.qh:9
bool entcs_send(entity this, entity to, int sf)
Definition ent_cs.qc:220
bool _entcs_send(entity this, entity to, int sf, int chan)
Definition ent_cs.qc:191
void entcs_think(entity this)
Definition ent_cs.qc:225
entity entcs
Definition ent_cs.qh:34
#define assert(expr,...)
Definition log.qh:8
float MSG_ONE
Definition menudefs.qc:56
entity msg_entity
Definition progsdefs.qc:63
#define setthink(e, f)
#define IS_REAL_CLIENT(v)
Definition utils.qh:17
#define FOREACH_CLIENT(cond, body)
Definition utils.qh:50

References _entcs_send(), assert, BITS, CS(), entcs, entcs_send(), entcs_think(), entity(), FOREACH_CLIENT, IS_REAL_CLIENT, msg_entity, MSG_ONE, Net_LinkEntity(), new_pure, setthink, and time.

Referenced by ClientState_attach().

◆ entcs_detach()

void entcs_detach ( entity this)

Definition at line 268 of file ent_cs.qc.

269 {
270 if (!CS(player).entcs) return;
271 delete(CS(player).entcs);
272 CS(player).entcs = NULL;
273 }

References CS(), entcs, entity(), and NULL.

Referenced by ClientState_detach().

◆ Inventory_clear()

void Inventory_clear ( PlayerState this)

Referenced by PlayerState_detach().

◆ Inventory_delete()

void Inventory_delete ( entity this)

Definition at line 158 of file inventory.qh.

158{ delete(e.inventory); }

References entity().

Referenced by PlayerState_detach().

◆ Inventory_new()

void Inventory_new ( PlayerState this)

Definition at line 149 of file inventory.qh.

150{
151 Inventory inv = NEW(Inventory);
153 this.inventory = inv;
154 inv.owner = this;
155 Net_LinkEntity(inv, false, 0, Inventory_Send);
156}
bool Inventory_Send(Inventory this, Client to, int sf)
Definition inventory.qh:134
Inventory inventory
Player inventory.
Definition inventory.qh:12
bool Inventory_customize(entity this, entity client)
Definition inventory.qh:143
#define setcefc(e, f)

References Inventory_customize(), Inventory_Send(), Net_LinkEntity(), NEW, and setcefc.

Referenced by PlayerState_attach().

◆ InventoryStorage_attach()

void InventoryStorage_attach ( PlayerState this)

Referenced by ClientState_attach().

◆ InventoryStorage_delete()

void InventoryStorage_delete ( PlayerState this)

Referenced by ClientState_detach().

◆ PlayerScore_Attach()

void PlayerScore_Attach ( entity this)

Definition at line 334 of file scores.qc.

335{
336 if(CS(player).scorekeeper)
337 error("player already has a scorekeeper");
339 sk.owner = player;
341 CS(player).scorekeeper = sk;
342}
#define error
Definition pre.qh:6
bool PlayerScore_SendEntity(entity this, entity to, float sendflags)
Definition scores.qc:257
entity scorekeeper
Definition scores.qc:19

References CS(), entity(), error, Net_LinkEntity(), new_pure, PlayerScore_SendEntity(), and scorekeeper.

Referenced by ClientState_attach().

◆ PlayerScore_Detach()

void PlayerScore_Detach ( entity this)

Definition at line 344 of file scores.qc.

345{
346 if(!CS(player).scorekeeper)
347 error("player has no scorekeeper");
348 delete(CS(player).scorekeeper);
349 CS(player).scorekeeper = NULL;
350}

References CS(), entity(), error, NULL, and scorekeeper.

Referenced by ClientState_detach().

◆ PlayerState_attach()

void PlayerState_attach ( entity this)

Definition at line 12 of file state.qc.

13{
14 if (PS(this) && PS(this).m_client == this)
15 return;
16
17 this._ps = NEW(PlayerState, this);
18
19 Inventory_new(PS(this));
20}
Purpose: common player state, usable on client and server Client: singleton representing the viewed p...
Definition state.qh:8
void Inventory_new(PlayerState this)
Definition inventory.qh:149
#define PS(this)
Definition state.qh:18
PlayerState _ps
Definition state.qh:17

References _ps, entity(), Inventory_new(), NEW, and PS.

Referenced by PutPlayerInServer().

◆ PlayerState_detach()

void PlayerState_detach ( entity this)

Definition at line 22 of file state.qc.

23{
24 PlayerState ps = PS(this);
25 if (!ps) return; // initial connect
26 PS(this) = NULL;
27 Inventory_clear(this.inventory_store); // no need to network updates, as there is no inventory attached
28
29 if (ps.m_client != this) return; // don't own state, spectator
30 ps.ps_push(ps, this);
32
33 FOREACH_CLIENT(PS(it) == ps, { PS(it) = NULL; });
34 delete(ps);
35}
Inventory inventory_store
Player inventory storage (holds previous state)
Definition inventory.qh:14
void Inventory_clear(PlayerState this)
void Inventory_delete(entity this)
Definition inventory.qh:158

References entity(), FOREACH_CLIENT, Inventory_clear(), Inventory_delete(), inventory_store, NULL, and PS.

Referenced by PutObserverInServer().

◆ W_HitPlotClose()

void W_HitPlotClose ( entity this)

Definition at line 92 of file hitplot.qc.

93{
94 if(CS(player).hitplotfh >= 0)
95 {
96 fclose(CS(player).hitplotfh);
97 CS(player).hitplotfh = -1;
98 }
99}
float hitplotfh
Definition hitplot.qh:6
void fclose(float fhandle)

References CS(), entity(), fclose(), and hitplotfh.

Referenced by ClientState_detach().

◆ W_HitPlotOpen()

void W_HitPlotOpen ( entity this)

Definition at line 82 of file hitplot.qc.

83{
85 {
86 CS(player).hitplotfh = fopen(strcat("hits-", matchid, "-", player.netaddress, "-", ftos(player.playerid), ".plot"), FILE_WRITE);
87 fputs(CS(player).hitplotfh, strcat("#name ", playername(player.netname, player.team, false), "\n"));
88 }
89 else { CS(player).hitplotfh = -1; }
90}
string playername(string thename, int teamid, bool team_colorize)
Definition util.qc:2082
const float FILE_WRITE
bool autocvar_g_hitplots
Definition hitplot.qh:3
string autocvar_g_hitplots_individuals
Definition hitplot.qh:4
void fputs(float fhandle, string s)
float fopen(string filename, float mode)
#define strhasword(s, w)
Definition string.qh:370
string matchid
Definition world.qh:63

References autocvar_g_hitplots, autocvar_g_hitplots_individuals, CS(), entity(), FILE_WRITE, fopen(), fputs(), ftos(), hitplotfh, matchid, playername(), strcat(), and strhasword.

Referenced by ClientState_attach().