ref: de82ea5061aeb1646c0fb6c2e25383c8416ad089
parent: a35f125fd08c1e3206fcc3258d0ac5f3ea9aa6e2
parent: 46d461a5ae15d081b743f9293aa10ac838884254
author: Mike Swanson <[email protected]>
date: Wed Oct 12 09:14:43 EDT 2016
Merge pull request #762 from jmtd/korax Add CheckACSPresent and gracefully exit
--- a/src/hexen/p_acs.c
+++ b/src/hexen/p_acs.c
@@ -56,6 +56,8 @@
// PUBLIC FUNCTION PROTOTYPES ----------------------------------------------
+void CheckACSPresent(int number);
+
// PRIVATE FUNCTION PROTOTYPES ---------------------------------------------
static void StartOpenACS(int number, int infoIndex, int *address);
@@ -783,6 +785,23 @@
}
}
return -1;
+}
+
+//==========================================================================
+//
+// CheckACSPresent
+//
+// Placing Korax in a PWAD without extra steps will result in a crash in
+// Vanilla because the relevant ACS scripts are not initialised
+//
+//==========================================================================
+
+void CheckACSPresent(int number)
+{
+ if (GetACSIndex(number) == -1)
+ {
+ I_Error("Required ACS script %d not initialised", number);
+ }
}
//==========================================================================
--- a/src/hexen/p_enemy.c
+++ b/src/hexen/p_enemy.c
@@ -4970,6 +4970,7 @@
P_Teleport(actor, spot->x, spot->y, spot->angle, true);
}
+ CheckACSPresent(249);
P_StartACS(249, 0, args, actor, NULL, 0);
actor->special2.i = 1; // Don't run again
@@ -5047,6 +5048,7 @@
if (mo)
KSpiritInit(mo, actor);
+ CheckACSPresent(255);
P_StartACS(255, 0, args, actor, NULL, 0); // Death script
}
@@ -5164,18 +5166,23 @@
switch (P_Random() % numcommands)
{
case 0:
+ CheckACSPresent(250);
P_StartACS(250, 0, args, actor, NULL, 0);
break;
case 1:
+ CheckACSPresent(251);
P_StartACS(251, 0, args, actor, NULL, 0);
break;
case 2:
+ CheckACSPresent(252);
P_StartACS(252, 0, args, actor, NULL, 0);
break;
case 3:
+ CheckACSPresent(253);
P_StartACS(253, 0, args, actor, NULL, 0);
break;
case 4:
+ CheckACSPresent(254);
P_StartACS(254, 0, args, actor, NULL, 0);
break;
}
--- a/src/hexen/p_spec.h
+++ b/src/hexen/p_spec.h
@@ -546,6 +546,7 @@
void P_PolyobjFinished(int po);
void P_ACSInitNewGame(void);
void P_CheckACSStore(void);
+void CheckACSPresent(int number);
extern int ACScriptCount;
extern byte *ActionCodeBase;