]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Fix spectators not seeing race timer if they start to spectate someone during their lap
authorDr. Jaska <drjaska83@gmail.com>
Wed, 29 May 2024 22:04:48 +0000 (22:04 +0000)
committerDr. Jaska <drjaska83@gmail.com>
Wed, 29 May 2024 22:04:48 +0000 (22:04 +0000)
qcsrc/client/main.qc
qcsrc/server/client.qc
qcsrc/server/race.qc
qcsrc/server/race.qh

index 015e9be076592a07f56ede0c4d1c6ef7280e5fc7..650f80c01fbca61e833621bfcb9119afbb977b6a 100644 (file)
@@ -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;
        }
index 4bd2e2e695a1208b68b338e81517c3d9b6733e9c..6b2b73f1fc610da85b417eb4e96c0dc8d47ed8b6 100644 (file)
@@ -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);
+                       }
+               }
        }
 }
 
index 7f37db341cb78479fcbea450060eb97638f1d140..746fda0deb8a04183f0d71c5f917e8119ecafe34 100644 (file)
@@ -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))));
index 1e851ee3041e7fd671397c917571292b5a5ef863..b335f527765c32f00ec924aeb9412850945e6ec7 100644 (file)
@@ -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);