From 17356f93bf1f77f582f68494d4ee2b1574ff36cc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gustaf=20Alh=C3=A4ll?= <gustaf@hanicef.me>
Date: Mon, 19 Jun 2023 22:19:39 +0200
Subject: [PATCH] Fix segfault when ghost dies from a death pit

---
 src/p_mobj.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/p_mobj.c b/src/p_mobj.c
index a04351ae77..3eab29c095 100644
--- a/src/p_mobj.c
+++ b/src/p_mobj.c
@@ -3139,7 +3139,8 @@ boolean P_SceneryZMovement(mobj_t *mo)
 
 	if (P_CheckDeathPitCollide(mo))
 	{
-		P_RemoveMobj(mo);
+		if (mo->type != MT_GHOST)  // ghosts play death animations instead, so don't remove them
+			P_RemoveMobj(mo);
 		return false;
 	}
 
-- 
GitLab