summaryrefslogtreecommitdiffstats
path: root/src/control/Script.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/control/Script.h')
-rw-r--r--src/control/Script.h75
1 files changed, 54 insertions, 21 deletions
diff --git a/src/control/Script.h b/src/control/Script.h
index aafc681c..0a7f64bf 100644
--- a/src/control/Script.h
+++ b/src/control/Script.h
@@ -47,7 +47,7 @@ void FlushLog();
#define KEY_LENGTH_IN_SCRIPT (8)
-//#define GTA_SCRIPT_COLLECTIVE
+#define GTA_SCRIPT_COLLECTIVE
struct intro_script_rectangle
{
@@ -215,15 +215,33 @@ public:
};
enum {
+ MAX_STACK_DEPTH = 16,
+ NUM_LOCAL_VARS = 96,
+ NUM_TIMERS = 2,
+ NUM_GLOBAL_SLOTS = 26
+};
+
+enum {
ARGUMENT_END = 0,
+ ARGUMENT_INT_ZERO,
+ ARGUMENT_FLOAT_ZERO,
+ ARGUMENT_FLOAT_1BYTE,
+ ARGUMENT_FLOAT_2BYTES,
+ ARGUMENT_FLOAT_3BYTES,
ARGUMENT_INT32,
- ARGUMENT_GLOBALVAR,
- ARGUMENT_LOCALVAR,
ARGUMENT_INT8,
ARGUMENT_INT16,
- ARGUMENT_FLOAT
+ ARGUMENT_FLOAT,
+ ARGUMENT_TIMER,
+ ARGUMENT_LOCAL = ARGUMENT_TIMER + NUM_TIMERS,
+ ARGUMENT_LOCAL_ARRAY = ARGUMENT_LOCAL + NUM_LOCAL_VARS,
+ ARGUMENT_GLOBAL = ARGUMENT_LOCAL_ARRAY + NUM_LOCAL_VARS,
+ ARGUMENT_GLOBAL_ARRAY = ARGUMENT_GLOBAL + NUM_GLOBAL_SLOTS,
+ MAX_ARGUMENT = ARGUMENT_GLOBAL_ARRAY + NUM_GLOBAL_SLOTS
};
+static_assert(MAX_ARGUMENT <= 256, "MAX_ARGUMENT must be less or equal to 256");
+
struct tCollectiveData
{
int32 colIndex;
@@ -269,22 +287,25 @@ enum {
MAX_NUM_INTRO_RECTANGLES = 16,
MAX_NUM_SCRIPT_SRPITES = 16,
MAX_NUM_SCRIPT_SPHERES = 16,
- MAX_NUM_USED_OBJECTS = 220,
- MAX_NUM_MISSION_SCRIPTS = 120,
- MAX_NUM_BUILDING_SWAPS = 25,
- MAX_NUM_INVISIBILITY_SETTINGS = 20,
- MAX_NUM_STORED_LINES = 1024
+ MAX_NUM_COLLECTIVES = 32,
+ MAX_NUM_USED_OBJECTS = 305,
+ MAX_NUM_MISSION_SCRIPTS = 150,
+ MAX_NUM_BUILDING_SWAPS = 80,
+ MAX_NUM_INVISIBILITY_SETTINGS = 52,
+ MAX_NUM_STORED_LINES = 1024,
+ MAX_ALLOWED_COLLISIONS = 2
};
class CTheScripts
{
public:
- static uint8 ScriptSpace[SIZE_SCRIPT_SPACE];
+ static uint8* ScriptSpace;
static CRunningScript ScriptsArray[MAX_NUM_SCRIPTS];
static intro_text_line IntroTextLines[MAX_NUM_INTRO_TEXT_LINES];
static intro_script_rectangle IntroRectangles[MAX_NUM_INTRO_RECTANGLES];
static CSprite2d ScriptSprites[MAX_NUM_SCRIPT_SRPITES];
static script_sphere_struct ScriptSphereArray[MAX_NUM_SCRIPT_SPHERES];
+ static tCollectiveData CollectiveArray[MAX_NUM_COLLECTIVES];
static tUsedObject UsedObjectArray[MAX_NUM_USED_OBJECTS];
static int32 MultiScriptArray[MAX_NUM_MISSION_SCRIPTS];
static tBuildingSwap BuildingSwapArray[MAX_NUM_BUILDING_SWAPS];
@@ -325,11 +346,20 @@ public:
static int16 CardStack[CARDS_IN_STACK];
static int16 CardStackPosition;
#endif
+
static bool bPlayerIsInTheStatium;
static uint8 RiotIntensity;
static bool bPlayerHasMetDebbieHarry;
- static void Init();
+ static int AllowedCollision[MAX_ALLOWED_COLLISIONS];
+ static short* SavedVarIndices;
+ static int NumSaveVars;
+ static bool FSDestroyedFlag;
+ static int NextProcessId;
+ static bool InTheScripts;
+ static CRunningScript* pCurrent;
+
+ static bool Init(bool loaddata = false);
static void Process();
static CRunningScript* StartTestScript();
@@ -420,6 +450,9 @@ public:
static void SwitchToMission(int32 mission);
#endif
+ static int GetSaveVarIndex(int);
+ static void Shutdown(void);
+
#ifdef GTA_SCRIPT_COLLECTIVE
static void AdvanceCollectiveIndex()
{
@@ -441,12 +474,7 @@ public:
};
-
-enum {
- MAX_STACK_DEPTH = 6,
- NUM_LOCAL_VARS = 16,
- NUM_TIMERS = 2
-};
+extern int ScriptParams[32];
class CRunningScript
{
@@ -473,11 +501,13 @@ class CRunningScript
public:
CRunningScript* next;
CRunningScript* prev;
+ int m_nId;
char m_abScriptName[8];
uint32 m_nIp;
uint32 m_anStack[MAX_STACK_DEPTH];
uint16 m_nStackPointer;
- int32 m_anLocalVariables[NUM_LOCAL_VARS + NUM_TIMERS];
+ int32 m_anLocalVariables[NUM_LOCAL_VARS + 8 + NUM_TIMERS]; // TODO(LCS): figure out why 106
+ int32 m_nLocalsPointer;
bool m_bIsActive;
bool m_bCondResult;
bool m_bIsMissionScript;
@@ -497,8 +527,8 @@ public:
void Load(uint8*& buf);
void UpdateTimers(float timeStep) {
- m_anLocalVariables[NUM_LOCAL_VARS] += timeStep;
- m_anLocalVariables[NUM_LOCAL_VARS + 1] += timeStep;
+ for (int i = 0; i < NUM_TIMERS; i++)
+ m_anLocalVariables[NUM_LOCAL_VARS + 8 + i] += timeStep;
}
void Init();
@@ -509,7 +539,7 @@ public:
static const uint32 nSaveStructSize;
- void CollectParameters(uint32*, int16);
+ void CollectParameters(uint32*, int16, int* pParams = (int*)&ScriptParams);
int32 CollectNextParameterWithoutIncreasingPC(uint32);
int32* GetPointerToScriptVariable(uint32*, int16);
void StoreParameters(uint32*, int16);
@@ -600,3 +630,6 @@ void RetryMission(int, int);
#ifdef USE_DEBUG_SCRIPT_LOADER
extern int scriptToLoad;
#endif
+
+extern int gScriptsFile;
+