From 7fae683316db64e772fb82833d73860cc16cf03a Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Thu, 4 Jul 2019 01:16:24 +0300 Subject: Script stuff + bug fixes --- src/control/Script.h | 109 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 103 insertions(+), 6 deletions(-) (limited to 'src/control/Script.h') diff --git a/src/control/Script.h b/src/control/Script.h index 1eb02c1b..7b62a1b0 100644 --- a/src/control/Script.h +++ b/src/control/Script.h @@ -1,5 +1,8 @@ #pragma once +#include "Ped.h" +#include "Object.h" #include "Sprite2d.h" +#include "Vehicle.h" struct CScriptRectangle { @@ -32,17 +35,111 @@ struct CTextLine wchar m_awText[500]; }; +struct CRunningScript +{ + CRunningScript *next; + CRunningScript *prev; + uint8 m_abScriptName[8]; + uint32 m_nIp; + uint32 m_anStack[6]; + uint16 m_nStackPointer; + void* m_anLocalVariables[18]; + bool m_bCondResult; + bool m_bIsMissionThread; + bool m_bSkipWakeTime; + uint32 m_nWakeTime; + uint16 m_wIfOp; + bool m_bNotFlag; + bool m_bWBCheck; + bool m_bWastedOrBusted; + bool m_bMissionFlag; +}; + +enum { + CLEANUP_UNUSED = 0, + CLEANUP_CAR, + CLEANUP_CHAR, + CLEANUP_OBJECT +}; + +struct CMissionCleanupEntity +{ + uint8 type; + int32 id; +}; + +enum { + MAX_CLEANUP = 50, + MAX_UPSIDEDOWN_CAR_CHECKS = 6, + MAX_STUCK_CAR_CHECKS = 6 +}; + +class CMissionCleanup +{ + CMissionCleanupEntity m_sEntities[MAX_CLEANUP]; + uint8 m_bCount; + +public: + CMissionCleanup(); + + void Init(); + CMissionCleanupEntity* FindFree(); + void AddEntityToList(int32, uint8); + void RemoveEntityFromList(int32, uint8); + void Process(); +}; + +struct CUpsideDownCarCheckEntry +{ + int32 m_nVehicleIndex; + uint32 m_nUpsideDownTimer; +}; + +class CUpsideDownCarCheck +{ + CUpsideDownCarCheckEntry m_sCars[MAX_UPSIDEDOWN_CAR_CHECKS]; + +public: + void Init(); +}; + +struct CStuckCarCheckEntry +{ + int32 m_nVehicleIndex; + CVector m_vecPos; + int32 m_nStartTime; + float m_fDistance; + uint32 m_nStuckTime; + bool m_bStuck; +}; + +class CStuckCarCheck +{ + CStuckCarCheckEntry m_sCars[MAX_STUCK_CAR_CHECKS]; + +public: + void Init(); +}; + class CTheScripts { public: - static uint8 *ScriptSpace;//[160*1024] - static CTextLine* IntroTextLines; - static CScriptRectangle* IntroRectangles; - static CSprite2d* ScriptSprites; - static bool DbgFlag; - static uint32 OnAMissionFlag; + static uint8(&ScriptSpace)[160 * 1024]; + static CTextLine(&IntroTextLines)[2]; + static CScriptRectangle(&IntroRectangles)[16]; + static CSprite2d(&ScriptSprites)[16]; + static bool &DbgFlag; + static uint32 &OnAMissionFlag; + static CMissionCleanup &MissionCleanup; + static CStuckCarCheck &StuckCars; + static CUpsideDownCarCheck &UpsideDownCars; + static int32 &StoreVehicleIndex; + static bool &StoreVehicleWasRandom; public: static bool IsPlayerOnAMission(); static void ScriptDebugLine3D(float x1, float y1, float z1, float x2, float y2, float z2, int col, int col2); + static void CleanUpThisVehicle(CVehicle*); + static void CleanUpThisPed(CPed*); + static void CleanUpThisObject(CObject*); }; -- cgit v1.2.3