From: Mario Date: Tue, 24 Dec 2019 16:57:22 +0000 (+1000) Subject: Optimise ReplicateVars further by only calling cvar() once X-Git-Tag: xonotic-v0.8.5~1187 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=d4a342bf6f9ba1f3eeaf5b5efc658a068fd4d718;p=xonotic%2Fxonotic-data.pk3dir.git Optimise ReplicateVars further by only calling cvar() once --- diff --git a/qcsrc/lib/replicate.qh b/qcsrc/lib/replicate.qh index a88bde462..311774260 100644 --- a/qcsrc/lib/replicate.qh +++ b/qcsrc/lib/replicate.qh @@ -82,12 +82,16 @@ } #define REPLICATE_SIMPLE(field, cvarname) MACRO_BEGIN \ - if (ReplicateVars_NOT_SENDING() && field != cvar(cvarname)) \ + if (ReplicateVars_NOT_SENDING()) \ { \ - localcmd(strcat("cl_cmd sendcvar ", cvarname, "\n")); \ - ReplicateVars_DELAY_1FRAME(); \ - field = cvar(cvarname); \ - return; \ + float thecvar = cvar(cvarname); \ + if(field != thecvar) \ + { \ + localcmd(strcat("cl_cmd sendcvar ", cvarname, "\n")); \ + ReplicateVars_DELAY_1FRAME(); \ + field = thecvar; \ + return; \ + } \ } \ MACRO_END #endif