]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Small cleanup
authorterencehill <piuntn@gmail.com>
Sun, 16 Jan 2022 23:15:46 +0000 (00:15 +0100)
committerterencehill <piuntn@gmail.com>
Sun, 16 Jan 2022 23:15:46 +0000 (00:15 +0100)
qcsrc/client/main.qc
qcsrc/client/view.qc
qcsrc/lib/replicate.qh

index 5dbfb7209d19127b0600039fbcaeaf16da0ff1ed..d817b6be6c33cd6d11e6d84f5e1613eba77d73a5 100644 (file)
@@ -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()
index 4086e1b199ecb9ba31adc1a44c48045a084ba70c..b25dc11d7d02b347e359307de33506de36d350db 100644 (file)
@@ -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();
 
index 8237c1db317386124b3868087302346f16e0fba1..2083b4166fe122e9fb9aae39b396169775ac437c 100644 (file)
@@ -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 \