From a9559f03b020b16aa64dee1554b22e960c9dcc14 Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Sat, 9 Jan 2021 00:20:09 +0300 Subject: lcs script mode --- src/control/Script.h | 65 ++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 45 insertions(+), 20 deletions(-) (limited to 'src/control/Script.h') diff --git a/src/control/Script.h b/src/control/Script.h index e4196220..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 { @@ -214,6 +214,13 @@ public: bool HasCarBeenStuckForAWhile(int32); }; +enum { + MAX_STACK_DEPTH = 16, + NUM_LOCAL_VARS = 96, + NUM_TIMERS = 2, + NUM_GLOBAL_SLOTS = 26 +}; + enum { ARGUMENT_END = 0, ARGUMENT_INT_ZERO, @@ -224,9 +231,17 @@ enum { ARGUMENT_INT32, 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; @@ -272,10 +287,11 @@ 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_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 }; @@ -283,12 +299,13 @@ enum { 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]; @@ -328,14 +345,21 @@ public: #define CARDS_IN_STACK (CARDS_IN_DECK * MAX_DECKS) static int16 CardStack[CARDS_IN_STACK]; static int16 CardStackPosition; - - static int AllowedCollision[MAX_ALLOWED_COLLISIONS]; #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(); @@ -426,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() { @@ -447,13 +474,6 @@ public: }; - -enum { - MAX_STACK_DEPTH = 6, - NUM_LOCAL_VARS = 16, - NUM_TIMERS = 2 -}; - extern int ScriptParams[32]; class CRunningScript @@ -481,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; @@ -505,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(); @@ -608,3 +630,6 @@ void RetryMission(int, int); #ifdef USE_DEBUG_SCRIPT_LOADER extern int scriptToLoad; #endif + +extern int gScriptsFile; + -- cgit v1.2.3