From: terencehill Date: Mon, 22 Mar 2021 14:23:57 +0000 (+0100) Subject: Avoid settings cvars every frame to optimize code and to avoid console spam with... X-Git-Tag: xonotic-v0.8.5~493 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=b315da9882695b2add6461b55ffa3621161c717d;p=xonotic%2Fxonotic-data.pk3dir.git Avoid settings cvars every frame to optimize code and to avoid console spam with developer 1; developer_extra 1 --- diff --git a/qcsrc/client/hud/panel/chat.qc b/qcsrc/client/hud/panel/chat.qc index 954a3676a..972848260 100644 --- a/qcsrc/client/hud/panel/chat.qc +++ b/qcsrc/client/hud/panel/chat.qc @@ -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) { diff --git a/qcsrc/client/hud/panel/chat.qh b/qcsrc/client/hud/panel/chat.qh index 31bbaf71c..9ed87d9f3 100644 --- a/qcsrc/client/hud/panel/chat.qh +++ b/qcsrc/client/hud/panel/chat.qh @@ -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; diff --git a/qcsrc/lib/csqcmodel/cl_player.qc b/qcsrc/lib/csqcmodel/cl_player.qc index af19a9d4a..15d9d2798 100644 --- a/qcsrc/lib/csqcmodel/cl_player.qc +++ b/qcsrc/lib/csqcmodel/cl_player.qc @@ -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; }