Maelstrom: Fixed game over timing for co-op multiplayer games

From 50bcc904a5fc1598dc75f4306921dddb1c56d548 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Tue, 28 Apr 2026 03:02:38 -0700
Subject: [PATCH] Fixed game over timing for co-op multiplayer games

---
 game/player.cpp | 50 +++++++++++++++++++++++++------------------------
 1 file changed, 26 insertions(+), 24 deletions(-)

diff --git a/game/player.cpp b/game/player.cpp
index ce6d42b5..555c9abb 100644
--- a/game/player.cpp
+++ b/game/player.cpp
@@ -317,29 +317,6 @@ Player::BeenTimedOut(void)
 	Exploding = 0;
 	SetSpawnPosition();
 
-	// If we're the last life in a co-op multiplayer game, we're done
-	if (gGameInfo.IsMultiplayer() && !gGameInfo.IsDeathmatch() && !Lives) {
-		int i;
-		bool allGhosts = true;
-		OBJ_LOOP(i, MAX_PLAYERS) {
-			if (!gPlayers[i]->IsValid()) {
-				continue;
-			}
-			if ( i != Index && !gPlayers[i]->Ghost) {
-				allGhosts = false;
-				break;
-			}
-		}
-		if (allGhosts) {
-			OBJ_LOOP(i, MAX_PLAYERS) {
-				if (!gPlayers[i]->IsValid()) {
-					continue;
-				}
-				gPlayers[i]->Playing = 0;
-			}
-		}
-	}
-
 	return(0);
 }
 
@@ -572,7 +549,32 @@ printf("\n");
 
 	/* Check to see if we are dead... */
 	if ( Dead ) {
-		if ( --Dead == 0 ) {  // New Chance at Life!
+		if (--Dead == 0) {  // New Chance at Life!
+			// If we're the last life in a co-op multiplayer game, we're done
+			if (gGameInfo.IsMultiplayer() && !gGameInfo.IsDeathmatch() && !Lives) {
+				int i;
+				bool allGhosts = true;
+				OBJ_LOOP(i, MAX_PLAYERS) {
+					if (!gPlayers[i]->IsValid() || i == Index) {
+						continue;
+					}
+					if (i != Index && !gPlayers[i]->Ghost) {
+						allGhosts = false;
+						break;
+					}
+				}
+				if (allGhosts) {
+					OBJ_LOOP(i, MAX_PLAYERS) {
+						if (!gPlayers[i]->IsValid()) {
+							continue;
+						}
+						gPlayers[i]->Dead = DEAD_DELAY;
+						gPlayers[i]->Playing = 0;
+					}
+					return (0);
+				}
+			}
+
 			if ( NewShip() < 0 ) {
 				/* Game Over */
 				Dead = DEAD_DELAY;