]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/state.qh
Merge branch 'Mario/wepent_experimental' into Mario/wepent_experimental_2
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / state.qh
1 #pragma once
2
3 /**
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
7  */
8 CLASS(PlayerState, Object)
9         ATTRIB(PlayerState, m_client, entity);
10         CONSTRUCTOR(PlayerState, entity client)
11         {
12                 CONSTRUCT(PlayerState);
13                 this.m_client = client;
14         }
15 ENDCLASS(PlayerState)
16
17 .PlayerState _ps;
18 #define PS(this) ((this)._ps)
19
20 // TODO: renew on death
21 void PlayerState_attach(entity this);
22 void PlayerState_detach(entity this);
23
24 /**
25  * Purpose: common client state, usable on client and server
26  * Client: singleton representing the viewed player
27  * Server: instance per client
28  */
29 CLASS(ClientState, Object)
30         ATTRIB(ClientState, m_client, entity);
31         CONSTRUCTOR(ClientState, entity client)
32         {
33                 CONSTRUCT(ClientState);
34                 this.m_client = client;
35         }
36 ENDCLASS(ClientState)
37
38 .ClientState _cs;
39
40 #if NDEBUG
41         #define CS(this) (this._cs)
42 #else
43         ClientState CS(Client this) { TC(Client, this); assert(this._cs); return this._cs; }
44 #endif
45
46 void ClientState_attach(entity this);
47 void ClientState_detach(entity this);