From: terencehill Date: Sun, 17 Apr 2022 02:01:22 +0000 (+0200) Subject: On client connection, send client cvars only after client has been initialized on... X-Git-Tag: xonotic-v0.8.5~69 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=222b94d2d796e4282af54ed199b6605c73b690f3;p=xonotic%2Fxonotic-data.pk3dir.git On client connection, send client cvars only after client has been initialized on the server 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) --- diff --git a/qcsrc/client/main.qc b/qcsrc/client/main.qc index 5beca00be..e5b38b768 100644 --- a/qcsrc/client/main.qc +++ b/qcsrc/client/main.qc @@ -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) diff --git a/qcsrc/common/playerstats.qh b/qcsrc/common/playerstats.qh index 06feced27..9fff940f2 100644 --- a/qcsrc/common/playerstats.qh +++ b/qcsrc/common/playerstats.qh @@ -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); diff --git a/qcsrc/lib/replicate.qh b/qcsrc/lib/replicate.qh index a7a8d10df..470d56aa0 100644 --- a/qcsrc/lib/replicate.qh +++ b/qcsrc/lib/replicate.qh @@ -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, )