]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/state.qc
Update hash again...
[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.m_switchweapon = WEP_Null;
21         ps.m_weapon = WEP_Null;
22         ps.m_switchingweapon = WEP_Null;
23         ps.ps_push(ps, this);
24         
25         FOREACH_CLIENT(PS(it) == ps, { PS(it) = NULL; });
26         delete(ps);
27
28     Inventory_delete(this);
29 }
30
31 void GetCvars(entity this, int);
32 void DecodeLevelParms(entity this);
33 void PlayerScore_Attach(entity this);
34 void ClientData_Attach(entity this);
35 void accuracy_init(entity this);
36 void entcs_attach(entity this);
37 void playerdemo_init(entity this);
38 void anticheat_init(entity this);
39 void W_HitPlotOpen(entity this);
40 void bot_clientconnect(entity this);
41
42 void ClientState_attach(entity this)
43 {
44         this._cs = NEW(ClientState, this);
45
46     GetCvars(this, 0);  // get other cvars from player
47
48         // TODO: fold all of these into ClientState
49
50         DecodeLevelParms(this);
51
52         PlayerScore_Attach(this);
53         PlayerStats_PlayerBasic_CheckUpdate(this);
54         ClientData_Attach(this);
55         accuracy_init(this);
56         entcs_attach(this);
57         playerdemo_init(this);
58         anticheat_init(this);
59         W_HitPlotOpen(this);
60
61         bot_clientconnect(this);
62 }
63
64 void bot_clientdisconnect(entity this);
65 void W_HitPlotClose(entity this);
66 void anticheat_report(entity this);
67 void playerdemo_shutdown(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         delete(CS(this));
76         this._cs = NULL;
77
78     GetCvars(this, -1);  // free cvars
79
80     bot_clientdisconnect(this);
81
82     W_HitPlotClose(this);
83     anticheat_report(this);
84     playerdemo_shutdown(this);
85     entcs_detach(this);
86     accuracy_free(this);
87     ClientData_Detach(this);
88     PlayerScore_Detach(this);
89 }