]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Avoid settings cvars every frame to optimize code and to avoid console spam with...
authorterencehill <piuntn@gmail.com>
Mon, 22 Mar 2021 14:23:57 +0000 (15:23 +0100)
committerterencehill <piuntn@gmail.com>
Mon, 22 Mar 2021 14:23:57 +0000 (15:23 +0100)
qcsrc/client/hud/panel/chat.qc
qcsrc/client/hud/panel/chat.qh
qcsrc/lib/csqcmodel/cl_player.qc

index 954a3676afe74cec7dd1c4c8381b9049a5efedec..972848260dcc94ab74d4c5fafa735517782d2625 100644 (file)
@@ -74,11 +74,19 @@ void HUD_Chat()
        if (!autocvar_con_chatrect)
                cvar_set("con_chatrect", "1");
 
-       cvar_set("con_chatrect_x", ftos(pos.x/vid_conwidth));
-       cvar_set("con_chatrect_y", ftos(pos.y/vid_conheight));
-
-       cvar_set("con_chatwidth", ftos(mySize.x/vid_conwidth));
-       cvar_set("con_chat", ftos(floor(mySize.y/autocvar_con_chatsize - 0.5)));
+       // can't use a name ending with _x, _y and _z for a float autocvar as for autocvar specs
+       // it prevents ambiguity with component names of vector autocvars
+       if (cvar_string("con_chatrect_x") != ftos(pos.x / vid_conwidth))
+               cvar_set("con_chatrect_x", ftos(pos.x / vid_conwidth));
+       if (cvar_string("con_chatrect_y") != ftos(pos.y / vid_conheight))
+               cvar_set("con_chatrect_y", ftos(pos.y / vid_conheight));
+       // can't use direct comparison here, it would always returns true even if
+       // both arguments are equal because con_chatwidth is saved with cvar_set
+       //if (autocvar_con_chatwidth != mySize.x / vid_conwidth)
+       if (fabs(autocvar_con_chatwidth - mySize.x / vid_conwidth) > 0.00001)
+               cvar_set("con_chatwidth", ftos(mySize.x / vid_conwidth));
+       if (autocvar_con_chat != floor(mySize.y / autocvar_con_chatsize - 0.5))
+               cvar_set("con_chat", ftos(floor(mySize.y / autocvar_con_chatsize - 0.5)));
 
        if(autocvar__hud_configure)
        {
index 31bbaf71c117658d870d27c7f1796b3aab34e8e9..9ed87d9f3a5159ab499dc78088921f7cc0fdbf14 100644 (file)
@@ -5,7 +5,11 @@ bool autocvar_hud_panel_chat;
 
 bool autocvar__con_chat_maximized;
 bool autocvar_con_chat;
-bool autocvar_con_chatrect;
 float autocvar_con_chatsize;
 float autocvar_con_notify;
 float autocvar_con_notifysize;
+
+bool autocvar_con_chatrect;
+//float autocvar_con_chatrect_x;
+//float autocvar_con_chatrect_y;
+float autocvar_con_chatwidth;
index af19a9d4a6dffcb811d5135dd702b4c332304fa6..15d9d279889ea215d90afc24178f385269a7c161 100644 (file)
@@ -667,7 +667,8 @@ bool CSQCPlayer_PostUpdate(entity this)
        if (this.entnum != player_localnum + 1) return false;
        csqcplayer = this;
        csqcplayer_status = CSQCPLAYERSTATUS_FROMSERVER;
-       cvar_settemp("cl_movement_replay", "0");
+       if (cvar("cl_movement_replay"))
+               cvar_settemp("cl_movement_replay", "0");
        this.entremove = CSQCPlayer_Remove;
        return true;
 }