]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/ent_cs.qh
Use entcs to handle client colors (improves FPS by not using the slow engine function)
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / ent_cs.qh
index fdaaab2d57c0f37be4345a824a3892a3fdd90e51..9981665e90f5d5003ddf7aa73a1b572ae81b5ce4 100644 (file)
@@ -64,13 +64,22 @@ REGISTER_NET_TEMP(CLIENT_ENTCS)
                return unconnected || 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"));
+       }
+
        /**
        * @param i zero indexed player
        * @returns 0 if not teamplay
        */
        int entcs_GetTeamColor(int i)
        {
-               return (!teamplay) ? 0 : stof(getplayerkeyvalue(i, "colors")) & 15;
+               return (!teamplay) ? 0 : entcs_GetClientColors(i) & 15;
        }
 
        /**
@@ -97,7 +106,8 @@ REGISTER_NET_TEMP(CLIENT_ENTCS)
        */
        string entcs_GetName(int i)
        {
-               return ColorTranslateRGB(getplayerkeyvalue(i, "name"));
+               entity e = entcs_receiver(i);
+               return e ? ColorTranslateRGB(e.netname) : ColorTranslateRGB(getplayerkeyvalue(i, "name"));
        }
 
     /**
@@ -126,7 +136,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)
                ;
        }