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.h334
1 files changed, 167 insertions, 167 deletions
diff --git a/src/control/Script.h b/src/control/Script.h
index 11c1b185..8b54f28f 100644
--- a/src/control/Script.h
+++ b/src/control/Script.h
@@ -289,6 +289,173 @@ struct script_corona
int flareType;
};
+class CRunningScript
+{
+ enum {
+ ANDOR_NONE = 0,
+ ANDS_1 = 1,
+ ANDS_2,
+ ANDS_3,
+ ANDS_4,
+ ANDS_5,
+ ANDS_6,
+ ANDS_7,
+ ANDS_8,
+ ORS_1 = 21,
+ ORS_2,
+ ORS_3,
+ ORS_4,
+ ORS_5,
+ ORS_6,
+ ORS_7,
+ ORS_8
+ };
+
+ enum {
+ STACKVALUE_IP_BITS = 22,
+ STACKVALUE_INVERT_RETURN_BIT = STACKVALUE_IP_BITS,
+ STACKVALUE_IS_FUNCTION_CALL_BIT,
+ STACKVALUE_IP_PARAMS_OFFSET,
+
+ STACKVALUE_IP_MASK = ((1 << STACKVALUE_IP_BITS) - 1)
+ };
+
+public:
+ CRunningScript* next;
+ CRunningScript* prev;
+ int32 m_nId;
+ char m_abScriptName[8];
+ uint32 m_nIp;
+ uint32 m_anStack[MAX_STACK_DEPTH];
+ uint16 m_nStackPointer;
+ 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;
+ bool m_bSkipWakeTime;
+ uint32 m_nWakeTime;
+ uint16 m_nAndOrState;
+ bool m_bNotFlag;
+ bool m_bDeatharrestEnabled;
+ bool m_bDeatharrestExecuted;
+ bool m_bMissionFlag;
+
+public:
+ void SetIP(uint32 ip) { m_nIp = ip; }
+ CRunningScript* GetNext() const { return next; }
+
+ void Save(uint8*& buf);
+ void Load(uint8*& buf);
+
+ void UpdateTimers(float timeStep) {
+ for (int i = 0; i < NUM_TIMERS; i++)
+ m_anLocalVariables[NUM_LOCAL_VARS + 8 + i] += timeStep;
+ }
+
+ void Init();
+ void Process();
+
+ void RemoveScriptFromList(CRunningScript**);
+ void AddScriptToList(CRunningScript**);
+
+ static const uint32 nSaveStructSize;
+
+ void CollectParameters(uint32*, int16, int* pParams = (int*)&ScriptParams);
+ int32 CollectNextParameterWithoutIncreasingPC(uint32);
+ int32* GetPointerToScriptVariable(uint32*, int16);
+ void StoreParameters(uint32*, int16);
+
+ int8 ProcessOneCommand();
+ void DoDeatharrestCheck();
+ void UpdateCompareFlag(bool flag)
+ {
+ if (m_bNotFlag)
+ flag = !flag;
+ if (m_nAndOrState == ANDOR_NONE) {
+ m_bCondResult = flag;
+ return;
+ }
+ if (m_nAndOrState >= ANDS_1 && m_nAndOrState <= ANDS_8) {
+ m_bCondResult &= flag;
+ if (m_nAndOrState == ANDS_1) {
+ m_nAndOrState = ANDOR_NONE;
+ return;
+ }
+ }
+ else {
+ m_bCondResult |= flag;
+ if (m_nAndOrState <= ORS_1) {
+ m_nAndOrState = ANDOR_NONE;
+ return;
+ }
+ }
+ m_nAndOrState--;
+ }
+ int16 GetPadState(uint16, uint16);
+
+ int8 ProcessCommands0To99(int32);
+ int8 ProcessCommands100To199(int32);
+ int8 ProcessCommands200To299(int32);
+ int8 ProcessCommands300To399(int32);
+ int8 ProcessCommands400To499(int32);
+ int8 ProcessCommands500To599(int32);
+ int8 ProcessCommands600To699(int32);
+ int8 ProcessCommands700To799(int32);
+ int8 ProcessCommands800To899(int32);
+ int8 ProcessCommands900To999(int32);
+ int8 ProcessCommands1000To1099(int32);
+ int8 ProcessCommands1100To1199(int32);
+ int8 ProcessCommands1200To1299(int32);
+ int8 ProcessCommands1300To1399(int32);
+ int8 ProcessCommands1400To1499(int32);
+ int8 ProcessCommands1500To1599(int32);
+ int8 ProcessCommands1600To1699(int32);
+
+ uint32 CollectLocateParameters(uint32*, bool);
+ void LocatePlayerCommand(int32, uint32*);
+ void LocatePlayerCharCommand(int32, uint32*);
+ void LocatePlayerCarCommand(int32, uint32*);
+ void LocateCharCommand(int32, uint32*);
+ void LocateCharCharCommand(int32, uint32*);
+ void LocateCharCarCommand(int32, uint32*);
+ void LocateCharObjectCommand(int32, uint32*);
+ void LocateCarCommand(int32, uint32*);
+ void LocateSniperBulletCommand(int32, uint32*);
+ void PlayerInAreaCheckCommand(int32, uint32*);
+ void PlayerInAngledAreaCheckCommand(int32, uint32*);
+ void CharInAreaCheckCommand(int32, uint32*);
+ void CarInAreaCheckCommand(int32, uint32*);
+ void LocateObjectCommand(int32, uint32*);
+ void ObjectInAreaCheckCommand(int32, uint32*);
+
+#ifdef GTA_SCRIPT_COLLECTIVE
+ void LocateCollectiveCommand(int32, uint32*);
+ void LocateCollectiveCharCommand(int32, uint32*);
+ void LocateCollectiveCarCommand(int32, uint32*);
+ void LocateCollectivePlayerCommand(int32, uint32*);
+ void CollectiveInAreaCheckCommand(int32, uint32*);
+#endif
+
+#ifdef MISSION_REPLAY
+ bool CanAllowMissionReplay();
+#endif
+
+#ifdef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT
+ int CollectParameterForDebug(char* buf, bool& var);
+ void GetStoredParameterForDebug(char* buf);
+#endif
+
+ float LimitAngleOnCircle(float angle) { return angle < 0.0f ? angle + 360.0f : angle; }
+
+ bool ThisIsAValidRandomCop(uint32 mi, int cop, int swat, int fbi, int army, int miami);
+ bool ThisIsAValidRandomPed(uint32 pedtype, int civ, int gang, int criminal);
+ bool CheckDamagedWeaponType(int32 actual, int32 type);
+
+ void ReturnFromGosubOrFunction();
+
+};
+
enum {
VAR_LOCAL = 1,
@@ -494,173 +661,6 @@ extern int ScriptParams[32];
VALIDATE_SIZE(uStackReturnValue, 4);
-class CRunningScript
-{
- enum {
- ANDOR_NONE = 0,
- ANDS_1 = 1,
- ANDS_2,
- ANDS_3,
- ANDS_4,
- ANDS_5,
- ANDS_6,
- ANDS_7,
- ANDS_8,
- ORS_1 = 21,
- ORS_2,
- ORS_3,
- ORS_4,
- ORS_5,
- ORS_6,
- ORS_7,
- ORS_8
- };
-
- enum {
- STACKVALUE_IP_BITS = 22,
- STACKVALUE_INVERT_RETURN_BIT = STACKVALUE_IP_BITS,
- STACKVALUE_IS_FUNCTION_CALL_BIT,
- STACKVALUE_IP_PARAMS_OFFSET,
-
- STACKVALUE_IP_MASK = ((1 << STACKVALUE_IP_BITS) - 1)
- };
-
-public:
- CRunningScript* next;
- CRunningScript* prev;
- int32 m_nId;
- char m_abScriptName[8];
- uint32 m_nIp;
- uint32 m_anStack[MAX_STACK_DEPTH];
- uint16 m_nStackPointer;
- 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;
- bool m_bSkipWakeTime;
- uint32 m_nWakeTime;
- uint16 m_nAndOrState;
- bool m_bNotFlag;
- bool m_bDeatharrestEnabled;
- bool m_bDeatharrestExecuted;
- bool m_bMissionFlag;
-
-public:
- void SetIP(uint32 ip) { m_nIp = ip; }
- CRunningScript* GetNext() const { return next; }
-
- void Save(uint8*& buf);
- void Load(uint8*& buf);
-
- void UpdateTimers(float timeStep) {
- for (int i = 0; i < NUM_TIMERS; i++)
- m_anLocalVariables[NUM_LOCAL_VARS + 8 + i] += timeStep;
- }
-
- void Init();
- void Process();
-
- void RemoveScriptFromList(CRunningScript**);
- void AddScriptToList(CRunningScript**);
-
- static const uint32 nSaveStructSize;
-
- void CollectParameters(uint32*, int16, int* pParams = (int*)&ScriptParams);
- int32 CollectNextParameterWithoutIncreasingPC(uint32);
- int32* GetPointerToScriptVariable(uint32*, int16);
- void StoreParameters(uint32*, int16);
-
- int8 ProcessOneCommand();
- void DoDeatharrestCheck();
- void UpdateCompareFlag(bool flag)
- {
- if (m_bNotFlag)
- flag = !flag;
- if (m_nAndOrState == ANDOR_NONE) {
- m_bCondResult = flag;
- return;
- }
- if (m_nAndOrState >= ANDS_1 && m_nAndOrState <= ANDS_8) {
- m_bCondResult &= flag;
- if (m_nAndOrState == ANDS_1) {
- m_nAndOrState = ANDOR_NONE;
- return;
- }
- }
- else {
- m_bCondResult |= flag;
- if (m_nAndOrState <= ORS_1) {
- m_nAndOrState = ANDOR_NONE;
- return;
- }
- }
- m_nAndOrState--;
- }
- int16 GetPadState(uint16, uint16);
-
- int8 ProcessCommands0To99(int32);
- int8 ProcessCommands100To199(int32);
- int8 ProcessCommands200To299(int32);
- int8 ProcessCommands300To399(int32);
- int8 ProcessCommands400To499(int32);
- int8 ProcessCommands500To599(int32);
- int8 ProcessCommands600To699(int32);
- int8 ProcessCommands700To799(int32);
- int8 ProcessCommands800To899(int32);
- int8 ProcessCommands900To999(int32);
- int8 ProcessCommands1000To1099(int32);
- int8 ProcessCommands1100To1199(int32);
- int8 ProcessCommands1200To1299(int32);
- int8 ProcessCommands1300To1399(int32);
- int8 ProcessCommands1400To1499(int32);
- int8 ProcessCommands1500To1599(int32);
- int8 ProcessCommands1600To1699(int32);
-
- uint32 CollectLocateParameters(uint32*, bool);
- void LocatePlayerCommand(int32, uint32*);
- void LocatePlayerCharCommand(int32, uint32*);
- void LocatePlayerCarCommand(int32, uint32*);
- void LocateCharCommand(int32, uint32*);
- void LocateCharCharCommand(int32, uint32*);
- void LocateCharCarCommand(int32, uint32*);
- void LocateCharObjectCommand(int32, uint32*);
- void LocateCarCommand(int32, uint32*);
- void LocateSniperBulletCommand(int32, uint32*);
- void PlayerInAreaCheckCommand(int32, uint32*);
- void PlayerInAngledAreaCheckCommand(int32, uint32*);
- void CharInAreaCheckCommand(int32, uint32*);
- void CarInAreaCheckCommand(int32, uint32*);
- void LocateObjectCommand(int32, uint32*);
- void ObjectInAreaCheckCommand(int32, uint32*);
-
-#ifdef GTA_SCRIPT_COLLECTIVE
- void LocateCollectiveCommand(int32, uint32*);
- void LocateCollectiveCharCommand(int32, uint32*);
- void LocateCollectiveCarCommand(int32, uint32*);
- void LocateCollectivePlayerCommand(int32, uint32*);
- void CollectiveInAreaCheckCommand(int32, uint32*);
-#endif
-
-#ifdef MISSION_REPLAY
- bool CanAllowMissionReplay();
-#endif
-
-#ifdef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT
- int CollectParameterForDebug(char* buf, bool& var);
- void GetStoredParameterForDebug(char* buf);
-#endif
-
- float LimitAngleOnCircle(float angle) { return angle < 0.0f ? angle + 360.0f : angle; }
-
- bool ThisIsAValidRandomCop(uint32 mi, int cop, int swat, int fbi, int army, int miami);
- bool ThisIsAValidRandomPed(uint32 pedtype, int civ, int gang, int criminal);
- bool CheckDamagedWeaponType(int32 actual, int32 type);
-
- void ReturnFromGosubOrFunction();
-
-};
-
#ifdef USE_DEBUG_SCRIPT_LOADER
extern int scriptToLoad;
#endif