]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Use entcs to handle client colors (improves FPS by not using the slow engine function)
authorMario <mario@smbclan.net>
Sun, 21 Aug 2016 02:57:10 +0000 (12:57 +1000)
committerMario <mario@smbclan.net>
Sun, 21 Aug 2016 02:57:10 +0000 (12:57 +1000)
12 files changed:
qcsrc/client/csqcmodel_hooks.qc
qcsrc/client/hud/hud.qc
qcsrc/client/hud/hud.qh
qcsrc/client/hud/panel/scoreboard.qc
qcsrc/client/view.qc
qcsrc/common/ent_cs.qc
qcsrc/common/ent_cs.qh
qcsrc/common/weapons/weapon/arc.qc
qcsrc/common/weapons/weapon/vaporizer.qc
qcsrc/server/bot/default/bot.qc
qcsrc/server/cl_client.qc
qcsrc/server/teamplay.qc

index d6ee5f8f79add97bf2dfded05615e01788260bab..0643bb09d5b37e3bdd7b014f13964959ab837484 100644 (file)
@@ -3,6 +3,7 @@
 #include "player_skeleton.qh"
 #include "weapons/projectile.qh"
 #include <common/animdecide.qh>
+#include <common/ent_cs.qh>
 #include <common/physics/movetypes/movetypes.qh>
 #include <common/viewloc.qh>
 #include <lib/csqcmodel/cl_model.qh>
@@ -192,7 +193,7 @@ void CSQCPlayer_ModelAppearance_Apply(entity this, bool islocalplayer)
        bool isfriend;
        int cm;
        cm = this.forceplayermodels_savecolormap;
-       cm = (cm >= 1024) ? cm : (stof(getplayerkeyvalue(cm - 1, "colors")) + 1024);
+       cm = (cm >= 1024) ? cm : (entcs_GetClientColors(cm - 1) + 1024);
 
        if(teamplay)
                isfriend = (cm == 1024 + 17 * myteam);
@@ -279,7 +280,7 @@ void CSQCPlayer_ModelAppearance_Apply(entity this, bool islocalplayer)
 
        // GLOWMOD AND DEATH FADING
        if(this.colormap > 0)
-               this.glowmod = colormapPaletteColor(((this.colormap >= 1024) ? this.colormap : stof(getplayerkeyvalue(this.colormap - 1, "colors"))) & 0x0F, true) * 2;
+               this.glowmod = colormapPaletteColor(((this.colormap >= 1024) ? this.colormap : entcs_GetClientColors(this.colormap - 1)) & 0x0F, true) * 2;
        else
                this.glowmod = '1 1 1';
 
index c87e733e1d4e633dc2bd28e815d8c885c89ab22e..ef8afcb19638c709557e392edb93a8f63812062f 100644 (file)
@@ -556,11 +556,11 @@ void HUD_Main()
                {
                        string hud_dock_color = autocvar_hud_dock_color;
                        if(hud_dock_color == "shirt") {
-                               f = stof(getplayerkeyvalue(current_player, "colors"));
+                               f = entcs_GetClientColors(current_player);
                                color = colormapPaletteColor(floor(f / 16), 0);
                        }
                        else if(hud_dock_color == "pants") {
-                               f = stof(getplayerkeyvalue(current_player, "colors"));
+                               f = entcs_GetClientColors(current_player);
                                color = colormapPaletteColor(f % 16, 1);
                        }
                        else
index b269312d8871ceb2212ea6fd8beba1f15d28779d..66db85fd8638618eb1cda825899c546a5cff9d40 100644 (file)
@@ -280,9 +280,9 @@ REGISTER_HUD_PANEL(SCOREBOARD,      Scoreboard_Draw,    scoreboard,     PANEL_CO
                        panel_bg_color = autocvar_hud_panel_bg_color;                                                           \
                } else {                                                                                                    \
                        if (panel_bg_color_str == "shirt") {                                                                    \
-                               panel_bg_color = colormapPaletteColor(floor(stof(getplayerkeyvalue(current_player, "colors")) / 16), 0); \
+                               panel_bg_color = colormapPaletteColor(floor(entcs_GetClientColors(current_player) / 16), 0); \
                        } else if (panel_bg_color_str == "pants") {                                                             \
-                               panel_bg_color = colormapPaletteColor(stof(getplayerkeyvalue(current_player, "colors")) % 16, 1); \
+                               panel_bg_color = colormapPaletteColor(entcs_GetClientColors(current_player) % 16, 1); \
                        } else {                                                                                                \
                                panel_bg_color = stov(panel_bg_color_str);                                                          \
                        }                                                                                                       \
index 9762384faa0d68aca8ae04dc0bee7ff413717a26..22be8b195c34076ec706b9f3680f14d114210605 100644 (file)
@@ -605,7 +605,7 @@ string Scoreboard_GetField(entity pl, PlayerScoreField field)
                        }
                        else if(!teamplay)
                        {
-                               f = stof(getplayerkeyvalue(pl.sv_entnum, "colors"));
+                               f = entcs_GetClientColors(pl.sv_entnum);
                                {
                                        sbt_field_icon0 = "gfx/scoreboard/playercolor_base";
                                        sbt_field_icon1 = "gfx/scoreboard/playercolor_shirt";
index db6df4dadfc972de58f3c8f2c4effbd1f563c883..ddd16ec02e420fd6a128d14a4b2039744a98f0b1 100644 (file)
@@ -293,7 +293,7 @@ void viewmodel_draw(entity this)
        else if (wasinvehicle) a = 1;
        wasinvehicle = invehicle;
        Weapon wep = activeweapon;
-       int c = stof(getplayerkeyvalue(current_player, "colors"));
+       int c = entcs_GetClientColors(current_player);
        vector g = weaponentity_glowmod(wep, c);
        entity me = CSQCModel_server2csqc(player_localentnum - 1);
        int fx = ((me.csqcmodel_effects & EFMASK_CHEAP)
index 2a7b3f80c485ef413e246028834d20ad38d8156b..1290a9356477a0704c3e15893c94eb1b8a369518 100644 (file)
        PROP(true, skin, \
        { WriteByte(chan, this.skin); }, \
        { this.skin = ReadByte(); }) \
+    \
+    PROP(true, clientcolors, \
+       { WriteByte(chan, this.clientcolors); }, \
+       { this.colormap = ReadByte(); }) \
     \
        /**/
 
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)
                ;
        }
 
index c0d85831ae730be7dc9c9981d9f8b86150286bc5..abd30509f04c8e9447261d066189c58fdb554c2a 100644 (file)
@@ -1397,7 +1397,7 @@ NET_HANDLE(ENT_CLIENT_ARC_BEAM, bool isnew)
        {
                this.beam_type = ReadByte();
 
-               vector beamcolor = ((autocvar_cl_arcbeam_teamcolor) ? colormapPaletteColor(stof(getplayerkeyvalue(this.sv_entnum - 1, "colors")) & 0x0F, true) : '1 1 1');
+               vector beamcolor = ((autocvar_cl_arcbeam_teamcolor) ? colormapPaletteColor(entcs_GetClientColors(this.sv_entnum - 1) & 0x0F, true) : '1 1 1');
                switch(this.beam_type)
                {
                        case ARC_BT_MISS:
index 8fa43c1d8c019e73f209a081a778f9c7950b0687..7badd5d2bc7d24f9f018363da342bb5d8d83374e 100644 (file)
@@ -111,7 +111,7 @@ void VaporizerBeam_Draw(entity this)
        //entity e = CSQCModel_server2csqc(this.sv_entnum - 1);
        //if (e == NULL)
        //{
-               rgb = colormapPaletteColor(stof(getplayerkeyvalue(this.sv_entnum - 1, "colors")) & 0x0F, true);
+               rgb = colormapPaletteColor(entcs_GetClientColors(this.sv_entnum - 1) & 0x0F, true);
                //rgb = '1 1 1';
        //}
        //else
index cab38143db598d743f377c3556736116782e2f84..8ee00e7d5cca3176308647e6e69d2f593af71d73 100644 (file)
@@ -224,7 +224,7 @@ void bot_setnameandstuff(entity this)
        this.bot_config_loaded = true;
 
        // this is really only a default, JoinBestTeam is called later
-       setcolor(this, stof(bot_shirt) * 16 + stof(bot_pants));
+       set_color(this, stof(bot_shirt) * 16 + stof(bot_pants));
        this.bot_preferredcolors = this.clientcolors;
 
        // pick the name
@@ -340,7 +340,7 @@ void bot_endgame()
        e = bot_list;
        while (e)
        {
-               setcolor(e, e.bot_preferredcolors);
+               set_color(e, e.bot_preferredcolors);
                e = e.nextbot;
        }
        // if dynamic waypoints are ever implemented, save them here
index 0a608e979bff5da3e4b535fed7019bc0a9fb2301..85bfd4eb69138caf30a689e789d4abbe170768a0 100644 (file)
@@ -471,7 +471,7 @@ void FixPlayermodel(entity player)
        if(!teamplay)
                if(strlen(autocvar_sv_defaultplayercolors))
                        if(player.clientcolors != stof(autocvar_sv_defaultplayercolors))
-                               setcolor(player, stof(autocvar_sv_defaultplayercolors));
+                               set_color(player, stof(autocvar_sv_defaultplayercolors));
 }
 
 
index 61a9d2fadd52f4292bff1cf0719378939f726b39..a1ff864664672ccf1d0877bd78252504e9e4dd27 100644 (file)
@@ -158,6 +158,16 @@ string getwelcomemessage(entity this)
        return s;
 }
 
+void set_color(entity this, int clr)
+{
+#if 0
+       this.clientcolors = clr;
+       this.team = (clr & 15) + 1;
+#else
+       setcolor(this, clr);
+#endif
+}
+
 void SetPlayerColors(entity pl, float _color)
 {
        /*string s;
@@ -173,9 +183,9 @@ void SetPlayerColors(entity pl, float _color)
 
 
        if(teamplay) {
-               setcolor(pl, 16*pants + pants);
+               set_color(pl, 16*pants + pants);
        } else {
-               setcolor(pl, shirt + pants);
+               set_color(pl, shirt + pants);
        }
 }