From 39e33bd98eeab87362457eea7f30a1d94b3b6b3b Mon Sep 17 00:00:00 2001 From: toaster Date: Thu, 11 Sep 2025 20:36:20 +0100 Subject: [PATCH 1/2] K_DoIngameRespawn: Index into previously-picked array, rather than branching for every single available spawnpoint --- src/k_respawn.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/k_respawn.c b/src/k_respawn.c index 8f2c31e70..4ff1a1ddb 100644 --- a/src/k_respawn.c +++ b/src/k_respawn.c @@ -238,14 +238,17 @@ void K_DoIngameRespawn(player_t *player) UINT32 bestdist = UINT32_MAX; mapthing_t *beststart = NULL; UINT8 numstarts = 0; + mapthing_t **starts; if (gametyperules & GTR_BATTLESTARTS) { numstarts = numdmstarts; + starts = deathmatchstarts; } else { numstarts = numcoopstarts; + starts = playerstarts; } if (numstarts > 0) @@ -257,14 +260,7 @@ void K_DoIngameRespawn(player_t *player) UINT32 dist = UINT32_MAX; mapthing_t *checkstart = NULL; - if (gametyperules & GTR_BATTLESTARTS) - { - checkstart = deathmatchstarts[i]; - } - else - { - checkstart = playerstarts[i]; - } + checkstart = starts[i]; dist = (UINT32)P_AproxDistance((player->mo->x >> FRACBITS) - checkstart->x, (player->mo->y >> FRACBITS) - checkstart->y); From 9bd29a87b28f896dc9838c1d7be9c1174259ea20 Mon Sep 17 00:00:00 2001 From: toaster Date: Thu, 11 Sep 2025 20:38:46 +0100 Subject: [PATCH 2/2] 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;