From: Dr. Jaska Date: Wed, 29 May 2024 22:04:48 +0000 (+0000) Subject: Fix spectators not seeing race timer if they start to spectate someone during their lap X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=56e45e813dc61874769299c2ad3f36ef63d58f61;p=xonotic%2Fxonotic-data.pk3dir.git Fix spectators not seeing race timer if they start to spectate someone during their lap --- diff --git a/qcsrc/client/main.qc b/qcsrc/client/main.qc index 015e9be07..650f80c01 100644 --- a/qcsrc/client/main.qc +++ b/qcsrc/client/main.qc @@ -696,9 +696,6 @@ NET_HANDLE(ENT_CLIENT_CLIENTDATA, bool isnew) if(newspectatee_status != spectatee_status) { - // clear race stuff - race_laptime = 0; - race_checkpointtime = 0; hud_dynamic_shake_factor = -1; spectatee_status_changed_time = time; } diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index 4bd2e2e69..6b2b73f1f 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -1879,8 +1879,26 @@ void SetSpectatee_status(entity this, int spectatee_num) CS(this).pressedkeys = 0; STAT(PRESSED_KEYS, this) = 0; } + ClientData_Touch(this); - if (g_race || g_cts) race_InitSpectator(); + + // init or clear race data + if ((g_race || g_cts) && g_race_qualifying && IS_REAL_CLIENT(this)) + { + msg_entity = this; + + if (this.enemy && this.enemy.race_laptime) + { + // init + race_SendNextCheckpoint(this.enemy, 1); + } + else + { + // send reset to this spectator + WriteHeader(MSG_ONE, TE_CSQC_RACE); + WriteByte(MSG_ONE, RACE_NET_CHECKPOINT_CLEAR); + } + } } } diff --git a/qcsrc/server/race.qc b/qcsrc/server/race.qc index 7f37db341..746fda0de 100644 --- a/qcsrc/server/race.qc +++ b/qcsrc/server/race.qc @@ -68,13 +68,6 @@ void write_recordmarker(entity pl, float tstart, float dt) IntrusiveList g_race_targets; IntrusiveList g_racecheckpoints; -void race_InitSpectator() -{ - if(g_race_qualifying) - if(msg_entity.enemy.race_laptime) - race_SendNextCheckpoint(msg_entity.enemy, 1); -} - float race_readTime(string map, float pos) { return stof(db_get(ServerProgsDB, strcat(map, record_type, "time", ftos(pos)))); diff --git a/qcsrc/server/race.qh b/qcsrc/server/race.qh index 1e851ee30..b335f5277 100644 --- a/qcsrc/server/race.qh +++ b/qcsrc/server/race.qh @@ -72,8 +72,6 @@ void race_SendAll(entity player, bool only_rankings); void race_RetractPlayer(entity this); -void race_InitSpectator(); - string uid2name(string myuid); spawnfunc(target_checkpoint);