Xonotic
state.qc
Go to the documentation of this file.
1 #include "state.qh"
2 
5 
6 void Inventory_new(PlayerState this);
7 void Inventory_delete(entity this);
11 
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 }
21 
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 }
36 
37 void DecodeLevelParms(entity this);
38 void PlayerScore_Attach(entity this);
39 void ClientData_Attach(entity this);
40 void accuracy_init(entity this);
41 void entcs_attach(entity this);
42 void anticheat_init(entity this);
43 void W_HitPlotOpen(entity this);
44 void bot_clientconnect(entity this);
45 
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 }
64 
65 void bot_clientdisconnect(entity this);
66 void W_HitPlotClose(entity this);
68 void entcs_detach(entity this);
69 void accuracy_free(entity this);
70 void ClientData_Detach(entity this);
71 void PlayerScore_Detach(entity this);
72 
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)
#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 PlayerScore_Detach(entity this)
Definition: scores.qc:328
void InventoryStorage_delete(PlayerState this)
entity() spawn
void anticheat_report_to_eventlog(entity this)
Definition: anticheat.qc:195
ClientState CS(Client this)
Definition: state.qh:47
#define FOREACH_CLIENT(cond, body)
Definition: utils.qh:49
#define CS_CVAR(this)
Definition: state.qh:51
void PlayerState_attach(entity this)
Definition: state.qc:12
#define PS(this)
Definition: state.qh:18
PlayerState _ps
Definition: state.qh:17
void ClientData_Attach(entity this)
Definition: client.qc:158
void bot_clientconnect(entity this)
Definition: bot.qc:426
void anticheat_init(entity this)
Definition: anticheat.qc:240
ClientState _cs
Definition: state.qh:42
void ClientState_attach(entity this)
Definition: state.qc:46
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
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_new(PlayerState this)
void PlayerScore_Attach(entity this)
Definition: scores.qc:318
void Inventory_delete(entity this)
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
void PlayerState_detach(entity this)
Definition: state.qc:22
void bot_clientdisconnect(entity this)
Definition: bot.qc:411
void ClientState_detach(entity this)
Definition: state.qc:73