ref: 714b700b1cf7f9cb0f6dca3c9bc7b0653a74f270
parent: 07109cb24fab1ecde3f2abc8220201f3da99f4e8
author: Simon Howard <fraggle@soulsphere.org>
date: Thu Jan 4 20:47:19 EST 2018
hexen: Add doc comments for new functions.
--- a/src/hexen/p_acs.c
+++ b/src/hexen/p_acs.c
@@ -874,14 +874,34 @@
ACScript->stackPtr--;
}
+//==========================================================================
+//
+// ReadCodeImmediate
+//
+// Some instructions take "immediate" parameters which are stored in the
+// bytecode immediately following the instruction. This function should be
+// used to read them.
+//
+//==========================================================================
+
static int ReadCodeImmediate(void)
{
int result;
+ // TODO: Add bounds checking
result = *PCodePtr;
++PCodePtr;
return result;
}
+//==========================================================================
+//
+// ReadScriptVar
+//
+// Read a script variable index as an immediate value, validating the
+// result is a valid script variable number.
+//
+//==========================================================================
+
static int ReadScriptVar(void)
{
int var = ReadCodeImmediate();
@@ -891,6 +911,15 @@
return var;
}
+//==========================================================================
+//
+// ReadMapVar
+//
+// Read a map variable index as an immediate value, validating the
+// result is a valid map variable number.
+//
+//==========================================================================
+
static int ReadMapVar(void)
{
int var = ReadCodeImmediate();
@@ -900,6 +929,15 @@
return var;
}
+//==========================================================================
+//
+// ReadWorldVar
+//
+// Read a world variable index as an immediate value, validating the
+// result is a valid world variable number.
+//
+//==========================================================================
+
static int ReadWorldVar(void)
{
int var = ReadCodeImmediate();
@@ -908,6 +946,15 @@
"invalid world variable: %d >= %d", var, MAX_ACS_WORLD_VARS);
return var;
}
+
+//==========================================================================
+//
+// StringLookup
+//
+// Look up the given string in the strings table by index, validating that
+// it is a valid string index.
+//
+//==========================================================================
static char *StringLookup(int string_index)
{