From 20bfbca029cb3addbfece42e1ae6b17a0bd24084 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 23 Oct 2022 15:31:31 -0700 Subject: [PATCH] Fix spectators spawning at 0, 0 when joining mid game --- src/g_game.c | 4 +++- src/p_mobj.c | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/g_game.c b/src/g_game.c index fb3bda9ec..e7ec538e3 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2562,7 +2562,9 @@ void G_MovePlayerToSpawnOrStarpost(INT32 playernum) else P_MovePlayerToStarpost(playernum); #else - if (leveltime > starttime) + // Player's first spawn should be at the "map start". + // I.e. level load or join mid game. + if (leveltime > starttime && players[playernum].jointime > 0) P_MovePlayerToStarpost(playernum); else P_MovePlayerToSpawn(playernum, G_FindMapStart(playernum)); diff --git a/src/p_mobj.c b/src/p_mobj.c index 6df9b921c..b450731aa 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -11556,6 +11556,15 @@ void P_MovePlayerToSpawn(INT32 playernum, mapthing_t *mthing) { K_DoIngameRespawn(p); } + else + { + // This is important for spectators. If you are + // a spectator now, then when you enter the game, + // respawn back at this point. + p->respawn.pointx = x; + p->respawn.pointy = y; + p->respawn.pointz = z; + } P_AfterPlayerSpawn(playernum); }