]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/state.qc
Merge branch 'terencehill/clockedtime_tostring_improvements' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / state.qc
1 #include "state.qh"
2
3 #include <common/mutators/mutator/status_effects/_mod.qh>
4 #include <server/command/getreplies.qh>
5
6 void Inventory_new(PlayerState this);
7 void Inventory_delete(entity this);
8 void Inventory_clear(PlayerState this);
9 void InventoryStorage_attach(PlayerState this);
10 void InventoryStorage_delete(PlayerState this);
11
12 void PlayerState_attach(entity this)
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
22 void PlayerState_detach(entity this)
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
46 void ClientState_attach(entity this)
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);
61         InventoryStorage_attach(this);
62         StatusEffectsStorage_attach(this);
63 }
64
65 void bot_clientdisconnect(entity this);
66 void W_HitPlotClose(entity this);
67 void anticheat_report_to_eventlog(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
73 void ClientState_detach(entity this)
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);
81     InventoryStorage_delete(this);
82     StatusEffectsStorage_delete(this);
83         delete(CS(this));
84         this._cs = NULL;
85
86     bot_clientdisconnect(this);
87
88     anticheat_report_to_eventlog(this);
89 }