]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/cl_client.qh
Fix regressions in 911f8048
[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, flags, int, this.flags)
32     ATTRIB(Client, playerid, int, this.playerid)
33
34     METHOD(Client, m_unwind, bool(Client this));
35
36     INIT(Client) {
37         if (this.m_unwind(this)) return this;
38         this.classname = "player_joining";
39         this.flags = FL_CLIENT;
40         static int playerid_last;
41         this.playerid = ++playerid_last;
42         ClientState_attach(this);
43     }
44 ENDCLASS(Client)
45
46 CLASS(Observer, Client)
47     INIT(Observer) {
48         this.classname = STR_OBSERVER;
49     }
50     DESTRUCTOR(Observer) { }
51 ENDCLASS(Observer)
52
53 CLASS(Spectator, Client)
54     INIT(Spectator) {
55         this.classname = STR_SPECTATOR;
56     }
57     DESTRUCTOR(Spectator) { }
58 ENDCLASS(Spectator)
59
60 CLASS(Player, Client)
61     INIT(Player) {
62         this.classname = STR_PLAYER;
63     }
64     DESTRUCTOR(Player) { }
65 ENDCLASS(Player)
66
67 METHOD(Client, m_unwind, bool(Client this))
68 {
69     TC(Client, this);
70     #define UNWIND(class) MACRO_BEGIN if (this.instanceOf##class) { METHOD_REFERENCE(class, dtorimpl)(this); } MACRO_END
71     switch (this.classname) {
72         case "Observer":
73             UNWIND(Spectator);
74             UNWIND(Player);
75             return true;
76         case "Spectator":
77             UNWIND(Observer);
78             UNWIND(Player);
79             return true;
80         case "Player":
81             UNWIND(Observer);
82             UNWIND(Spectator);
83             return true;
84     }
85     #undef UNWIND
86     return false;
87 }
88
89 float c1, c2, c3, c4;
90
91 void play_countdown(float finished, Sound samp);
92
93 float CalcRotRegen(float current, float regenstable, float regenfactor, float regenlinear, float regenframetime, float rotstable, float rotfactor, float rotlinear, float rotframetime, float limit);
94
95 float Spectate(entity pl);
96
97 #define SPECTATE_COPY() [[accumulate]] void SpectateCopy(entity this, entity spectatee)
98 #define SPECTATE_COPYFIELD(fld) SPECTATE_COPY() { this.(fld) = spectatee.(fld); }