Maelstrom: You can't gain lives while you're a ghost

https://github.com/libsdl-org/Maelstrom/commit/9b79c7fcdc70f15edb541d7bcc87df652aa86140

From 9b79c7fcdc70f15edb541d7bcc87df652aa86140 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Fri, 25 Nov 2011 13:19:36 -0500
Subject: [PATCH] You can't gain lives while you're a ghost

---
 game/game.cpp  | 8 +++++---
 game/object.h  | 3 +++
 game/objects.h | 6 ++++--
 game/player.h  | 5 ++++-
 4 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/game/game.cpp b/game/game.cpp
index 463ef41f..4009c8d7 100644
--- a/game/game.cpp
+++ b/game/game.cpp
@@ -554,10 +554,12 @@ GamePanelDelegate::DrawStatus(Bool first)
 			/* -- See if they got a new life */
 			lastScores[i] = Score;
 			if ((Score - lastLife[i]) >= NEW_LIFE) {
-				gPlayers[i]->IncrLives(1);
+				if (!gPlayers[i]->IsGhost()) {
+					gPlayers[i]->IncrLives(1);
+					if ( gGameInfo.IsLocalPlayer(i) )
+						sound->PlaySound(gNewLife, 5);
+				}
 				lastLife[i] = (Score / NEW_LIFE) * NEW_LIFE;
-				if ( gGameInfo.IsLocalPlayer(i) )
-					sound->PlaySound(gNewLife, 5);
 			}
 		}
 	}
diff --git a/game/object.h b/game/object.h
index bf933525..9105e6e5 100644
--- a/game/object.h
+++ b/game/object.h
@@ -35,6 +35,9 @@ class Object {
 	virtual int IsPlayer(void) {
 		return(0);
 	}
+	virtual int IsGhost(void) {
+		return(0);
+	}
 	virtual int Alive(void) {
 		return(1);
 	}
diff --git a/game/objects.h b/game/objects.h
index 7a415c5a..9275730e 100644
--- a/game/objects.h
+++ b/game/objects.h
@@ -218,8 +218,10 @@ class DamagedShip : public Object {
 	~DamagedShip() { }
 
 	int BeenRunOver(Object *ship) {
-		ship->IncrLives(1);
-		sound->PlaySound(gSavedShipSound, 4);
+		if (!ship->IsGhost()) {
+			ship->IncrLives(1);
+			sound->PlaySound(gSavedShipSound, 4);
+		}
 		return(1);
 	}
 
diff --git a/game/player.h b/game/player.h
index 5960660a..6e79f3da 100644
--- a/game/player.h
+++ b/game/player.h
@@ -47,11 +47,14 @@ class Player : public Object {
 	virtual int IsPlayer(void) {
 		return(1);
 	}
+	virtual int IsGhost(void) {
+		return Ghost;
+	}
 	virtual int Alive(void) {
 		return(!Dead);
 	}
 	virtual int Kicking(void) {
-		return(Playing && !Ghost);
+		return(Playing && !IsGhost());
 	}
 	virtual void NewGame(int lives);
 	virtual void NewWave(void);