Merge pull request #372 from Nick007J/master

CGarages done
This commit is contained in:
Nikolay Korolev 2020-04-01 01:58:28 +03:00 committed by GitHub
commit 8ff8a4de5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 1100 additions and 151 deletions

View File

@ -49,8 +49,6 @@ CCullZone
CCullZones CCullZones
CExplosion CExplosion
CFallingGlassPane CFallingGlassPane
CGarage
CGarages
CGlass CGlass
CMenuManager - WIP CMenuManager - WIP
CMotionBlurStreaks CMotionBlurStreaks

File diff suppressed because it is too large Load Diff

View File

@ -45,7 +45,8 @@ enum eGarageType : int8
enum enum
{ {
TOTAL_COLLECTCARS_GARAGES = GARAGE_COLLECTCARS_3 - GARAGE_COLLECTCARS_1 + 1 TOTAL_COLLECTCARS_GARAGES = GARAGE_COLLECTCARS_3 - GARAGE_COLLECTCARS_1 + 1,
TOTAL_COLLECTCARS_CARS = 16
}; };
class CStoredCar class CStoredCar
@ -66,6 +67,8 @@ class CStoredCar
int8 m_nCarBombType; int8 m_nCarBombType;
public: public:
void Init() { m_nModelIndex = 0; } void Init() { m_nModelIndex = 0; }
void Clear() { m_nModelIndex = 0; }
bool HasCar() { return m_nModelIndex != 0; }
CStoredCar(const CStoredCar& other); CStoredCar(const CStoredCar& other);
void StoreCar(CVehicle*); void StoreCar(CVehicle*);
CVehicle* RestoreCar(); CVehicle* RestoreCar();
@ -77,10 +80,9 @@ static_assert(sizeof(CStoredCar) == 0x28, "CStoredCar");
class CGarage class CGarage
{ {
public:
eGarageType m_eGarageType; eGarageType m_eGarageType;
eGarageState m_eGarageState; eGarageState m_eGarageState;
char field_2; bool field_2; // unused
bool m_bClosingWithoutTargetCar; bool m_bClosingWithoutTargetCar;
bool m_bDeactivated; bool m_bDeactivated;
bool m_bResprayHappened; bool m_bResprayHappened;
@ -109,13 +111,10 @@ public:
float m_fDoor1Z; float m_fDoor1Z;
float m_fDoor2Z; float m_fDoor2Z;
uint32 m_nTimeToStartAction; uint32 m_nTimeToStartAction;
char m_bCollectedCarsState; uint8 m_bCollectedCarsState;
char field_89;
char field_90;
char field_91;
CVehicle *m_pTarget; CVehicle *m_pTarget;
int field_96; void* field_96; // unused
CStoredCar m_sStoredCar; CStoredCar m_sStoredCar; // not needed
void OpenThisGarage(); void OpenThisGarage();
void CloseThisGarage(); void CloseThisGarage();
@ -125,7 +124,7 @@ public:
void Update(); void Update();
float GetGarageCenterX() { return (m_fX1 + m_fX2) / 2; } float GetGarageCenterX() { return (m_fX1 + m_fX2) / 2; }
float GetGarageCenterY() { return (m_fY1 + m_fY2) / 2; } float GetGarageCenterY() { return (m_fY1 + m_fY2) / 2; }
bool IsClose() bool IsFar()
{ {
#ifdef FIX_BUGS #ifdef FIX_BUGS
return Abs(TheCamera.GetPosition().x - GetGarageCenterX()) > SWITCH_GARAGE_DISTANCE_CLOSE || return Abs(TheCamera.GetPosition().x - GetGarageCenterX()) > SWITCH_GARAGE_DISTANCE_CLOSE ||
@ -151,7 +150,7 @@ public:
bool IsAnyCarBlockingDoor(); bool IsAnyCarBlockingDoor();
void CenterCarInGarage(CVehicle*); void CenterCarInGarage(CVehicle*);
bool DoesCraigNeedThisCar(int32); bool DoesCraigNeedThisCar(int32);
void MarkThisCarAsCollectedForCraig(int32); bool MarkThisCarAsCollectedForCraig(int32);
bool HasCraigCollectedThisCar(int32); bool HasCraigCollectedThisCar(int32);
bool IsGarageEmpty(); bool IsGarageEmpty();
void UpdateCrusherShake(float, float); void UpdateCrusherShake(float, float);
@ -166,13 +165,18 @@ public:
void FindDoorsEntities(); void FindDoorsEntities();
void FindDoorsEntitiesSectorList(CPtrList&, bool); void FindDoorsEntitiesSectorList(CPtrList&, bool);
void PlayerArrestedOrDied(); void PlayerArrestedOrDied();
friend class CGarages;
friend class cAudioManager;
}; };
static_assert(sizeof(CGarage) == 140, "CGarage"); static_assert(sizeof(CGarage) == 140, "CGarage");
class CGarages class CGarages
{ {
public: enum {
MESSAGE_LENGTH = 8
};
static int32 &BankVansCollected; static int32 &BankVansCollected;
static bool &BombsAreFree; static bool &BombsAreFree;
static bool &RespraysAreFree; static bool &RespraysAreFree;
@ -181,7 +185,7 @@ public:
static int32 &CrushedCarId; static int32 &CrushedCarId;
static uint32 &LastTimeHelpMessage; static uint32 &LastTimeHelpMessage;
static int32 &MessageNumberInString; static int32 &MessageNumberInString;
static const char *MessageIDString; static char(&MessageIDString)[MESSAGE_LENGTH];
static int32 &MessageNumberInString2; static int32 &MessageNumberInString2;
static uint32 &MessageStartTime; static uint32 &MessageStartTime;
static uint32 &MessageEndTime; static uint32 &MessageEndTime;
@ -195,50 +199,56 @@ public:
static CStoredCar(&aCarsInSafeHouse3)[NUM_GARAGE_STORED_CARS]; static CStoredCar(&aCarsInSafeHouse3)[NUM_GARAGE_STORED_CARS];
static int32 &AudioEntity; static int32 &AudioEntity;
static bool &bCamShouldBeOutisde; static bool &bCamShouldBeOutisde;
public: public:
static void Init(void); static void Init(void);
#ifndef PS2 #ifndef PS2
static void Shutdown(void); static void Shutdown(void);
#endif #endif
static int16 AddOne(float X1, float Y1, float Z1, float X2, float Y2, float Z2, eGarageType type, int32 targetId);
static bool IsModelIndexADoor(uint32 id);
static void TriggerMessage(const char *text, int16, uint16 time, int16);
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 Update(void);
static void Load(uint8 *buf, uint32 size);
static void Save(uint8 *buf, uint32 *size); 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 void TriggerMessage(const char* text, int16, uint16 time, int16);
static void SetTargetCarForMissonGarage(int16, CVehicle*); static void SetTargetCarForMissonGarage(int16, CVehicle*);
static bool HasCarBeenDroppedOffYet(int16); static bool HasCarBeenDroppedOffYet(int16);
static void ActivateGarage(int16);
static void DeActivateGarage(int16); static void DeActivateGarage(int16);
static void ActivateGarage(int16);
static int32 QueryCarsCollected(int16); static int32 QueryCarsCollected(int16);
static bool HasThisCarBeenCollected(int16, uint8); static bool HasImportExportGarageCollectedThisCar(int16, int8);
static void ChangeGarageType(int16, eGarageType, int32);
static bool HasResprayHappened(int16);
static void GivePlayerDetonator();
static bool IsGarageOpen(int16); static bool IsGarageOpen(int16);
static bool IsGarageClosed(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 void SetGarageDoorToRotate(int16);
static bool HasImportExportGarageCollectedThisCar(int16, int8);
static void SetLeaveCameraForThisGarage(int16); static void SetLeaveCameraForThisGarage(int16);
static bool IsThisCarWithinGarageArea(int16, CEntity*); static bool IsThisCarWithinGarageArea(int16, CEntity*);
static bool IsCarSprayable(CVehicle*); static bool HasCarBeenCrushed(int32);
static int32 FindMaxNumStoredCarsForGarage(eGarageType);
static int32 CountCarsInHideoutGarage(eGarageType);
static bool IsPointInAGarageCameraZone(CVector); static bool IsPointInAGarageCameraZone(CVector);
static bool CameraShouldBeOutside(); static bool CameraShouldBeOutside(void);
static void CloseHideOutGaragesBeforeSave(); static void GivePlayerDetonator(void);
static void SetAllDoorsBackToOriginalHeight(); static void PlayerArrestedOrDied(void);
static bool IsPointWithinHideOutGarage(CVector&);
static int GetBombTypeForGarageType(eGarageType type) { return type - GARAGE_BOMBSHOP1 + 1; } static bool IsPointWithinAnyGarage(CVector&);
static int GetCarsCollectedIndexForGarageType(eGarageType type) { return type - GARAGE_COLLECTCARS_1; } 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: private:
static bool IsCarSprayable(CVehicle*);
static float FindDoorHeightForMI(int32); 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;
}; };

View File

@ -4671,7 +4671,7 @@ int8 CRunningScript::ProcessCommands500To599(int32 command)
return 0; return 0;
case COMMAND_SET_FREE_BOMBS: case COMMAND_SET_FREE_BOMBS:
CollectParameters(&m_nIp, 1); CollectParameters(&m_nIp, 1);
CGarages::BombsAreFree = (ScriptParams[0] != 0); CGarages::SetFreeBombs(ScriptParams[0] != 0);
return 0; return 0;
#ifdef GTA_PS2 #ifdef GTA_PS2
case COMMAND_SET_POWERPOINT: case COMMAND_SET_POWERPOINT:
@ -6662,7 +6662,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command)
} }
case COMMAND_SET_FREE_RESPRAYS: case COMMAND_SET_FREE_RESPRAYS:
CollectParameters(&m_nIp, 1); CollectParameters(&m_nIp, 1);
CGarages::RespraysAreFree = (ScriptParams[0] != 0); CGarages::SetFreeResprays(ScriptParams[0] != 0);
return 0; return 0;
case COMMAND_SET_PLAYER_VISIBLE: case COMMAND_SET_PLAYER_VISIBLE:
{ {
@ -7110,13 +7110,13 @@ int8 CRunningScript::ProcessCommands800To899(int32 command)
case COMMAND_OPEN_GARAGE: case COMMAND_OPEN_GARAGE:
{ {
CollectParameters(&m_nIp, 1); CollectParameters(&m_nIp, 1);
CGarages::aGarages[ScriptParams[0]].OpenThisGarage(); CGarages::OpenGarage(ScriptParams[0]);
return 0; return 0;
} }
case COMMAND_CLOSE_GARAGE: case COMMAND_CLOSE_GARAGE:
{ {
CollectParameters(&m_nIp, 1); CollectParameters(&m_nIp, 1);
CGarages::aGarages[ScriptParams[0]].CloseThisGarage(); CGarages::CloseGarage(ScriptParams[1]);
return 0; return 0;
} }
case COMMAND_WARP_CHAR_FROM_CAR_TO_COORD: case COMMAND_WARP_CHAR_FROM_CAR_TO_COORD: