From 9bd29a87b28f896dc9838c1d7be9c1174259ea20 Mon Sep 17 00:00:00 2001 From: toaster Date: Thu, 11 Sep 2025 20:38:46 +0100 Subject: [PATCH] K_DoIngameRespawn: In Tutorial specifically, tightly tie allowed fallback spawnpoints (if not yet crossed a checkpoint line) to relative player ID Not literal player ID so that nothing gets messy when returning from Test Track challenge --- src/k_respawn.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/k_respawn.c b/src/k_respawn.c index 4ff1a1ddb..5c2cf393c 100644 --- a/src/k_respawn.c +++ b/src/k_respawn.c @@ -255,7 +255,24 @@ void K_DoIngameRespawn(player_t *player) { UINT8 i = 0; - for (i = 0; i < numstarts; i++) + if (gametype == GT_TUTORIAL) + { + // In tutorial, spawnpoints are player ID locked. + // ...but returning from Test Track can do funny things, + // so we use relative ID instead of literal slot number. + UINT8 spos = 0; + for (; i < MAXPLAYERS; i++) + { + if (i == player-players) + break; + if (!playeringame[i]) + continue; + spos++; + } + + beststart = starts[spos % numstarts]; + } + else for (i = 0; i < numstarts; i++) { UINT32 dist = UINT32_MAX; mapthing_t *checkstart = NULL;