]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
On client connection, send client cvars only after client has been initialized on...
authorterencehill <piuntn@gmail.com>
Sun, 17 Apr 2022 02:01:22 +0000 (04:01 +0200)
committerterencehill <piuntn@gmail.com>
Sun, 17 Apr 2022 02:01:22 +0000 (04:01 +0200)
It fixes issue https://gitlab.com/xonotic/xonstat-go/-/issues/44 that was due to .playerstats_id getting wrongly set to "Player#0" because .playerid was not initialized yet (0)

qcsrc/client/main.qc
qcsrc/common/playerstats.qh
qcsrc/lib/replicate.qh

index 5beca00bef44dd88d0d05ef17464ba8a7510e455..e5b38b76834bb1cb1d40335e058f2c9f71e2a6b8 100644 (file)
@@ -58,8 +58,6 @@ void CSQC_Init()
                maxclients = i;
        }
 
-       ReplicateVars(REPLICATEVARS_SEND_ALL);
-
        // needs to be done so early because of the constants they create
        static_init();
        static_init_late();
@@ -667,6 +665,9 @@ NET_HANDLE(ENT_CLIENT_CLIENTDATA, bool isnew)
        spectatee_status = newspectatee_status;
 
        // we could get rid of spectatee_status, and derive it from player_localentnum and player_localnum
+
+       // this can't be called in CSQC_Init as it'd send cvars too early
+       ReplicateVars_Start();
 }
 
 NET_HANDLE(ENT_CLIENT_NAGGER, bool isnew)
index 06feced27bc5ca66305f999f86d2a9eacf884a46..9fff940f243ad4025e26ed424810263700c4fdb8 100644 (file)
@@ -81,7 +81,7 @@ void PlayerStats_GameReport_Accuracy(entity p);
 void PlayerStats_GameReport_FinalizePlayer(entity p);
 
 // call this at the end of the match
-void PlayerStats_GameReport(float finished);
+void PlayerStats_GameReport(bool finished);
 
 void PlayerStats_GameReport_Handler(entity fh, entity pass, float status);
 
index a7a8d10df7fa4e06be5021bff35384a2330929a6..470d56aa039f72ce71d7d66b2ffc69fbb2dce198 100644 (file)
@@ -45,10 +45,15 @@ const int REPLICATEVARS_DESTROY = 1; // destroy data associated with cvars (shut
        noref float ReplicateVars_time;
        ACCUMULATE void ReplicateVars(int mode)
        {
-               if (time < ReplicateVars_time)
+               if (!ReplicateVars_time || time < ReplicateVars_time)
                        return;
                ReplicateVars_time = time + 0.8 + random() * 0.4; // check cvars periodically
        }
+       void ReplicateVars_Start()
+       {
+               ReplicateVars_time = time;
+               ReplicateVars(REPLICATEVARS_SEND_ALL);
+       }
        #endif
 
        #define REPLICATE_3(fld, type, var) REPLICATE_4(fld, type, var, )