X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fent_cs.qh;h=fdaaab2d57c0f37be4345a824a3892a3fdd90e51;hb=a8e9c14803c6ee158f8183701f8e9c8601da9983;hp=7f773527b073f34b85907ee481e4442bd38f28fd;hpb=201f6309c92217b63dc34daf004fbb7424096eca;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/ent_cs.qh b/qcsrc/common/ent_cs.qh index 7f773527b..fdaaab2d5 100644 --- a/qcsrc/common/ent_cs.qh +++ b/qcsrc/common/ent_cs.qh @@ -1,7 +1,7 @@ -#ifndef ENT_CS_H -#define ENT_CS_H +#pragma once REGISTER_NET_LINKED(ENT_CLIENT_ENTCS) +REGISTER_NET_TEMP(CLIENT_ENTCS) /** True when private information such as origin is available */ .bool m_entcs_private; @@ -25,7 +25,7 @@ REGISTER_NET_LINKED(ENT_CLIENT_ENTCS) bool entcs_send(entity this, entity to, int sf); - void entcs_think(); + void entcs_think(entity this); void entcs_attach(entity e); @@ -40,25 +40,35 @@ REGISTER_NET_LINKED(ENT_CLIENT_ENTCS) #ifdef CSQC - AL_declare(_entcs); + ArrayList _entcs; STATIC_INIT(_entcs) { - AL_init(_entcs, 255, NULL, e); // 255 is the engine limit on maxclients + AL_NEW(_entcs, 255, NULL, e); // 255 is the engine limit on maxclients } SHUTDOWN(_entcs) { - AL_delete(_entcs); + AL_DELETE(_entcs); } - #define entcs_receiver(...) EVAL(OVERLOAD(entcs_receiver, __VA_ARGS__)) + #define entcs_receiver(...) EVAL_entcs_receiver(OVERLOAD(entcs_receiver, __VA_ARGS__)) + #define EVAL_entcs_receiver(...) __VA_ARGS__ #define entcs_receiver_1(i) AL_gete(_entcs, i) #define entcs_receiver_2(i, v) AL_sete(_entcs, i, v) #define entcs_is_self(e) ((e).sv_entnum == player_localentnum - 1) + /** + * @param i zero indexed player + */ + bool entcs_IsSpectating(int i) + { + bool unconnected = !playerslots[i].gotscores; + return unconnected || stof(getplayerkeyvalue(i, "frags")) == FRAGS_SPECTATOR; + } + /** * @param i zero indexed player * @returns 0 if not teamplay */ - int GetPlayerColorForce(int i) + int entcs_GetTeamColor(int i) { return (!teamplay) ? 0 : stof(getplayerkeyvalue(i, "colors")) & 15; } @@ -67,17 +77,25 @@ REGISTER_NET_LINKED(ENT_CLIENT_ENTCS) * @param i zero indexed player * @returns 0 if not teamplay | NUM_TEAM_##N | NUM_SPECTATOR */ - int GetPlayerColor(int i) + int entcs_GetTeam(int i) { - bool unconnected = !playerslots[i].gotscores; - bool spec = unconnected || stof(getplayerkeyvalue(i, "frags")) == FRAGS_SPECTATOR; - return (spec) ? NUM_SPECTATOR : GetPlayerColorForce(i); + return entcs_IsSpectating(i) ? NUM_SPECTATOR : entcs_GetTeamColor(i); + } + + /** + * Same as `entcs_GetTeam`, but returns -1 for no team in teamplay + */ + int entcs_GetScoreTeam(int i) + { + int t = entcs_GetTeam(i); + if (teamplay && !t) t = -1; + return t; } /** * @param i zero indexed player */ - string GetPlayerName(int i) + string entcs_GetName(int i) { return ColorTranslateRGB(getplayerkeyvalue(i, "name")); } @@ -92,7 +110,7 @@ REGISTER_NET_LINKED(ENT_CLIENT_ENTCS) /** * @param i zero indexed player */ - float getplayeralpha(int i) + float entcs_GetAlpha(int i) { entity e = CSQCModel_server2csqc(i); return e ? e.alpha : 1; @@ -101,7 +119,7 @@ REGISTER_NET_LINKED(ENT_CLIENT_ENTCS) /** * @param i zero indexed player */ - vector getcsqcplayercolor(int i) + vector entcs_GetColor(int i) { entity e = CSQCModel_server2csqc(i); return (!e || e.colormap <= 0) @@ -115,12 +133,10 @@ REGISTER_NET_LINKED(ENT_CLIENT_ENTCS) /** * @param i zero indexed player */ - bool getplayerisdead(int i) + bool entcs_IsDead(int i) { entity e = CSQCModel_server2csqc(i); return e ? e.csqcmodel_isdead : false; } #endif - -#endif