From d4a342bf6f9ba1f3eeaf5b5efc658a068fd4d718 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 25 Dec 2019 02:57:22 +1000 Subject: [PATCH] Optimise ReplicateVars further by only calling cvar() once --- qcsrc/lib/replicate.qh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) 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 -- 2.39.2