]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/cl_client.qh
Merge branch 'master' into terencehill/infomessages_panel_update
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / cl_client.qh
1 #pragma once
2
3 void ClientState_attach(entity this);
4
5 CLASS(Client, Object)
6     /** Client name */
7     ATTRIB(Client, netname, string, this.netname)
8     ATTRIB(Client, colormap, int, this.colormap)
9     ATTRIB(Client, team, int, this.team)
10     ATTRIB(Client, clientcolors, int, this.clientcolors)
11     /** Client IP */
12     ATTRIB(Client, netaddress, string, this.netaddress)
13     ATTRIB(Client, playermodel, string, this.playermodel)
14     ATTRIB(Client, playerskin, int, this.playerskin)
15
16     /** fingerprint of CA key the player used to authenticate */
17     ATTRIB(Client, crypto_keyfp, string, this.crypto_keyfp)
18     /** fingerprint of CA key the server used to authenticate to the player */
19     ATTRIB(Client, crypto_mykeyfp, string, this.crypto_mykeyfp)
20     /** fingerprint of ID used by the player entity, or string_null if not identified */
21     ATTRIB(Client, crypto_idfp, string, this.crypto_idfp)
22     /** set if the player's ID has been signed */
23     ATTRIB(Client, crypto_idfp_signed, bool, this.crypto_idfp_signed)
24     /** the string "AES128" if encrypting, and string_null if plaintext */
25     ATTRIB(Client, crypto_encryptmethod, string, this.crypto_encryptmethod)
26     /** the string "HMAC-SHA256" if signing, and string_null if plaintext */
27     ATTRIB(Client, crypto_signmethod, string, this.crypto_signmethod)
28
29     // custom
30
31     ATTRIB(Client, playerid, int, this.playerid)
32
33     METHOD(Client, m_unwind, bool(Client this));
34
35     STATIC_METHOD(Client, Add, void(Client this, int _team));
36     STATIC_METHOD(Client, Remove, void(Client this));
37
38     INIT(Client) {
39         if (this.m_unwind(this)) return this;
40         make_impure(this);
41         this.classname = "player_joining";
42         static int playerid_last;
43         this.playerid = ++playerid_last;
44         ClientState_attach(this);
45     }
46     DESTRUCTOR(Client) {
47         Client_Remove(this);
48     }
49     CONSTRUCTOR(Client, string name) {
50         CONSTRUCT(Client);
51         this.netname = name;
52         this.netaddress = "local";
53         this.playermodel = "models/player/megaerebus.iqm";
54     }
55 ENDCLASS(Client)
56
57 CLASS(Observer, Client)
58     INIT(Observer) {
59         this.classname = STR_OBSERVER;
60     }
61     DESTRUCTOR(Observer) { }
62 ENDCLASS(Observer)
63
64 CLASS(Spectator, Client)
65     INIT(Spectator) {
66         this.classname = STR_SPECTATOR;
67     }
68     DESTRUCTOR(Spectator) { }
69 ENDCLASS(Spectator)
70
71 CLASS(Player, Client)
72     INIT(Player) {
73         this.classname = STR_PLAYER;
74     }
75     DESTRUCTOR(Player) { }
76 ENDCLASS(Player)
77
78 METHOD(Client, m_unwind, bool(Client this))
79 {
80     TC(Client, this);
81     #define UNWIND(class) MACRO_BEGIN if (this.instanceOf##class) { METHOD_REFERENCE(class, dtorimpl)(this); } MACRO_END
82     switch (this.classname) {
83         case "Observer":
84             UNWIND(Spectator);
85             UNWIND(Player);
86             return true;
87         case "Spectator":
88             UNWIND(Observer);
89             UNWIND(Player);
90             return true;
91         case "Player":
92             UNWIND(Observer);
93             UNWIND(Spectator);
94             return true;
95     }
96     #undef UNWIND
97     return false;
98 }
99
100 float c1, c2, c3, c4;
101
102 void play_countdown(entity this, float finished, Sound samp);
103
104 float CalcRotRegen(float current, float regenstable, float regenfactor, float regenlinear, float regenframetime, float rotstable, float rotfactor, float rotlinear, float rotframetime, float limit);
105
106 bool Spectate(entity this, entity pl);
107
108 #define SPECTATE_COPY() [[accumulate]] void SpectateCopy(entity this, entity spectatee)
109 #define SPECTATE_COPYFIELD(fld) SPECTATE_COPY() { this.(fld) = spectatee.(fld); }