4 * Purpose: common player state, usable on client and server
5 * Client: singleton representing the viewed player
6 * Server: instance per client, clients decoupled from players
8 CLASS(PlayerState, Object)
9 ATTRIB(PlayerState, m_client, entity, NULL)
10 CONSTRUCTOR(PlayerState, entity client)
12 CONSTRUCT(PlayerState);
13 this.m_client = client;
15 ATTRIB(PlayerState, m_switchingweapon, Weapon, Weapons_from(-1))
16 ATTRIB(PlayerState, m_switchweapon, Weapon, Weapons_from(-1))
17 ATTRIB(PlayerState, m_weapon, Weapon, Weapons_from(-1))
18 METHOD(PlayerState, ps_push, void(PlayerState this, entity cl))
20 STAT(ACTIVEWEAPON, cl) = this.m_weapon.m_id;
21 STAT(SWITCHINGWEAPON, cl) = this.m_switchingweapon.m_id;
22 STAT(SWITCHWEAPON, cl) = this.m_switchweapon.m_id;
28 #define PS(this) (this._ps)
30 PlayerState PS(entity this) { assert(IS_CLIENT(this)); return this._ps; }
33 void Inventory_new(entity this);
34 void Inventory_delete(entity this);
36 // TODO: renew on death
38 void PlayerState_attach(entity this)
40 this._ps = NEW(PlayerState, this);
45 void PlayerState_detach(entity this)
47 if (!PS(this)) return; // initial connect
51 Inventory_delete(self);
55 * Purpose: common client state, usable on client and server
56 * Client: singleton representing the viewed player
57 * Server: instance per client
59 CLASS(ClientState, Object)
60 ATTRIB(ClientState, m_client, entity, NULL)
61 CONSTRUCTOR(ClientState, entity client)
63 CONSTRUCT(ClientState);
64 this.m_client = client;
71 #define CS(this) (this._cs)
73 ClientState CS(entity this) { assert(IS_CLIENT(this)); assert(this._cs); return this._cs; }
77 void DecodeLevelParms(entity this);
78 void PlayerScore_Attach(entity this);
79 void ClientData_Attach(entity this);
80 void accuracy_init(entity this);
81 void entcs_attach(entity this);
82 void playerdemo_init(entity this);
83 void anticheat_init(entity this);
84 void W_HitPlotOpen(entity this);
85 void bot_clientconnect(entity this);
87 void ClientState_attach(entity this)
89 this._cs = NEW(ClientState, this);
91 GetCvars(0); // get other cvars from player
93 // TODO: xonstat elo.txt support, until then just 404s
94 if (false && IS_REAL_CLIENT(this)) { PlayerStats_PlayerBasic_CheckUpdate(this); }
96 // TODO: fold all of these into ClientState
98 DecodeLevelParms(this);
100 PlayerScore_Attach(this);
101 ClientData_Attach(this);
104 playerdemo_init(this);
105 anticheat_init(this);
108 bot_clientconnect(this);
111 void bot_clientdisconnect();
112 void W_HitPlotClose(entity this);
113 void anticheat_report();
114 void playerdemo_shutdown();
115 void entcs_detach(entity this);
116 void accuracy_free(entity this);
117 void ClientData_Detach(entity this);
118 void PlayerScore_Detach(entity this);
120 void ClientState_detach(entity this)
125 GetCvars(-1); // free cvars
127 bot_clientdisconnect();
129 W_HitPlotClose(this);
131 playerdemo_shutdown();
134 ClientData_Detach(this);
135 PlayerScore_Detach(self);