From: terencehill Date: Sun, 9 Jan 2022 10:39:45 +0000 (+0100) Subject: REPLICATE: allow all changed cvars to be sent to the server in the current frame X-Git-Tag: xonotic-v0.8.5~204^2~5 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=1230015fd976097cac54091cf60a663b82fa65dc;p=xonotic%2Fxonotic-data.pk3dir.git REPLICATE: allow all changed cvars to be sent to the server in the current frame --- diff --git a/qcsrc/lib/replicate.qh b/qcsrc/lib/replicate.qh index 8b17b740a..6dabc772c 100644 --- a/qcsrc/lib/replicate.qh +++ b/qcsrc/lib/replicate.qh @@ -84,9 +84,6 @@ string strcat1(string s) = #115; // FRIK_FILE } #elif defined(CSQC) noref float ReplicateVars_time; - #define ReplicateVars_NOT_SENDING() (time > ReplicateVars_time) - #define ReplicateVars_DELAY(t) ReplicateVars_time = time + t - #define ReplicateVars_DELAY_1FRAME() ReplicateVars_time = time #define REPLICATE_string(fld, var, func) REPLICATE_7(fld, float, var, func, (fld != cvar_string(var)), { strcpy(fld, cvar_string(var)); }, { strfree(fld); }) #define REPLICATE_float(fld, var, func) REPLICATE_7(fld, float, var, func, (fld != cvar(var)), { fld = cvar(var); }, ) #define REPLICATE_bool(fld, var, func) REPLICATE_7(fld, bool, var, func, (fld != cvar(var)), { fld = cvar(var); }, ) @@ -96,10 +93,10 @@ string strcat1(string s) = #115; // FRIK_FILE void ReplicateVars_Send_All() { ReplicateVars(-1); } void ReplicateVars_Check() { - // if a cvar has changed send it and check cvars again next frame + if (time < ReplicateVars_time) + return; ReplicateVars(0); - if (ReplicateVars_NOT_SENDING()) // if no cvar has changed - ReplicateVars_DELAY(0.8 + random() * 0.4); // check cvars after a while + ReplicateVars_time = time + 0.8 + random() * 0.4; // check cvars periodically } void ReplicateVars_Send(string cvarname) { localcmd(strcat("cl_cmd sendcvar ", cvarname, "\n")); } @@ -107,27 +104,19 @@ string strcat1(string s) = #115; // FRIK_FILE void ReplicateVars(int mode) \ { \ if (mode == 1) { destroy } \ - else if (mode == -1) { ReplicateVars_Send(var); update } \ - else if (ReplicateVars_NOT_SENDING() && check) \ + else if (mode == -1 || check) \ { \ ReplicateVars_Send(var); \ - ReplicateVars_DELAY_1FRAME(); \ update \ - return; \ } \ } #define REPLICATE_SIMPLE(field, cvarname) MACRO_BEGIN \ - if (ReplicateVars_NOT_SENDING()) \ + float thecvar = cvar(cvarname); \ + if(field != thecvar) \ { \ - float thecvar = cvar(cvarname); \ - if(field != thecvar) \ - { \ - ReplicateVars_Send(cvarname); \ - ReplicateVars_DELAY_1FRAME(); \ - field = thecvar; \ - return; \ - } \ + ReplicateVars_Send(cvarname); \ + field = thecvar; \ } \ MACRO_END #endif