summaryrefslogtreecommitdiff
path: root/src/hexen/p_acs.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/hexen/p_acs.c')
-rw-r--r--src/hexen/p_acs.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/hexen/p_acs.c b/src/hexen/p_acs.c
index f76fa167..b9fd8f08 100644
--- a/src/hexen/p_acs.c
+++ b/src/hexen/p_acs.c
@@ -27,6 +27,7 @@
// MACROS ------------------------------------------------------------------
+#define MAX_SCRIPT_ARGS 3
#define SCRIPT_CONTINUE 0
#define SCRIPT_STOP 1
#define SCRIPT_TERMINATE 2
@@ -195,7 +196,7 @@ static acs_t *NewScript;
static int (*PCodeCmds[]) (void) =
{
-CmdNOP,
+ CmdNOP,
CmdTerminate,
CmdSuspend,
CmdPushNumber,
@@ -294,7 +295,10 @@ CmdNOP,
CmdSoundSequence,
CmdSetLineTexture,
CmdSetLineBlocking,
- CmdSetLineSpecial, CmdThingSound, CmdEndPrintBold};
+ CmdSetLineSpecial,
+ CmdThingSound,
+ CmdEndPrintBold,
+};
// CODE --------------------------------------------------------------------
@@ -336,6 +340,16 @@ void P_LoadACScripts(int lump)
info->argCount = LONG(*buffer);
++buffer;
+ if (info->argCount > MAX_SCRIPT_ARGS)
+ {
+ fprintf(stderr, "Warning: ACS script #%i has %i arguments, more "
+ "than the maximum of %i. Enforcing limit.\n"
+ "If you are seeing this message, please report "
+ "the name of the WAD where you saw it.\n",
+ i, info->argCount, MAX_SCRIPT_ARGS);
+ info->argCount = MAX_SCRIPT_ARGS;
+ }
+
if (info->number >= OPEN_SCRIPTS_BASE)
{ // Auto-activate
info->number -= OPEN_SCRIPTS_BASE;
@@ -414,6 +428,9 @@ void P_CheckACSStore(void)
//
// P_StartACS
//
+// Start an ACS script. The 'args' array should be at least MAX_SCRIPT_ARGS
+// elements in length.
+//
//==========================================================================
static char ErrorMsg[128];
@@ -458,7 +475,7 @@ boolean P_StartACS(int number, int map, byte * args, mobj_t * activator,
script->side = side;
script->ip = ACSInfo[infoIndex].address;
script->thinker.function = T_InterpretACS;
- for (i = 0; i < ACSInfo[infoIndex].argCount; i++)
+ for (i = 0; i < MAX_SCRIPT_ARGS && i < ACSInfo[infoIndex].argCount; i++)
{
script->vars[i] = args[i];
}
@@ -503,7 +520,7 @@ static boolean AddToACSStore(int map, int number, byte * args)
}
ACSStore[index].map = map;
ACSStore[index].script = number;
- memcpy(ACSStore[index].args, args, sizeof(int));
+ memcpy(ACSStore[index].args, args, MAX_SCRIPT_ARGS);
return true;
}