minor refactoring

This commit is contained in:
Nikolay Korolev 2021-01-07 16:33:42 +03:00
parent 02a28996f4
commit 416a898943
8 changed files with 143 additions and 135 deletions

View File

@ -81,6 +81,7 @@ VALIDATE_SIZE(CStoredCar, 0x28);
class CGarage class CGarage
{ {
public:
uint8 m_eGarageType; uint8 m_eGarageType;
uint8 m_eGarageState; uint8 m_eGarageState;
bool field_2; // unused bool field_2; // unused
@ -167,9 +168,6 @@ class CGarage
void FindDoorsEntitiesSectorList(CPtrList&, bool); void FindDoorsEntitiesSectorList(CPtrList&, bool);
void PlayerArrestedOrDied(); void PlayerArrestedOrDied();
friend class CGarages;
friend class cAudioManager;
friend class CCamera;
}; };
VALIDATE_SIZE(CGarage, 140); VALIDATE_SIZE(CGarage, 140);
@ -179,6 +177,7 @@ class CGarages
enum { enum {
MESSAGE_LENGTH = 8 MESSAGE_LENGTH = 8
}; };
public:
static int32 BankVansCollected; static int32 BankVansCollected;
static bool BombsAreFree; static bool BombsAreFree;
static bool RespraysAreFree; static bool RespraysAreFree;
@ -200,7 +199,6 @@ class CGarages
static CStoredCar aCarsInSafeHouse3[NUM_GARAGE_STORED_CARS]; static CStoredCar aCarsInSafeHouse3[NUM_GARAGE_STORED_CARS];
static bool bCamShouldBeOutisde; static bool bCamShouldBeOutisde;
public:
static void Init(void); static void Init(void);
#ifndef PS2 #ifndef PS2
static void Shutdown(void); static void Shutdown(void);
@ -240,7 +238,6 @@ public:
static void SetFreeBombs(bool bValue) { BombsAreFree = bValue; } static void SetFreeBombs(bool bValue) { BombsAreFree = bValue; }
static void SetFreeResprays(bool bValue) { RespraysAreFree = bValue; } static void SetFreeResprays(bool bValue) { RespraysAreFree = bValue; }
private:
static bool IsCarSprayable(CVehicle*); static bool IsCarSprayable(CVehicle*);
static float FindDoorHeightForMI(int32); static float FindDoorHeightForMI(int32);
static void CloseHideOutGaragesBeforeSave(void); static void CloseHideOutGaragesBeforeSave(void);
@ -249,9 +246,4 @@ private:
static int32 GetBombTypeForGarageType(uint8 type) { return type - GARAGE_BOMBSHOP1 + 1; } static int32 GetBombTypeForGarageType(uint8 type) { return type - GARAGE_BOMBSHOP1 + 1; }
static int32 GetCarsCollectedIndexForGarageType(uint8 type) { return type - GARAGE_COLLECTCARS_1; } static int32 GetCarsCollectedIndexForGarageType(uint8 type) { return type - GARAGE_COLLECTCARS_1; }
friend class cAudioManager;
friend class CGarage;
#ifdef FIX_BUGS
friend class CReplay;
#endif
}; };

View File

@ -1225,7 +1225,7 @@ const tScriptCommandData commands[] = {
REGISTER_COMMAND(COMMAND_SET_JAMES_CAR_ON_PATH_TO_PLAYER, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), REGISTER_COMMAND(COMMAND_SET_JAMES_CAR_ON_PATH_TO_PLAYER, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""),
REGISTER_COMMAND(COMMAND_LOAD_END_OF_GAME_TUNE, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), REGISTER_COMMAND(COMMAND_LOAD_END_OF_GAME_TUNE, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
REGISTER_COMMAND(COMMAND_ENABLE_PLAYER_CONTROL_CAMERA, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), REGISTER_COMMAND(COMMAND_ENABLE_PLAYER_CONTROL_CAMERA, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
#ifndef GTA_PS2 #if GTA_VERSION > GTA3_PS2_160
REGISTER_COMMAND(COMMAND_SET_OBJECT_ROTATION, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), REGISTER_COMMAND(COMMAND_SET_OBJECT_ROTATION, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""),
REGISTER_COMMAND(COMMAND_GET_DEBUG_CAMERA_COORDINATES, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), false, -1, ""), REGISTER_COMMAND(COMMAND_GET_DEBUG_CAMERA_COORDINATES, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), false, -1, ""),
REGISTER_COMMAND(COMMAND_GET_DEBUG_CAMERA_FRONT_VECTOR, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), false, -1, ""), REGISTER_COMMAND(COMMAND_GET_DEBUG_CAMERA_FRONT_VECTOR, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), false, -1, ""),
@ -1444,10 +1444,16 @@ void CUpsideDownCarCheck::Init()
bool CUpsideDownCarCheck::IsCarUpsideDown(int32 id) bool CUpsideDownCarCheck::IsCarUpsideDown(int32 id)
{ {
CVehicle* v = CPools::GetVehiclePool()->GetAt(id); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(id);
return v->GetUp().z <= -0.97f && return IsCarUpsideDown(pVehicle);
v->GetMoveSpeed().Magnitude() < 0.01f && }
v->GetTurnSpeed().Magnitude() < 0.02f;
bool CUpsideDownCarCheck::IsCarUpsideDown(CVehicle* pVehicle)
{
assert(pVehicle);
return pVehicle->GetUp().z <= UPSIDEDOWN_UP_THRESHOLD &&
pVehicle->GetMoveSpeed().Magnitude() < UPSIDEDOWN_MOVE_SPEED_THRESHOLD &&
pVehicle->GetTurnSpeed().Magnitude() < UPSIDEDOWN_TURN_SPEED_THRESHOLD;
} }
void CUpsideDownCarCheck::UpdateTimers() void CUpsideDownCarCheck::UpdateTimers()
@ -1470,7 +1476,7 @@ void CUpsideDownCarCheck::UpdateTimers()
bool CUpsideDownCarCheck::AreAnyCarsUpsideDown() bool CUpsideDownCarCheck::AreAnyCarsUpsideDown()
{ {
for (int i = 0; i < MAX_UPSIDEDOWN_CAR_CHECKS; i++){ for (int i = 0; i < MAX_UPSIDEDOWN_CAR_CHECKS; i++){
if (m_sCars[i].m_nVehicleIndex >= 0 && m_sCars[i].m_nUpsideDownTimer > 1000) if (m_sCars[i].m_nVehicleIndex >= 0 && m_sCars[i].m_nUpsideDownTimer > UPSIDEDOWN_TIMER_THRESHOLD)
return true; return true;
} }
return false; return false;
@ -1481,8 +1487,10 @@ void CUpsideDownCarCheck::AddCarToCheck(int32 id)
uint16 index = 0; uint16 index = 0;
while (index < MAX_UPSIDEDOWN_CAR_CHECKS && m_sCars[index].m_nVehicleIndex >= 0) while (index < MAX_UPSIDEDOWN_CAR_CHECKS && m_sCars[index].m_nVehicleIndex >= 0)
index++; index++;
#ifdef FIX_BUGS
if (index >= MAX_UPSIDEDOWN_CAR_CHECKS) if (index >= MAX_UPSIDEDOWN_CAR_CHECKS)
return; return;
#endif
m_sCars[index].m_nVehicleIndex = id; m_sCars[index].m_nVehicleIndex = id;
m_sCars[index].m_nUpsideDownTimer = 0; m_sCars[index].m_nUpsideDownTimer = 0;
} }
@ -1501,7 +1509,7 @@ bool CUpsideDownCarCheck::HasCarBeenUpsideDownForAWhile(int32 id)
{ {
for (int i = 0; i < MAX_UPSIDEDOWN_CAR_CHECKS; i++){ for (int i = 0; i < MAX_UPSIDEDOWN_CAR_CHECKS; i++){
if (m_sCars[i].m_nVehicleIndex == id) if (m_sCars[i].m_nVehicleIndex == id)
return m_sCars[i].m_nUpsideDownTimer > 1000; return m_sCars[i].m_nUpsideDownTimer > UPSIDEDOWN_TIMER_THRESHOLD;
} }
return false; return false;
} }
@ -1551,7 +1559,10 @@ void CStuckCarCheck::AddCarToCheck(int32 id, float radius, uint32 time)
int index = 0; int index = 0;
while (index < MAX_STUCK_CAR_CHECKS && m_sCars[index].m_nVehicleIndex >= 0) while (index < MAX_STUCK_CAR_CHECKS && m_sCars[index].m_nVehicleIndex >= 0)
index++; index++;
/* Would be nice to return if index >= MAX_STUCK_CAR_CHECKS... */ #ifdef FIX_BUGS
if (index >= MAX_STUCK_CAR_CHECKS)
return;
#endif
m_sCars[index].m_nVehicleIndex = id; m_sCars[index].m_nVehicleIndex = id;
m_sCars[index].m_vecPos = pv->GetPosition(); m_sCars[index].m_vecPos = pv->GetPosition();
m_sCars[index].m_nLastCheck = CTimer::GetTimeInMilliseconds(); m_sCars[index].m_nLastCheck = CTimer::GetTimeInMilliseconds();
@ -2098,7 +2109,7 @@ int8 CRunningScript::ProcessOneCommand()
retval = ProcessCommands800To899(command); retval = ProcessCommands800To899(command);
else if (command < 1000) else if (command < 1000)
retval = ProcessCommands900To999(command); retval = ProcessCommands900To999(command);
#ifdef GTA_PS2 #if GTA_VERSION <= GTA3_PS2_160
else if (command < 1200) else if (command < 1200)
retval = ProcessCommands1000To1099(command); retval = ProcessCommands1000To1099(command);
#else #else
@ -4314,81 +4325,6 @@ int8 CRunningScript::ProcessCommands200To299(int32 command)
return -1; return -1;
} }
void CRunningScript::Save(uint8*& buf)
{
#ifdef COMPATIBLE_SAVES
SkipSaveBuf(buf, 8);
for (int i = 0; i < 8; i++)
WriteSaveBuf<char>(buf, m_abScriptName[i]);
WriteSaveBuf<uint32>(buf, m_nIp);
#ifdef CHECK_STRUCT_SIZES
static_assert(MAX_STACK_DEPTH == 6, "Compatibility loss: MAX_STACK_DEPTH != 6");
#endif
for (int i = 0; i < MAX_STACK_DEPTH; i++)
WriteSaveBuf<uint32>(buf, m_anStack[i]);
WriteSaveBuf<uint16>(buf, m_nStackPointer);
SkipSaveBuf(buf, 2);
#ifdef CHECK_STRUCT_SIZES
static_assert(NUM_LOCAL_VARS + NUM_TIMERS == 18, "Compatibility loss: NUM_LOCAL_VARS + NUM_TIMERS != 18");
#endif
for (int i = 0; i < NUM_LOCAL_VARS + NUM_TIMERS; i++)
WriteSaveBuf<int32>(buf, m_anLocalVariables[i]);
WriteSaveBuf<bool>(buf, m_bCondResult);
WriteSaveBuf<bool>(buf, m_bIsMissionScript);
WriteSaveBuf<bool>(buf, m_bSkipWakeTime);
SkipSaveBuf(buf, 1);
WriteSaveBuf<uint32>(buf, m_nWakeTime);
WriteSaveBuf<uint16>(buf, m_nAndOrState);
WriteSaveBuf<bool>(buf, m_bNotFlag);
WriteSaveBuf<bool>(buf, m_bDeatharrestEnabled);
WriteSaveBuf<bool>(buf, m_bDeatharrestExecuted);
WriteSaveBuf<bool>(buf, m_bMissionFlag);
SkipSaveBuf(buf, 2);
#else
WriteSaveBuf(buf, *this);
#endif
}
void CRunningScript::Load(uint8*& buf)
{
#ifdef COMPATIBLE_SAVES
SkipSaveBuf(buf, 8);
for (int i = 0; i < 8; i++)
m_abScriptName[i] = ReadSaveBuf<char>(buf);
m_nIp = ReadSaveBuf<uint32>(buf);
#ifdef CHECK_STRUCT_SIZES
static_assert(MAX_STACK_DEPTH == 6, "Compatibility loss: MAX_STACK_DEPTH != 6");
#endif
for (int i = 0; i < MAX_STACK_DEPTH; i++)
m_anStack[i] = ReadSaveBuf<uint32>(buf);
m_nStackPointer = ReadSaveBuf<uint16>(buf);
SkipSaveBuf(buf, 2);
#ifdef CHECK_STRUCT_SIZES
static_assert(NUM_LOCAL_VARS + NUM_TIMERS == 18, "Compatibility loss: NUM_LOCAL_VARS + NUM_TIMERS != 18");
#endif
for (int i = 0; i < NUM_LOCAL_VARS + NUM_TIMERS; i++)
m_anLocalVariables[i] = ReadSaveBuf<int32>(buf);
m_bCondResult = ReadSaveBuf<bool>(buf);
m_bIsMissionScript = ReadSaveBuf<bool>(buf);
m_bSkipWakeTime = ReadSaveBuf<bool>(buf);
SkipSaveBuf(buf, 1);
m_nWakeTime = ReadSaveBuf<uint32>(buf);
m_nAndOrState = ReadSaveBuf<uint16>(buf);
m_bNotFlag = ReadSaveBuf<bool>(buf);
m_bDeatharrestEnabled = ReadSaveBuf<bool>(buf);
m_bDeatharrestExecuted = ReadSaveBuf<bool>(buf);
m_bMissionFlag = ReadSaveBuf<bool>(buf);
SkipSaveBuf(buf, 2);
#else
CRunningScript* n = next;
CRunningScript* p = prev;
*this = ReadSaveBuf<CRunningScript>(buf);
next = n;
prev = p;
#endif
}
#ifdef MISSION_REPLAY #ifdef MISSION_REPLAY
bool CRunningScript::CanAllowMissionReplay() bool CRunningScript::CanAllowMissionReplay()

View File

@ -20,27 +20,32 @@ extern int32 ScriptParams[32];
void FlushLog(); void FlushLog();
#define script_assert(_Expression) FlushLog(); assert(_Expression); #define script_assert(_Expression) FlushLog(); assert(_Expression);
#define PICKUP_PLACEMENT_OFFSET 0.5f #define PICKUP_PLACEMENT_OFFSET (0.5f)
#define PED_FIND_Z_OFFSET 5.0f #define PED_FIND_Z_OFFSET (5.0f)
#define SPHERE_MARKER_R 0 #define UPSIDEDOWN_UP_THRESHOLD (-0.97f)
#define SPHERE_MARKER_G 128 #define UPSIDEDOWN_MOVE_SPEED_THRESHOLD (0.01f)
#define SPHERE_MARKER_B 255 #define UPSIDEDOWN_TURN_SPEED_THRESHOLD (0.02f)
#define SPHERE_MARKER_A 128 #define UPSIDEDOWN_TIMER_THRESHOLD (1000)
#define SPHERE_MARKER_PULSE_PERIOD 2048
#define SPHERE_MARKER_PULSE_FRACTION 0.1f #define SPHERE_MARKER_R (0)
#define SPHERE_MARKER_G (128)
#define SPHERE_MARKER_B (255)
#define SPHERE_MARKER_A (128)
#define SPHERE_MARKER_PULSE_PERIOD (2048)
#define SPHERE_MARKER_PULSE_FRACTION (0.1f)
#ifdef USE_PRECISE_MEASUREMENT_CONVERTION #ifdef USE_PRECISE_MEASUREMENT_CONVERTION
#define METERS_IN_FOOT 0.3048f #define METERS_IN_FOOT (0.3048f)
#define FEET_IN_METER 3.28084f #define FEET_IN_METER (3.28084f)
#else #else
#define METERS_IN_FOOT 0.3f #define METERS_IN_FOOT (0.3f)
#define FEET_IN_METER 3.33f #define FEET_IN_METER (3.33f)
#endif #endif
#define KEY_LENGTH_IN_SCRIPT 8 #define KEY_LENGTH_IN_SCRIPT (8)
#if GTA_VERSION <= GTA_PS2_160 #if GTA_VERSION <= GTA3_PS2_160
#define GTA_SCRIPT_COLLECTIVE #define GTA_SCRIPT_COLLECTIVE
#endif #endif
@ -95,8 +100,8 @@ struct intro_text_line
m_bCentered = false; m_bCentered = false;
m_bBackground = false; m_bBackground = false;
m_bBackgroundOnly = false; m_bBackgroundOnly = false;
m_fWrapX = 182.0f; /* TODO: scaling as bugfix */ m_fWrapX = 182.0f;
m_fCenterSize = 640.0f; /* --||-- */ m_fCenterSize = DEFAULT_SCREEN_WIDTH;
m_sBackgroundColor = CRGBA(128, 128, 128, 128); m_sBackgroundColor = CRGBA(128, 128, 128, 128);
m_bTextProportional = true; m_bTextProportional = true;
m_bTextBeforeFade = false; m_bTextBeforeFade = false;
@ -162,7 +167,7 @@ public:
void Process(); void Process();
}; };
struct CUpsideDownCarCheckEntry struct upsidedown_car_data
{ {
int32 m_nVehicleIndex; int32 m_nVehicleIndex;
uint32 m_nUpsideDownTimer; uint32 m_nUpsideDownTimer;
@ -170,11 +175,12 @@ struct CUpsideDownCarCheckEntry
class CUpsideDownCarCheck class CUpsideDownCarCheck
{ {
CUpsideDownCarCheckEntry m_sCars[MAX_UPSIDEDOWN_CAR_CHECKS]; upsidedown_car_data m_sCars[MAX_UPSIDEDOWN_CAR_CHECKS];
public: public:
void Init(); void Init();
bool IsCarUpsideDown(int32); bool IsCarUpsideDown(int32);
bool IsCarUpsideDown(CVehicle*);
void UpdateTimers(); void UpdateTimers();
bool AreAnyCarsUpsideDown(); bool AreAnyCarsUpsideDown();
void AddCarToCheck(int32); void AddCarToCheck(int32);
@ -192,7 +198,7 @@ struct stuck_car_data
bool m_bStuck; bool m_bStuck;
stuck_car_data() { } stuck_car_data() { }
inline void Reset(); void Reset();
}; };
class CStuckCarCheck class CStuckCarCheck
@ -269,6 +275,7 @@ enum {
class CTheScripts class CTheScripts
{ {
public:
static uint8 ScriptSpace[SIZE_SCRIPT_SPACE]; static uint8 ScriptSpace[SIZE_SCRIPT_SPACE];
static CRunningScript ScriptsArray[MAX_NUM_SCRIPTS]; static CRunningScript ScriptsArray[MAX_NUM_SCRIPTS];
static int32 BaseBriefIdForContact[MAX_NUM_CONTACTS]; static int32 BaseBriefIdForContact[MAX_NUM_CONTACTS];
@ -310,7 +317,6 @@ class CTheScripts
static uint16 CommandsExecuted; static uint16 CommandsExecuted;
static uint16 ScriptsUpdated; static uint16 ScriptsUpdated;
public:
static void Init(); static void Init();
static void Process(); static void Process();
@ -367,8 +373,6 @@ public:
return Read4BytesFromScript(&tmp); return Read4BytesFromScript(&tmp);
} }
private:
static CRunningScript* StartNewScript(uint32); static CRunningScript* StartNewScript(uint32);
static void CleanUpThisVehicle(CVehicle*); static void CleanUpThisVehicle(CVehicle*);
@ -418,13 +422,6 @@ private:
static void SetObjectiveForAllPedsInCollective(int, eObjective); static void SetObjectiveForAllPedsInCollective(int, eObjective);
#endif #endif
friend class CRunningScript;
friend class CHud;
friend void CMissionCleanup::Process();
#ifdef MISSION_REPLAY
friend void RetryMission(int, int);
#endif
#ifdef MISSION_SWITCHER #ifdef MISSION_SWITCHER
public: public:
static void SwitchToMission(int32 mission); static void SwitchToMission(int32 mission);
@ -433,7 +430,11 @@ public:
enum { enum {
MAX_STACK_DEPTH = 6, // 4 PS2 #if GTA_VERSION > GTA3_PS2_160
MAX_STACK_DEPTH = 6,
#else
MAX_STACK_DEPTH = 4,
#endif
NUM_LOCAL_VARS = 16, NUM_LOCAL_VARS = 16,
NUM_TIMERS = 2 NUM_TIMERS = 2
}; };
@ -460,6 +461,7 @@ class CRunningScript
ORS_8 ORS_8
}; };
public:
CRunningScript* next; CRunningScript* next;
CRunningScript* prev; CRunningScript* prev;
char m_abScriptName[8]; char m_abScriptName[8];
@ -497,7 +499,6 @@ public:
static const uint32 nSaveStructSize; static const uint32 nSaveStructSize;
private:
void CollectParameters(uint32*, int16); void CollectParameters(uint32*, int16);
int32 CollectNextParameterWithoutIncreasingPC(uint32); int32 CollectNextParameterWithoutIncreasingPC(uint32);
int32* GetPointerToScriptVariable(uint32*, int16); int32* GetPointerToScriptVariable(uint32*, int16);
@ -519,7 +520,7 @@ private:
int8 ProcessCommands800To899(int32); int8 ProcessCommands800To899(int32);
int8 ProcessCommands900To999(int32); int8 ProcessCommands900To999(int32);
int8 ProcessCommands1000To1099(int32); int8 ProcessCommands1000To1099(int32);
#ifndef GTA_PS2 #if GTA_VERSION > GTA3_PS2_160
int8 ProcessCommands1100To1199(int32); int8 ProcessCommands1100To1199(int32);
#endif #endif
void LocatePlayerCommand(int32, uint32*); void LocatePlayerCommand(int32, uint32*);
@ -575,8 +576,6 @@ private:
return false; return false;
} }
} }
friend class CTheScripts;
}; };
#ifdef MISSION_REPLAY #ifdef MISSION_REPLAY

View File

@ -342,7 +342,7 @@ int8 CRunningScript::ProcessCommands500To599(int32 command)
CollectParameters(&m_nIp, 1); CollectParameters(&m_nIp, 1);
CGarages::SetFreeBombs(ScriptParams[0] != 0); CGarages::SetFreeBombs(ScriptParams[0] != 0);
return 0; return 0;
#ifdef GTA_PS2 #if GTA_VERSION <= GTA3_PS2_160
case COMMAND_SET_POWERPOINT: case COMMAND_SET_POWERPOINT:
{ {
CollectParameters(&m_nIp, 7); CollectParameters(&m_nIp, 7);
@ -376,7 +376,7 @@ int8 CRunningScript::ProcessCommands500To599(int32 command)
return 0; return 0;
} }
#endif // GTA_PS2 #endif // GTA_VERSION <= GTA3_PS2_160
case COMMAND_SET_ALL_TAXI_LIGHTS: case COMMAND_SET_ALL_TAXI_LIGHTS:
CollectParameters(&m_nIp, 1); CollectParameters(&m_nIp, 1);
CAutomobile::SetAllTaxiLights(ScriptParams[0] != 0); CAutomobile::SetAllTaxiLights(ScriptParams[0] != 0);

View File

@ -2075,6 +2075,80 @@ VALIDATESAVEBUF(size)
#undef SCRIPT_DATA_SIZE #undef SCRIPT_DATA_SIZE
void CRunningScript::Save(uint8*& buf)
{
#ifdef COMPATIBLE_SAVES
SkipSaveBuf(buf, 8);
for (int i = 0; i < 8; i++)
WriteSaveBuf<char>(buf, m_abScriptName[i]);
WriteSaveBuf<uint32>(buf, m_nIp);
#ifdef CHECK_STRUCT_SIZES
static_assert(MAX_STACK_DEPTH == 6, "Compatibility loss: MAX_STACK_DEPTH != 6");
#endif
for (int i = 0; i < MAX_STACK_DEPTH; i++)
WriteSaveBuf<uint32>(buf, m_anStack[i]);
WriteSaveBuf<uint16>(buf, m_nStackPointer);
SkipSaveBuf(buf, 2);
#ifdef CHECK_STRUCT_SIZES
static_assert(NUM_LOCAL_VARS + NUM_TIMERS == 18, "Compatibility loss: NUM_LOCAL_VARS + NUM_TIMERS != 18");
#endif
for (int i = 0; i < NUM_LOCAL_VARS + NUM_TIMERS; i++)
WriteSaveBuf<int32>(buf, m_anLocalVariables[i]);
WriteSaveBuf<bool>(buf, m_bCondResult);
WriteSaveBuf<bool>(buf, m_bIsMissionScript);
WriteSaveBuf<bool>(buf, m_bSkipWakeTime);
SkipSaveBuf(buf, 1);
WriteSaveBuf<uint32>(buf, m_nWakeTime);
WriteSaveBuf<uint16>(buf, m_nAndOrState);
WriteSaveBuf<bool>(buf, m_bNotFlag);
WriteSaveBuf<bool>(buf, m_bDeatharrestEnabled);
WriteSaveBuf<bool>(buf, m_bDeatharrestExecuted);
WriteSaveBuf<bool>(buf, m_bMissionFlag);
SkipSaveBuf(buf, 2);
#else
WriteSaveBuf(buf, *this);
#endif
}
void CRunningScript::Load(uint8*& buf)
{
#ifdef COMPATIBLE_SAVES
SkipSaveBuf(buf, 8);
for (int i = 0; i < 8; i++)
m_abScriptName[i] = ReadSaveBuf<char>(buf);
m_nIp = ReadSaveBuf<uint32>(buf);
#ifdef CHECK_STRUCT_SIZES
static_assert(MAX_STACK_DEPTH == 6, "Compatibility loss: MAX_STACK_DEPTH != 6");
#endif
for (int i = 0; i < MAX_STACK_DEPTH; i++)
m_anStack[i] = ReadSaveBuf<uint32>(buf);
m_nStackPointer = ReadSaveBuf<uint16>(buf);
SkipSaveBuf(buf, 2);
#ifdef CHECK_STRUCT_SIZES
static_assert(NUM_LOCAL_VARS + NUM_TIMERS == 18, "Compatibility loss: NUM_LOCAL_VARS + NUM_TIMERS != 18");
#endif
for (int i = 0; i < NUM_LOCAL_VARS + NUM_TIMERS; i++)
m_anLocalVariables[i] = ReadSaveBuf<int32>(buf);
m_bCondResult = ReadSaveBuf<bool>(buf);
m_bIsMissionScript = ReadSaveBuf<bool>(buf);
m_bSkipWakeTime = ReadSaveBuf<bool>(buf);
SkipSaveBuf(buf, 1);
m_nWakeTime = ReadSaveBuf<uint32>(buf);
m_nAndOrState = ReadSaveBuf<uint16>(buf);
m_bNotFlag = ReadSaveBuf<bool>(buf);
m_bDeatharrestEnabled = ReadSaveBuf<bool>(buf);
m_bDeatharrestExecuted = ReadSaveBuf<bool>(buf);
m_bMissionFlag = ReadSaveBuf<bool>(buf);
SkipSaveBuf(buf, 2);
#else
CRunningScript* n = next;
CRunningScript* p = prev;
*this = ReadSaveBuf<CRunningScript>(buf);
next = n;
prev = p;
#endif
}
void CTheScripts::ClearSpaceForMissionEntity(const CVector& pos, CEntity* pEntity) void CTheScripts::ClearSpaceForMissionEntity(const CVector& pos, CEntity* pEntity)
{ {
static CColPoint aTempColPoints[MAX_COLLISION_POINTS]; static CColPoint aTempColPoints[MAX_COLLISION_POINTS];

View File

@ -33,9 +33,12 @@
#include "Zones.h" #include "Zones.h"
#include "main.h" #include "main.h"
// NB: on PS2 this file did not exist; ProcessCommands1000To1099 was in Script5.cpp and ProcessCommands1100To1199 was only added on PC
// however to avoid redundant copies of code, Script6.cpp is used with PS2 defines
int8 CRunningScript::ProcessCommands1000To1099(int32 command) int8 CRunningScript::ProcessCommands1000To1099(int32 command)
{ {
#ifdef GTA_PS2 #if GTA_VERSION <= GTA3_PS2_160
char tmp[48]; char tmp[48];
#endif #endif
switch (command) { switch (command) {
@ -746,7 +749,7 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command)
pPed->m_objective != OBJECTIVE_ENTER_CAR_AS_DRIVER); pPed->m_objective != OBJECTIVE_ENTER_CAR_AS_DRIVER);
return 0; return 0;
} }
#ifndef GTA_PS2 #if GTA_VERSION > GTA3_PS2_160
default: default:
script_assert(0); script_assert(0);
} }
@ -838,8 +841,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command)
case COMMAND_ENABLE_PLAYER_CONTROL_CAMERA: case COMMAND_ENABLE_PLAYER_CONTROL_CAMERA:
CPad::GetPad(0)->SetEnablePlayerControls(PLAYERCONTROL_CAMERA); CPad::GetPad(0)->SetEnablePlayerControls(PLAYERCONTROL_CAMERA);
return 0; return 0;
#ifndef GTA_PS2 #if GTA_VERSION > GTA3_PS2_160
// To be precise, on PS2 previous handlers were in 1000-1099 function
// These are "beta" VC commands (with bugs) // These are "beta" VC commands (with bugs)
case COMMAND_SET_OBJECT_ROTATION: case COMMAND_SET_OBJECT_ROTATION:
{ {

View File

@ -1108,7 +1108,7 @@ enum {
COMMAND_SET_JAMES_CAR_ON_PATH_TO_PLAYER, COMMAND_SET_JAMES_CAR_ON_PATH_TO_PLAYER,
COMMAND_LOAD_END_OF_GAME_TUNE, COMMAND_LOAD_END_OF_GAME_TUNE,
COMMAND_ENABLE_PLAYER_CONTROL_CAMERA, COMMAND_ENABLE_PLAYER_CONTROL_CAMERA,
#ifndef GTA_PS2 #if GTA_VERSION > GTA3_PS2_160
COMMAND_SET_OBJECT_ROTATION, COMMAND_SET_OBJECT_ROTATION,
COMMAND_GET_DEBUG_CAMERA_COORDINATES, COMMAND_GET_DEBUG_CAMERA_COORDINATES,
COMMAND_GET_DEBUG_CAMERA_FRONT_VECTOR, COMMAND_GET_DEBUG_CAMERA_FRONT_VECTOR,

View File

@ -323,6 +323,11 @@ enum Config {
#define USE_BASIC_SCRIPT_DEBUG_OUTPUT #define USE_BASIC_SCRIPT_DEBUG_OUTPUT
#endif #endif
#ifdef MASTER
#undef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT
#undef USE_BASIC_SCRIPT_DEBUG_OUTPUT
#endif
// Replay // Replay
//#define DONT_FIX_REPLAY_BUGS // keeps various bugs in CReplay, some of which are fairly cool! //#define DONT_FIX_REPLAY_BUGS // keeps various bugs in CReplay, some of which are fairly cool!
//#define USE_BETA_REPLAY_MODE // adds another replay mode, a few seconds slomo (caution: buggy!) //#define USE_BETA_REPLAY_MODE // adds another replay mode, a few seconds slomo (caution: buggy!)