foxygit / doom Log in
commit 717b09c5b5c58453dfafbdc0e48c8a54182ceeeb
Author:     jens <jens.se@icloud.com>
AuthorDate: Sat Aug 22 08:58:57 2026 +0200
Commit:     jens <jens.se@icloud.com>
CommitDate: Sat Aug 22 08:58:57 2026 +0200

    Fix death/respawn resetting the whole game in local splitscreen

    G_DoReborn (g_game.c) reloaded the entire level from scratch whenever
    !netgame, which is vanilla's correct behavior for true single-player
    (there's only one player, so "respawn" and "restart the level" are the
    same thing) - but local splitscreen is also !netgame despite having
    several simultaneously-alive players, none of whom asked for their
    level reloaded out from under them because a different player died.

    Excludes splitscreen from that check so a dying player instead falls
    through to the same in-place coop respawn logic netgames already use.
    Verified with 2 local players: killed player 1 (via a temporary debug
    key, removed after verifying), confirmed player 2's position/health
    were completely untouched both during player 1's death and after
    their respawn.

    Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
---
 TODO.md           |  2 --
 src/doom/g_game.c | 22 +++++++++++++++-------
 2 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/TODO.md b/TODO.md
index 29c1dac3..a45677ec 100644
--- a/TODO.md
+++ b/TODO.md
@@ -28,8 +28,6 @@ and unstructured wish list of features and improvements. The bug tracker
   - Screensaver mode

 * Infinite splitscreen fork:
-  - A player dying and respawning resets the whole game for everybody
-    instead of just that player.
   - Losing connection or reloading the phone controller page spawns a new
     player instead of reclaiming the existing one.

diff --git a/src/doom/g_game.c b/src/doom/g_game.c
index 34b19ecd..b2cc0e91 100644
--- a/src/doom/g_game.c
+++ b/src/doom/g_game.c
@@ -1518,16 +1518,24 @@ void G_DeathMatchSpawnPlayer (int playernum)
 //
 // G_DoReborn
 //
-void G_DoReborn (int playernum)
-{
-    int                             i;
-
-    if (!netgame)
+void G_DoReborn (int playernum)
+{
+    int                             i;
+
+    // Vanilla only ever reaches G_DoReborn with exactly one player in
+    // the game (true single-player, no in-place respawn point to speak
+    // of), so respawning there means restarting the level from
+    // scratch. Local splitscreen (see doomstat.h's splitscreen) is
+    // also !netgame - it's not an actual network game - but can very
+    // much have other players still alive, who shouldn't have their
+    // game yanked out from under them because slot playernum died.
+    // Respawn them in place instead, exactly like a netgame would.
+    if (!netgame && !splitscreen)
     {
 	// reload the level from scratch
-	gameaction = ga_loadlevel;
+	gameaction = ga_loadlevel;
     }
-    else
+    else
     {
 	// respawn at the start