Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
ent_cs.qh File Reference
Include dependency graph for ent_cs.qh:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define entcs_is_self(e)
#define entcs_IsSpectating(i)
#define entcs_receiver(...)
#define entcs_receiver_1(i)
#define entcs_receiver_2(i, v)
#define EVAL_entcs_receiver(...)

Functions

entity CSQCModel_server2csqc (int i)
void entcs_attach (entity player)
void entcs_detach (entity player)
void entcs_force_origin (entity player)
float entcs_GetAlpha (int i)
int entcs_GetClientColors (int i)
vector entcs_GetColor (int i)
int entcs_GetHandicapLevel (int i)
string entcs_GetName (int i)
int entcs_GetScoreTeam (int i)
 Same as entcs_GetTeam, but returns -1 for no team in teamplay.
int entcs_GetSpecState (int i)
int entcs_GetTeam (int i)
int entcs_GetTeamColor (int i)
int entcs_GetWantsJoin (int i)
bool entcs_IsDead (int i)
bool entcs_send (entity this, entity to, int sf)
void entcs_think (entity this)
void entcs_update_players (entity player)
 SHUTDOWN (_entcs)
 STATIC_INIT (_entcs)

Variables

ArrayList _entcs
float alpha
entity entcs
const int ENTCS_SPEC_IN_SCOREBOARD = 2
const int ENTCS_SPEC_PURE = 1
int frags
int handicap_level
bool has_origin
 True when origin is available.
bool has_sv_origin
 True when a recent server sent origin has been received.
bool m_entcs_private
 True when private information such as origin is available.
int m_forceupdate
bool radar_showenemies
int sv_solid
int wants_join

Macro Definition Documentation

◆ entcs_is_self

#define entcs_is_self ( e)
Value:
((e).sv_entnum == player_localentnum - 1)
float player_localentnum

Definition at line 69 of file ent_cs.qh.

◆ entcs_IsSpectating

#define entcs_IsSpectating ( i)
Value:
#define boolean(value)
Definition bool.qh:9
int entcs_GetSpecState(int i)
Definition ent_cs.qh:81

Definition at line 76 of file ent_cs.qh.

Referenced by Draw_ShowNames_All(), and HUD_Mod_Survival().

◆ entcs_receiver

#define entcs_receiver ( ...)

◆ entcs_receiver_1

#define entcs_receiver_1 ( i)
Value:
#define AL_gete(this, idx)
Definition arraylist.qh:56
ArrayList _entcs
Definition ent_cs.qh:56

Definition at line 67 of file ent_cs.qh.

◆ entcs_receiver_2

#define entcs_receiver_2 ( i,
v )
Value:
#define AL_sete(this, idx, val)
Definition arraylist.qh:57

Definition at line 68 of file ent_cs.qh.

◆ EVAL_entcs_receiver

#define EVAL_entcs_receiver ( ...)
Value:
__VA_ARGS__

Definition at line 66 of file ent_cs.qh.

Function Documentation

◆ CSQCModel_server2csqc()

entity CSQCModel_server2csqc ( int i)
Parameters
izero indexed player

Definition at line 314 of file cl_model.qc.

315{
316 if (i < maxclients) return CSQCModel_players[i];
317 ++i;
318 LOG_DEBUGF("player out of bounds: %d", i);
319 return findfloat(NULL, entnum, i);
320}
entity CSQCModel_players[255]
Definition cl_model.qc:216
float maxclients
float entnum
#define LOG_DEBUGF(...)
Definition log.qh:81
entity findfloat(entity start,.float field, float match)
#define NULL
Definition post.qh:14

References CSQCModel_players, entity(), entnum, findfloat(), LOG_DEBUGF, maxclients, and NULL.

Referenced by CSQC_UpdateView(), CSQCPlayer_SetCamera(), entcs_GetAlpha(), entcs_GetColor(), entcs_IsDead(), Hud_Dynamic_Frame(), Scoreboard_WouldDraw(), StrafeHUD_GetStrafeplayer(), viewloc_SetViewLocation(), viewmodel_animate(), and viewmodel_draw().

◆ entcs_attach()

void entcs_attach ( entity player)

Definition at line 251 of file ent_cs.qc.

252 {
253 entity e = CS(player).entcs = new_pure(entcs_sender);
254 e.owner = player;
256 e.nextthink = time;
257 Net_LinkEntity(e, false, 0, entcs_send);
258 // NOTE: the following code block has been disabled as a workaround for https://gitlab.com/xonotic/xonotic-data.pk3dir/-/issues/1824
259#if 0
260 if (!IS_REAL_CLIENT(player)) return;
261 FOREACH_CLIENT(true, {
262 assert(CS(it).entcs);
263 _entcs_send(CS(it).entcs, msg_entity = player, BITS(23), MSG_ONE);
264 });
265#endif
266 }
#define BITS(n)
Definition bits.qh:9
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
float time
bool entcs_send(entity this, entity to, int sf)
Definition ent_cs.qc:220
bool _entcs_send(entity this, entity to, int sf, int chan)
Definition ent_cs.qc:191
void entcs_think(entity this)
Definition ent_cs.qc:225
entity entcs
Definition ent_cs.qh:34
void Net_LinkEntity(entity e, bool docull, float dt, bool(entity this, entity to, int sendflags) sendfunc)
Definition net.qh:123
#define assert(expr,...)
Definition log.qh:8
float MSG_ONE
Definition menudefs.qc:56
#define new_pure(class)
purely logical entities (not linked to the area grid)
Definition oo.qh:67
entity msg_entity
Definition progsdefs.qc:63
#define setthink(e, f)
ClientState CS(Client this)
Definition state.qh:47
#define IS_REAL_CLIENT(v)
Definition utils.qh:17
#define FOREACH_CLIENT(cond, body)
Definition utils.qh:50

◆ entcs_detach()

void entcs_detach ( entity player)

Definition at line 268 of file ent_cs.qc.

269 {
270 if (!CS(player).entcs) return;
271 delete(CS(player).entcs);
272 CS(player).entcs = NULL;
273 }

◆ entcs_force_origin()

void entcs_force_origin ( entity player)

Definition at line 36 of file ent_cs.qc.

37{
38 CS(player).entcs.m_forceupdate = BIT(ENTCS_PROP_ORIGIN_id);
39}
#define BIT(n)
Only ever assign into the first 24 bits in QC (so max is BIT(23)).
Definition bits.qh:8
int ENTCS_PROP_ORIGIN_id
Definition ent_cs.qc:23

References BIT, CS(), ENTCS_PROP_ORIGIN_id, and entity().

Referenced by globalsound(), and playersound().

◆ entcs_GetAlpha()

float entcs_GetAlpha ( int i)
Parameters
izero indexed player

Definition at line 167 of file ent_cs.qh.

168 {
170 return e ? e.alpha : 1;
171 }
entity CSQCModel_server2csqc(int i)
Definition cl_model.qc:314

References CSQCModel_server2csqc(), and entity().

Referenced by Draw_ShowNames().

◆ entcs_GetClientColors()

int entcs_GetClientColors ( int i)
Parameters
izero indexed player

Definition at line 115 of file ent_cs.qh.

116 {
117 entity e = entcs_receiver(i);
118 return e ? e.colormap : 0;
119 }

References entcs_receiver, and entity().

Referenced by CSQCPlayer_ModelAppearance_Apply(), entcs_GetColor(), entcs_GetTeamColor(), HUD_Main(), NET_HANDLE(), Scoreboard_GetName(), and viewmodel_draw().

◆ entcs_GetColor()

vector entcs_GetColor ( int i)
Parameters
izero indexed player

Definition at line 176 of file ent_cs.qh.

177 {
179 return (!e || e.colormap <= 0)
180 ? '1 1 1'
181 : colormapPaletteColor(((e.colormap >= 1024)
182 ? e.colormap
183 : entcs_GetClientColors(e.colormap - 1)) & 15, true)
184 ;
185 }
#define colormapPaletteColor(c, isPants)
Definition color.qh:5
int entcs_GetClientColors(int i)
Definition ent_cs.qh:115

References colormapPaletteColor, CSQCModel_server2csqc(), entcs_GetClientColors(), entity(), and vector.

Referenced by Draw_GrapplingHook(), and NET_HANDLE().

◆ entcs_GetHandicapLevel()

int entcs_GetHandicapLevel ( int i)
Parameters
izero indexed player

Definition at line 97 of file ent_cs.qh.

98 {
100 return e.handicap_level;
101 }

References entcs_receiver, and entity().

Referenced by Scoreboard_GetName().

◆ entcs_GetName()

◆ entcs_GetScoreTeam()

int entcs_GetScoreTeam ( int i)

Same as entcs_GetTeam, but returns -1 for no team in teamplay.

Definition at line 141 of file ent_cs.qh.

142 {
143 int t = entcs_GetTeam(i);
144 if (teamplay && !t) t = -1;
145 return t;
146 }
int entcs_GetTeam(int i)
Definition ent_cs.qh:133
bool teamplay
Definition teams.qh:59

References entcs_GetTeam(), and teamplay.

Referenced by Playerchecker_Think(), and Scoreboard_UpdatePlayerTeams().

◆ entcs_GetSpecState()

int entcs_GetSpecState ( int i)
Parameters
izero indexed player

Definition at line 81 of file ent_cs.qh.

82 {
83 bool unconnected = !playerslots[i].gotscores;
85 int fr = ((e) ? e.frags : 0);
86 if (unconnected || fr == FRAGS_SPECTATOR)
87 return ENTCS_SPEC_PURE;
88 int sol = ((e) ? e.sv_solid : SOLID_NOT);
89 if (fr == FRAGS_PLAYER_OUT_OF_GAME && sol == SOLID_NOT)
91 return 0;
92 }
entity playerslots[255]
Definition main.qh:84
const int FRAGS_PLAYER_OUT_OF_GAME
Definition constants.qh:5
const int FRAGS_SPECTATOR
Definition constants.qh:4
const float SOLID_NOT
const int ENTCS_SPEC_PURE
Definition ent_cs.qh:74
const int ENTCS_SPEC_IN_SCOREBOARD
Definition ent_cs.qh:75

References entcs_receiver, ENTCS_SPEC_IN_SCOREBOARD, ENTCS_SPEC_PURE, entity(), FRAGS_PLAYER_OUT_OF_GAME, FRAGS_SPECTATOR, playerslots, and SOLID_NOT.

Referenced by entcs_GetTeam(), MUTATOR_HOOKFUNCTION(), and Scoreboard_DrawItem().

◆ entcs_GetTeam()

int entcs_GetTeam ( int i)
Parameters
izero indexed player

Definition at line 133 of file ent_cs.qh.

134 {
136 }
int entcs_GetTeamColor(int i)
Definition ent_cs.qh:125
const int NUM_SPECTATOR
Definition teams.qh:23

References entcs_GetSpecState(), entcs_GetTeamColor(), ENTCS_SPEC_PURE, and NUM_SPECTATOR.

Referenced by CSQC_UpdateView(), Draw_ShowNames(), Draw_WaypointSprite(), EnemyHitCheck(), entcs_GetScoreTeam(), Scoreboard_ComparePlayerScores(), and turret_draw2d().

◆ entcs_GetTeamColor()

int entcs_GetTeamColor ( int i)
Parameters
izero indexed player
Returns
0 if not teamplay

Definition at line 125 of file ent_cs.qh.

126 {
127 return (!teamplay) ? 0 : entcs_GetClientColors(i) & 15;
128 }

References entcs_GetClientColors(), and teamplay.

Referenced by Draw_GrapplingHook(), and entcs_GetTeam().

◆ entcs_GetWantsJoin()

int entcs_GetWantsJoin ( int i)
Parameters
izero indexed player

Definition at line 106 of file ent_cs.qh.

107 {
108 entity e = entcs_receiver(i);
109 return e.wants_join;
110 }

References entcs_receiver, and entity().

Referenced by HUD_InfoMessages(), Scoreboard_DrawItem(), and Scoreboard_DrawOthers().

◆ entcs_IsDead()

bool entcs_IsDead ( int i)
Parameters
izero indexed player

Definition at line 190 of file ent_cs.qh.

191 {
193 return e ? e.csqcmodel_isdead : false;
194 }

References CSQCModel_server2csqc(), and entity().

Referenced by Draw_ShowNames_All().

◆ entcs_send()

bool entcs_send ( entity this,
entity to,
int sf )

Definition at line 220 of file ent_cs.qc.

221 {
222 return _entcs_send(this, to, sf, MSG_ENTITY);
223 }
const int MSG_ENTITY
Definition net.qh:115

References _entcs_send(), entity(), and MSG_ENTITY.

Referenced by entcs_attach().

◆ entcs_think()

void entcs_think ( entity this)

Definition at line 225 of file ent_cs.qc.

226 {
227 this.nextthink = time + 0.015625; // TODO: increase this to like 0.125 once the client can do smoothing
228 entity player = this.owner;
229 FOREACH(EntCSProps, it.m_check(this, player),
230 {
231 it.m_set(this, player);
232 this.SendFlags |= BIT(it.m_id);
233 });
234
236 {
237 // health is set to special values after the game ends, ignore any change
239 }
240
241 // always send origin of players even if they stand still otherwise
242 // if a teammate isn't in my pvs and their health (or view angle or name
243 // etc...) changes then their tag disappears
244 if (IS_PLAYER(this.owner))
246
247 // not needed, origin is just data to be sent
248 //setorigin(this, this.origin); // relink
249 }
entity owner
Definition main.qh:87
#define IS_PLAYER(s)
Definition player.qh:243
float nextthink
int ENTCS_PROP_HEALTH_id
Definition ent_cs.qc:24
bool intermission_running
#define FOREACH(list, cond, body)
Definition iter.qh:19
int SendFlags
Definition net.qh:118

References BIT, ENTCS_PROP_HEALTH_id, ENTCS_PROP_ORIGIN_id, entity(), FOREACH, intermission_running, IS_PLAYER, nextthink, owner, SendFlags, and time.

Referenced by entcs_attach(), and ReadEntcs().

◆ entcs_update_players()

void entcs_update_players ( entity player)

Definition at line 183 of file ent_cs.qc.

184 {
185 FOREACH_CLIENT(it != player && IS_PLAYER(it),
186 {
187 CS(it).entcs.SendFlags |= ENTCS_PRIVATEMASK;
188 });
189 }
int ENTCS_PRIVATEMASK
Definition ent_cs.qc:171

References CS(), ENTCS_PRIVATEMASK, entity(), FOREACH_CLIENT, and IS_PLAYER.

Referenced by MUTATOR_HOOKFUNCTION(), and PutObserverInServer().

◆ SHUTDOWN()

SHUTDOWN ( _entcs )

Definition at line 61 of file ent_cs.qh.

62 {
64 }
#define AL_DELETE(this)
Definition arraylist.qh:18

References _entcs, and AL_DELETE.

◆ STATIC_INIT()

STATIC_INIT ( _entcs )

Definition at line 57 of file ent_cs.qh.

58 {
59 AL_NEW(_entcs, 255, NULL, e); // 255 is the engine limit on maxclients
60 }
#define AL_NEW(this, n, default, T)
Definition arraylist.qh:7

References _entcs, AL_NEW, and NULL.

Variable Documentation

◆ _entcs

ArrayList _entcs

Definition at line 56 of file ent_cs.qh.

Referenced by SHUTDOWN(), and STATIC_INIT().

◆ alpha

float alpha

Definition at line 162 of file ent_cs.qh.

◆ entcs

entity entcs

Definition at line 34 of file ent_cs.qh.

Referenced by Draw_ShowNames(), Draw_ShowNames_All(), entcs_attach(), entcs_detach(), and NET_HANDLE().

◆ ENTCS_SPEC_IN_SCOREBOARD

const int ENTCS_SPEC_IN_SCOREBOARD = 2

Definition at line 75 of file ent_cs.qh.

Referenced by entcs_GetSpecState(), and MUTATOR_HOOKFUNCTION().

◆ ENTCS_SPEC_PURE

const int ENTCS_SPEC_PURE = 1

Definition at line 74 of file ent_cs.qh.

Referenced by entcs_GetSpecState(), entcs_GetTeam(), and Scoreboard_DrawItem().

◆ frags

◆ handicap_level

int handicap_level

Definition at line 72 of file ent_cs.qh.

◆ has_origin

bool has_origin

True when origin is available.

Definition at line 16 of file ent_cs.qh.

◆ has_sv_origin

bool has_sv_origin

True when a recent server sent origin has been received.

Definition at line 19 of file ent_cs.qh.

◆ m_entcs_private

bool m_entcs_private

True when private information such as origin is available.

Definition at line 13 of file ent_cs.qh.

◆ m_forceupdate

int m_forceupdate

Definition at line 44 of file ent_cs.qh.

Referenced by _entcs_send(), and _wepent_send().

◆ radar_showenemies

bool radar_showenemies

Definition at line 50 of file ent_cs.qh.

Referenced by _entcs_send(), nb_Initialize(), and race_Initialize().

◆ sv_solid

int sv_solid

Definition at line 21 of file ent_cs.qh.

◆ wants_join