Xonotic
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)
 
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 53 of file accuracy.qc.

Referenced by ClientState_attach(), and ClientState_detach().

54 {
55  delete(CS(e).accuracy);
56 }
ClientState CS(Client this)
Definition: state.qh:47
+ Here is the caller graph for this function:

◆ accuracy_init()

void accuracy_init ( entity  this)

Definition at line 45 of file accuracy.qc.

Referenced by ClientState_attach(), and PlayerState_detach().

46 {
47  entity a = CS(e).accuracy = new_pure(accuracy);
48  a.owner = e;
49  a.drawonlytoclient = e;
50  Net_LinkEntity(a, false, 0, accuracy_send);
51 }
entity() spawn
ClientState CS(Client this)
Definition: state.qh:47
bool accuracy_send(entity this, entity to, int sf)
Definition: accuracy.qc:21
entity accuracy
Definition: accuracy.qh:26
#define new_pure(class)
purely logical entities (.origin doesn't work)
Definition: oo.qh:62
+ Here is the caller graph for this function:

◆ anticheat_init()

void anticheat_init ( entity  this)

Definition at line 240 of file anticheat.qc.

Referenced by ClientState_attach(), and PlayerState_detach().

241 {
242  CS(this).anticheat_speedhack_offset = 0;
243  CS(this).anticheat_jointime = servertime;
244 }
ClientState CS(Client this)
Definition: state.qh:47
float servertime
Definition: main.qh:36
+ Here is the caller graph for this function:

◆ anticheat_report_to_eventlog()

void anticheat_report_to_eventlog ( entity  this)

Definition at line 195 of file anticheat.qc.

Referenced by ClientState_attach(), ClientState_detach(), and GameCommand_anticheat().

195  {
197  return;
198  GameLogEcho(strcat(":anticheat:_time:", ftos(this.playerid), ":", ftos(servertime - CS(this).anticheat_jointime)));
199 #define ANTICHEAT_REPORT_ONE(name, f, tmin, mi, ma) \
200  GameLogEcho(strcat(":anticheat:", name, ":", anticheat_display(f, servertime - CS(this).anticheat_jointime, tmin, mi, ma)))
202 #undef ANTICHEAT_REPORT_ONE
203 }
#define ANTICHEATS(ANTICHEAT)
Definition: anticheat.qc:176
int playerid
Definition: client.qh:78
ClientState CS(Client this)
Definition: state.qh:47
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
void GameLogEcho(string s)
Definition: gamelog.qc:12
#define ANTICHEAT_REPORT_ONE(name, f, tmin, mi, ma)
float servertime
Definition: main.qh:36
bool autocvar_sv_eventlog
Definition: gamelog.qh:3
float anticheat_jointime
Definition: anticheat.qc:13
+ Here is the caller graph for this function:

◆ bot_clientconnect()

void bot_clientconnect ( entity  this)

Definition at line 426 of file bot.qc.

Referenced by ClientConnect(), and PlayerState_detach().

427 {
428  if (!IS_BOT_CLIENT(this)) return;
429  this.bot_preferredcolors = this.clientcolors;
430  this.bot_nextthink = time - random();
431  this.lag_func = bot_lagfunc;
432  this.isbot = true;
433  this.createdtime = this.bot_nextthink;
434 
435  if(!this.bot_config_loaded) // This is needed so team overrider doesn't break between matches
436  {
437  bot_setnameandstuff(this);
438  bot_setclientfields(this);
439  }
440 
442  {
444  }
445  else
446  {
447  this.bot_forced_team = 0;
449  }
450 
451  havocbot_setupbot(this);
452 }
bool SetPlayerTeam(entity player, int team_index, int type)
Sets the team of the player.
Definition: teamplay.qc:237
float bot_preferredcolors
Definition: bot.qh:60
bool Team_IsValidIndex(int index)
Returns whether the team index is valid.
Definition: teams.qh:151
void bot_setclientfields(entity this)
Definition: bot.qc:36
void TeamBalance_JoinBestTeam(entity player)
Assigns the given player to a team that will make the game most balanced.
Definition: teamplay.qc:451
Player has manually selected their team.
Definition: teamplay.qh:112
void bot_lagfunc(entity this, float t, float f1, float f2, entity e1, vector v1, vector v2, vector v3, vector v4)
Definition: aim.qc:151
float bot_nextthink
Definition: bot.qh:57
float teamplay
Definition: progsdefs.qc:31
void bot_setnameandstuff(entity this)
Definition: bot.qc:143
float bot_config_loaded
Definition: bot.qh:73
float bot_forced_team
Definition: api.qh:41
void havocbot_setupbot(entity this)
Definition: havocbot.qc:1683
#define IS_BOT_CLIENT(v)
want: (IS_CLIENT(v) && !IS_REAL_CLIENT(v))
Definition: utils.qh:15
float createdtime
Definition: bot.qh:59
float clientcolors
float time
Definition: csprogsdefs.qc:16
float isbot
Definition: api.qh:49
+ Here is the caller graph for this function:

◆ bot_clientdisconnect()

void bot_clientdisconnect ( entity  this)

Definition at line 411 of file bot.qc.

Referenced by ClientState_attach(), and ClientState_detach().

412 {
413  if (!IS_BOT_CLIENT(this))
414  return;
415  bot_clearqueue(this);
416  strfree(this.cleanname);
417  strfree(this.netname_freeme);
420  if(this.bot_cmd_current)
421  delete(this.bot_cmd_current);
422  if(bot_waypoint_queue_owner == this)
424 }
entity bot_cmd_current
Definition: scripting.qh:60
string netname_freeme
Definition: bot.qh:53
string playermodel_freeme
Definition: bot.qh:54
string cleanname
Definition: api.qh:45
#define NULL
Definition: post.qh:17
string playerskin_freeme
Definition: bot.qh:55
#define IS_BOT_CLIENT(v)
want: (IS_CLIENT(v) && !IS_REAL_CLIENT(v))
Definition: utils.qh:15
#define strfree(this)
Definition: string.qh:56
void bot_clearqueue(entity bot)
Definition: scripting.qc:21
+ Here is the caller graph for this function:

◆ ClientData_Attach()

void ClientData_Attach ( entity  this)

Definition at line 158 of file client.qc.

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

Referenced by ClientState_attach(), and PlayerState_detach().

159 {
160  Net_LinkEntity(CS(this).clientdata = new_pure(clientdata), false, 0, ClientData_Send);
161  CS(this).clientdata.drawonlytoclient = this;
162  CS(this).clientdata.owner = this;
163 }
ClientState CS(Client this)
Definition: state.qh:47
entity clientdata
Definition: client.qh:62
bool ClientData_Send(entity this, entity to, int sf)
Definition: client.qc:129
#define new_pure(class)
purely logical entities (.origin doesn't work)
Definition: oo.qh:62
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ClientData_Detach()

void ClientData_Detach ( entity  this)

Definition at line 165 of file client.qc.

References CS(), and NULL.

Referenced by ClientState_attach(), and ClientState_detach().

166 {
167  delete(CS(this).clientdata);
168  CS(this).clientdata = NULL;
169 }
ClientState CS(Client this)
Definition: state.qh:47
#define NULL
Definition: post.qh:17
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ClientState_attach()

void ClientState_attach ( entity  this)

Definition at line 46 of file state.qc.

References _cs, accuracy_free(), accuracy_init(), anticheat_init(), anticheat_report_to_eventlog(), bot_clientdisconnect(), ClientData_Attach(), ClientData_Detach(), DecodeLevelParms(), entcs_attach(), entcs_detach(), entity(), InventoryStorage_attach(), NEW, PlayerScore_Attach(), PlayerScore_Detach(), W_HitPlotClose(), and W_HitPlotOpen().

Referenced by Client::Client ::Client().

47 {
48  this._cs = NEW(ClientState, this);
49 
50  // TODO: fold all of these into ClientState
51 
52  DecodeLevelParms(this);
53 
54  PlayerScore_Attach(this);
55  PlayerStats_PlayerBasic_CheckUpdate(this);
56  ClientData_Attach(this);
57  accuracy_init(this);
58  entcs_attach(this);
59  anticheat_init(this);
60  W_HitPlotOpen(this);
62  StatusEffectsStorage_attach(this);
63 }
#define NEW(cname,...)
Definition: oo.qh:105
void DecodeLevelParms(entity this)
Definition: client.qc:934
void entcs_attach(entity this)
void accuracy_init(entity this)
Definition: accuracy.qc:45
void ClientData_Attach(entity this)
Definition: client.qc:158
void anticheat_init(entity this)
Definition: anticheat.qc:240
ClientState _cs
Definition: state.qh:42
void PlayerScore_Attach(entity this)
Definition: scores.qc:318
void InventoryStorage_attach(PlayerState this)
void W_HitPlotOpen(entity this)
Definition: hitplot.qc:82
Purpose: common client state, usable on client and server Client: singleton representing the viewed p...
Definition: state.qh:29
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ClientState_detach()

void ClientState_detach ( entity  this)

Definition at line 73 of file state.qc.

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

Referenced by ClientDisconnect().

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);
79  ClientData_Detach(this);
80  entcs_detach(this);
82  StatusEffectsStorage_delete(this);
83  delete(CS(this));
84  this._cs = NULL;
85 
87 
89 }
void entcs_detach(entity this)
void PlayerScore_Detach(entity this)
Definition: scores.qc:328
void InventoryStorage_delete(PlayerState this)
void anticheat_report_to_eventlog(entity this)
Definition: anticheat.qc:195
ClientState CS(Client this)
Definition: state.qh:47
#define CS_CVAR(this)
Definition: state.qh:51
ClientState _cs
Definition: state.qh:42
void GetCvars(entity this, entity store, int f)
Definition: getreplies.qc:381
void ClientData_Detach(entity this)
Definition: client.qc:165
void W_HitPlotClose(entity this)
Definition: hitplot.qc:92
#define NULL
Definition: post.qh:17
void accuracy_free(entity this)
Definition: accuracy.qc:53
void bot_clientdisconnect(entity this)
Definition: bot.qc:411
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DecodeLevelParms()

void DecodeLevelParms ( entity  this)

Definition at line 934 of file client.qc.

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

Referenced by ClientState_attach(), and PlayerState_detach().

935 {
936  // load parms
937  CS(this).parm_idlesince = parm1;
938  if (CS(this).parm_idlesince == -(86400 * 366))
939  CS(this).parm_idlesince = time;
940 
941  // whatever happens, allow 60 seconds of idling directly after connect for map loading
942  CS(this).parm_idlesince = max(CS(this).parm_idlesince, time - autocvar_sv_maxidle + 60);
943 
945 }
float autocvar_sv_maxidle
Definition: client.qh:36
ClientState CS(Client this)
Definition: state.qh:47
void DecodeLevelParms(entity this)
Definition: client.qc:934
float parm1
Definition: progsdefs.qc:45
#define MUTATOR_CALLHOOK(id,...)
Definition: base.qh:140
float time
Definition: csprogsdefs.qc:16
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ entcs_attach()

void entcs_attach ( entity  this)

Referenced by ClientState_attach(), and PlayerState_detach().

+ Here is the caller graph for this function:

◆ entcs_detach()

void entcs_detach ( entity  this)

Referenced by ClientState_attach(), and ClientState_detach().

+ Here is the caller graph for this function:

◆ Inventory_clear()

void Inventory_clear ( PlayerState  this)

Referenced by PlayerState_detach(), and reset_map().

+ Here is the caller graph for this function:

◆ Inventory_delete()

void Inventory_delete ( entity  this)

Referenced by PlayerState_detach().

+ Here is the caller graph for this function:

◆ Inventory_new()

void Inventory_new ( PlayerState  this)

Referenced by PlayerState_attach().

+ Here is the caller graph for this function:

◆ InventoryStorage_attach()

void InventoryStorage_attach ( PlayerState  this)

Referenced by ClientState_attach().

+ Here is the caller graph for this function:

◆ InventoryStorage_delete()

void InventoryStorage_delete ( PlayerState  this)

Referenced by ClientState_detach().

+ Here is the caller graph for this function:

◆ PlayerScore_Attach()

void PlayerScore_Attach ( entity  this)

Definition at line 318 of file scores.qc.

Referenced by ClientState_attach(), and PlayerState_detach().

319 {
320  if(CS(player).scorekeeper)
321  error("player already has a scorekeeper");
322  entity sk = new_pure(scorekeeper);
323  sk.owner = player;
324  Net_LinkEntity(sk, false, 0, PlayerScore_SendEntity);
325  CS(player).scorekeeper = sk;
326 }
bool PlayerScore_SendEntity(entity this, entity to, float sendflags)
Definition: scores.qc:239
entity() spawn
ClientState CS(Client this)
Definition: state.qh:47
entity scorekeeper
Definition: scores.qc:19
#define new_pure(class)
purely logical entities (.origin doesn't work)
Definition: oo.qh:62
+ Here is the caller graph for this function:

◆ PlayerScore_Detach()

void PlayerScore_Detach ( entity  this)

Definition at line 328 of file scores.qc.

Referenced by ClientState_attach(), and ClientState_detach().

329 {
330  if(!CS(player).scorekeeper)
331  error("player has no scorekeeper");
332  delete(CS(player).scorekeeper);
333  CS(player).scorekeeper = NULL;
334 }
ClientState CS(Client this)
Definition: state.qh:47
entity scorekeeper
Definition: scores.qc:19
#define NULL
Definition: post.qh:17
+ Here is the caller graph for this function:

◆ PlayerState_attach()

void PlayerState_attach ( entity  this)

Definition at line 12 of file state.qc.

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

Referenced by PutPlayerInServer().

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 }
#define NEW(cname,...)
Definition: oo.qh:105
#define PS(this)
Definition: state.qh:18
PlayerState _ps
Definition: state.qh:17
Purpose: common player state, usable on client and server Client: singleton representing the viewed p...
Definition: state.qh:8
void Inventory_new(PlayerState this)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ PlayerState_detach()

void PlayerState_detach ( entity  this)

Definition at line 22 of file state.qc.

References accuracy_init(), anticheat_init(), bot_clientconnect(), ClientData_Attach(), DecodeLevelParms(), entcs_attach(), entity(), FOREACH_CLIENT, Inventory_clear(), Inventory_delete(), NULL, PlayerScore_Attach(), PS, and W_HitPlotOpen().

Referenced by PutObserverInServer().

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);
31  Inventory_delete(ps);
32 
33  FOREACH_CLIENT(PS(it) == ps, { PS(it) = NULL; });
34  delete(ps);
35 }
#define FOREACH_CLIENT(cond, body)
Definition: utils.qh:49
#define PS(this)
Definition: state.qh:18
#define NULL
Definition: post.qh:17
Purpose: common player state, usable on client and server Client: singleton representing the viewed p...
Definition: state.qh:8
void Inventory_clear(PlayerState this)
void Inventory_delete(entity this)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ W_HitPlotClose()

void W_HitPlotClose ( entity  this)

Definition at line 92 of file hitplot.qc.

Referenced by ClientState_attach(), and ClientState_detach().

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
ClientState CS(Client this)
Definition: state.qh:47
+ Here is the caller graph for this function:

◆ W_HitPlotOpen()

void W_HitPlotOpen ( entity  this)

Definition at line 82 of file hitplot.qc.

Referenced by ClientState_attach(), and PlayerState_detach().

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 }
float hitplotfh
Definition: hitplot.qh:6
ClientState CS(Client this)
Definition: state.qh:47
string autocvar_g_hitplots_individuals
Definition: hitplot.qh:4
#define strhasword(s, w)
Definition: string.qh:352
string matchid
Definition: world.qh:57
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
bool autocvar_g_hitplots
Definition: hitplot.qh:3
const float FILE_WRITE
Definition: csprogsdefs.qc:233
+ Here is the caller graph for this function: