From 56f18798e1260655d0530549a4904f3de2f04325 Mon Sep 17 00:00:00 2001 From: terencehill Date: Mon, 17 Jan 2022 00:15:46 +0100 Subject: [PATCH] Small cleanup --- qcsrc/client/main.qc | 4 ++-- qcsrc/client/view.qc | 2 +- qcsrc/lib/replicate.qh | 11 +++++------ 3 files changed, 8 insertions(+), 9 deletions(-) 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 \ -- 2.39.2