]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/state.qc
Merge branch 'Mario/teams_bitflag' into 'master'
[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         ps.m_switchweapon = WEP_Null;
20         ps.m_weapon = WEP_Null;
21         ps.m_switchingweapon = WEP_Null;
22         ps.ps_push(ps, this);
23
24         if (ps.m_client != this) return;  // don't own state, spectator
25         FOREACH_CLIENT(PS(it) == ps, { PS(it) = NULL; });
26         remove(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         if (IS_REAL_CLIENT(this)) { PlayerStats_PlayerBasic_CheckUpdate(this); }
49
50         // TODO: fold all of these into ClientState
51
52         DecodeLevelParms(this);
53
54         PlayerScore_Attach(this);
55         ClientData_Attach(this);
56         accuracy_init(this);
57         entcs_attach(this);
58         playerdemo_init(this);
59         anticheat_init(this);
60         W_HitPlotOpen(this);
61
62         bot_clientconnect(this);
63 }
64
65 void bot_clientdisconnect(entity this);
66 void W_HitPlotClose(entity this);
67 void anticheat_report(entity this);
68 void playerdemo_shutdown(entity this);
69 void entcs_detach(entity this);
70 void accuracy_free(entity this);
71 void ClientData_Detach(entity this);
72 void PlayerScore_Detach(entity this);
73
74 void ClientState_detach(entity this)
75 {
76         remove(CS(this));
77         this._cs = NULL;
78
79     GetCvars(this, -1);  // free cvars
80
81     bot_clientdisconnect(this);
82
83     W_HitPlotClose(this);
84     anticheat_report(this);
85     playerdemo_shutdown(this);
86     entcs_detach(this);
87     accuracy_free(this);
88     ClientData_Detach(this);
89     PlayerScore_Detach(this);
90 }