]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/client.qh
Merge branch 'master' into Mario/cs_clientcvars
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / client.qh
1 #pragma once
2
3 void ClientState_attach(entity this);
4
5 IntrusiveList g_players;
6 STATIC_INIT(g_players) { g_players = IL_NEW(); }
7
8 CLASS(Client, Object)
9     /** Client name */
10     ATTRIB(Client, netname, string, this.netname);
11     ATTRIB(Client, colormap, int, this.colormap);
12     ATTRIB(Client, team, int, this.team);
13     ATTRIB(Client, clientcolors, int, this.clientcolors);
14     /** Client IP */
15     ATTRIB(Client, netaddress, string, this.netaddress);
16     ATTRIB(Client, playermodel, string, this.playermodel);
17     ATTRIB(Client, playerskin, int, this.playerskin);
18
19     /** fingerprint of CA key the player used to authenticate */
20     ATTRIB(Client, crypto_keyfp, string, this.crypto_keyfp);
21     /** fingerprint of CA key the server used to authenticate to the player */
22     ATTRIB(Client, crypto_mykeyfp, string, this.crypto_mykeyfp);
23     /** fingerprint of ID used by the player entity, or string_null if not identified */
24     ATTRIB(Client, crypto_idfp, string, this.crypto_idfp);
25     /** set if the player's ID has been signed */
26     ATTRIB(Client, crypto_idfp_signed, bool, this.crypto_idfp_signed);
27     /** the string "AES128" if encrypting, and string_null if plaintext */
28     ATTRIB(Client, crypto_encryptmethod, string, this.crypto_encryptmethod);
29     /** the string "HMAC-SHA256" if signing, and string_null if plaintext */
30     ATTRIB(Client, crypto_signmethod, string, this.crypto_signmethod);
31
32     // engine client fields
33     ATTRIB(Client, impulse, int, this.impulse);
34
35     ATTRIB(Client, button0, int, this.button0);
36     ATTRIB(Client, button2, int, this.button2);
37     ATTRIB(Client, button3, int, this.button3);
38     ATTRIB(Client, button4, int, this.button4);
39     ATTRIB(Client, button5, int, this.button5);
40     ATTRIB(Client, button6, int, this.button6);
41     ATTRIB(Client, button7, int, this.button7);
42     ATTRIB(Client, button8, int, this.button8);
43     ATTRIB(Client, button9, int, this.button9);
44     ATTRIB(Client, button10, int, this.button10);
45     ATTRIB(Client, button11, int, this.button11);
46     ATTRIB(Client, button12, int, this.button12);
47     ATTRIB(Client, button13, int, this.button13);
48     ATTRIB(Client, button14, int, this.button14);
49     ATTRIB(Client, button15, int, this.button15);
50     ATTRIB(Client, button16, int, this.button16);
51     ATTRIB(Client, buttonuse, int, this.buttonuse);
52     ATTRIB(Client, buttonchat, int, this.buttonchat);
53
54     ATTRIB(Client, cursor_active, int, this.cursor_active);
55     ATTRIB(Client, cursor_screen, vector, this.cursor_screen);
56     ATTRIB(Client, cursor_trace_start, vector, this.cursor_trace_start);
57     ATTRIB(Client, cursor_trace_endpos, vector, this.cursor_trace_endpos);
58     ATTRIB(Client, cursor_trace_ent, entity, this.cursor_trace_ent);
59
60     ATTRIB(Client, ping, float, this.ping);
61     ATTRIB(Client, ping_packetloss, float, this.ping_packetloss);
62     ATTRIB(Client, ping_movementloss, float, this.ping_movementloss);
63
64     ATTRIB(Client, v_angle, vector, this.v_angle);
65     ATTRIB(Client, movement, vector, this.movement);
66
67     // custom
68
69     ATTRIB(Client, playerid, int, this.playerid);
70
71     ATTRIB(Client, parm_idlesince, int, this.parm_idlesince);
72     ATTRIB(Client, muted, bool, this.muted);
73     ATTRIB(Client, killindicator_teamchange, int, this.killindicator_teamchange);
74     ATTRIB(Client, idlekick_lasttimeleft, float, this.idlekick_lasttimeleft);
75     ATTRIB(Client, pm_frametime, float, this.pm_frametime);
76     ATTRIB(Client, pressedkeys, int, this.pressedkeys);
77     ATTRIB(Client, movement_old, vector, this.movement_old);
78     ATTRIB(Client, buttons_old, int, this.buttons_old);
79     ATTRIB(Client, teamkill_complain, float, this.teamkill_complain);
80     ATTRIB(Client, teamkill_soundtime, float, this.teamkill_soundtime);
81     ATTRIB(Client, teamkill_soundsource, entity, this.teamkill_soundsource);
82     ATTRIB(Client, usekeypressed, bool, this.usekeypressed);
83     ATTRIB(Client, motd_actived_time, float, this.motd_actived_time);
84     ATTRIB(Client, jointime, float, this.jointime);
85     ATTRIB(Client, spectatortime, float, this.spectatortime);
86     ATTRIB(Client, version_nagtime, float, this.version_nagtime);
87     ATTRIB(Client, netname_previous, string, this.netname_previous);
88     ATTRIB(Client, allowed_timeouts, int, this.allowed_timeouts);
89     ATTRIB(Client, active_minigame, entity, this.active_minigame);
90     ATTRIB(Client, taunt_soundtime, float, this.taunt_soundtime);
91     ATTRIB(Client, killcount, int, this.killcount);
92     ATTRIB(Client, version_mismatch, bool, this.version_mismatch);
93     ATTRIB(Client, version, int, this.version);
94     ATTRIB(Client, spectatee_status, int, this.spectatee_status);
95     ATTRIB(Client, zoomstate, bool, this.zoomstate);
96     ATTRIB(Client, just_joined, bool, this.just_joined);
97     ATTRIB(Client, race_completed, bool, this.race_completed);
98     ATTRIBARRAY(Client, msg_choice_choices, int, 50); // TODO: actually NOTIF_CHOICE_MAX
99     ATTRIB(Client, latency_sum, float, this.latency_sum);
100     ATTRIB(Client, latency_cnt, int, this.latency_cnt);
101     ATTRIB(Client, latency_time, float, this.latency_time);
102     ATTRIB(Client, v_angle_old, vector, this.v_angle_old);
103     ATTRIB(Client, model_randomizer, float, this.model_randomizer);
104     ATTRIB(Client, accuracy, entity, this.accuracy);
105     ATTRIB(Client, hasweapon_complain_spam, float, this.hasweapon_complain_spam);
106     ATTRIB(Client, scorekeeper, entity, this.scorekeeper);
107     ATTRIB(Client, specialcommand_pos, int, this.specialcommand_pos);
108     ATTRIB(Client, hitplotfh, int, this.hitplotfh);
109     ATTRIB(Client, clientdata, entity, this.clientdata);
110     ATTRIB(Client, cmd_floodcount, int, this.cmd_floodcount);
111     ATTRIB(Client, cmd_floodtime, float, this.cmd_floodtime);
112
113     // networked cvars
114
115     ATTRIB(Client, cvar_cl_allow_uid2name, int, this.cvar_cl_allow_uid2name);
116     ATTRIB(Client, cvar_cl_allow_uidtracking, int, this.cvar_cl_allow_uidtracking);
117     ATTRIB(Client, cvar_cl_autotaunt, float, this.cvar_cl_autotaunt);
118     ATTRIB(Client, cvar_cl_voice_directional, int, this.cvar_cl_voice_directional);
119     ATTRIB(Client, cvar_cl_voice_directional_taunt_attenuation, float, this.cvar_cl_voice_directional_taunt_attenuation);
120     ATTRIB(Client, cvar_cl_physics, string, this.cvar_cl_physics);
121     ATTRIB(Client, cvar_cl_buffs_autoreplace, bool, this.cvar_cl_buffs_autoreplace);
122     ATTRIB(Client, cvar_cl_nade_type, int, this.cvar_cl_nade_type);
123     ATTRIB(Client, cvar_cl_pokenade_type, string, this.cvar_cl_pokenade_type);
124     ATTRIB(Client, cvar_cl_spawn_near_teammate, bool, this.cvar_cl_spawn_near_teammate);
125     ATTRIB(Client, cvar_cl_gunalign, int, this.cvar_cl_gunalign);
126     ATTRIB(Client, cvar_cl_handicap, float, this.cvar_cl_handicap);
127     ATTRIB(Client, cvar_cl_clippedspectating, bool, this.cvar_cl_clippedspectating);
128     ATTRIB(Client, cvar_cl_autoscreenshot, int, this.cvar_cl_autoscreenshot);
129     ATTRIB(Client, cvar_cl_jetpack_jump, bool, this.cvar_cl_jetpack_jump);
130     ATTRIB(Client, cvar_cl_newusekeysupported, bool, this.cvar_cl_newusekeysupported);
131     ATTRIB(Client, cvar_cl_noantilag, bool, this.cvar_cl_noantilag);
132     ATTRIB(Client, cvar_cl_movement_track_canjump, bool, this.cvar_cl_movement_track_canjump);
133     ATTRIB(Client, cvar_cl_weaponimpulsemode, int, this.cvar_cl_weaponimpulsemode);
134     ATTRIB(Client, cvar_g_xonoticversion, string, this.cvar_g_xonoticversion);
135     ATTRIB(Client, autoswitch, bool, this.autoswitch);
136     ATTRIB(Client, cvar_cl_dodging_timeout, float, this.cvar_cl_dodging_timeout);
137     ATTRIB(Client, cvar_cl_multijump, bool, this.cvar_cl_multijump);
138     ATTRIB(Client, cvar_cl_accuracy_data_share, bool, this.cvar_cl_accuracy_data_share);
139     ATTRIB(Client, cvar_cl_accuracy_data_receive, bool, this.cvar_cl_accuracy_data_receive);
140
141     METHOD(Client, m_unwind, bool(Client this));
142
143     STATIC_METHOD(Client, Add, void(Client this, int _team));
144     STATIC_METHOD(Client, Remove, void(Client this));
145
146     INIT(Client) {
147         if (this.m_unwind(this)) return this;
148         make_impure(this);
149         this.classname = "player_joining";
150         static int playerid_last;
151         this.playerid = ++playerid_last;
152         ClientState_attach(this);
153     }
154     DESTRUCTOR(Client) {
155         Client_Remove(this);
156     }
157     CONSTRUCTOR(Client, string name) {
158         CONSTRUCT(Client);
159         this.netname = name;
160         this.netaddress = "local";
161         this.playermodel = cvar_defstring("sv_defaultplayermodel");
162     }
163 ENDCLASS(Client)
164
165 CLASS(Observer, Client)
166     INIT(Observer) {
167         this.classname = STR_OBSERVER;
168     }
169     DESTRUCTOR(Observer) { }
170 ENDCLASS(Observer)
171
172 CLASS(Spectator, Client)
173     INIT(Spectator) {
174         this.classname = STR_SPECTATOR;
175     }
176     DESTRUCTOR(Spectator) { }
177 ENDCLASS(Spectator)
178
179 CLASS(Player, Client)
180     
181     // custom
182
183     ATTRIB(Player, dual_weapons, vector, this.dual_weapons); // TODO: actually WepSet!
184     ATTRIB(Player, itemkeys, int, this.itemkeys);
185
186     INIT(Player) {
187         this.classname = STR_PLAYER;
188         IL_PUSH(g_players, this);
189     }
190     DESTRUCTOR(Player) {
191         IL_REMOVE(g_players, this);
192     }
193 ENDCLASS(Player)
194
195 METHOD(Client, m_unwind, bool(Client this))
196 {
197     TC(Client, this);
198     #define UNWIND(class) MACRO_BEGIN if (this.instanceOf##class) { METHOD_REFERENCE(class, dtorimpl)(this); } MACRO_END
199     switch (this.classname) {
200         case "Observer":
201             UNWIND(Spectator);
202             UNWIND(Player);
203             return true;
204         case "Spectator":
205             UNWIND(Observer);
206             UNWIND(Player);
207             return true;
208         case "Player":
209             UNWIND(Observer);
210             UNWIND(Spectator);
211             return true;
212     }
213     #undef UNWIND
214     return false;
215 }
216
217 float c1, c2, c3, c4;
218
219 void play_countdown(entity this, float finished, Sound samp);
220
221 float CalcRotRegen(float current, float regenstable, float regenfactor, float regenlinear, float regenframetime, float rotstable, float rotfactor, float rotlinear, float rotframetime, float limit);
222
223 bool Spectate(entity this, entity pl);
224
225 #define SPECTATE_COPY() [[accumulate]] void SpectateCopy(entity this, entity spectatee)
226 #define SPECTATE_COPYFIELD(fld) SPECTATE_COPY() { this.(fld) = spectatee.(fld); }