Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
client.qh
Go to the documentation of this file.
1#pragma once
2
3#include "utils.qh"
5//#include <common/resources/resources.qh>
6#include <common/replicate.qh>
8
59
60// WEAPONTODO
62
63.entity clientdata;
64
65.float jointime; // time of connecting
66.float startplaytime; // time of switching from spectator to player
67.float alivetime_start; // start time of being alive
69
72
78
80
82
84.string playerskin;
85
86void ClientState_attach(entity this);
87
98
111
112 // engine client fields
114
133
139
143
146
147 // custom
148
150
192
193 // networked cvars
194
195// not currently handled by ClientState
196#if 0
197 ATTRIBARRAY(Client, msg_choice_choices, int, 20); // TODO: actually NOTIF_CHOICE_MAX
198 ATTRIB(Client, cvar_cl_allow_uid2name, int, this.cvar_cl_allow_uid2name);
199 ATTRIB(Client, cvar_cl_allow_uidtracking, int, this.cvar_cl_allow_uidtracking);
200 ATTRIB(Client, cvar_cl_autotaunt, float, this.cvar_cl_autotaunt);
201 ATTRIB(Client, cvar_cl_voice_directional, int, this.cvar_cl_voice_directional);
202 ATTRIB(Client, cvar_cl_voice_directional_taunt_attenuation, float, this.cvar_cl_voice_directional_taunt_attenuation);
203 ATTRIB(Client, cvar_cl_physics, string, this.cvar_cl_physics);
204 ATTRIB(Client, cvar_cl_buffs_autoreplace, bool, this.cvar_cl_buffs_autoreplace);
207 ATTRIB(Client, cvar_cl_spawn_near_teammate, bool, this.cvar_cl_spawn_near_teammate);
208 ATTRIB(Client, cvar_cl_gunalign, int, this.cvar_cl_gunalign);
209 ATTRIB(Client, cvar_cl_handicap_damage_given, float, this.cvar_cl_handicap_damage_given);
210 ATTRIB(Client, cvar_cl_handicap_damage_taken, float, this.cvar_cl_handicap_damage_taken);
211 ATTRIB(Client, cvar_cl_clippedspectating, bool, this.cvar_cl_clippedspectating);
212 ATTRIB(Client, cvar_cl_autoscreenshot, int, this.cvar_cl_autoscreenshot);
213 ATTRIB(Client, cvar_cl_jetpack_jump, bool, this.cvar_cl_jetpack_jump);
214 ATTRIB(Client, cvar_cl_noantilag, bool, this.cvar_cl_noantilag);
215 ATTRIB(Client, cvar_cl_movement_track_canjump, bool, this.cvar_cl_movement_track_canjump);
216 ATTRIB(Client, cvar_cl_weaponimpulsemode, int, this.cvar_cl_weaponimpulsemode);
217 ATTRIB(Client, cvar_g_xonoticversion, string, this.cvar_g_xonoticversion);
218 ATTRIB(Client, cvar_cl_autoswitch, bool, this.cvar_cl_autoswitch);
219 ATTRIB(Client, cvar_cl_casings, bool, this.cvar_cl_casings);
220 ATTRIB(Client, cvar_r_drawviewmodel, bool, this.cvar_r_drawviewmodel);
221 ATTRIB(Client, cvar_cl_dodging_timeout, float, this.cvar_cl_dodging_timeout);
222 ATTRIB(Client, cvar_cl_dodging, float, this.cvar_cl_dodging);
223 ATTRIB(Client, cvar_cl_multijump, bool, this.cvar_cl_multijump);
224 ATTRIB(Client, cvar_cl_accuracy_data_share, bool, this.cvar_cl_accuracy_data_share);
225 ATTRIB(Client, cvar_cl_accuracy_data_receive, bool, this.cvar_cl_accuracy_data_receive);
226 ATTRIBARRAY(Client, cvar_cl_weaponpriorities, string, 10);
227 ATTRIB(Client, cvar_cl_weaponpriority, string, this.cvar_cl_weaponpriority);
228 ATTRIB(Client, cvar_cl_autoswitch_cts, int, this.cvar_cl_autoswitch_cts);
229 ATTRIB(Client, cvar_cl_weapon_switch_reload, bool, this.cvar_cl_weapon_switch_reload);
230 ATTRIB(Client, cvar_cl_weapon_switch_fallback_to_impulse, bool, this.cvar_cl_weapon_switch_fallback_to_impulse);
231#endif
232
233 METHOD(Client, m_unwind, bool(Client this));
234
235 STATIC_METHOD(Client, Add, void(Client this, int _team));
236 STATIC_METHOD(Client, Remove, void(Client this));
237
239 if (this.m_unwind(this)) return this;
240 make_impure(this);
241 this.classname = "player_joining";
242 static int playerid_last;
243 this.playerid = ++playerid_last;
244 ClientState_attach(this);
245 }
247 Client_Remove(this);
248 }
251 this.netname = name;
252 this.netaddress = "local";
253 this.playermodel = cvar_defstring("sv_defaultplayermodel");
254 }
256
263
270
285
287{
288 TC(Client, this);
289 #define UNWIND(class) MACRO_BEGIN if (this.instanceOf##class) { METHOD_REFERENCE(class, dtorimpl)(this); } MACRO_END
290 switch (this.classname) {
291 case "Observer":
293 UNWIND(Player);
294 return true;
295 case "Spectator":
297 UNWIND(Player);
298 return true;
299 case "Player":
302 return true;
303 }
304 #undef UNWIND
305 return false;
306}
307
310#define INDEPENDENT_PLAYERS (autocvar__independent_players ? (autocvar__independent_players > 0) : independent_players)
311#define IS_INDEPENDENT_PLAYER(e) ((e).solid == SOLID_TRIGGER)
312#define MAKE_INDEPENDENT_PLAYER(e) ((e).solid = SOLID_TRIGGER, (e).frags = FRAGS_PLAYER_NONSOLID)
313
315
316void SendWelcomeMessage(entity this, int msg_type);
317
318// respawning
322
323.float respawn_countdown; // next number to count
324
325const int RESPAWN_FORCE = BIT(0);
326const int RESPAWN_SILENT = BIT(1);
327const int RESPAWN_DENY = BIT(2);
328
329.float spectatortime; // point in time since the client is spectating or observing
330
332
333const int SVC_SETVIEW = 5; // TODO: move to dpdefs where this belongs!
334
335// TODO: standardise resource regeneration
340
341// g_<gametype>_str:
342// If 0, default is used.
343// If <0, 0 is used.
344// Otherwise, g_str (default value) is used.
345// For consistency, negative values there are mapped to zero too.
346#define GAMETYPE_DEFAULTED_SETTING(str) \
347 ((gametype_setting_tmp = cvar(strcat("g_", GetGametype(), "_" #str))), \
348 (gametype_setting_tmp < 0) ? 0 \
349 : (gametype_setting_tmp == 0 || autocvar_g_respawn_delay_forced) ? max(0, autocvar_g_##str) \
350 : gametype_setting_tmp)
351
353
354bool PlayerInList(entity player, string list);
355
356bool PlayerInIDList(entity p, string idlist);
357
358bool PlayerInIPList(entity p, string iplist);
359
360void ClientData_Touch(entity e, bool to_spectators_too);
361
362void PlayerUseKey(entity this);
363
364void FixClientCvars(entity e);
365
366// called when a client connects, useful for updating sounds and such of static objects
367.void(entity this, entity player) init_for_player;
368
371STATIC_INIT(client_lists)
372{
375}
376
377void play_countdown(entity this, float finished, Sound samp);
378void player_powerups_remove_all(entity this, bool allow_poweroff_sound);
379
380// NOTE: current type is Resource (avoiding circular includes!)
381void RotRegen(entity this, entity current, float limit_mod,
382 float regenstable, float regenfactor, float regenlinear, float regenframetime,
383 float rotstable, float rotfactor, float rotlinear, float rotframetime);
384
385bool Spectate(entity this, entity pl);
386
387void ClientInit_Spawn();
388
389void PutObserverInServer(entity this, bool is_forced, bool use_spawnpoint);
390
391void SetSpectatee(entity this, entity spectatee);
392void SetSpectatee_status(entity this, int spectatee_num);
393
394void FixPlayermodel(entity player);
395
396void GiveWarmupResources(entity this);
397
398void ClientInit_misc(entity this);
399
400int GetPlayerLimit();
401
402const int MIN_SPEC_TIME = 1;
403void Join(entity this, bool queued_join);
404int nJoinAllowed(entity this);
405bool joinAllowed(entity this, int team_index);
406
407void PlayerFrame (entity this);
408
409#define SPECTATE_COPY() ACCUMULATE void SpectateCopy(entity this, entity spectatee)
410#define SPECTATE_COPYFIELD(fld) SPECTATE_COPY() { this.(fld) = spectatee.(fld); }
411
412const int MAX_SPECTATORS = 7;
#define BIT(n)
Only ever assign into the first 24 bits in QC (so max is BIT(23)).
Definition bits.qh:8
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
entity cursor_trace_ent
Definition client.qh:138
float jointime
Definition client.qh:162
float cmd_floodtime
Definition client.qh:189
entity teamkill_soundsource
Definition client.qh:160
int button6
Definition client.qh:120
int playerid
Definition client.qh:149
int button5
Definition client.qh:119
bool just_joined
Definition client.qh:176
int team
Definition client.qh:92
vector movement_old
Definition client.qh:156
string crypto_keyfp
fingerprint of CA key the player used to authenticate
Definition client.qh:100
bool crypto_idfp_signed
set if the player's ID has been signed
Definition client.qh:106
float latency_time
Definition client.qh:180
string playerskin
Definition client.qh:97
vector v_angle_old
Definition client.qh:181
string crypto_encryptmethod
the string "AES128" if encrypting, and string_null if plaintext
Definition client.qh:108
float hasweapon_complain_spam
Definition client.qh:184
bool version_mismatch
Definition client.qh:172
string netname
Client name.
Definition client.qh:90
int cursor_active
Definition client.qh:134
STATIC_METHOD(Client, Add, void(Client this, int _team))
int button2
Definition client.qh:116
int button14
Definition client.qh:128
float latency_sum
Definition client.qh:178
float pm_frametime
Definition client.qh:154
int button7
Definition client.qh:121
float idlekick_lasttimeleft
Definition client.qh:153
string playermodel
Definition client.qh:96
entity clientdata
Definition client.qh:188
int buttons_old
Definition client.qh:157
bool usekeypressed
Definition client.qh:161
entity scorekeeper
Definition client.qh:185
int colormap
Definition client.qh:91
float ping_movementloss
Definition client.qh:142
int button8
Definition client.qh:122
int parm_idlesince
Definition client.qh:151
int latency_cnt
Definition client.qh:179
string crypto_idfp
fingerprint of ID used by the player entity, or string_null if not identified
Definition client.qh:104
bool muted
Definition client.qh:152
int clientcolors
Definition client.qh:93
int button15
Definition client.qh:129
bool zoomstate
Definition client.qh:175
int buttonuse
Definition client.qh:131
int button13
Definition client.qh:127
int spectatee_status
Definition client.qh:174
entity accuracy
Definition client.qh:183
int button10
Definition client.qh:124
int impulse
Definition client.qh:113
string netname_previous
Definition client.qh:167
int button4
Definition client.qh:118
int hitplotfh
Definition client.qh:187
entity active_minigame
Definition client.qh:169
int allowed_timeouts
Definition client.qh:168
float teamkill_soundtime
Definition client.qh:159
int button0
Definition client.qh:115
float taunt_soundtime
Definition client.qh:170
float ping_packetloss
Definition client.qh:141
int buttonchat
Definition client.qh:132
float version_nagtime
Definition client.qh:166
float spectatortime
Definition client.qh:164
int button9
Definition client.qh:123
string weaponorder_byimpulse
Definition client.qh:190
vector cursor_trace_start
Definition client.qh:136
int button11
Definition client.qh:125
int specialcommand_pos
Definition client.qh:186
int pressedkeys
Definition client.qh:155
int version
Definition client.qh:173
bool race_completed
Definition client.qh:177
string crypto_mykeyfp
fingerprint of CA key the server used to authenticate to the player
Definition client.qh:102
string netaddress
Client IP.
Definition client.qh:95
int wants_join
Definition client.qh:163
STATIC_METHOD(Client, Remove, void(Client this))
float ping
Definition client.qh:140
string crypto_signmethod
the string "HMAC-SHA256" if signing, and string_null if plaintext
Definition client.qh:110
int button3
Definition client.qh:117
float teamkill_complain
Definition client.qh:158
int autojoin_checked
Definition client.qh:191
vector v_angle
Definition client.qh:144
int button12
Definition client.qh:126
int button16
Definition client.qh:130
vector cursor_screen
Definition client.qh:135
vector cursor_trace_endpos
Definition client.qh:137
virtual void m_unwind()
Definition client.qh:286
float startplaytime
Definition client.qh:165
Client()
Definition client.qh:238
vector movement
Definition client.qh:145
float model_randomizer
Definition client.qh:182
int killcount
Definition client.qh:171
limitations: NULL cannot be present elements can only be present once a maximum of IL_MAX lists can e...
Observer()
Definition client.qh:258
vector dual_weapons
Definition client.qh:275
int itemkeys
Definition client.qh:276
float ballistics_density
Definition client.qh:277
Player()
Definition client.qh:279
Spectator()
Definition client.qh:265
int spectatee_status
the -1 disables HUD panels before CSQC receives necessary data
Definition main.qh:197
const int MAX_SPECTATORS
Definition main.qh:177
string classname
float death_time
string playerskin
string playermodel
int wants_join
Definition ent_cs.qh:69
#define IL_NEW()
#define TC(T, sym)
Definition _all.inc:82
string name
Definition menu.qh:30
const string cvar_defstring(string name)
int msg_choice_choices[NOTIF_CHOICE_MAX]
set on each player containing MSG_CHOICE choices
Definition all.qh:722
#define ATTRIBARRAY(cname, name, type, cnt)
Definition oo.qh:271
#define INIT(cname)
Definition oo.qh:214
#define make_impure(e)
Definition oo.qh:22
#define CLASS(...)
Definition oo.qh:149
#define ENDCLASS(cname)
Definition oo.qh:286
#define DESTRUCTOR(cname)
Definition oo.qh:224
#define METHOD(cname, name, prototype)
Definition oo.qh:274
#define ATTRIB(...)
Definition oo.qh:152
#define CONSTRUCTOR(cname,...)
Definition oo.qh:217
#define CONSTRUCT(cname,...)
Definition oo.qh:126
vector
Definition self.qh:96
entity this
Definition self.qh:76
float autocvar_g_respawn_delay_small
Definition client.qh:22
int killcount
Definition client.qh:314
void player_powerups_remove_all(entity this, bool allow_poweroff_sound)
Definition client.qc:1540
void play_countdown(entity this, float finished, Sound samp)
Definition client.qc:1531
string autocvar_sv_quickmenu_file
Definition client.qh:54
float autocvar_sv_maxidle
Definition client.qh:37
float respawn_time_max
Definition client.qh:321
string autocvar_g_xonoticversion
Definition client.qh:46
bool independent_players
Definition client.qh:309
float startplaytime
Definition client.qh:66
int respawn_flags
Definition client.qh:319
const int RESPAWN_SILENT
Definition client.qh:326
float autocvar_g_player_alpha
Definition client.qh:19
bool autocvar_g_respawn_ghosts
Definition client.qh:28
bool autocvar_g_forced_respawn
Definition client.qh:43
int autocvar_g_respawn_waves
Definition client.qh:33
string weaponorder_byimpulse
Definition client.qh:61
float autocvar_g_balance_pause_health_rot_spawn
Definition client.qh:15
void GiveWarmupResources(entity this)
Definition client.qc:568
string autocvar_sv_motd
Definition client.qh:52
bool autocvar_sv_servermodelsonly
Definition client.qh:55
int playerid
Definition client.qh:81
int GetPlayerLimit()
Definition client.qc:2154
string autocvar_g_mutatormsg
Definition client.qh:35
float autocvar_gameversion_min
Definition client.qh:48
void PlayerUseKey(entity this)
Definition client.qc:2634
bool player_blocked
Definition client.qh:331
bool autocvar_sv_spectate
Definition client.qh:57
bool autocvar_g_fullbrightplayers
Definition client.qh:17
const int MIN_SPEC_TIME
Definition client.qh:402
IntrusiveList g_observepoints
Definition client.qh:370
void SendWelcomeMessage(entity this, int msg_type)
Definition client.qc:1078
int team_selected
Definition client.qh:74
bool autocvar_g_botclip_collisions
Definition client.qh:16
float autocvar_sv_player_scale
Definition client.qh:58
void RotRegen(entity this, entity current, float limit_mod, float regenstable, float regenfactor, float regenlinear, float regenframetime, float rotstable, float rotfactor, float rotlinear, float rotframetime)
void FixClientCvars(entity e)
Definition client.qc:1000
bool PlayerInIDList(entity p, string idlist)
Definition client.qc:1039
bool just_joined
Definition client.qh:75
float autocvar_g_balance_pause_armor_rot_spawn
Definition client.qh:12
int autocvar_sv_maxidle_minplayers
Definition client.qh:38
IntrusiveList g_initforplayer
Definition client.qh:369
float autocvar_g_respawn_delay_large
Definition client.qh:24
int autocvar_g_balance_armor_start
Definition client.qh:11
float autocvar_sv_maxidle_playertospectator
Definition client.qh:39
float autocvar_g_balance_pause_fuel_rot_spawn
Definition client.qh:13
void PutObserverInServer(entity this, bool is_forced, bool use_spawnpoint)
putting a client as observer in the server
Definition client.qc:261
bool autocvar__notarget
Definition client.qh:9
float autocvar_g_maxplayers_spectator_blocktime
Definition client.qh:45
string autocvar_hostname
Definition client.qh:50
const int RESPAWN_DENY
Definition client.qh:327
bool autocvar_g_respawn_delay_forced
Definition client.qh:27
float jointime
Definition client.qh:65
float pauserotfuel_finished
Definition client.qh:339
float autocvar_g_respawn_ghosts_time
Definition client.qh:31
void calculate_player_respawn_time(entity this)
Definition client.qc:1398
bool zoomstate
Definition client.qh:71
float respawn_time
Definition client.qh:320
float autocvar_g_respawn_ghosts_alpha
Definition client.qh:29
bool autocvar_sv_maxidle_slots_countbots
Definition client.qh:42
bool PlayerInIPList(entity p, string iplist)
Definition client.qc:1030
int autocvar_spawn_debug
Definition client.qh:51
bool autocvar_g_playerclip_collisions
Definition client.qh:18
bool autocvar_g_nodepthtestplayers
Definition client.qh:34
float pauseregen_finished
Definition client.qh:336
int autocvar_g_maxplayers
Definition client.qh:44
float pauserothealth_finished
Definition client.qh:337
float autocvar_g_respawn_ghosts_speed
Definition client.qh:32
int autocvar_g_respawn_delay_large_count
Definition client.qh:25
const int SVC_SETVIEW
Definition client.qh:333
float respawn_countdown
Definition client.qh:323
float autocvar_g_player_brightness
Definition client.qh:20
int nJoinAllowed(entity this)
Determines how many player slots are free.
Definition client.qc:2176
float autocvar_g_respawn_delay_max
Definition client.qh:26
void SetSpectatee_status(entity this, int spectatee_num)
Definition client.qc:1903
bool Spectate(entity this, entity pl)
Definition client.qc:1976
float autocvar_g_player_damageforcescale
Definition client.qh:21
float pauserotarmor_finished
Definition client.qh:338
bool joinAllowed(entity this, int team_index)
Definition client.qc:2263
float spectatortime
Definition client.qh:329
void FixPlayermodel(entity player)
Definition client.qc:454
void PlayerFrame(entity this)
Definition client.qc:2863
const int RESPAWN_FORCE
Definition client.qh:325
bool PlayerInList(entity player, string list)
Definition client.qc:1048
void ClientInit_Spawn()
Definition client.qc:947
int autocvar_sv_name_maxlength
Definition client.qh:53
float autocvar_gameversion
Definition client.qh:47
int autocvar_sv_maxidle_slots
Definition client.qh:41
float autocvar_g_respawn_ghosts_fadetime
Definition client.qh:30
bool autocvar_sv_show_entnum
Definition client.qh:10
int autocvar__independent_players
Definition client.qh:308
float autocvar_g_balance_pause_health_regen_spawn
Definition client.qh:14
void Join(entity this, bool queued_join)
it's assumed this isn't called for bots (campaign_bots_may_start, centreprints)
Definition client.qc:2073
void ClientInit_misc(entity this)
Definition client.qc:909
void SetSpectatee(entity this, entity spectatee)
Definition client.qc:1938
entity clientdata
Definition client.qh:63
bool autocvar_sv_maxidle_alsokickspectators
Definition client.qh:40
float alivetime_start
Definition client.qh:67
int autocvar_g_respawn_delay_small_count
Definition client.qh:23
bool autocvar_sv_foginterval
Definition client.qh:36
void ClientData_Touch(entity e, bool to_spectators_too)
Definition client.qc:185
#define UNWIND(class)
bool autocvar_sv_showspectators
Definition client.qh:56
void ClientState_attach(entity this)
Definition state.qc:46
float autocvar_gameversion_max
Definition client.qh:49
#define STATIC_INIT(func)
during worldspawn
Definition static.qh:33
int pressedkeys
string cvar_cl_pokenade_type
Definition sv_nades.qh:51
string cvar_cl_nade_type
Definition sv_nades.qh:50
const string STR_SPECTATOR
Definition utils.qh:6
const string STR_OBSERVER
Definition utils.qh:7
const string STR_PLAYER
Definition utils.qh:5