]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/state.qc
Merge branch 'master' into terencehill/scoreboard_item_stats
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / state.qc
1 #include "state.qh"
2
3 #include <server/command/getreplies.qh>
4
5 void Inventory_new(PlayerState this);
6 void Inventory_delete(entity this);
7 void Inventory_clear(PlayerState this);
8 void InventoryStorage_attach(PlayerState this);
9 void InventoryStorage_delete(PlayerState this);
10
11 void PlayerState_attach(entity this)
12 {
13         if (PS(this) && PS(this).m_client == this)
14                 return;
15
16         this._ps = NEW(PlayerState, this);
17
18         Inventory_new(PS(this));
19 }
20
21 void PlayerState_detach(entity this)
22 {
23     PlayerState ps = PS(this);
24         if (!ps) return;  // initial connect
25         PS(this) = NULL;
26     Inventory_clear(this.inventory_store); // no need to network updates, as there is no inventory attached
27
28         if (ps.m_client != this) return;  // don't own state, spectator
29         ps.ps_push(ps, this);
30     Inventory_delete(ps);
31
32         FOREACH_CLIENT(PS(it) == ps, { PS(it) = NULL; });
33         delete(ps);
34 }
35
36 void DecodeLevelParms(entity this);
37 void PlayerScore_Attach(entity this);
38 void ClientData_Attach(entity this);
39 void accuracy_init(entity this);
40 void entcs_attach(entity this);
41 void anticheat_init(entity this);
42 void W_HitPlotOpen(entity this);
43 void bot_clientconnect(entity this);
44
45 void ClientState_attach(entity this)
46 {
47         this._cs = NEW(ClientState, this);
48
49         // TODO: fold all of these into ClientState
50
51         DecodeLevelParms(this);
52
53         PlayerScore_Attach(this);
54         PlayerStats_PlayerBasic_CheckUpdate(this);
55         ClientData_Attach(this);
56         accuracy_init(this);
57         entcs_attach(this);
58         anticheat_init(this);
59         W_HitPlotOpen(this);
60         InventoryStorage_attach(this);
61 }
62
63 void bot_clientdisconnect(entity this);
64 void W_HitPlotClose(entity this);
65 void anticheat_report_to_eventlog(entity this);
66 void entcs_detach(entity this);
67 void accuracy_free(entity this);
68 void ClientData_Detach(entity this);
69 void PlayerScore_Detach(entity this);
70
71 void ClientState_detach(entity this)
72 {
73     GetCvars(this, CS_CVAR(this), -1);  // free cvars TODO: is this still needed now that it's stored on the clientstate entity?
74     accuracy_free(this); // TODO: needs to be before CS() is deleted!
75     PlayerScore_Detach(this); // what ^they^ said
76     W_HitPlotClose(this);
77     ClientData_Detach(this);
78     entcs_detach(this);
79     InventoryStorage_delete(this);
80         delete(CS(this));
81         this._cs = NULL;
82
83     bot_clientdisconnect(this);
84
85     anticheat_report_to_eventlog(this);
86 }