]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/state.qc
Merge branch 'master' into Mario/overkill
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / state.qc
1 #include "state.qh"
2
3 void Inventory_new(entity this);
4 void Inventory_delete(entity this);
5
6 void PlayerState_attach(entity this)
7 {
8         this._ps = NEW(PlayerState, this);
9
10         Inventory_new(this);
11 }
12
13 void PlayerState_detach(entity this)
14 {
15     PlayerState ps = PS(this);
16         if (!ps) return;  // initial connect
17         PS(this) = NULL;
18
19         if (ps.m_client != this) return;  // don't own state, spectator
20         ps.ps_push(ps, this);
21
22         FOREACH_CLIENT(PS(it) == ps, { PS(it) = NULL; });
23         delete(ps);
24
25     Inventory_delete(this);
26 }
27
28 void GetCvars(entity this, int);
29 void DecodeLevelParms(entity this);
30 void PlayerScore_Attach(entity this);
31 void ClientData_Attach(entity this);
32 void accuracy_init(entity this);
33 void entcs_attach(entity this);
34 void playerdemo_init(entity this);
35 void anticheat_init(entity this);
36 void W_HitPlotOpen(entity this);
37 void bot_clientconnect(entity this);
38
39 void ClientState_attach(entity this)
40 {
41         this._cs = NEW(ClientState, this);
42
43     GetCvars(this, 0);  // get other cvars from player
44
45         // TODO: fold all of these into ClientState
46
47         DecodeLevelParms(this);
48
49         PlayerScore_Attach(this);
50         PlayerStats_PlayerBasic_CheckUpdate(this);
51         ClientData_Attach(this);
52         accuracy_init(this);
53         entcs_attach(this);
54         playerdemo_init(this);
55         anticheat_init(this);
56         W_HitPlotOpen(this);
57
58         bot_clientconnect(this);
59 }
60
61 void bot_clientdisconnect(entity this);
62 void W_HitPlotClose(entity this);
63 void anticheat_report_to_eventlog(entity this);
64 void playerdemo_shutdown(entity this);
65 void entcs_detach(entity this);
66 void accuracy_free(entity this);
67 void ClientData_Detach(entity this);
68 void PlayerScore_Detach(entity this);
69
70 void ClientState_detach(entity this)
71 {
72         delete(CS(this));
73         this._cs = NULL;
74
75     GetCvars(this, -1);  // free cvars
76
77     bot_clientdisconnect(this);
78
79     W_HitPlotClose(this);
80     anticheat_report_to_eventlog(this);
81     playerdemo_shutdown(this);
82     entcs_detach(this);
83     accuracy_free(this);
84     ClientData_Detach(this);
85     PlayerScore_Detach(this);
86 }