summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/control/Garages.cpp28
-rw-r--r--src/control/Garages.h67
-rw-r--r--src/control/Script.cpp8
3 files changed, 55 insertions, 48 deletions
diff --git a/src/control/Garages.cpp b/src/control/Garages.cpp
index f7211272..c63818e1 100644
--- a/src/control/Garages.cpp
+++ b/src/control/Garages.cpp
@@ -489,7 +489,7 @@ void CGarage::Update()
DMAudio.PlayFrontEndSound(SOUND_GARAGE_BOMB_ALREADY_SET, 1);
break;
}
- if (!CGarages::BombsAreFree && CWorld::Players[CWorld::PlayerInFocus].m_nMoney >= BOMB_PRICE) {
+ if (!CGarages::BombsAreFree && CWorld::Players[CWorld::PlayerInFocus].m_nMoney < BOMB_PRICE) {
CGarages::TriggerMessage("GA_4", -1, 4000, -1); // "Car bombs are $1000 each"
m_eGarageState = GS_OPENEDCONTAINSCAR;
DMAudio.PlayFrontEndSound(SOUND_GARAGE_NO_MONEY, 1);
@@ -1973,23 +1973,23 @@ bool CGarages::IsPointInAGarageCameraZone(CVector point)
for (int i = 0; i < NUM_GARAGES; i++) {
switch (aGarages[i].m_eGarageType) {
case GARAGE_NONE:
- continue;
+ break;
case GARAGE_COLLECTCARS_1:
case GARAGE_COLLECTCARS_2:
case GARAGE_COLLECTCARS_3:
- if (aGarages[i].m_fX1 - MARGIN_FOR_CAMERA_COLLECTCARS < point.x ||
- aGarages[i].m_fX2 - MARGIN_FOR_CAMERA_COLLECTCARS > point.x ||
- aGarages[i].m_fY1 - MARGIN_FOR_CAMERA_COLLECTCARS < point.y ||
- aGarages[i].m_fY2 - MARGIN_FOR_CAMERA_COLLECTCARS > point.y)
- continue;
- return true;
+ if (aGarages[i].m_fX1 - MARGIN_FOR_CAMERA_COLLECTCARS <= point.x &&
+ aGarages[i].m_fX2 + MARGIN_FOR_CAMERA_COLLECTCARS >= point.x &&
+ aGarages[i].m_fY1 - MARGIN_FOR_CAMERA_COLLECTCARS <= point.y &&
+ aGarages[i].m_fY2 + MARGIN_FOR_CAMERA_COLLECTCARS >= point.y)
+ return true;
+ break;
default:
- if (aGarages[i].m_fX1 - MARGIN_FOR_CAMERA_DEFAULT < point.x ||
- aGarages[i].m_fX2 - MARGIN_FOR_CAMERA_DEFAULT > point.x ||
- aGarages[i].m_fY1 - MARGIN_FOR_CAMERA_DEFAULT < point.y ||
- aGarages[i].m_fY2 - MARGIN_FOR_CAMERA_DEFAULT > point.y)
- continue;
- return true;
+ if (aGarages[i].m_fX1 - MARGIN_FOR_CAMERA_DEFAULT <= point.x &&
+ aGarages[i].m_fX2 + MARGIN_FOR_CAMERA_DEFAULT >= point.x &&
+ aGarages[i].m_fY1 - MARGIN_FOR_CAMERA_DEFAULT <= point.y &&
+ aGarages[i].m_fY2 + MARGIN_FOR_CAMERA_DEFAULT >= point.y)
+ return true;
+ break;
}
}
return false;
diff --git a/src/control/Garages.h b/src/control/Garages.h
index 5d1063ca..8b88359a 100644
--- a/src/control/Garages.h
+++ b/src/control/Garages.h
@@ -80,10 +80,9 @@ static_assert(sizeof(CStoredCar) == 0x28, "CStoredCar");
class CGarage
{
-public:
eGarageType m_eGarageType;
eGarageState m_eGarageState;
- bool field_2;
+ bool field_2; // unused
bool m_bClosingWithoutTargetCar;
bool m_bDeactivated;
bool m_bResprayHappened;
@@ -114,7 +113,7 @@ public:
uint32 m_nTimeToStartAction;
uint8 m_bCollectedCarsState;
CVehicle *m_pTarget;
- void* field_96;
+ void* field_96; // unused
CStoredCar m_sStoredCar; // not needed
void OpenThisGarage();
@@ -166,13 +165,15 @@ public:
void FindDoorsEntities();
void FindDoorsEntitiesSectorList(CPtrList&, bool);
void PlayerArrestedOrDied();
+
+ friend class CGarages;
+ friend class cAudioManager;
};
static_assert(sizeof(CGarage) == 140, "CGarage");
class CGarages
{
-public:
static int32 &BankVansCollected;
static bool &BombsAreFree;
static bool &RespraysAreFree;
@@ -195,50 +196,56 @@ public:
static CStoredCar(&aCarsInSafeHouse3)[NUM_GARAGE_STORED_CARS];
static int32 &AudioEntity;
static bool &bCamShouldBeOutisde;
+
public:
static void Init(void);
#ifndef PS2
static void Shutdown(void);
#endif
- static int16 AddOne(float X1, float Y1, float Z1, float X2, float Y2, float Z2, eGarageType type, int32 targetId);
+ static void Update(void);
- static bool IsModelIndexADoor(uint32 id);
- static void TriggerMessage(const char *text, int16, uint16 time, int16);
+ static int16 AddOne(float X1, float Y1, float Z1, float X2, float Y2, float Z2, eGarageType type, int32 targetId);
+ static void ChangeGarageType(int16, eGarageType, int32);
static void PrintMessages(void);
- static bool HasCarBeenCrushed(int32);
- static bool IsPointWithinHideOutGarage(CVector&);
- static bool IsPointWithinAnyGarage(CVector&);
- static void PlayerArrestedOrDied();
-
- static void Update(void);
- static void Load(uint8 *buf, uint32 size);
- static void Save(uint8 *buf, uint32 *size);
+ static void TriggerMessage(const char* text, int16, uint16 time, int16);
static void SetTargetCarForMissonGarage(int16, CVehicle*);
static bool HasCarBeenDroppedOffYet(int16);
- static void ActivateGarage(int16);
static void DeActivateGarage(int16);
+ static void ActivateGarage(int16);
static int32 QueryCarsCollected(int16);
- static bool HasThisCarBeenCollected(int16, uint8);
- static void ChangeGarageType(int16, eGarageType, int32);
- static bool HasResprayHappened(int16);
- static void GivePlayerDetonator();
+ static bool HasImportExportGarageCollectedThisCar(int16, int8);
static bool IsGarageOpen(int16);
static bool IsGarageClosed(int16);
+ static bool HasThisCarBeenCollected(int16, uint8);
+ static void OpenGarage(int16 garage) { aGarages[garage].OpenThisGarage(); }
+ static void CloseGarage(int16 garage) { aGarages[garage].CloseThisGarage(); }
+ static bool HasResprayHappened(int16);
static void SetGarageDoorToRotate(int16);
- static bool HasImportExportGarageCollectedThisCar(int16, int8);
static void SetLeaveCameraForThisGarage(int16);
static bool IsThisCarWithinGarageArea(int16, CEntity*);
- static bool IsCarSprayable(CVehicle*);
- static int32 FindMaxNumStoredCarsForGarage(eGarageType);
- static int32 CountCarsInHideoutGarage(eGarageType);
+ static bool HasCarBeenCrushed(int32);
static bool IsPointInAGarageCameraZone(CVector);
- static bool CameraShouldBeOutside();
- static void CloseHideOutGaragesBeforeSave();
- static void SetAllDoorsBackToOriginalHeight();
-
- static int GetBombTypeForGarageType(eGarageType type) { return type - GARAGE_BOMBSHOP1 + 1; }
- static int GetCarsCollectedIndexForGarageType(eGarageType type) { return type - GARAGE_COLLECTCARS_1; }
+ static bool CameraShouldBeOutside(void);
+ static void GivePlayerDetonator(void);
+ static void PlayerArrestedOrDied(void);
+ static bool IsPointWithinHideOutGarage(CVector&);
+ static bool IsPointWithinAnyGarage(CVector&);
+ static void SetAllDoorsBackToOriginalHeight(void);
+ static void Save(uint8* buf, uint32* size);
+ static void Load(uint8* buf, uint32 size);
+ static bool IsModelIndexADoor(uint32 id);
+ static void SetFreeBombs(bool bValue) { BombsAreFree = bValue; }
+ static void SetFreeResprays(bool bValue) { RespraysAreFree = bValue; }
private:
+ static bool IsCarSprayable(CVehicle*);
static float FindDoorHeightForMI(int32);
+ static void CloseHideOutGaragesBeforeSave(void);
+ static int32 CountCarsInHideoutGarage(eGarageType);
+ static int32 FindMaxNumStoredCarsForGarage(eGarageType);
+ static int32 GetBombTypeForGarageType(eGarageType type) { return type - GARAGE_BOMBSHOP1 + 1; }
+ static int32 GetCarsCollectedIndexForGarageType(eGarageType type) { return type - GARAGE_COLLECTCARS_1; }
+
+ friend class cAudioManager;
+ friend class CGarage;
};
diff --git a/src/control/Script.cpp b/src/control/Script.cpp
index 2ea5ee24..8a79ba1d 100644
--- a/src/control/Script.cpp
+++ b/src/control/Script.cpp
@@ -4671,7 +4671,7 @@ int8 CRunningScript::ProcessCommands500To599(int32 command)
return 0;
case COMMAND_SET_FREE_BOMBS:
CollectParameters(&m_nIp, 1);
- CGarages::BombsAreFree = (ScriptParams[0] != 0);
+ CGarages::SetFreeBombs(ScriptParams[0] != 0);
return 0;
#ifdef GTA_PS2
case COMMAND_SET_POWERPOINT:
@@ -6662,7 +6662,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command)
}
case COMMAND_SET_FREE_RESPRAYS:
CollectParameters(&m_nIp, 1);
- CGarages::RespraysAreFree = (ScriptParams[0] != 0);
+ CGarages::SetFreeResprays(ScriptParams[0] != 0);
return 0;
case COMMAND_SET_PLAYER_VISIBLE:
{
@@ -7110,13 +7110,13 @@ int8 CRunningScript::ProcessCommands800To899(int32 command)
case COMMAND_OPEN_GARAGE:
{
CollectParameters(&m_nIp, 1);
- CGarages::aGarages[ScriptParams[0]].OpenThisGarage();
+ CGarages::OpenGarage(ScriptParams[0]);
return 0;
}
case COMMAND_CLOSE_GARAGE:
{
CollectParameters(&m_nIp, 1);
- CGarages::aGarages[ScriptParams[0]].CloseThisGarage();
+ CGarages::CloseGarage(ScriptParams[1]);
return 0;
}
case COMMAND_WARP_CHAR_FROM_CAR_TO_COORD: