From: terencehill Date: Sun, 16 Jan 2022 23:15:46 +0000 (+0100) Subject: Small cleanup X-Git-Tag: xonotic-v0.8.5~204^2~2 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=56f18798e1260655d0530549a4904f3de2f04325;p=xonotic%2Fxonotic-data.pk3dir.git Small cleanup --- diff --git a/qcsrc/client/main.qc b/qcsrc/client/main.qc index 5dbfb7209..d817b6be6 100644 --- a/qcsrc/client/main.qc +++ b/qcsrc/client/main.qc @@ -57,7 +57,7 @@ void CSQC_Init() maxclients = i; } - ReplicateVars_Send_All(); + ReplicateVars(REPLICATEVARS_SEND_ALL); // needs to be done so early because of the constants they create static_init(); @@ -189,7 +189,7 @@ void Shutdown() deactivate_minigame(); HUD_MinigameMenu_Close(NULL, NULL, NULL); - ReplicateVars_Destroy(); + ReplicateVars(REPLICATEVARS_DESTROY); } void AuditLists() diff --git a/qcsrc/client/view.qc b/qcsrc/client/view.qc index 4086e1b19..b25dc11d7 100644 --- a/qcsrc/client/view.qc +++ b/qcsrc/client/view.qc @@ -1540,7 +1540,7 @@ void CSQC_UpdateView(entity this, float w, float h) stats_get(); hud = STAT(HUD); - ReplicateVars_Check(); + ReplicateVars(REPLICATEVARS_CHECK); HUD_Scale_Disable(); diff --git a/qcsrc/lib/replicate.qh b/qcsrc/lib/replicate.qh index 8237c1db3..2083b4166 100644 --- a/qcsrc/lib/replicate.qh +++ b/qcsrc/lib/replicate.qh @@ -6,6 +6,9 @@ string strcat1(string s) = #115; // FRIK_FILE #endif #if defined(CSQC) +const int REPLICATEVARS_SEND_ALL = -1; // sync all cvars with the server (init) +const int REPLICATEVARS_CHECK = 0; // check if any cvar has changed and sync it with the server +const int REPLICATEVARS_DESTROY = 1; // destroy data associated with cvars (shutdown) #define REPLICATE_FIELD(type, name) type name #elif defined(SVQC) #define REPLICATE_FIELD(type, name) .type name @@ -94,17 +97,13 @@ string strcat1(string s) = #115; // FRIK_FILE #define REPLICATE_bool(fld, var, func) REPLICATE_7(fld, bool, var, func, (fld != cvar(var)), { fld = cvar(var); }, ) #define REPLICATE_int(fld, var, func) REPLICATE_7(fld, int, var, func, (fld != cvar(var)), { fld = cvar(var); }, ) - #define ReplicateVars_Destroy() ReplicateVars(1) - #define ReplicateVars_Send_All() ReplicateVars(-1) - #define ReplicateVars_Check() ReplicateVars(0) - void ReplicateVars_Send(string cvarname) { localcmd(strcat("cl_cmd sendcvar ", cvarname, "\n")); } #define REPLICATE_7(fld, type, var, func, check, update, destroy) \ void ReplicateVars(int mode) \ { \ - if (mode == 1) { destroy } \ - else if (mode == -1 || check) \ + if (mode == REPLICATEVARS_DESTROY) { destroy } \ + else if (mode == REPLICATEVARS_SEND_ALL || check) \ { \ ReplicateVars_Send(var); \ update \