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
60
61// WEAPONTODO
63
64.entity clientdata;
65
66.float jointime; // time of connecting
67.float startplaytime; // time of switching from spectator to player
68.float alivetime_start; // start time of being alive
70
73
79
81
83
85.string playerskin;
86
87void ClientState_attach(entity this);
88
99
112
113 // engine client fields
115
134
140
144
147
148 // custom
149
151
193
194 // networked cvars
195
196// not currently handled by ClientState
197#if 0
198 ATTRIBARRAY(Client, msg_choice_choices, int, 20); // TODO: actually NOTIF_CHOICE_MAX
199 ATTRIB(Client, cvar_cl_allow_uid2name, int, this.cvar_cl_allow_uid2name);
200 ATTRIB(Client, cvar_cl_allow_uidtracking, int, this.cvar_cl_allow_uidtracking);
201 ATTRIB(Client, cvar_cl_autotaunt, float, this.cvar_cl_autotaunt);
202 ATTRIB(Client, cvar_cl_voice_directional, int, this.cvar_cl_voice_directional);
203 ATTRIB(Client, cvar_cl_voice_directional_taunt_attenuation, float, this.cvar_cl_voice_directional_taunt_attenuation);
204 ATTRIB(Client, cvar_cl_physics, string, this.cvar_cl_physics);
205 ATTRIB(Client, cvar_cl_buffs_autoreplace, bool, this.cvar_cl_buffs_autoreplace);
208 ATTRIB(Client, cvar_cl_spawn_near_teammate, bool, this.cvar_cl_spawn_near_teammate);
209 ATTRIB(Client, cvar_cl_gunalign, int, this.cvar_cl_gunalign);
210 ATTRIB(Client, cvar_cl_handicap_damage_given, float, this.cvar_cl_handicap_damage_given);
211 ATTRIB(Client, cvar_cl_handicap_damage_taken, float, this.cvar_cl_handicap_damage_taken);
212 ATTRIB(Client, cvar_cl_clippedspectating, bool, this.cvar_cl_clippedspectating);
213 ATTRIB(Client, cvar_cl_autoscreenshot, int, this.cvar_cl_autoscreenshot);
214 ATTRIB(Client, cvar_cl_jetpack_jump, bool, this.cvar_cl_jetpack_jump);
215 ATTRIB(Client, cvar_cl_noantilag, bool, this.cvar_cl_noantilag);
216 ATTRIB(Client, cvar_cl_movement_track_canjump, bool, this.cvar_cl_movement_track_canjump);
217 ATTRIB(Client, cvar_cl_weaponimpulsemode, int, this.cvar_cl_weaponimpulsemode);
218 ATTRIB(Client, cvar_g_xonoticversion, string, this.cvar_g_xonoticversion);
219 ATTRIB(Client, cvar_cl_autoswitch, bool, this.cvar_cl_autoswitch);
220 ATTRIB(Client, cvar_cl_casings, bool, this.cvar_cl_casings);
221 ATTRIB(Client, cvar_r_drawviewmodel, bool, this.cvar_r_drawviewmodel);
222 ATTRIB(Client, cvar_cl_dodging_timeout, float, this.cvar_cl_dodging_timeout);
223 ATTRIB(Client, cvar_cl_dodging, float, this.cvar_cl_dodging);
224 ATTRIB(Client, cvar_cl_multijump, bool, this.cvar_cl_multijump);
225 ATTRIB(Client, cvar_cl_accuracy_data_share, bool, this.cvar_cl_accuracy_data_share);
226 ATTRIB(Client, cvar_cl_accuracy_data_receive, bool, this.cvar_cl_accuracy_data_receive);
227 ATTRIBARRAY(Client, cvar_cl_weaponpriorities, string, 10);
228 ATTRIB(Client, cvar_cl_weaponpriority, string, this.cvar_cl_weaponpriority);
229 ATTRIB(Client, cvar_cl_autoswitch_cts, int, this.cvar_cl_autoswitch_cts);
230 ATTRIB(Client, cvar_cl_weapon_switch_reload, bool, this.cvar_cl_weapon_switch_reload);
231 ATTRIB(Client, cvar_cl_weapon_switch_fallback_to_impulse, bool, this.cvar_cl_weapon_switch_fallback_to_impulse);
232#endif
233
234 METHOD(Client, m_unwind, bool(Client this));
235
236 STATIC_METHOD(Client, Add, void(Client this, int _team));
237 STATIC_METHOD(Client, Remove, void(Client this));
238
240 if (this.m_unwind(this)) return this;
241 make_impure(this);
242 this.classname = "player_joining";
243 static int playerid_last;
244 this.playerid = ++playerid_last;
245 ClientState_attach(this);
246 }
248 Client_Remove(this);
249 }
252 this.netname = name;
253 this.netaddress = "local";
254 this.playermodel = cvar_defstring("sv_defaultplayermodel");
255 }
257
264
271
286
288{
289 TC(Client, this);
290 #define UNWIND(class) MACRO_BEGIN if (this.instanceOf##class) { METHOD_REFERENCE(class, dtorimpl)(this); } MACRO_END
291 switch (this.classname) {
292 case "Observer":
294 UNWIND(Player);
295 return true;
296 case "Spectator":
298 UNWIND(Player);
299 return true;
300 case "Player":
303 return true;
304 }
305 #undef UNWIND
306 return false;
307}
308
311#define INDEPENDENT_PLAYERS (autocvar__independent_players ? (autocvar__independent_players > 0) : independent_players)
312#define IS_INDEPENDENT_PLAYER(e) ((e).solid == SOLID_TRIGGER)
313#define MAKE_INDEPENDENT_PLAYER(e) (((e).solid = SOLID_TRIGGER), ((e).frags = FRAGS_PLAYER_OUT_OF_GAME))
314
316
317void SendWelcomeMessage(entity this, int msg_type);
318
319// respawning
323
324.float respawn_countdown; // next number to count
325
326const int RESPAWN_FORCE = BIT(0);
327const int RESPAWN_SILENT = BIT(1);
328const int RESPAWN_DENY = BIT(2);
329
330.float spectatortime; // point in time since the client is spectating or observing
331
333
334const int SVC_SETVIEW = 5; // TODO: move to dpdefs where this belongs!
335
336// TODO: standardise resource regeneration
341
342// g_<gametype>_str:
343// If 0, default is used.
344// If <0, 0 is used.
345// Otherwise, g_str (default value) is used.
346// For consistency, negative values there are mapped to zero too.
347#define GAMETYPE_DEFAULTED_SETTING(str) \
348 ((gametype_setting_tmp = cvar(strcat("g_", GetGametype(), "_" #str))), \
349 (gametype_setting_tmp < 0) ? 0 \
350 : (gametype_setting_tmp == 0 || autocvar_g_respawn_delay_forced) ? max(0, autocvar_g_##str) \
351 : gametype_setting_tmp)
352
354
355bool PlayerInList(entity player, string list);
356
357bool PlayerInIDList(entity p, string idlist);
358
359bool PlayerInIPList(entity p, string iplist);
360
361void ClientData_Touch(entity e, bool to_spectators_too);
362
363void PlayerUseKey(entity this);
364
365void FixClientCvars(entity e);
366
367// called when a client connects, useful for updating sounds and such of static objects
368.void(entity this, entity player) init_for_player;
369
372STATIC_INIT(client_lists)
373{
376}
377
378void play_countdown(entity this, float finished, Sound samp);
379void player_powerups_remove_all(entity this, bool allow_poweroff_sound);
380
381// NOTE: current type is Resource (avoiding circular includes!)
382void RotRegen(entity this, entity current, float limit_mod,
383 float regenstable, float regenfactor, float regenlinear, float regenframetime,
384 float rotstable, float rotfactor, float rotlinear, float rotframetime);
385
386bool Spectate(entity this, entity pl);
387
388void ClientInit_Spawn();
389
390void PutObserverInServer(entity this, bool is_forced, bool use_spawnpoint);
391
392void SetSpectatee(entity this, entity spectatee);
393void SetSpectatee_status(entity this, int spectatee_num);
394
395void FixPlayermodel(entity player);
396
397void GiveWarmupResources(entity this);
398
399void ClientInit_misc(entity this);
400
401int GetPlayerLimit();
402
403const int MIN_SPEC_TIME = 1;
404void Join(entity this, bool queued_join);
405int nJoinAllowed(entity this);
406bool joinAllowed(entity this, int team_index);
407
408void PlayerFrame (entity this);
409
410#define SPECTATE_COPY() ACCUMULATE void SpectateCopy(entity this, entity spectatee)
411#define SPECTATE_COPYFIELD(fld) SPECTATE_COPY() { this.(fld) = spectatee.(fld); }
412
413const 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:139
float jointime
Definition client.qh:163
float cmd_floodtime
Definition client.qh:190
entity teamkill_soundsource
Definition client.qh:161
int button6
Definition client.qh:121
int playerid
Definition client.qh:150
int button5
Definition client.qh:120
bool just_joined
Definition client.qh:177
int team
Definition client.qh:93
vector movement_old
Definition client.qh:157
string crypto_keyfp
fingerprint of CA key the player used to authenticate
Definition client.qh:101
bool crypto_idfp_signed
set if the player's ID has been signed
Definition client.qh:107
float latency_time
Definition client.qh:181
string playerskin
Definition client.qh:98
vector v_angle_old
Definition client.qh:182
string crypto_encryptmethod
the string "AES128" if encrypting, and string_null if plaintext
Definition client.qh:109
float hasweapon_complain_spam
Definition client.qh:185
bool version_mismatch
Definition client.qh:173
string netname
Client name.
Definition client.qh:91
int cursor_active
Definition client.qh:135
STATIC_METHOD(Client, Add, void(Client this, int _team))
int button2
Definition client.qh:117
int button14
Definition client.qh:129
float latency_sum
Definition client.qh:179
float pm_frametime
Definition client.qh:155
int button7
Definition client.qh:122
float idlekick_lasttimeleft
Definition client.qh:154
string playermodel
Definition client.qh:97
entity clientdata
Definition client.qh:189
int buttons_old
Definition client.qh:158
bool usekeypressed
Definition client.qh:162
entity scorekeeper
Definition client.qh:186
int colormap
Definition client.qh:92
float ping_movementloss
Definition client.qh:143
int button8
Definition client.qh:123
int parm_idlesince
Definition client.qh:152
int latency_cnt
Definition client.qh:180
string crypto_idfp
fingerprint of ID used by the player entity, or string_null if not identified
Definition client.qh:105
bool muted
Definition client.qh:153
int clientcolors
Definition client.qh:94
int button15
Definition client.qh:130
bool zoomstate
Definition client.qh:176
int buttonuse
Definition client.qh:132
int button13
Definition client.qh:128
int spectatee_status
Definition client.qh:175
entity accuracy
Definition client.qh:184
int button10
Definition client.qh:125
int impulse
Definition client.qh:114
string netname_previous
Definition client.qh:168
int button4
Definition client.qh:119
int hitplotfh
Definition client.qh:188
entity active_minigame
Definition client.qh:170
int allowed_timeouts
Definition client.qh:169
float teamkill_soundtime
Definition client.qh:160
int button0
Definition client.qh:116
float taunt_soundtime
Definition client.qh:171
float ping_packetloss
Definition client.qh:142
int buttonchat
Definition client.qh:133
float version_nagtime
Definition client.qh:167
float spectatortime
Definition client.qh:165
int button9
Definition client.qh:124
string weaponorder_byimpulse
Definition client.qh:191
vector cursor_trace_start
Definition client.qh:137
int button11
Definition client.qh:126
int specialcommand_pos
Definition client.qh:187
int pressedkeys
Definition client.qh:156
int version
Definition client.qh:174
bool race_completed
Definition client.qh:178
string crypto_mykeyfp
fingerprint of CA key the server used to authenticate to the player
Definition client.qh:103
string netaddress
Client IP.
Definition client.qh:96
int wants_join
Definition client.qh:164
STATIC_METHOD(Client, Remove, void(Client this))
float ping
Definition client.qh:141
string crypto_signmethod
the string "HMAC-SHA256" if signing, and string_null if plaintext
Definition client.qh:111
int button3
Definition client.qh:118
float teamkill_complain
Definition client.qh:159
int autojoin_checked
Definition client.qh:192
vector v_angle
Definition client.qh:145
int button12
Definition client.qh:127
int button16
Definition client.qh:131
vector cursor_screen
Definition client.qh:136
vector cursor_trace_endpos
Definition client.qh:138
virtual void m_unwind()
Definition client.qh:287
float startplaytime
Definition client.qh:166
Client()
Definition client.qh:239
vector movement
Definition client.qh:146
float model_randomizer
Definition client.qh:183
int killcount
Definition client.qh:172
limitations: NULL cannot be present elements can only be present once a maximum of IL_MAX lists can e...
Observer()
Definition client.qh:259
vector dual_weapons
Definition client.qh:276
int itemkeys
Definition client.qh:277
float ballistics_density
Definition client.qh:278
Player()
Definition client.qh:280
Spectator()
Definition client.qh:266
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:73
#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]
Definition all.qh:737
#define ATTRIBARRAY(cname, name, type, cnt)
Definition oo.qh:266
#define INIT(cname)
Definition oo.qh:210
#define make_impure(e)
Definition oo.qh:22
#define CLASS(...)
Definition oo.qh:145
#define ENDCLASS(cname)
Definition oo.qh:281
#define DESTRUCTOR(cname)
Definition oo.qh:220
#define METHOD(cname, name, prototype)
Definition oo.qh:269
#define ATTRIB(...)
Definition oo.qh:148
#define CONSTRUCTOR(cname,...)
Definition oo.qh:213
#define CONSTRUCT(cname,...)
Definition oo.qh:123
vector
Definition self.qh:92
entity this
Definition self.qh:72
float autocvar_g_respawn_delay_small
Definition client.qh:22
int killcount
Definition client.qh:315
void player_powerups_remove_all(entity this, bool allow_poweroff_sound)
Definition client.qc:1535
void play_countdown(entity this, float finished, Sound samp)
Definition client.qc:1526
string autocvar_sv_quickmenu_file
Definition client.qh:54
float autocvar_sv_foginterval
Definition client.qh:36
float autocvar_sv_maxidle
Definition client.qh:37
float respawn_time_max
Definition client.qh:322
string autocvar_g_xonoticversion
Definition client.qh:46
bool independent_players
Definition client.qh:310
float startplaytime
Definition client.qh:67
int respawn_flags
Definition client.qh:320
const int RESPAWN_SILENT
Definition client.qh:327
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:62
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:82
bool autocvar_sv_teamnagger
Definition client.qh:58
int GetPlayerLimit()
Definition client.qc:2127
string autocvar_g_mutatormsg
Definition client.qh:35
float autocvar_gameversion_min
Definition client.qh:48
void PlayerUseKey(entity this)
Definition client.qc:2584
bool player_blocked
Definition client.qh:332
bool autocvar_sv_spectate
Definition client.qh:57
bool autocvar_g_fullbrightplayers
Definition client.qh:17
const int MIN_SPEC_TIME
Definition client.qh:403
IntrusiveList g_observepoints
Definition client.qh:371
void SendWelcomeMessage(entity this, int msg_type)
Definition client.qc:1075
int team_selected
Definition client.qh:75
bool autocvar_g_botclip_collisions
Definition client.qh:16
float autocvar_sv_player_scale
Definition client.qh:59
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:997
bool PlayerInIDList(entity p, string idlist)
Definition client.qc:1036
bool just_joined
Definition client.qh:76
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:370
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:328
bool autocvar_g_respawn_delay_forced
Definition client.qh:27
float jointime
Definition client.qh:66
float pauserotfuel_finished
Definition client.qh:340
float autocvar_g_respawn_ghosts_time
Definition client.qh:31
void calculate_player_respawn_time(entity this)
Definition client.qc:1392
bool zoomstate
Definition client.qh:72
float respawn_time
Definition client.qh:321
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:1027
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:337
int autocvar_g_maxplayers
Definition client.qh:44
float pauserothealth_finished
Definition client.qh:338
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:334
float respawn_countdown
Definition client.qh:324
float autocvar_g_player_brightness
Definition client.qh:20
int nJoinAllowed(entity this)
Determines how many player slots are free.
Definition client.qc:2143
float autocvar_g_respawn_delay_max
Definition client.qh:26
void SetSpectatee_status(entity this, int spectatee_num)
Definition client.qc:1898
bool Spectate(entity this, entity pl)
Definition client.qc:1971
float autocvar_g_player_damageforcescale
Definition client.qh:21
float pauserotarmor_finished
Definition client.qh:339
bool joinAllowed(entity this, int team_index)
Definition client.qc:2230
float spectatortime
Definition client.qh:330
void FixPlayermodel(entity player)
Definition client.qc:454
void PlayerFrame(entity this)
Definition client.qc:2822
const int RESPAWN_FORCE
Definition client.qh:326
bool PlayerInList(entity player, string list)
Definition client.qc:1045
void ClientInit_Spawn()
Definition client.qc:944
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:309
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:2068
void ClientInit_misc(entity this)
Definition client.qc:905
void SetSpectatee(entity this, entity spectatee)
Definition client.qc:1933
entity clientdata
Definition client.qh:64
bool autocvar_sv_maxidle_alsokickspectators
Definition client.qh:40
float alivetime_start
Definition client.qh:68
int autocvar_g_respawn_delay_small_count
Definition client.qh:23
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:32
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