X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fent_cs.qh;h=65cdd83d3a71f4f5df325a8e90b727d936cb1300;hb=1bb89291d13308a708e74a7434a79fa9967fa64f;hp=389aadc1fd9283d1301f635d9d6f0dc93fc8b42f;hpb=b8aa1409c31da37c43d111b20f137ea69afb2d9b;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/ent_cs.qh b/qcsrc/common/ent_cs.qh index 389aadc1f..65cdd83d3 100644 --- a/qcsrc/common/ent_cs.qh +++ b/qcsrc/common/ent_cs.qh @@ -1,5 +1,4 @@ -#ifndef ENT_CS_H -#define ENT_CS_H +#pragma once REGISTER_NET_LINKED(ENT_CLIENT_ENTCS) REGISTER_NET_TEMP(CLIENT_ENTCS) @@ -26,7 +25,7 @@ REGISTER_NET_TEMP(CLIENT_ENTCS) bool entcs_send(entity this, entity to, int sf); - void entcs_think(); + void entcs_think(entity this); void entcs_attach(entity e); @@ -50,7 +49,8 @@ REGISTER_NET_TEMP(CLIENT_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) @@ -58,10 +58,21 @@ REGISTER_NET_TEMP(CLIENT_ENTCS) /** * @param i zero indexed player */ + .int frags; bool entcs_IsSpectating(int i) { bool unconnected = !playerslots[i].gotscores; - return unconnected || stof(getplayerkeyvalue(i, "frags")) == FRAGS_SPECTATOR; + entity e = entcs_receiver(i); + return unconnected || ((e) ? e.frags : stof(getplayerkeyvalue(i, "frags"))) == FRAGS_SPECTATOR; + } + + /** + * @param i zero indexed player + */ + int entcs_GetClientColors(int i) + { + entity e = entcs_receiver(i); + return e ? e.colormap : stof(getplayerkeyvalue(i, "colors")); } /** @@ -70,7 +81,7 @@ REGISTER_NET_TEMP(CLIENT_ENTCS) */ int entcs_GetTeamColor(int i) { - return (!teamplay) ? 0 : stof(getplayerkeyvalue(i, "colors")) & 15; + return (!teamplay) ? 0 : entcs_GetClientColors(i) & 15; } /** @@ -97,7 +108,8 @@ REGISTER_NET_TEMP(CLIENT_ENTCS) */ string entcs_GetName(int i) { - return ColorTranslateRGB(getplayerkeyvalue(i, "name")); + entity e = entcs_receiver(i); + return ColorTranslateRGB(e ? e.netname : getplayerkeyvalue(i, "name")); } /** @@ -126,7 +138,7 @@ REGISTER_NET_TEMP(CLIENT_ENTCS) ? '1 1 1' : colormapPaletteColor(((e.colormap >= 1024) ? e.colormap - : stof(getplayerkeyvalue(e.colormap - 1, "colors"))) & 15, true) + : entcs_GetClientColors(e.colormap - 1)) & 15, true) ; } @@ -140,5 +152,3 @@ REGISTER_NET_TEMP(CLIENT_ENTCS) } #endif - -#endif