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
 spectator but still in game (can be in a team)
const int ENTCS_SPEC_PURE = 1
 real spectator
int frags
int handicap_level
bool has_origin
bool has_sv_origin
 True when a recent server sent origin has been received.
bool m_entcs_private
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 65 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:77

Definition at line 72 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:54
ArrayList _entcs
Definition ent_cs.qh:52

Definition at line 63 of file ent_cs.qh.

◆ entcs_receiver_2

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

Definition at line 64 of file ent_cs.qh.

◆ EVAL_entcs_receiver

#define EVAL_entcs_receiver ( ...)
Value:
__VA_ARGS__

Definition at line 62 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:79
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 271 of file ent_cs.qc.

272 {
273 entity e = CS(player).entcs = new_pure(entcs_sender);
274 e.owner = player;
276 e.nextthink = time;
277 Net_LinkEntity(e, false, 0, entcs_send);
278 // NOTE: the following code block has been disabled as a workaround for https://gitlab.com/xonotic/xonotic-data.pk3dir/-/issues/1824
279#if 0
280 if (!IS_REAL_CLIENT(player)) return;
281 FOREACH_CLIENT(true,
282 {
283 assert(CS(it).entcs);
284 _entcs_send(CS(it).entcs, msg_entity = player, BITS(23), MSG_ONE);
285 });
286#endif
287 }
#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:242
bool _entcs_send(entity this, entity to, int sf, int chan)
Definition ent_cs.qc:213
void entcs_think(entity this)
Definition ent_cs.qc:247
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:167
#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:66
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:52

◆ entcs_detach()

void entcs_detach ( entity player)

Definition at line 289 of file ent_cs.qc.

290 {
291 if (!CS(player).entcs)
292 return;
293 delete(CS(player).entcs);
294 CS(player).entcs = NULL;
295 }

◆ entcs_force_origin()

void entcs_force_origin ( entity player)

Definition at line 39 of file ent_cs.qc.

40{
41 CS(player).entcs.m_forceupdate = BIT(ENTCS_PROP_ORIGIN_id);
42}
#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:25

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 161 of file ent_cs.qh.

162 {
164 return e ? e.alpha : 1;
165 }
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 111 of file ent_cs.qh.

112 {
113 entity e = entcs_receiver(i);
114 return e ? e.colormap : 0;
115 }

References entcs_receiver, and entity().

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

◆ entcs_GetColor()

vector entcs_GetColor ( int i)
Parameters
izero indexed player

Definition at line 170 of file ent_cs.qh.

171 {
173 return (!e || e.colormap <= 0)
174 ? '1 1 1'
175 : colormapPaletteColor(((e.colormap >= 1024)
176 ? e.colormap
177 : entcs_GetClientColors(e.colormap - 1)) & 15, true);
178 }
#define colormapPaletteColor(c, isPants)
Definition color.qh:5
int entcs_GetClientColors(int i)
Definition ent_cs.qh:111

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 93 of file ent_cs.qh.

94 {
96 return e.handicap_level;
97 }

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 135 of file ent_cs.qh.

136 {
137 int t = entcs_GetTeam(i);
138 if (teamplay && !t) t = -1;
139 return t;
140 }
int entcs_GetTeam(int i)
Definition ent_cs.qh:129
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 77 of file ent_cs.qh.

78 {
79 bool unconnected = !playerslots[i].gotscores;
81 int fr = ((e) ? e.frags : 0);
82 if (unconnected || fr == FRAGS_SPECTATOR)
83 return ENTCS_SPEC_PURE;
84 int sol = ((e) ? e.sv_solid : SOLID_NOT);
85 if (fr == FRAGS_PLAYER_OUT_OF_GAME && sol == SOLID_NOT)
87 return 0;
88 }
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
real spectator
Definition ent_cs.qh:70
const int ENTCS_SPEC_IN_SCOREBOARD
spectator but still in game (can be in a team)
Definition ent_cs.qh:71

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 129 of file ent_cs.qh.

130 {
132 }
int entcs_GetTeamColor(int i)
Definition ent_cs.qh:121
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 121 of file ent_cs.qh.

122 {
123 return (!teamplay) ? 0 : entcs_GetClientColors(i) & 15;
124 }

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 102 of file ent_cs.qh.

103 {
104 entity e = entcs_receiver(i);
105 return e.wants_join;
106 }

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 183 of file ent_cs.qh.

184 {
186 return e ? e.csqcmodel_isdead : false;
187 }

References CSQCModel_server2csqc(), and entity().

Referenced by Draw_ShowNames_All().

◆ entcs_send()

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

Definition at line 242 of file ent_cs.qc.

243 {
244 return _entcs_send(this, to, sf, MSG_ENTITY);
245 }
const int MSG_ENTITY
Definition net.qh:156

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

Referenced by entcs_attach().

◆ entcs_think()

void entcs_think ( entity this)

Definition at line 247 of file ent_cs.qc.

248 {
249 this.nextthink = time + 0.015625; // TODO: increase this to like 0.125 once the client can do smoothing
250 entity player = this.owner;
251 FOREACH(EntCSProps, it.m_check(this, player),
252 {
253 it.m_set(this, player);
254 this.SendFlags |= BIT(it.m_id);
255 });
256
258 // health is set to special values after the game ends, ignore any change
260
261 // always send origin of players even if they stand still otherwise
262 // if a teammate isn't in my pvs and their health (or view angle or name
263 // etc...) changes then their tag disappears
264 if (IS_PLAYER(this.owner))
266
267 // not needed, origin is just data to be sent
268 //setorigin(this, this.origin); // relink
269 }
entity owner
Definition main.qh:87
#define IS_PLAYER(s)
Definition player.qh:242
float nextthink
int ENTCS_PROP_HEALTH_id
Definition ent_cs.qc:26
bool intermission_running
#define FOREACH(list, cond, body)
Definition iter.qh:19
int SendFlags
Definition net.qh:159

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 208 of file ent_cs.qc.

209 {
210 FOREACH_CLIENT(it != player && IS_PLAYER(it), CS(it).entcs.SendFlags |= ENTCS_PRIVATEMASK);
211 }

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

Referenced by MUTATOR_HOOKFUNCTION(), and PutObserverInServer().

◆ SHUTDOWN()

SHUTDOWN ( _entcs )

Definition at line 57 of file ent_cs.qh.

58 {
60 }
#define AL_DELETE(this)
Definition arraylist.qh:17

References _entcs, and AL_DELETE.

◆ STATIC_INIT()

STATIC_INIT ( _entcs )

Definition at line 53 of file ent_cs.qh.

54 {
55 AL_NEW(_entcs, 255, NULL, e); // 255 is the engine limit on maxclients
56 }
#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 52 of file ent_cs.qh.

Referenced by SHUTDOWN(), and STATIC_INIT().

◆ alpha

float alpha

Definition at line 156 of file ent_cs.qh.

◆ entcs

◆ ENTCS_SPEC_IN_SCOREBOARD

const int ENTCS_SPEC_IN_SCOREBOARD = 2

spectator but still in game (can be in a team)

Definition at line 71 of file ent_cs.qh.

Referenced by entcs_GetSpecState(), and MUTATOR_HOOKFUNCTION().

◆ ENTCS_SPEC_PURE

const int ENTCS_SPEC_PURE = 1

real spectator

Definition at line 70 of file ent_cs.qh.

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

◆ frags

◆ handicap_level

int handicap_level

Definition at line 68 of file ent_cs.qh.

Referenced by WriteByte().

◆ has_origin

bool has_origin

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

Definition at line 13 of file ent_cs.qh.

◆ m_forceupdate

int m_forceupdate

Definition at line 41 of file ent_cs.qh.

Referenced by _entcs_send(), and _wepent_send().

◆ radar_showenemies

bool radar_showenemies

Definition at line 46 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.

Referenced by WriteByte().

◆ wants_join