]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/state.qc
Merge branch 'master' into terencehill/hud_fixes
[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         if (ps.m_client != this) return;  // don't own state, spectator
19         FOREACH_CLIENT(PS(it) == ps, { PS(it) = NULL; });
20         remove(ps);
21
22     Inventory_delete(this);
23 }
24
25 void GetCvars(entity this, int);
26 void DecodeLevelParms(entity this);
27 void PlayerScore_Attach(entity this);
28 void ClientData_Attach(entity this);
29 void accuracy_init(entity this);
30 void entcs_attach(entity this);
31 void playerdemo_init(entity this);
32 void anticheat_init(entity this);
33 void W_HitPlotOpen(entity this);
34 void bot_clientconnect(entity this);
35
36 void ClientState_attach(entity this)
37 {
38         this._cs = NEW(ClientState, this);
39
40     GetCvars(this, 0);  // get other cvars from player
41
42         // TODO: xonstat elo.txt support, until then just 404s
43         if (false && IS_REAL_CLIENT(this)) { PlayerStats_PlayerBasic_CheckUpdate(this); }
44
45         // TODO: fold all of these into ClientState
46
47         DecodeLevelParms(this);
48
49         PlayerScore_Attach(this);
50         ClientData_Attach(this);
51         accuracy_init(this);
52         entcs_attach(this);
53         playerdemo_init(this);
54         anticheat_init(this);
55         W_HitPlotOpen(this);
56
57         bot_clientconnect(this);
58 }
59
60 void bot_clientdisconnect(entity this);
61 void W_HitPlotClose(entity this);
62 void anticheat_report(entity this);
63 void playerdemo_shutdown();
64 void entcs_detach(entity this);
65 void accuracy_free(entity this);
66 void ClientData_Detach(entity this);
67 void PlayerScore_Detach(entity this);
68
69 void ClientState_detach(entity this)
70 {
71         remove(CS(this));
72         this._cs = NULL;
73
74     GetCvars(this, -1);  // free cvars
75
76     bot_clientdisconnect(this);
77
78     W_HitPlotClose(this);
79     anticheat_report(this);
80     playerdemo_shutdown();
81     entcs_detach(this);
82     accuracy_free(self);
83     ClientData_Detach(this);
84     PlayerScore_Detach(self);
85 }