foxygit / doom Log in
commit 3181ed3caeaaefc20806486078f71919bc770bc9
Author:     mfrancis95 <mikefrancis95@gmail.com>
AuthorDate: Tue Dec 18 01:11:24 2018 -0500
Commit:     mfrancis95 <mikefrancis95@gmail.com>
CommitDate: Tue Dec 18 10:58:51 2018 -0500

    Heretic: Gracefully error out when player starts are missing (fix #1122)
---
 src/heretic/doomdef.h |  1 +
 src/heretic/p_mobj.c  |  1 +
 src/heretic/p_setup.c | 13 +++++++++++++
 3 files changed, 15 insertions(+)

diff --git a/src/heretic/doomdef.h b/src/heretic/doomdef.h
index 72355b20..82258211 100644
--- a/src/heretic/doomdef.h
+++ b/src/heretic/doomdef.h
@@ -553,6 +553,7 @@ extern ticcmd_t *netcmds;
 extern mapthing_t *deathmatch_p;
 extern mapthing_t deathmatchstarts[10];
 extern mapthing_t playerstarts[MAXPLAYERS];
+extern boolean playerstartsingame[MAXPLAYERS];

 extern int mouseSensitivity;

diff --git a/src/heretic/p_mobj.c b/src/heretic/p_mobj.c
index 00e6a33c..c0759848 100644
--- a/src/heretic/p_mobj.c
+++ b/src/heretic/p_mobj.c
@@ -1052,6 +1052,7 @@ void P_SpawnMapThing(mapthing_t * mthing)
     {
         // save spots for respawning in network games
         playerstarts[mthing->type - 1] = *mthing;
+        playerstartsingame[mthing->type - 1] = true;
         if (!deathmatch)
         {
             P_SpawnPlayer(mthing);
diff --git a/src/heretic/p_setup.c b/src/heretic/p_setup.c
index b14fc916..0dd0dcfa 100644
--- a/src/heretic/p_setup.c
+++ b/src/heretic/p_setup.c
@@ -60,6 +60,7 @@ byte *rejectmatrix;             // for fast sight rejection

 mapthing_t deathmatchstarts[10], *deathmatch_p;
 mapthing_t playerstarts[MAXPLAYERS];
+boolean playerstartsingame[MAXPLAYERS];

 /*
 =================
@@ -279,6 +280,18 @@ void P_LoadThings(int lump)
         P_SpawnMapThing(&spawnthing);
     }

+    if (!deathmatch)
+    {
+        for (i = 0; i < MAXPLAYERS; i++)
+        {
+            if (playeringame[i] && !playerstartsingame[i])
+            {
+                I_Error("P_LoadThings: Player %d start missing (vanilla crashes here)", i + 1);
+            }
+            playerstartsingame[i] = false;
+        }
+    }
+
     W_ReleaseLumpNum(lump);
 }