summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSergeanur <s.anureev@yandex.ua>2020-03-30 19:10:12 +0200
committerSergeanur <s.anureev@yandex.ua>2020-03-30 19:10:12 +0200
commit2607a91d87270709db4303ee8cb9011e2d9146ad (patch)
tree611cf59f1c46b60908057affe8d86eb9b39a23ad /src
parentAdd russian lang support (diff)
parentMerge pull request #366 from Nick007J/master (diff)
downloadre3-2607a91d87270709db4303ee8cb9011e2d9146ad.tar
re3-2607a91d87270709db4303ee8cb9011e2d9146ad.tar.gz
re3-2607a91d87270709db4303ee8cb9011e2d9146ad.tar.bz2
re3-2607a91d87270709db4303ee8cb9011e2d9146ad.tar.lz
re3-2607a91d87270709db4303ee8cb9011e2d9146ad.tar.xz
re3-2607a91d87270709db4303ee8cb9011e2d9146ad.tar.zst
re3-2607a91d87270709db4303ee8cb9011e2d9146ad.zip
Diffstat (limited to 'src')
-rw-r--r--src/audio/AudioManager.cpp14
-rw-r--r--src/audio/DMAudio.h2
-rw-r--r--src/control/AutoPilot.cpp4
-rw-r--r--src/control/CarCtrl.cpp9
-rw-r--r--src/control/Curves.cpp10
-rw-r--r--src/control/Darkel.cpp16
-rw-r--r--src/control/GameLogic.cpp2
-rw-r--r--src/control/Gangs.cpp6
-rw-r--r--src/control/Gangs.h2
-rw-r--r--src/control/Garages.cpp1428
-rw-r--r--src/control/Garages.h114
-rw-r--r--src/control/Replay.cpp122
-rw-r--r--src/control/Script.cpp41
-rw-r--r--src/control/Script.h2
-rw-r--r--src/core/Cam.cpp208
-rw-r--r--src/core/Camera.h3
-rw-r--r--src/core/CutsceneMgr.cpp5
-rw-r--r--src/core/EventList.cpp18
-rw-r--r--src/core/Frontend.cpp47
-rw-r--r--src/core/Game.cpp447
-rw-r--r--src/core/Game.h17
-rw-r--r--src/core/Pad.h7
-rw-r--r--src/core/Radar.cpp174
-rw-r--r--src/core/RwHelper.cpp20
-rw-r--r--src/core/RwHelper.h9
-rw-r--r--src/core/Stats.cpp2
-rw-r--r--src/core/Stats.h2
-rw-r--r--src/core/Timer.cpp4
-rw-r--r--src/core/TxdStore.cpp4
-rw-r--r--src/core/TxdStore.h2
-rw-r--r--src/core/Wanted.cpp125
-rw-r--r--src/core/Wanted.h4
-rw-r--r--src/core/World.cpp16
-rw-r--r--src/core/World.h3
-rw-r--r--src/core/config.h5
-rw-r--r--src/core/main.cpp3
-rw-r--r--src/core/main.h1
-rw-r--r--src/core/re3.cpp4
-rw-r--r--src/modelinfo/VehicleModelInfo.cpp2
-rw-r--r--src/modelinfo/VehicleModelInfo.h1
-rw-r--r--src/peds/Ped.cpp26
-rw-r--r--src/render/Coronas.cpp3
-rw-r--r--src/render/Hud.cpp42
-rw-r--r--src/render/Rubbish.cpp1
-rw-r--r--src/render/Rubbish.h1
-rw-r--r--src/render/Skidmarks.cpp1
-rw-r--r--src/render/Skidmarks.h1
-rw-r--r--src/render/SpecialFX.cpp1
-rw-r--r--src/render/SpecialFX.h1
-rw-r--r--src/render/WeaponEffects.cpp113
-rw-r--r--src/render/WeaponEffects.h30
-rw-r--r--src/save/GenericGameStorage.cpp1
-rw-r--r--src/skel/win/win.cpp6
-rw-r--r--src/vehicles/Automobile.cpp4
-rw-r--r--src/vehicles/Vehicle.cpp24
-rw-r--r--src/vehicles/Vehicle.h2
-rw-r--r--src/weapons/Explosion.cpp2
-rw-r--r--src/weapons/ShotInfo.cpp140
-rw-r--r--src/weapons/ShotInfo.h23
-rw-r--r--src/weapons/Weapon.cpp1
-rw-r--r--src/weapons/Weapon.h13
61 files changed, 2609 insertions, 732 deletions
diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp
index 5410ed6f..8e8d024a 100644
--- a/src/audio/AudioManager.cpp
+++ b/src/audio/AudioManager.cpp
@@ -3938,7 +3938,7 @@ cAudioManager::ProcessFrontEnd()
break;
case SOUND_GARAGE_NO_MONEY:
case SOUND_GARAGE_BAD_VEHICLE:
- case SOUND_3C:
+ case SOUND_GARAGE_BOMB_ALREADY_SET:
m_sQueueSample.m_nSampleIndex = SFX_PICKUP_ERROR_LEFT;
stereo = true;
break;
@@ -4095,7 +4095,7 @@ cAudioManager::ProcessGarages()
CalculateDistance(distCalculated, distSquared); \
m_sQueueSample.m_bVolume = ComputeVolume(60, 80.f, m_sQueueSample.m_fDistance); \
if(m_sQueueSample.m_bVolume) { \
- if(CGarages::Garages[i].m_eGarageType == GARAGE_CRUSHER) { \
+ if(CGarages::aGarages[i].m_eGarageType == GARAGE_CRUSHER) { \
m_sQueueSample.m_nSampleIndex = SFX_COL_CAR_PANEL_2; \
m_sQueueSample.m_nFrequency = 6735; \
} else if(m_asAudioEntities[m_sQueueSample.m_nEntityIndex] \
@@ -4131,20 +4131,20 @@ cAudioManager::ProcessGarages()
}
for(uint32 i = 0; i < CGarages::NumGarages; ++i) {
- if(CGarages::Garages[i].m_eGarageType == GARAGE_NONE) continue;
- entity = CGarages::Garages[i].m_pDoor1;
+ if(CGarages::aGarages[i].m_eGarageType == GARAGE_NONE) continue;
+ entity = CGarages::aGarages[i].m_pDoor1;
if(!entity) continue;
m_sQueueSample.m_vecPos = entity->GetPosition();
distCalculated = false;
distSquared = GetDistanceSquared(&m_sQueueSample.m_vecPos);
if(distSquared < 6400.f) {
- state = CGarages::Garages[i].m_eGarageState;
+ state = CGarages::aGarages[i].m_eGarageState;
if(state == GS_OPENING || state == GS_CLOSING || state == GS_AFTERDROPOFF) {
CalculateDistance(distCalculated, distSquared);
m_sQueueSample.m_bVolume = ComputeVolume(90, 80.f, m_sQueueSample.m_fDistance);
if(m_sQueueSample.m_bVolume) {
- if(CGarages::Garages[i].m_eGarageType == GARAGE_CRUSHER) {
- if(CGarages::Garages[i].m_eGarageState == GS_AFTERDROPOFF) {
+ if(CGarages::aGarages[i].m_eGarageType == GARAGE_CRUSHER) {
+ if(CGarages::aGarages[i].m_eGarageState == GS_AFTERDROPOFF) {
if(!(m_FrameCounter & 1)) {
LOOP_HELPER
continue;
diff --git a/src/audio/DMAudio.h b/src/audio/DMAudio.h
index c792b414..d2cdf466 100644
--- a/src/audio/DMAudio.h
+++ b/src/audio/DMAudio.h
@@ -64,7 +64,7 @@ enum eSound : int16
SOUND_GARAGE_NO_MONEY = 57,
SOUND_GARAGE_BAD_VEHICLE = 58,
SOUND_GARAGE_OPENING = 59,
- SOUND_3C = 60,
+ SOUND_GARAGE_BOMB_ALREADY_SET = 60,
SOUND_GARAGE_BOMB1_SET = 61,
SOUND_GARAGE_BOMB2_SET = 62,
SOUND_GARAGE_BOMB3_SET = 63,
diff --git a/src/control/AutoPilot.cpp b/src/control/AutoPilot.cpp
index e3d5c9e9..70099291 100644
--- a/src/control/AutoPilot.cpp
+++ b/src/control/AutoPilot.cpp
@@ -6,9 +6,6 @@
#include "Curves.h"
#include "PathFind.h"
-#if 0
-WRAPPER void CAutoPilot::ModifySpeed(float) { EAXJMP(0x4137B0); }
-#else
void CAutoPilot::ModifySpeed(float speed)
{
m_fMaxTrafficSpeed = max(0.01f, speed);
@@ -41,7 +38,6 @@ void CAutoPilot::ModifySpeed(float speed)
m_nTimeEnteredCurve = CTimer::GetTimeInMilliseconds() - positionBetweenNodes * m_nSpeedScaleFactor;
#endif
}
-#endif
void CAutoPilot::RemoveOnePathNode()
{
diff --git a/src/control/CarCtrl.cpp b/src/control/CarCtrl.cpp
index 07ba2e3c..3174a253 100644
--- a/src/control/CarCtrl.cpp
+++ b/src/control/CarCtrl.cpp
@@ -881,9 +881,7 @@ CCarCtrl::SlowCarOnRailsDownForTrafficAndLights(CVehicle* pVehicle)
pVehicle->AutoPilot.ModifySpeed(max(maxSpeed, curSpeed - 0.5f * CTimer::GetTimeStep()));
}
}
-#if 0
-WRAPPER void CCarCtrl::SlowCarDownForPedsSectorList(CPtrList&, CVehicle*, float, float, float, float, float*, float) { EAXJMP(0x419300); }
-#else
+
void CCarCtrl::SlowCarDownForPedsSectorList(CPtrList& lst, CVehicle* pVehicle, float x_inf, float y_inf, float x_sup, float y_sup, float* pSpeed, float curSpeed)
{
float frontOffset = pVehicle->GetModelInfo()->GetColModel()->boundingBox.max.y;
@@ -991,7 +989,6 @@ void CCarCtrl::SlowCarDownForPedsSectorList(CPtrList& lst, CVehicle* pVehicle, f
}
}
}
-#endif
void CCarCtrl::SlowCarDownForCarsSectorList(CPtrList& lst, CVehicle* pVehicle, float x_inf, float y_inf, float x_sup, float y_sup, float* pSpeed, float curSpeed)
{
@@ -1055,9 +1052,6 @@ void CCarCtrl::SlowCarDownForOtherCar(CEntity* pOtherEntity, CVehicle* pVehicle,
}
}
-#if 0
-WRAPPER float CCarCtrl::TestCollisionBetween2MovingRects(CVehicle* pVehicleA, CVehicle* pVehicleB, float projectionX, float projectionY, CVector* pForwardA, CVector* pForwardB, uint8 id) { EAXJMP(0x41A020); }
-#else
float CCarCtrl::TestCollisionBetween2MovingRects(CVehicle* pVehicleA, CVehicle* pVehicleB, float projectionX, float projectionY, CVector* pForwardA, CVector* pForwardB, uint8 id)
{
CVector2D vecBToA = pVehicleA->GetPosition() - pVehicleB->GetPosition();
@@ -1180,7 +1174,6 @@ float CCarCtrl::TestCollisionBetween2MovingRects(CVehicle* pVehicleA, CVehicle*
}
return proximity;
}
-#endif
float CCarCtrl::FindAngleToWeaveThroughTraffic(CVehicle* pVehicle, CPhysical* pTarget, float angleToTarget, float angleForward)
{
diff --git a/src/control/Curves.cpp b/src/control/Curves.cpp
index c5f64bf7..5c6ef06d 100644
--- a/src/control/Curves.cpp
+++ b/src/control/Curves.cpp
@@ -2,9 +2,6 @@
#include "patcher.h"
#include "Curves.h"
-#if 0
-WRAPPER float CCurves::CalcSpeedScaleFactor(CVector*, CVector*, float, float, float, float) { EAXJMP(0x420410); }
-#else
float CCurves::CalcSpeedScaleFactor(CVector* pPoint1, CVector* pPoint2, float dir1X, float dir1Y, float dir2X, float dir2Y)
{
CVector2D dir1(dir1X, dir1Y);
@@ -16,11 +13,7 @@ float CCurves::CalcSpeedScaleFactor(CVector* pPoint1, CVector* pPoint2, float di
else
return ((1.0f - dp) * 0.2f + 1.0f) * distance;
}
-#endif
-#if 0
-WRAPPER void CCurves::CalcCurvePoint(CVector*, CVector*, CVector*, CVector*, float, int32, CVector*, CVector*) { EAXJMP(0x4204D0); }
-#else
void CCurves::CalcCurvePoint(CVector* pPos1, CVector* pPos2, CVector* pDir1, CVector* pDir2, float between, int32 timeOnCurve, CVector* pOutPos, CVector* pOutDir)
{
float actualFactor = CalcSpeedScaleFactor(pPos1, pPos2, pDir1->x, pDir1->y, pDir2->x, pDir2->y);
@@ -35,5 +28,4 @@ void CCurves::CalcCurvePoint(CVector* pPos1, CVector* pPos2, CVector* pDir1, CVe
(dir1.x * (1.0f - curveCoef) + dir2.x * curveCoef) / (timeOnCurve * 0.001f),
(dir1.y * (1.0f - curveCoef) + dir2.y * curveCoef) / (timeOnCurve * 0.001f),
0.0f);
-}
-#endif \ No newline at end of file
+} \ No newline at end of file
diff --git a/src/control/Darkel.cpp b/src/control/Darkel.cpp
index ec1b887e..b4d15abf 100644
--- a/src/control/Darkel.cpp
+++ b/src/control/Darkel.cpp
@@ -162,9 +162,6 @@ CDarkel::ReadStatus()
return Status;
}
-#if 0
-WRAPPER void CDarkel::RegisterCarBlownUpByPlayer(CVehicle *vehicle) { EAXJMP(0x421070); }
-#else
void
CDarkel::RegisterCarBlownUpByPlayer(CVehicle *vehicle)
{
@@ -178,11 +175,7 @@ CDarkel::RegisterCarBlownUpByPlayer(CVehicle *vehicle)
RegisteredKills[vehicle->GetModelIndex()]++;
CStats::CarsExploded++;
}
-#endif
-#if 0
-WRAPPER void CDarkel::RegisterKillByPlayer(CPed *victim, eWeaponType weapontype, bool headshot) { EAXJMP(0x420F60); }
-#else
void
CDarkel::RegisterKillByPlayer(CPed *victim, eWeaponType weapon, bool headshot)
{
@@ -207,7 +200,6 @@ CDarkel::RegisterKillByPlayer(CPed *victim, eWeaponType weapon, bool headshot)
CStats::HeadsPopped++;
CStats::KillsSinceLastCheckpoint++;
}
-#endif
void
CDarkel::RegisterKillNotByPlayer(CPed* victim, eWeaponType weapontype)
@@ -222,9 +214,6 @@ CDarkel::ResetModelsKilledByPlayer()
RegisteredKills[i] = 0;
}
-#if 0
-WRAPPER void CDarkel::ResetOnPlayerDeath() { EAXJMP(0x420E70); }
-#else
void
CDarkel::ResetOnPlayerDeath()
{
@@ -253,11 +242,7 @@ CDarkel::ResetOnPlayerDeath()
player->MakeChangesForNewWeapon(player->m_currentWeapon);
}
}
-#endif
-#if 0
-WRAPPER void CDarkel::StartFrenzy(eWeaponType weaponType, int32 time, uint16 kill, int32 modelId0, wchar *text, int32 modelId2, int32 modelId3, int32 modelId4, bool standardSound, bool needHeadShot) { EAXJMP(0x4210E0); }
-#else
void
CDarkel::StartFrenzy(eWeaponType weaponType, int32 time, uint16 kill, int32 modelId0, wchar *text, int32 modelId2, int32 modelId3, int32 modelId4, bool standardSound, bool needHeadShot)
{
@@ -306,7 +291,6 @@ CDarkel::StartFrenzy(eWeaponType weaponType, int32 time, uint16 kill, int32 mode
if (CDarkel::bStandardSoundAndMessages)
DMAudio.PlayFrontEndSound(SOUND_RAMPAGE_START, 0);
}
-#endif
void
CDarkel::Update()
diff --git a/src/control/GameLogic.cpp b/src/control/GameLogic.cpp
index 1493cec0..0abae7d6 100644
--- a/src/control/GameLogic.cpp
+++ b/src/control/GameLogic.cpp
@@ -57,7 +57,7 @@ CGameLogic::SortOutStreamingAndMemory(const CVector &pos)
CStreaming::FlushRequestList();
CStreaming::DeleteRwObjectsAfterDeath(pos);
CStreaming::RemoveUnusedModelsInLoadedList();
- CGame::DrasticTidyUpMemory();
+ CGame::DrasticTidyUpMemory(true);
CStreaming::LoadScene(pos);
CTimer::Update();
}
diff --git a/src/control/Gangs.cpp b/src/control/Gangs.cpp
index 340fe0f6..ac32ad98 100644
--- a/src/control/Gangs.cpp
+++ b/src/control/Gangs.cpp
@@ -14,7 +14,7 @@ CGangInfo::CGangInfo() :
m_Weapon2(WEAPONTYPE_UNARMED)
{}
-void CGangs::Initialize(void)
+void CGangs::Initialise(void)
{
Gang[GANG_MAFIA].m_nVehicleMI = MI_MAFIA;
Gang[GANG_TRIAD].m_nVehicleMI = MI_BELLYUP;
@@ -67,7 +67,7 @@ VALIDATESAVEBUF(*size);
void CGangs::LoadAllGangData(uint8 *buf, uint32 size)
{
- Initialize();
+ Initialise();
INITSAVEBUF
// original: SkipSaveBuf(buf, SAVE_HEADER_SIZE);
@@ -79,7 +79,7 @@ VALIDATESAVEBUF(size);
}
STARTPATCHES
- InjectHook(0x4C3FB0, CGangs::Initialize, PATCH_JUMP);
+ InjectHook(0x4C3FB0, CGangs::Initialise, PATCH_JUMP);
InjectHook(0x4C4010, CGangs::SetGangVehicleModel, PATCH_JUMP);
InjectHook(0x4C4030, CGangs::SetGangWeapons, PATCH_JUMP);
InjectHook(0x4C4050, CGangs::SetGangPedModelOverride, PATCH_JUMP);
diff --git a/src/control/Gangs.h b/src/control/Gangs.h
index cf22cc73..dd7a7f93 100644
--- a/src/control/Gangs.h
+++ b/src/control/Gangs.h
@@ -28,7 +28,7 @@ enum {
class CGangs
{
public:
- static void Initialize(void);
+ static void Initialise(void);
static void SetGangVehicleModel(int16, int32);
static void SetGangWeapons(int16, int32, int32);
static void SetGangPedModelOverride(int16, int8);
diff --git a/src/control/Garages.cpp b/src/control/Garages.cpp
index 5ac15377..b4d7a703 100644
--- a/src/control/Garages.cpp
+++ b/src/control/Garages.cpp
@@ -1,15 +1,93 @@
#include "common.h"
#include "patcher.h"
-#include "main.h"
-#include "ModelIndices.h"
#include "Garages.h"
-#include "Timer.h"
+#include "main.h"
+
+#include "DMAudio.h"
+#include "General.h"
#include "Font.h"
+#include "HandlingMgr.h"
+#include "Hud.h"
#include "Messages.h"
+#include "ModelIndices.h"
+#include "Pad.h"
+#include "Particle.h"
#include "PlayerPed.h"
+#include "Replay.h"
+#include "Stats.h"
#include "Text.h"
+#include "Timer.h"
+#include "Vehicle.h"
+#include "Wanted.h"
#include "World.h"
+#define CRUSHER_GARAGE_X1 (1135.5f)
+#define CRUSHER_GARAGE_Y1 (57.0f)
+#define CRUSHER_GARAGE_Z1 (-1.0f)
+#define CRUSHER_GARAGE_X2 (1149.5f)
+#define CRUSHER_GARAGE_Y2 (63.7f)
+#define CRUSHER_GARAGE_Z2 (3.5f)
+
+#define ROTATED_DOOR_OPEN_SPEED (0.015f)
+#define ROTATED_DOOR_CLOSE_SPEED (0.02f)
+#define DEFAULT_DOOR_OPEN_SPEED (0.035f)
+#define DEFAULT_DOOR_CLOSE_SPEED (0.04f)
+#define CRUSHER_CRANE_SPEED (0.005f)
+
+// Prices
+#define BOMB_PRICE (1000)
+#define RESPRAY_PRICE (1000)
+
+// Distances
+#define DISTANCE_TO_CALL_OFF_CHASE (10.0f)
+#define DISTANCE_FOR_MRWHOOP_HACK (4.0f)
+#define DISTANCE_TO_ACTIVATE_GARAGE (8.0f)
+#define DISTANCE_TO_ACTIVATE_KEEPCAR_GARAGE (17.0f)
+#define DISTANCE_TO_CLOSE_MISSION_GARAGE (30.0f)
+#define DISTANCE_TO_CLOSE_COLLECTSPECIFICCARS_GARAGE (25.0f)
+#define DISTANCE_TO_CLOSE_COLLECTCARS_GARAGE (40.0f)
+#define DISTANCE_TO_CLOSE_HIDEOUT_GARAGE_ON_FOOT (2.2f)
+#define DISTANCE_TO_CLOSE_HIDEOUT_GARAGE_IN_CAR (15.0f)
+#define DISTANCE_TO_FORCE_CLOSE_HIDEOUT_GARAGE (70.0f)
+#define DISTANCE_TO_OPEN_HIDEOUT_GARAGE_ON_FOOT (1.7f)
+#define DISTANCE_TO_OPEN_HIDEOUT_GARAGE_IN_CAR (10.0f)
+#define DISTANCE_TO_SHOW_HIDEOUT_MESSAGE (5.0f)
+
+// Time
+#define TIME_TO_RESPRAY (2000)
+#define TIME_TO_SETUP_BOMB (2000)
+#define TIME_TO_CRUSH_CAR (3000)
+#define TIME_TO_PROCESS_KEEPCAR_GARAGE (2000)
+
+// Respray stuff
+#define FREE_RESPRAY_HEALTH_THRESHOLD (970.0f)
+#define NUM_PARTICLES_IN_RESPRAY (200)
+
+// Bomb stuff
+#define KGS_OF_EXPLOSIVES_IN_BOMB (10)
+
+// Collect specific cars stuff
+#define REWARD_FOR_FIRST_POLICE_CAR (5000)
+#define REWARD_FOR_FIRST_BANK_VAN (5000)
+#define MAX_POLICE_CARS_TO_COLLECT (10)
+#define MAX_BANK_VANS_TO_COLLECT (10)
+
+// Collect cars stuff
+#define MAX_SPEED_TO_SHOW_COLLECTED_MESSAGE (0.03f)
+
+// Crusher stuff
+#define CRUSHER_VEHICLE_TEST_SPAN (8)
+#define CRUSHER_MIN_REWARD (25)
+#define CRUSHER_MAX_REWARD (125)
+#define CRUSHER_REWARD_COEFFICIENT (1.0f/500000)
+
+// Hideout stuff
+#define MAX_STORED_CARS_IN_INDUSTRIAL (1)
+#define MAX_STORED_CARS_IN_COMMERCIAL (NUM_GARAGE_STORED_CARS)
+#define MAX_STORED_CARS_IN_SUBURBAN (NUM_GARAGE_STORED_CARS)
+#define HIDEOUT_DOOR_SPEED_COEFFICIENT (1.7f)
+#define TIME_BETWEEN_HIDEOUT_MESSAGES (18000)
+
int32 &CGarages::BankVansCollected = *(int32 *)0x8F1B34;
bool &CGarages::BombsAreFree = *(bool *)0x95CD7A;
bool &CGarages::RespraysAreFree = *(bool *)0x95CD1D;
@@ -26,127 +104,1056 @@ uint32 &CGarages::NumGarages = *(uint32 *)0x8F29F4;
bool &CGarages::PlayerInGarage = *(bool *)0x95CD83;
int32 &CGarages::PoliceCarsCollected = *(int32 *)0x941444;
uint32 &CGarages::GarageToBeTidied = *(uint32 *)0x623570;
+CStoredCar(&CGarages::aCarsInSafeHouse1)[NUM_GARAGE_STORED_CARS] = *(CStoredCar(*)[NUM_GARAGE_STORED_CARS])*(uintptr*)0x6FA210;
+CStoredCar(&CGarages::aCarsInSafeHouse2)[NUM_GARAGE_STORED_CARS] = *(CStoredCar(*)[NUM_GARAGE_STORED_CARS])*(uintptr*)0x6FA300;
+CStoredCar(&CGarages::aCarsInSafeHouse3)[NUM_GARAGE_STORED_CARS] = *(CStoredCar(*)[NUM_GARAGE_STORED_CARS])*(uintptr*)0x6FA3F0;
+int32& CGarages::AudioEntity = *(int32*)0x5ECEA8;
+CGarage(&CGarages::aGarages)[NUM_GARAGES] = *(CGarage(*)[NUM_GARAGES])*(uintptr*)0x72BCD0;
+bool& CGarages::bCamShouldBeOutisde = *(bool*)0x95CDB2;
-CGarage(&CGarages::Garages)[NUM_GARAGES] = *(CGarage(*)[NUM_GARAGES])*(uintptr*)0x72BCD0;
-
-WRAPPER void CGarages::Init(void) { EAXJMP(0x421C60); }
-WRAPPER void CGarages::Update(void) { EAXJMP(0x421E40); }
-WRAPPER void CGarages::Load(uint8* buf, uint32 size) { EAXJMP(0x428940); }
-WRAPPER void CGarages::Save(uint8* buf, uint32 *size) { EAXJMP(0x4284e0); }
-
-bool
-CGarages::IsModelIndexADoor(uint32 id)
-{
- return id == MI_GARAGEDOOR1 ||
- id == MI_GARAGEDOOR2 ||
- id == MI_GARAGEDOOR3 ||
- id == MI_GARAGEDOOR4 ||
- id == MI_GARAGEDOOR5 ||
- id == MI_GARAGEDOOR6 ||
- id == MI_GARAGEDOOR7 ||
- id == MI_GARAGEDOOR9 ||
- id == MI_GARAGEDOOR10 ||
- id == MI_GARAGEDOOR11 ||
- id == MI_GARAGEDOOR12 ||
- id == MI_GARAGEDOOR13 ||
- id == MI_GARAGEDOOR14 ||
- id == MI_GARAGEDOOR15 ||
- id == MI_GARAGEDOOR16 ||
- id == MI_GARAGEDOOR17 ||
- id == MI_GARAGEDOOR18 ||
- id == MI_GARAGEDOOR19 ||
- id == MI_GARAGEDOOR20 ||
- id == MI_GARAGEDOOR21 ||
- id == MI_GARAGEDOOR22 ||
- id == MI_GARAGEDOOR23 ||
- id == MI_GARAGEDOOR24 ||
- id == MI_GARAGEDOOR25 ||
- id == MI_GARAGEDOOR26 ||
- id == MI_GARAGEDOOR27 ||
- id == MI_GARAGEDOOR28 ||
- id == MI_GARAGEDOOR29 ||
- id == MI_GARAGEDOOR30 ||
- id == MI_GARAGEDOOR31 ||
- id == MI_GARAGEDOOR32 ||
- id == MI_CRUSHERBODY ||
- id == MI_CRUSHERLID;
-}
-
-bool CGarages::HasCarBeenCrushed(int32 handle)
+void CGarages::Init(void)
{
- return CrushedCarId == handle;
+ CrushedCarId = -1;
+ NumGarages = 0;
+ MessageEndTime = 0;
+ MessageStartTime = 0;
+ PlayerInGarage = false;
+ BombsAreFree = false;
+ CarsCollected = 0;
+ BankVansCollected = 0;
+ PoliceCarsCollected = 0;
+ for (int i = 0; i < TOTAL_COLLECTCARS_GARAGES; i++)
+ CarTypesCollected[i] = 0;
+ LastTimeHelpMessage = 0;
+ for (int i = 0; i < NUM_GARAGE_STORED_CARS; i++)
+ aCarsInSafeHouse1[i].Init();
+ for (int i = 0; i < NUM_GARAGE_STORED_CARS; i++)
+ aCarsInSafeHouse2[i].Init();
+ for (int i = 0; i < NUM_GARAGE_STORED_CARS; i++)
+ aCarsInSafeHouse3[i].Init();
+ AudioEntity = DMAudio.CreateEntity(AUDIOTYPE_GARAGE, (void*)1);
+ if (AudioEntity >= 0)
+ DMAudio.SetEntityStatus(AudioEntity, 1);
+ AddOne(
+ CRUSHER_GARAGE_X1, CRUSHER_GARAGE_Y1, CRUSHER_GARAGE_Z1,
+ CRUSHER_GARAGE_X2, CRUSHER_GARAGE_Y2, CRUSHER_GARAGE_Z2,
+ GARAGE_CRUSHER, 0);
}
-WRAPPER void CGarages::TriggerMessage(const char *text, int16, uint16 time, int16) { EAXJMP(0x426B20); }
-WRAPPER bool CGarages::IsPointWithinHideOutGarage(CVector&) { EAXJMP(0x428260); }
-WRAPPER bool CGarages::IsPointWithinAnyGarage(CVector&) { EAXJMP(0x428320); }
-WRAPPER void CGarages::PlayerArrestedOrDied() { EAXJMP(0x427F60); }
-WRAPPER int16 CGarages::AddOne(float, float, float, float, float, float, uint8, uint32) { EAXJMP(0x421FA0); }
-WRAPPER void CGarages::SetTargetCarForMissonGarage(int16, CVehicle*) { EAXJMP(0x426BD0); }
-WRAPPER bool CGarages::HasCarBeenDroppedOffYet(int16) { EAXJMP(0x426C20); }
-WRAPPER void CGarages::DeActivateGarage(int16) { EAXJMP(0x426C40); }
-WRAPPER void CGarages::ActivateGarage(int16) { EAXJMP(0x426C60); }
-
-int32 CGarages::QueryCarsCollected(int16 garage)
+#ifndef PS2
+void CGarages::Shutdown(void)
{
- return 0;
-}
-
-void CGarages::GivePlayerDetonator()
-{
- FindPlayerPed()->GiveWeapon(WEAPONTYPE_DETONATOR, 1);
- FindPlayerPed()->GetWeapon(FindPlayerPed()->GetWeaponSlot(WEAPONTYPE_DETONATOR)).m_eWeaponState = WEAPONSTATE_READY;
-}
-
-WRAPPER bool CGarages::HasThisCarBeenCollected(int16 garage, uint8 id) { EAXJMP(0x426D50); }
-WRAPPER void CGarages::ChangeGarageType(int16 garage, eGarageType type, int32 mi) { EAXJMP(0x4222A0); }
-WRAPPER bool CGarages::HasResprayHappened(int16 garage) { EAXJMP(0x4274F0); }
-WRAPPER bool CGarages::IsThisCarWithinGarageArea(int16 garage, CEntity* pCar) { EAXJMP(0x427570); }
-
-void CGarage::OpenThisGarage()
-{
- if (m_eGarageState == GS_FULLYCLOSED || m_eGarageState == GS_CLOSING || m_eGarageState == GS_CLOSEDCONTAINSCAR)
- m_eGarageState = GS_OPENING;
+ NumGarages = 0;
+ if (AudioEntity < 0)
+ return;
+ DMAudio.DestroyEntity(AudioEntity);
+ AudioEntity = AEHANDLE_NONE;
}
+#endif
-bool CGarages::IsGarageOpen(int16 garage)
+void CGarages::Update(void)
{
- return Garages[garage].IsOpen();
+ static int GarageToBeTidied = 0;
+#ifndef PS2
+ if (CReplay::IsPlayingBack())
+ return;
+#endif
+ bCamShouldBeOutisde = false;
+ TheCamera.pToGarageWeAreIn = nil;
+ TheCamera.pToGarageWeAreInForHackAvoidFirstPerson = nil;
+ for (int i = 0; i < NUM_GARAGES; i++) {
+ if (aGarages[i].IsUsed())
+ aGarages[i].Update();
+ }
+ if ((CTimer::GetFrameCounter() & 0xF) != 0xC)
+ return;
+ if (++GarageToBeTidied >= NUM_GARAGES)
+ GarageToBeTidied = 0;
+ if (!aGarages[GarageToBeTidied].IsUsed())
+ return;
+ if (aGarages[GarageToBeTidied].IsClose())
+ aGarages[GarageToBeTidied].TidyUpGarageClose();
+ else
+ aGarages[GarageToBeTidied].TidyUpGarage();
}
-bool CGarages::IsGarageClosed(int16 garage)
+int16 CGarages::AddOne(float X1, float Y1, float Z1, float X2, float Y2, float Z2, eGarageType type, int32 targetId)
{
- return Garages[garage].IsClosed();
+ if (NumGarages >= NUM_GARAGES) {
+ assert(0);
+ return NumGarages++;
+ }
+ CGarage* pGarage = &aGarages[NumGarages];
+ pGarage->m_fX1 = min(X1, X2);
+ pGarage->m_fX2 = max(X1, X2);
+ pGarage->m_fY1 = min(Y1, Y2);
+ pGarage->m_fY2 = max(Y1, Y2);
+ pGarage->m_fZ1 = min(Z1, Z2);
+ pGarage->m_fZ2 = max(Z1, Z2);
+ pGarage->m_pDoor1 = nil;
+ pGarage->m_pDoor2 = nil;
+ pGarage->m_fDoor1Z = Z1;
+ pGarage->m_fDoor2Z = Z1;
+ pGarage->m_eGarageType = type;
+ pGarage->m_bRecreateDoorOnNextRefresh = false;
+ pGarage->m_bRotatedDoor = false;
+ pGarage->m_bCameraFollowsPlayer = false;
+ pGarage->RefreshDoorPointers(true);
+ if (pGarage->m_pDoor1) {
+ pGarage->m_fDoor1Z = pGarage->m_pDoor1->GetPosition().z;
+ pGarage->m_fDoor1X = pGarage->m_pDoor1->GetPosition().x;
+ pGarage->m_fDoor1Y = pGarage->m_pDoor1->GetPosition().y;
+ }
+ if (pGarage->m_pDoor2) {
+ pGarage->m_fDoor2Z = pGarage->m_pDoor2->GetPosition().z;
+ pGarage->m_fDoor2X = pGarage->m_pDoor2->GetPosition().x;
+ pGarage->m_fDoor2Y = pGarage->m_pDoor2->GetPosition().y;
+ }
+ pGarage->m_fDoorHeight = pGarage->m_pDoor1 ? FindDoorHeightForMI(pGarage->m_pDoor1->GetModelIndex()) : 4.0f;
+ pGarage->m_fDoorPos = 0.0f;
+ pGarage->m_eGarageState = GS_FULLYCLOSED;
+ pGarage->m_nTimeToStartAction = 0;
+ pGarage->field_2 = 0;
+ pGarage->m_nTargetModelIndex = targetId;
+ pGarage->field_96 = 0;
+ pGarage->m_bCollectedCarsState = 0;
+ pGarage->m_bDeactivated = false;
+ pGarage->m_bResprayHappened = false;
+ switch (type) {
+ case GARAGE_MISSION:
+ case GARAGE_COLLECTORSITEMS:
+ case GARAGE_COLLECTSPECIFICCARS:
+ case GARAGE_COLLECTCARS_1:
+ case GARAGE_COLLECTCARS_2:
+ case GARAGE_COLLECTCARS_3:
+ case GARAGE_FORCARTOCOMEOUTOF:
+ case GARAGE_60SECONDS:
+ case GARAGE_MISSION_KEEPCAR:
+ case GARAGE_FOR_SCRIPT_TO_OPEN:
+ case GARAGE_HIDEOUT_ONE:
+ case GARAGE_HIDEOUT_TWO:
+ case GARAGE_HIDEOUT_THREE:
+ case GARAGE_FOR_SCRIPT_TO_OPEN_AND_CLOSE:
+ case GARAGE_KEEPS_OPENING_FOR_SPECIFIC_CAR:
+ case GARAGE_MISSION_KEEPCAR_REMAINCLOSED:
+ pGarage->m_eGarageState = GS_FULLYCLOSED;
+ pGarage->m_fDoorPos = 0.0f;
+ break;
+ case GARAGE_BOMBSHOP1:
+ case GARAGE_BOMBSHOP2:
+ case GARAGE_BOMBSHOP3:
+ case GARAGE_RESPRAY:
+ pGarage->m_eGarageState = GS_OPENED;
+ pGarage->m_fDoorPos = pGarage->m_fDoorHeight;
+ break;
+ case GARAGE_CRUSHER:
+ pGarage->m_eGarageState = GS_OPENED;
+ pGarage->m_fDoorPos = HALFPI;
+ break;
+ default:
+ assert(false);
+ }
+ if (type == GARAGE_CRUSHER)
+ pGarage->UpdateCrusherAngle();
+ else
+ pGarage->UpdateDoorsHeight();
+ return NumGarages++;
}
-void CGarage::CloseThisGarage()
+void CGarages::ChangeGarageType(int16 garage, eGarageType type, int32 mi)
{
- if (m_eGarageState == GS_OPENED || m_eGarageState == GS_OPENING)
- m_eGarageState = GS_CLOSING;
+ CGarage* pGarage = &aGarages[garage];
+ pGarage->m_eGarageType = type;
+ pGarage->m_nTargetModelIndex = mi;
+ pGarage->m_eGarageState = GS_FULLYCLOSED;
}
-void CGarages::SetGarageDoorToRotate(int16 garage)
+void CGarage::Update()
{
- if (Garages[garage].m_bRotatedDoor)
+ if (m_eGarageType != GARAGE_CRUSHER) {
+ switch (m_eGarageState) {
+ case GS_FULLYCLOSED:
+ case GS_OPENED:
+ case GS_CLOSING:
+ case GS_OPENING:
+ case GS_OPENEDCONTAINSCAR:
+ case GS_CLOSEDCONTAINSCAR:
+ if (FindPlayerPed() && !m_bCameraFollowsPlayer) {
+ CVehicle* pVehicle = FindPlayerVehicle();
+ if (IsEntityEntirelyInside3D(FindPlayerPed(), 0.25f)) {
+ TheCamera.pToGarageWeAreIn = this;
+ CGarages::bCamShouldBeOutisde = true;
+ }
+ if (pVehicle) {
+ if (IsEntityEntirelyOutside(pVehicle, 0.0f))
+ TheCamera.pToGarageWeAreInForHackAvoidFirstPerson = this;
+ if (pVehicle->GetModelIndex() == MI_MRWHOOP) {
+ if (pVehicle->IsWithinArea(
+ m_fX1 - DISTANCE_FOR_MRWHOOP_HACK,
+ m_fX2 + DISTANCE_FOR_MRWHOOP_HACK,
+ m_fY1 - DISTANCE_FOR_MRWHOOP_HACK,
+ m_fY2 + DISTANCE_FOR_MRWHOOP_HACK)) {
+ TheCamera.pToGarageWeAreIn = this;
+ CGarages::bCamShouldBeOutisde = true;
+ }
+ }
+ }
+ }
+ }
+ }
+ if (m_bDeactivated && m_eGarageState == GS_FULLYCLOSED)
return;
- Garages[garage].m_bRotatedDoor = true;
- Garages[garage].m_fDoorHeight /= 2.0f;
- Garages[garage].m_fDoorHeight -= 0.1f;
-}
+ switch (m_eGarageType) {
+ case GARAGE_RESPRAY:
+ switch (m_eGarageState) {
+ case GS_OPENED:
+ if (IsStaticPlayerCarEntirelyInside() && !IsAnyOtherCarTouchingGarage(FindPlayerVehicle())) {
+ if (CGarages::IsCarSprayable(FindPlayerVehicle())) {
+ if (CWorld::Players[CWorld::PlayerInFocus].m_nMoney >= RESPRAY_PRICE || CGarages::RespraysAreFree) {
+ m_eGarageState = GS_CLOSING;
+ CPad::GetPad(0)->SetDisablePlayerControls(PLAYERCONTROL_GARAGE);
+ FindPlayerPed()->m_pWanted->m_bIgnoredByCops = true;
+ } else {
+ CGarages::TriggerMessage("GA_3", -1, 4000, -1); // No more freebies. $1000 to respray!
+ m_eGarageState = GS_OPENEDCONTAINSCAR;
+ DMAudio.PlayFrontEndSound(SOUND_GARAGE_NO_MONEY, 1);
+ }
+ } else {
+ CGarages::TriggerMessage("GA_1", -1, 4000, -1); // Whoa! I don't touch nothing THAT hot!
+ m_eGarageState = GS_OPENEDCONTAINSCAR;
+ DMAudio.PlayFrontEndSound(SOUND_GARAGE_BAD_VEHICLE, 1);
+ }
+ }
+ if (FindPlayerVehicle()) {
+ if (CalcDistToGarageRectangleSquared(FindPlayerVehicle()->GetPosition().x, FindPlayerVehicle()->GetPosition().y) < SQR(DISTANCE_TO_ACTIVATE_GARAGE))
+ CWorld::CallOffChaseForArea(
+ m_fX1 - DISTANCE_TO_CALL_OFF_CHASE,
+ m_fY1 - DISTANCE_TO_CALL_OFF_CHASE,
+ m_fX2 + DISTANCE_TO_CALL_OFF_CHASE,
+ m_fY2 + DISTANCE_TO_CALL_OFF_CHASE);
+ }
+ break;
+ case GS_CLOSING:
+ m_fDoorPos = max(0.0f, m_fDoorPos - (m_bRotatedDoor ? ROTATED_DOOR_CLOSE_SPEED : DEFAULT_DOOR_CLOSE_SPEED) * CTimer::GetTimeStep());
+ if (m_fDoorPos == 0.0f) {
+ m_eGarageState = GS_FULLYCLOSED;
+ m_nTimeToStartAction = CTimer::GetTimeInMilliseconds() + TIME_TO_RESPRAY;
+ DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_CLOSED, 1.0f);
+ CStats::CheckPointReachedSuccessfully();
+ }
+ UpdateDoorsHeight();
+#ifdef FIX_BUGS
+ if (FindPlayerVehicle() && FindPlayerVehicle()->IsCar())
+#else
+ if (FindPlayerVehicle())
+#endif
+ ((CAutomobile*)(FindPlayerVehicle()))->m_fFireBlowUpTimer = 0.0f;
+ CWorld::CallOffChaseForArea(
+ m_fX1 - DISTANCE_TO_CALL_OFF_CHASE,
+ m_fY1 - DISTANCE_TO_CALL_OFF_CHASE,
+ m_fX2 + DISTANCE_TO_CALL_OFF_CHASE,
+ m_fY2 + DISTANCE_TO_CALL_OFF_CHASE);
+ break;
+ case GS_FULLYCLOSED:
+ if (CTimer::GetTimeInMilliseconds() > m_nTimeToStartAction) {
+ m_eGarageState = GS_OPENING;
+ DMAudio.PlayFrontEndSound(SOUND_GARAGE_OPENING, 1);
+ bool bTakeMoney = false;
+ if (FindPlayerPed()->m_pWanted->m_nWantedLevel != 0)
+ bTakeMoney = true;
+ FindPlayerPed()->m_pWanted->Reset();
+ CPad::GetPad(0)->SetEnablePlayerControls(PLAYERCONTROL_GARAGE);
+ FindPlayerPed()->m_pWanted->m_bIgnoredByCops = true;
+#ifdef FIX_BUGS
+ bool bChangedColour = false;
+#else
+ bool bChangedColour;
+#endif
+ if (FindPlayerVehicle() && FindPlayerVehicle()->IsCar()) {
+ if (FindPlayerVehicle()->m_fHealth < FREE_RESPRAY_HEALTH_THRESHOLD)
+ bTakeMoney = true;
+ FindPlayerVehicle()->m_fHealth = 1000.0f;
+ ((CAutomobile*)(FindPlayerVehicle()))->m_fFireBlowUpTimer = 0.0f;
+ ((CAutomobile*)(FindPlayerVehicle()))->Fix();
+ if (FindPlayerVehicle()->GetUp().z < 0.0f) {
+ FindPlayerVehicle()->GetUp() = -FindPlayerVehicle()->GetUp();
+ FindPlayerVehicle()->GetRight() = -FindPlayerVehicle()->GetRight();
+ }
+ bChangedColour = false;
+ if (!((CAutomobile*)(FindPlayerVehicle()))->bFixedColour) {
+ uint8 colour1, colour2;
+ uint16 attempt;
+ ((CVehicleModelInfo*)CModelInfo::GetModelInfo(FindPlayerVehicle()->GetModelIndex()))->ChooseVehicleColour(colour1, colour2);
+ for (attempt = 0; attempt < 10; attempt++) {
+ if (colour1 != FindPlayerVehicle()->m_currentColour1 || colour2 != FindPlayerVehicle()->m_currentColour2)
+ break;
+ ((CVehicleModelInfo*)CModelInfo::GetModelInfo(FindPlayerVehicle()->GetModelIndex()))->ChooseVehicleColour(colour1, colour2);
+ }
+ bChangedColour = (attempt < 10);
+ FindPlayerVehicle()->m_currentColour1 = colour1;
+ FindPlayerVehicle()->m_currentColour2 = colour2;
+ if (bChangedColour) {
+ for (int i = 0; i < NUM_PARTICLES_IN_RESPRAY; i++) {
+ CVector pos;
+#ifdef FIX_BUGS
+ pos.x = CGeneral::GetRandomNumberInRange(m_fX1 + 0.5f, m_fX2 - 0.5f);
+ pos.y = CGeneral::GetRandomNumberInRange(m_fY1 + 0.5f, m_fY2 - 0.5f);
+ pos.z = CGeneral::GetRandomNumberInRange(m_fDoor1Z - 3.0f, m_fDoor1Z + 1.0f);
+#else
+ // wtf is this
+ pos.x = m_fX1 + 0.5f + (uint8)(CGeneral::GetRandomNumber()) / 256.0f * (m_fX2 - m_fX1 - 1.0f);
+ pos.y = m_fY1 + 0.5f + (uint8)(CGeneral::GetRandomNumber()) / 256.0f * (m_fY2 - m_fY1 - 1.0f);
+ pos.z = m_fDoor1Z - 3.0f + (uint8)(CGeneral::GetRandomNumber()) / 256.0f * 4.0f;
+#endif
+ CParticle::AddParticle(PARTICLE_GARAGEPAINT_SPRAY, pos, CVector(0.0f, 0.0f, 0.0f), nil, 0.0f, CVehicleModelInfo::ms_vehicleColourTable[colour1]);
+ }
+ }
+ }
+ CenterCarInGarage(FindPlayerVehicle());
+ }
+ if (bTakeMoney) {
+ if (!CGarages::RespraysAreFree)
+ CWorld::Players[CWorld::PlayerInFocus].m_nMoney = max(0, CWorld::Players[CWorld::PlayerInFocus].m_nMoney - RESPRAY_PRICE);
+ CGarages::TriggerMessage("GA_2", -1, 4000, -1); // New engine and paint job. The cops won't recognize you!
+ }
+ else if (bChangedColour) {
+ if (CGeneral::GetRandomTrueFalse())
+ CGarages::TriggerMessage("GA_15", -1, 4000, -1); // Hope you like the new color.
+ else
+ CGarages::TriggerMessage("GA_16", -1, 4000, -1); // Respray is complementary.
+ }
+ m_bResprayHappened = true;
+ }
+ CWorld::CallOffChaseForArea(
+ m_fX1 - DISTANCE_TO_CALL_OFF_CHASE,
+ m_fY1 - DISTANCE_TO_CALL_OFF_CHASE,
+ m_fX2 + DISTANCE_TO_CALL_OFF_CHASE,
+ m_fY2 + DISTANCE_TO_CALL_OFF_CHASE);
+ break;
+ case GS_OPENING:
+ m_fDoorPos = min(m_fDoorHeight, m_fDoorPos + (m_bRotatedDoor ? ROTATED_DOOR_OPEN_SPEED : DEFAULT_DOOR_OPEN_SPEED) * CTimer::GetTimeStep());
+ if (m_fDoorPos == m_fDoorHeight) {
+ m_eGarageState = GS_OPENEDCONTAINSCAR;
+ DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_OPENED, 1.0f);
+ }
+ UpdateDoorsHeight();
+ break;
+ case GS_OPENEDCONTAINSCAR:
+ if (IsPlayerOutsideGarage())
+ m_eGarageState = GS_OPENED;
+ break;
+ //case GS_CLOSEDCONTAINSCAR:
+ //case GS_AFTERDROPOFF:
+ default:
+ break;
+ }
+ break;
+ case GARAGE_BOMBSHOP1:
+ case GARAGE_BOMBSHOP2:
+ case GARAGE_BOMBSHOP3:
+ switch (m_eGarageState) {
+ case GS_OPENED:
+ if (IsStaticPlayerCarEntirelyInside() && !IsAnyOtherCarTouchingGarage(FindPlayerVehicle())) {
+#ifdef FIX_BUGS // FindPlayerVehicle() can never be NULL here because IsStaticPlayerCarEntirelyInside() is true, and there is no IsCar() check
+ if (FindPlayerVehicle()->IsCar() && ((CAutomobile*)FindPlayerVehicle())->m_bombType) {
+#else
+ if (!FindPlayerVehicle() || ((CAutomobile*)FindPlayerVehicle())->m_bombType) {
+#endif
+ CGarages::TriggerMessage("GA_5", -1, 4000, -1); //"Your car is already fitted with a bomb"
+ m_eGarageState = GS_OPENEDCONTAINSCAR;
+ DMAudio.PlayFrontEndSound(SOUND_GARAGE_BOMB_ALREADY_SET, 1);
+ break;
+ }
+ 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);
+ break;
+ }
+ m_eGarageState = GS_CLOSING;
+ CPad::GetPad(0)->SetDisablePlayerControls(PLAYERCONTROL_GARAGE);
+ FindPlayerPed()->m_pWanted->m_bIgnoredByCops = true;
+ }
+ break;
+ case GS_CLOSING:
+ m_fDoorPos = max(0.0f, m_fDoorPos - (m_bRotatedDoor ? ROTATED_DOOR_CLOSE_SPEED : DEFAULT_DOOR_CLOSE_SPEED) * CTimer::GetTimeStep());
+ if (m_fDoorPos == 0.0f) {
+ m_eGarageState = GS_FULLYCLOSED;
+ m_nTimeToStartAction = CTimer::GetTimeInMilliseconds() + TIME_TO_SETUP_BOMB;
+ DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_CLOSED, 1.0f);
+ }
+ UpdateDoorsHeight();
+ break;
+ case GS_FULLYCLOSED:
+ if (CTimer::GetTimeInMilliseconds() > m_nTimeToStartAction) {
+ switch (m_eGarageType) {
+ case GARAGE_BOMBSHOP1: DMAudio.PlayFrontEndSound(SOUND_GARAGE_BOMB1_SET, 1); break;
+ case GARAGE_BOMBSHOP2: DMAudio.PlayFrontEndSound(SOUND_GARAGE_BOMB2_SET, 1); break;
+ case GARAGE_BOMBSHOP3: DMAudio.PlayFrontEndSound(SOUND_GARAGE_BOMB3_SET, 1); break;
+ }
+ m_eGarageState = GS_OPENING;
+ if (!CGarages::BombsAreFree)
+ CWorld::Players[CWorld::PlayerInFocus].m_nMoney = max(0, CWorld::Players[CWorld::PlayerInFocus].m_nMoney - BOMB_PRICE);
+ if (FindPlayerVehicle() && FindPlayerVehicle()->IsCar()) {
+ ((CAutomobile*)(FindPlayerVehicle()))->m_bombType = CGarages::GetBombTypeForGarageType(m_eGarageType);
+ ((CAutomobile*)(FindPlayerVehicle()))->m_pBombRigger = FindPlayerPed();
+ if (m_eGarageType == GARAGE_BOMBSHOP3)
+ CGarages::GivePlayerDetonator();
+ CStats::KgOfExplosivesUsed += KGS_OF_EXPLOSIVES_IN_BOMB;
+ }
+ switch (m_eGarageType) {
+ case GARAGE_BOMBSHOP1:
+ switch (CPad::GetPad(0)->Mode) {
+ case 0:
+ case 1:
+ case 2:
+ CHud::SetHelpMessage(TheText.Get("GA_6"), false); // Arm with ~h~~k~~PED_FIREWEAPON~ button~w~. Bomb will go off when engine is started.
+ break;
+ case 3:
+ CHud::SetHelpMessage(TheText.Get("GA_6B"), false); // Arm with ~h~~k~~PED_FIREWEAPON~ button~w~. Bomb will go off when engine is started.
+ break;
+ }
+ break;
+ case GARAGE_BOMBSHOP2:
+ switch (CPad::GetPad(0)->Mode) {
+ case 0:
+ case 1:
+ case 2:
+ CHud::SetHelpMessage(TheText.Get("GA_7"), false); // Park it, prime it by pressing the ~h~~k~~PED_FIREWEAPON~ button~w~ and LEG IT!
+ break;
+ case 3:
+ CHud::SetHelpMessage(TheText.Get("GA_7B"), false); // Park it, prime it by pressing the ~h~~k~~PED_FIREWEAPON~ button~w~ and LEG IT!
+ break;
+ }
+ break;
+ case GARAGE_BOMBSHOP3:
+ CHud::SetHelpMessage(TheText.Get("GA_8"), false); // Use the detonator to activate the bomb.
+ break;
+ }
+ CPad::GetPad(0)->SetEnablePlayerControls(PLAYERCONTROL_GARAGE);
+ FindPlayerPed()->m_pWanted->m_bIgnoredByCops = false;
+ }
+ break;
+ case GS_OPENING:
+ m_fDoorPos = min(m_fDoorHeight, m_fDoorPos + (m_bRotatedDoor ? ROTATED_DOOR_OPEN_SPEED : DEFAULT_DOOR_OPEN_SPEED) * CTimer::GetTimeStep());
+ if (m_fDoorPos == m_fDoorHeight) {
+ m_eGarageState = GS_OPENEDCONTAINSCAR;
+ DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_OPENED, 1.0f);
+ }
+ UpdateDoorsHeight();
+ break;
+ case GS_OPENEDCONTAINSCAR:
+ if (IsPlayerOutsideGarage())
+ m_eGarageState = GS_OPENED;
+ break;
+ //case GS_CLOSEDCONTAINSCAR:
+ //case GS_AFTERDROPOFF:
+ default:
+ break;
+ }
+ break;
+ case GARAGE_MISSION:
+ switch (m_eGarageState) {
+ case GS_OPENED:
+ if (((CVector2D)FindPlayerCoors() - CVector2D(GetGarageCenterX(), GetGarageCenterY())).MagnitudeSqr() > SQR(DISTANCE_TO_CLOSE_MISSION_GARAGE)) {
+ if ((CTimer::GetFrameCounter() & 0x1F) == 0 && !IsAnyOtherCarTouchingGarage(nil)) {
+ m_eGarageState = GS_CLOSING;
+ m_bClosingWithoutTargetCar = true;
+ }
+ }
+ else if (!FindPlayerVehicle() && m_pTarget && IsEntityEntirelyInside3D(m_pTarget, 0.0f) &&
+ !IsAnyOtherCarTouchingGarage(m_pTarget) && IsEntityEntirelyOutside(FindPlayerPed(), 2.0f)) {
+ CPad::GetPad(0)->SetDisablePlayerControls(PLAYERCONTROL_GARAGE);
+ FindPlayerPed()->m_pWanted->m_bIgnoredByCops = true;
+ m_eGarageState = GS_CLOSING;
+ m_bClosingWithoutTargetCar = false;
+ }
+ break;
+ case GS_CLOSING:
+ m_fDoorPos = max(0.0f, m_fDoorPos - (m_bRotatedDoor ? ROTATED_DOOR_CLOSE_SPEED : DEFAULT_DOOR_CLOSE_SPEED) * CTimer::GetTimeStep());
+ if (m_fDoorPos == 0.0f) {
+ DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_CLOSED, 1.0f);
+ if (m_bClosingWithoutTargetCar)
+ m_eGarageState = GS_FULLYCLOSED;
+ else {
+ if (m_pTarget) {
+ m_eGarageState = GS_CLOSEDCONTAINSCAR;
+ DestroyVehicleAndDriverAndPassengers(m_pTarget);
+ m_pTarget = nil;
+ }
+ else {
+ m_eGarageState = GS_FULLYCLOSED;
+ }
+ CPad::GetPad(0)->SetEnablePlayerControls(PLAYERCONTROL_GARAGE);
+ FindPlayerPed()->m_pWanted->m_bIgnoredByCops = false;
+ }
+ }
+ UpdateDoorsHeight();
+ break;
+ case GS_FULLYCLOSED:
+ if (FindPlayerVehicle() == m_pTarget && m_pTarget) {
+ if (CalcDistToGarageRectangleSquared(
+ FindPlayerVehicle()->GetPosition().x,
+ FindPlayerVehicle()->GetPosition().y) < SQR(DISTANCE_TO_ACTIVATE_GARAGE))
+ m_eGarageState = GS_OPENING;
+ }
+ break;
+ case GS_OPENING:
+ m_fDoorPos = min(m_fDoorHeight, m_fDoorPos + (m_bRotatedDoor ? ROTATED_DOOR_OPEN_SPEED : DEFAULT_DOOR_OPEN_SPEED) * CTimer::GetTimeStep());
+ if (m_fDoorPos == m_fDoorHeight) {
+ m_eGarageState = GS_OPENED;
+ DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_OPENED, 1.0f);
+ }
+ UpdateDoorsHeight();
+ break;
+ //case GS_OPENEDCONTAINSCAR:
+ //case GS_CLOSEDCONTAINSCAR:
+ //case GS_AFTERDROPOFF:
+ default:
+ break;
+ }
+ break;
+ case GARAGE_COLLECTSPECIFICCARS:
+ switch (m_eGarageState) {
+ case GS_OPENED:
+ if (FindPlayerVehicle() && m_nTargetModelIndex == FindPlayerVehicle()->GetModelIndex()) {
+ m_pTarget = FindPlayerVehicle();
+ m_pTarget->RegisterReference((CEntity**)&m_pTarget);
+ }
+ if (!FindPlayerVehicle()) {
+ if (m_pTarget && IsEntityEntirelyInside3D(m_pTarget, 0.0f) && !IsAnyOtherCarTouchingGarage(m_pTarget)) {
+ if (IsEntityEntirelyOutside(FindPlayerPed(), 2.0f)) {
+ CPad::GetPad(0)->SetDisablePlayerControls(PLAYERCONTROL_GARAGE);
+ FindPlayerPed()->m_pWanted->m_bIgnoredByCops = true;
+ m_eGarageState = GS_CLOSING;
+ }
+ }
+ else if (Abs(FindPlayerCoors().x - GetGarageCenterX()) > DISTANCE_TO_CLOSE_COLLECTSPECIFICCARS_GARAGE ||
+ Abs(FindPlayerCoors().y - GetGarageCenterY()) > DISTANCE_TO_CLOSE_COLLECTSPECIFICCARS_GARAGE) {
+ m_eGarageState = GS_CLOSING;
+ m_pTarget = nil;
+ }
+ }
+ break;
+ case GS_CLOSING:
+ m_fDoorPos = max(0.0f, m_fDoorPos - (m_bRotatedDoor ? ROTATED_DOOR_CLOSE_SPEED : DEFAULT_DOOR_CLOSE_SPEED) * CTimer::GetTimeStep());
+ if (m_fDoorPos == 0.0f) {
+ m_eGarageState = GS_FULLYCLOSED;
+ DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_CLOSED, 1.0f);
+ if (m_pTarget) {
+ DestroyVehicleAndDriverAndPassengers(m_pTarget);
+ m_pTarget = nil;
+ CPad::GetPad(0)->SetEnablePlayerControls(PLAYERCONTROL_GARAGE);
+ FindPlayerPed()->m_pWanted->m_bIgnoredByCops = false;
+ int16 reward;
+ switch (m_nTargetModelIndex) {
+ case MI_POLICE:
+ reward = REWARD_FOR_FIRST_POLICE_CAR * (MAX_POLICE_CARS_TO_COLLECT - CGarages::PoliceCarsCollected++) / MAX_POLICE_CARS_TO_COLLECT;
+ break;
+ case MI_SECURICA:
+ reward = REWARD_FOR_FIRST_BANK_VAN * (MAX_BANK_VANS_TO_COLLECT - CGarages::BankVansCollected++) / MAX_BANK_VANS_TO_COLLECT;
+ break;
+#ifdef FIX_BUGS // not possible though
+ default:
+ reward = 0;
+ break;
+#endif
+ }
+ if (reward > 0) {
+ CWorld::Players[CWorld::PlayerInFocus].m_nMoney += reward;
+ CGarages::TriggerMessage("GA_10", reward, 4000, -1); // Nice one. Here's your $~1~
+ DMAudio.PlayFrontEndSound(SOUND_GARAGE_VEHICLE_ACCEPTED, 1);
+ }
+ else {
+ CGarages::TriggerMessage("GA_11", -1, 4000, -1); // We got these wheels already. It's worthless to us!
+ DMAudio.PlayFrontEndSound(SOUND_GARAGE_VEHICLE_DECLINED, 1);
+ }
+ }
+ }
+ UpdateDoorsHeight();
+ break;
+ case GS_FULLYCLOSED:
+ if (FindPlayerVehicle() && m_nTargetModelIndex == FindPlayerVehicle()->GetModelIndex()) {
+ if (CalcDistToGarageRectangleSquared(FindPlayerVehicle()->GetPosition().x, FindPlayerVehicle()->GetPosition().y) < SQR(DISTANCE_TO_ACTIVATE_GARAGE))
+ m_eGarageState = GS_OPENING;
+ }
+ break;
+ case GS_OPENING:
+ if (FindPlayerVehicle() && m_nTargetModelIndex == FindPlayerVehicle()->GetModelIndex()) {
+ m_pTarget = FindPlayerVehicle();
+ m_pTarget->RegisterReference((CEntity**)&m_pTarget);
+ }
+ m_fDoorPos = min(m_fDoorHeight, m_fDoorPos + (m_bRotatedDoor ? ROTATED_DOOR_OPEN_SPEED : DEFAULT_DOOR_OPEN_SPEED) * CTimer::GetTimeStep());
+ if (m_fDoorPos == m_fDoorHeight) {
+ m_eGarageState = GS_OPENED;
+ DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_OPENED, 1.0f);
+ }
+ UpdateDoorsHeight();
+ break;
+ //case GS_OPENEDCONTAINSCAR:
+ //case GS_CLOSEDCONTAINSCAR:
+ //case GS_AFTERDROPOFF:
+ default:
+ break;
+ }
+ break;
+ case GARAGE_COLLECTCARS_1:
+ case GARAGE_COLLECTCARS_2:
+ case GARAGE_COLLECTCARS_3:
+ switch (m_eGarageState) {
+ case GS_OPENED:
+ if (FindPlayerVehicle() && DoesCraigNeedThisCar(FindPlayerVehicle()->GetModelIndex())) {
+ m_pTarget = FindPlayerVehicle();
+ m_pTarget->RegisterReference((CEntity**)&m_pTarget);
+ }
+ if (Abs(FindPlayerCoors().x - GetGarageCenterX()) > DISTANCE_TO_CLOSE_COLLECTCARS_GARAGE ||
+ Abs(FindPlayerCoors().y - GetGarageCenterY()) > DISTANCE_TO_CLOSE_COLLECTCARS_GARAGE) {
+ m_eGarageState = GS_CLOSING;
+ m_pTarget = nil;
+ break;
+ }
+ if (m_pTarget && !FindPlayerVehicle() && IsEntityEntirelyInside3D(m_pTarget, 0.0f) &&
+ !IsAnyOtherCarTouchingGarage(m_pTarget) && IsEntityEntirelyOutside(FindPlayerPed(), 2.0f)) {
+#ifdef FIX_BUGS
+ if (!m_pTarget->IsCar() ||
+ ((CAutomobile*)(m_pTarget))->Damage.GetEngineStatus() <= ENGINE_STATUS_ON_FIRE &&
+ ((CAutomobile*)(m_pTarget))->m_fFireBlowUpTimer == 0.0f) {
+#else
+ if (((CAutomobile*)(m_pTarget))->Damage.GetEngineStatus() <= ENGINE_STATUS_ON_FIRE &&
+ ((CAutomobile*)(m_pTarget))->m_fFireBlowUpTimer == 0.0f) {
+#endif
+ if (m_pTarget->m_status != STATUS_WRECKED) {
+ CPad::GetPad(0)->SetDisablePlayerControls(PLAYERCONTROL_GARAGE);
+ FindPlayerPed()->m_pWanted->m_bIgnoredByCops = true;
+ m_eGarageState = GS_CLOSING;
+ TheCamera.SetCameraDirectlyBehindForFollowPed_CamOnAString();
+ }
+ }
+ }
+ break;
+ case GS_CLOSING:
+ m_fDoorPos = max(0.0f, m_fDoorPos - (m_bRotatedDoor ? ROTATED_DOOR_CLOSE_SPEED : DEFAULT_DOOR_CLOSE_SPEED) * CTimer::GetTimeStep());
+ if (m_fDoorPos == 0.0f) {
+ m_eGarageState = GS_FULLYCLOSED;
+ DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_CLOSED, 1.0f);
+ if (m_pTarget) {
+ MarkThisCarAsCollectedForCraig(m_pTarget->GetModelIndex());
+ DestroyVehicleAndDriverAndPassengers(m_pTarget);
+ m_pTarget = nil;
+ CPad::GetPad(0)->SetEnablePlayerControls(PLAYERCONTROL_GARAGE);
+ FindPlayerPed()->m_pWanted->m_bIgnoredByCops = false;
+ }
+ }
+ UpdateDoorsHeight();
+ break;
+ case GS_FULLYCLOSED:
+ if (FindPlayerVehicle() &&
+ CalcSmallestDistToGarageDoorSquared(
+ FindPlayerVehicle()->GetPosition().x,
+ FindPlayerVehicle()->GetPosition().y
+ ) < SQR(DISTANCE_TO_ACTIVATE_GARAGE)) {
+ if (DoesCraigNeedThisCar(FindPlayerVehicle()->GetModelIndex())) {
+ if (FindPlayerVehicle()->VehicleCreatedBy == MISSION_VEHICLE)
+ CGarages::TriggerMessage("GA_1A", -1, 5000, -1); // Come back when you're not so busy...
+ else
+ m_eGarageState = GS_OPENING;
+ }
+ else {
+ if (HasCraigCollectedThisCar(FindPlayerVehicle()->GetModelIndex()))
+ CGarages::TriggerMessage("GA_20", -1, 5000, -1); // We got more of these than we can shift. Sorry man, no deal.
+ else if (FindPlayerSpeed().Magnitude() < MAX_SPEED_TO_SHOW_COLLECTED_MESSAGE)
+ CGarages::TriggerMessage("GA_19", -1, 5000, -1); // We're not interested in that model.
+ }
+ }
+ m_pTarget = nil;
+ break;
+ case GS_OPENING:
+ if (FindPlayerVehicle() && DoesCraigNeedThisCar(FindPlayerVehicle()->GetModelIndex())) {
+ m_pTarget = FindPlayerVehicle();
+ m_pTarget->RegisterReference((CEntity**)&m_pTarget);
+ }
+ m_fDoorPos = min(m_fDoorHeight, m_fDoorPos + (m_bRotatedDoor ? ROTATED_DOOR_OPEN_SPEED : DEFAULT_DOOR_OPEN_SPEED) * CTimer::GetTimeStep());
+ if (m_fDoorPos == m_fDoorHeight) {
+ m_eGarageState = GS_OPENED;
+ DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_OPENED, 1.0f);
+ }
+ UpdateDoorsHeight();
+ break;
+ //case GS_OPENEDCONTAINSCAR:
+ //case GS_CLOSEDCONTAINSCAR:
+ //case GS_AFTERDROPOFF:
+ default:
+ break;
+ }
+ break;
+ case GARAGE_FORCARTOCOMEOUTOF:
+ switch (m_eGarageState) {
+ case GS_OPENED:
+ if (IsGarageEmpty())
+ m_eGarageState = GS_CLOSING;
+ break;
+ case GS_CLOSING:
+ m_fDoorPos = max(0.0f, m_fDoorPos - (m_bRotatedDoor ? ROTATED_DOOR_CLOSE_SPEED : DEFAULT_DOOR_CLOSE_SPEED) * CTimer::GetTimeStep());
+ if (m_fDoorPos == 0.0f) {
+ m_eGarageState = GS_FULLYCLOSED;
+ DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_CLOSED, 1.0f);
+ }
+ if (!IsGarageEmpty())
+ m_eGarageState = GS_OPENING;
+ break;
+ case GS_FULLYCLOSED:
+ break;
+ case GS_OPENING:
+ m_fDoorPos = min(m_fDoorHeight, m_fDoorPos + (m_bRotatedDoor ? ROTATED_DOOR_OPEN_SPEED : DEFAULT_DOOR_OPEN_SPEED) * CTimer::GetTimeStep());
+ if (m_fDoorPos == m_fDoorHeight) {
+ m_eGarageState = GS_OPENED;
+ DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_OPENED, 1.0f);
+ }
+ UpdateDoorsHeight();
+ break;
+ //case GS_OPENEDCONTAINSCAR:
+ //case GS_CLOSEDCONTAINSCAR:
+ //case GS_AFTERDROPOFF:
+ default:
+ break;
+ }
+ break;
+ case GARAGE_CRUSHER:
+ switch (m_eGarageState) {
+ case GS_OPENED:
+ {
+ int i = CPools::GetVehiclePool()->GetSize() * (CTimer::GetFrameCounter() % CRUSHER_VEHICLE_TEST_SPAN) / CRUSHER_VEHICLE_TEST_SPAN;
+ int end = CPools::GetVehiclePool()->GetSize() * (CTimer::GetFrameCounter() % CRUSHER_VEHICLE_TEST_SPAN + 1) / CRUSHER_VEHICLE_TEST_SPAN;
+ for (; i < end; i++) {
+ CVehicle* pVehicle = CPools::GetVehiclePool()->GetSlot(i);
+ if (!pVehicle)
+ continue;
+ if (pVehicle->IsCar() && IsEntityEntirelyInside3D(pVehicle, 0.0f)) {
+ m_eGarageState = GS_CLOSING;
+ m_pTarget = pVehicle;
+ m_pTarget->RegisterReference((CEntity**)&m_pTarget);
+ }
+ }
+ break;
+ }
+ case GS_CLOSING:
+ if (m_pTarget) {
+ m_fDoorPos = max(0.0f, m_fDoorPos - CRUSHER_CRANE_SPEED * CTimer::GetTimeStep());
+ if (m_fDoorPos < TWOPI/5) {
+ m_pTarget->bUsesCollision = false;
+ m_pTarget->bAffectedByGravity = false;
+ m_pTarget->SetMoveSpeed(0.0f, 0.0f, 0.0f);
+ }
+ else {
+ m_pTarget->SetMoveSpeed(m_pTarget->GetMoveSpeed()* Pow(0.8f, CTimer::GetTimeStep()));
+ }
+ if (m_fDoorPos == 0.0f) {
+ CGarages::CrushedCarId = CPools::GetVehiclePool()->GetIndex(m_pTarget);
+ float reward = min(CRUSHER_MAX_REWARD, CRUSHER_MIN_REWARD + m_pTarget->pHandling->nMonetaryValue * m_pTarget->m_fHealth * CRUSHER_REWARD_COEFFICIENT);
+ CWorld::Players[CWorld::PlayerInFocus].m_nMoney += reward;
+ DestroyVehicleAndDriverAndPassengers(m_pTarget);
+ ++CStats::CarsCrushed;
+ m_pTarget = nil;
+ m_eGarageState = GS_AFTERDROPOFF;
+ m_nTimeToStartAction = CTimer::GetTimeInMilliseconds() + TIME_TO_CRUSH_CAR;
+ DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_CLOSED, 1.0f);
+ }
+ }
+ else
+ m_eGarageState = GS_OPENING;
+ UpdateCrusherAngle();
+ break;
+ case GS_AFTERDROPOFF:
+ if (CTimer::GetTimeInMilliseconds() <= m_nTimeToStartAction) {
+ UpdateCrusherShake((myrand() & 0xFF - 128) * 0.0002f, (myrand() & 0xFF - 128) * 0.0002f);
+ }
+ else {
+ UpdateCrusherShake(0.0f, 0.0f);
+ m_eGarageState = GS_OPENING;
+ }
+ break;
+ case GS_OPENING:
+ m_fDoorPos = min(HALFPI, m_fDoorPos + CTimer::GetTimeStep() * CRUSHER_CRANE_SPEED);
+ if (m_fDoorPos == HALFPI) {
+ m_eGarageState = GS_OPENED;
+ DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_OPENED, 1.0f);
+ }
+ UpdateCrusherAngle();
+ break;
+ //case GS_FULLYCLOSED:
+ //case GS_CLOSEDCONTAINSCAR:
+ //case GS_OPENEDCONTAINSCAR:
-bool CGarages::HasImportExportGarageCollectedThisCar(int16 garage, int8 car)
-{
- return CarTypesCollected[GetCarsCollectedIndexForGarageType(Garages[garage].m_eGarageType)] & (1 << car);
-}
+ default:
+ break;
+ }
+ if (!FindPlayerVehicle() && (CTimer::GetFrameCounter() & 0x1F) == 0x17 && IsEntityEntirelyInside(FindPlayerPed()))
+ FindPlayerPed()->InflictDamage(nil, WEAPONTYPE_RAMMEDBYCAR, 300.0f, PEDPIECE_TORSO, 0);
+ break;
+ case GARAGE_MISSION_KEEPCAR:
+ case GARAGE_MISSION_KEEPCAR_REMAINCLOSED:
+ switch (m_eGarageState) {
+ case GS_OPENED:
+ if (((CVector2D)FindPlayerCoors() - CVector2D(GetGarageCenterX(), GetGarageCenterY())).MagnitudeSqr() > SQR(DISTANCE_TO_CLOSE_MISSION_GARAGE) &&
+ !IsAnyOtherCarTouchingGarage(nil)) {
+ m_eGarageState = GS_CLOSING;
+ m_bClosingWithoutTargetCar = true;
+ }
+ else if (m_pTarget && m_pTarget == FindPlayerVehicle() && IsStaticPlayerCarEntirelyInside() && !IsAnyCarBlockingDoor()) {
+ CPad::GetPad(0)->SetDisablePlayerControls(PLAYERCONTROL_GARAGE);
+ FindPlayerPed()->m_pWanted->m_bIgnoredByCops = true;
+ m_eGarageState = GS_CLOSING;
+ m_bClosingWithoutTargetCar = false;
+ }
+ break;
+ case GS_CLOSING:
+ m_fDoorPos = max(0.0f, m_fDoorPos - (m_bRotatedDoor ? ROTATED_DOOR_CLOSE_SPEED : DEFAULT_DOOR_CLOSE_SPEED) * CTimer::GetTimeStep());
+ if (m_fDoorPos == 0.0f) {
+ DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_CLOSED, 1.0f);
+ if (m_bClosingWithoutTargetCar)
+ m_eGarageState = GS_FULLYCLOSED;
+ else {
+ if (m_pTarget) {
+ m_eGarageState = GS_CLOSEDCONTAINSCAR;
+ m_nTimeToStartAction = CTimer::GetTimeInMilliseconds() + TIME_TO_PROCESS_KEEPCAR_GARAGE;
+ m_pTarget = nil;
+ }
+ else
+ m_eGarageState = GS_FULLYCLOSED;
+ CPad::GetPad(0)->SetEnablePlayerControls(PLAYERCONTROL_GARAGE);
+ FindPlayerPed()->m_pWanted->m_bIgnoredByCops = false;
+ }
+ }
+ UpdateDoorsHeight();
+ break;
+ case GS_FULLYCLOSED:
+ if (FindPlayerVehicle() == m_pTarget && m_pTarget &&
+ CalcDistToGarageRectangleSquared(
+ FindPlayerVehicle()->GetPosition().x,
+ FindPlayerVehicle()->GetPosition().y
+ ) < SQR(DISTANCE_TO_ACTIVATE_KEEPCAR_GARAGE))
+ m_eGarageState = GS_OPENING;
+ break;
+ case GS_OPENING:
+ m_fDoorPos = min(m_fDoorHeight, m_fDoorPos + (m_bRotatedDoor ? ROTATED_DOOR_OPEN_SPEED : DEFAULT_DOOR_OPEN_SPEED) * CTimer::GetTimeStep());
+ if (m_fDoorPos == m_fDoorHeight) {
+ m_eGarageState = GS_OPENED;
+ DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_OPENED, 1.0f);
+ }
+ UpdateDoorsHeight();
+ break;
+ case GS_CLOSEDCONTAINSCAR:
+ if (m_eGarageType == GARAGE_MISSION_KEEPCAR && CTimer::GetTimeInMilliseconds() > m_nTimeToStartAction)
+ m_eGarageState = GS_OPENING;
+ break;
+ //case GS_OPENEDCONTAINSCAR:
+ //case GS_AFTERDROPOFF:
+ default:
+ break;
+ }
+ break;
+ case GARAGE_FOR_SCRIPT_TO_OPEN:
+ switch (m_eGarageState) {
+ case GS_OPENING:
+ m_fDoorPos = min(m_fDoorHeight, m_fDoorPos + (m_bRotatedDoor ? ROTATED_DOOR_OPEN_SPEED : DEFAULT_DOOR_OPEN_SPEED) * CTimer::GetTimeStep());
+ if (m_fDoorPos == m_fDoorHeight) {
+ m_eGarageState = GS_OPENED;
+ DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_OPENED, 1.0f);
+ }
+ UpdateDoorsHeight();
+ break;
+ //case GS_OPENED:
+ //case GS_CLOSING:
+ //case GS_FULLYCLOSED:
+ //case GS_OPENEDCONTAINSCAR:
+ //case GS_CLOSEDCONTAINSCAR:
+ //case GS_AFTERDROPOFF:
+ default:
+ break;
+ }
+ break;
+ case GARAGE_FOR_SCRIPT_TO_OPEN_AND_CLOSE:
+ switch (m_eGarageState) {
+ case GS_CLOSING:
+ m_fDoorPos = max(0.0f, m_fDoorPos - (m_bRotatedDoor ? ROTATED_DOOR_CLOSE_SPEED : DEFAULT_DOOR_CLOSE_SPEED) * CTimer::GetTimeStep());
+ if (m_fDoorPos == 0.0f) {
+ m_eGarageState = GS_FULLYCLOSED;
+ DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_CLOSED, 1.0f);
+ }
+ UpdateDoorsHeight();
+ break;
+ case GS_OPENING:
+ m_fDoorPos = min(m_fDoorHeight, m_fDoorPos + (m_bRotatedDoor ? ROTATED_DOOR_OPEN_SPEED : DEFAULT_DOOR_OPEN_SPEED) * CTimer::GetTimeStep());
+ if (m_fDoorPos == m_fDoorHeight) {
+ m_eGarageState = GS_OPENED;
+ DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_OPENED, 1.0f);
+ }
+ UpdateDoorsHeight();
+ break;
+ //case GS_OPENED:
+ //case GS_FULLYCLOSED:
+ //case GS_OPENEDCONTAINSCAR:
+ //case GS_CLOSEDCONTAINSCAR:
+ //case GS_AFTERDROPOFF:
+ default:
+ break;
+ }
+ break;
-void CGarages::SetLeaveCameraForThisGarage(int16 garage)
-{
- Garages[garage].m_bCameraFollowsPlayer = true;
+ case GARAGE_HIDEOUT_ONE:
+ case GARAGE_HIDEOUT_TWO:
+ case GARAGE_HIDEOUT_THREE:
+ switch (m_eGarageState) {
+ case GS_OPENED:
+ {
+ float distance = CalcDistToGarageRectangleSquared(FindPlayerCoors().x, FindPlayerCoors().y);
+ // Close car doors either if player is far, or if he is in vehicle and garage is full,
+ // or if player is very very far so that we can remove whatever is blocking garage door without him noticing
+ if ((distance > SQR(DISTANCE_TO_CLOSE_HIDEOUT_GARAGE_IN_CAR) ||
+ !FindPlayerVehicle() && distance > SQR(DISTANCE_TO_CLOSE_HIDEOUT_GARAGE_ON_FOOT) &&
+ !IsAnyCarBlockingDoor()))
+ m_eGarageState = GS_CLOSING;
+ else if (FindPlayerVehicle() &&
+ CountCarsWithCenterPointWithinGarage(FindPlayerVehicle()) >=
+ CGarages::FindMaxNumStoredCarsForGarage(m_eGarageType)) {
+ m_eGarageState = GS_CLOSING;
+ }
+ else if (distance > SQR(DISTANCE_TO_FORCE_CLOSE_HIDEOUT_GARAGE)) {
+ m_eGarageState = GS_CLOSING;
+ RemoveCarsBlockingDoorNotInside();
+ }
+ break;
+ }
+ case GS_CLOSING:
+#ifndef FIX_BUGS // TODO: check and replace with ifdef
+ if (!IsPlayerOutsideGarage())
+ m_eGarageState = GS_OPENING;
+ m_fDoorPos = max(0.0f, m_fDoorPos - HIDEOUT_DOOR_SPEED_COEFFICIENT * (m_bRotatedDoor ? ROTATED_DOOR_CLOSE_SPEED : DEFAULT_DOOR_CLOSE_SPEED) * CTimer::GetTimeStep());
+#else
+ m_fDoorPos = max(0.0f, m_fDoorPos - HIDEOUT_DOOR_SPEED_COEFFICIENT * (m_bRotatedDoor ? ROTATED_DOOR_CLOSE_SPEED : DEFAULT_DOOR_CLOSE_SPEED) * CTimer::GetTimeStep());
+ if (!IsPlayerOutsideGarage())
+ m_eGarageState = GS_OPENING;
+#endif
+ else if (m_fDoorPos == 0.0f) {
+ DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_CLOSED, 1.0f);
+ m_eGarageState = GS_FULLYCLOSED;
+ switch (m_eGarageType) {
+ case GARAGE_HIDEOUT_ONE: StoreAndRemoveCarsForThisHideout(CGarages::aCarsInSafeHouse1, MAX_STORED_CARS_IN_INDUSTRIAL); break;
+ case GARAGE_HIDEOUT_TWO: StoreAndRemoveCarsForThisHideout(CGarages::aCarsInSafeHouse2, MAX_STORED_CARS_IN_COMMERCIAL); break;
+ case GARAGE_HIDEOUT_THREE: StoreAndRemoveCarsForThisHideout(CGarages::aCarsInSafeHouse3, MAX_STORED_CARS_IN_SUBURBAN); break;
+ }
+ }
+ UpdateDoorsHeight();
+ break;
+ case GS_FULLYCLOSED:
+ {
+ float distance = CalcDistToGarageRectangleSquared(FindPlayerCoors().x, FindPlayerCoors().y);
+ if (distance < SQR(DISTANCE_TO_OPEN_HIDEOUT_GARAGE_ON_FOOT) ||
+ distance < SQR(DISTANCE_TO_OPEN_HIDEOUT_GARAGE_IN_CAR) && FindPlayerVehicle()) {
+ if (FindPlayerVehicle() && CGarages::CountCarsInHideoutGarage(m_eGarageType) >= CGarages::FindMaxNumStoredCarsForGarage(m_eGarageType)) {
+ if (m_pDoor1) {
+ if (((CVector2D)FindPlayerVehicle()->GetPosition() - (CVector2D)m_pDoor1->GetPosition()).MagnitudeSqr() < SQR(DISTANCE_TO_SHOW_HIDEOUT_MESSAGE) &&
+ CTimer::GetTimeInMilliseconds() - CGarages::LastTimeHelpMessage > TIME_BETWEEN_HIDEOUT_MESSAGES) {
+ CHud::SetHelpMessage(TheText.Get("GA_21"), false); // You cannot store any more cars in this garage.
+ CGarages::LastTimeHelpMessage = CTimer::GetTimeInMilliseconds();
+ }
+ }
+ }
+ else {
+#ifdef FIX_BUGS
+ bool bCreatedAllCars = false;
+#else
+ bool bCraetedAllCars;
+#endif
+ switch (m_eGarageType) {
+ case GARAGE_HIDEOUT_ONE: bCreatedAllCars = RestoreCarsForThisHideout(CGarages::aCarsInSafeHouse1); break;
+ case GARAGE_HIDEOUT_TWO: bCreatedAllCars = RestoreCarsForThisHideout(CGarages::aCarsInSafeHouse2); break;
+ case GARAGE_HIDEOUT_THREE: bCreatedAllCars = RestoreCarsForThisHideout(CGarages::aCarsInSafeHouse3); break;
+ }
+ if (bCreatedAllCars)
+ m_eGarageState = GS_OPENING;
+ }
+ }
+ break;
+ }
+ case GS_OPENING:
+ m_fDoorPos = min(m_fDoorHeight, m_fDoorPos + HIDEOUT_DOOR_SPEED_COEFFICIENT * (m_bRotatedDoor ? ROTATED_DOOR_OPEN_SPEED : DEFAULT_DOOR_OPEN_SPEED) * CTimer::GetTimeStep());
+ if (m_fDoorPos == m_fDoorHeight) {
+ m_eGarageState = GS_OPENED;
+ DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_OPENED, 1.0f);
+ }
+ UpdateDoorsHeight();
+ break;
+ //case GS_OPENEDCONTAINSCAR:
+ //case GS_CLOSEDCONTAINSCAR:
+ //case GS_AFTERDROPOFF:
+ default:
+ break;
+ }
+ break;
+ case GARAGE_KEEPS_OPENING_FOR_SPECIFIC_CAR:
+ switch (m_eGarageState) {
+ case GS_OPENED:
+ if (((CVector2D)FindPlayerCoors() - CVector2D(GetGarageCenterX(), GetGarageCenterY())).MagnitudeSqr() > SQR(DISTANCE_TO_CLOSE_MISSION_GARAGE)) {
+ if (m_pTarget && IsEntityEntirelyOutside(m_pTarget, 0.0f) && !IsAnyOtherCarTouchingGarage(nil)) {
+ m_eGarageState = GS_CLOSING;
+ m_bClosingWithoutTargetCar = true;
+ }
+ }
+ break;
+ case GS_CLOSING:
+ m_fDoorPos = max(0.0f, m_fDoorPos - (m_bRotatedDoor ? ROTATED_DOOR_CLOSE_SPEED : DEFAULT_DOOR_CLOSE_SPEED) * CTimer::GetTimeStep());
+ if (m_fDoorPos == 0.0f) {
+ m_eGarageState = GS_FULLYCLOSED;
+ DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_CLOSED, 1.0f);
+ }
+ UpdateDoorsHeight();
+ break;
+ case GS_FULLYCLOSED:
+ if (FindPlayerVehicle() == m_pTarget && m_pTarget &&
+ CalcDistToGarageRectangleSquared(
+ FindPlayerVehicle()->GetPosition().x,
+ FindPlayerVehicle()->GetPosition().y
+ ) < SQR(DISTANCE_TO_ACTIVATE_GARAGE))
+ m_eGarageState = GS_OPENING;
+ break;
+ case GS_OPENING:
+ m_fDoorPos = min(m_fDoorHeight, m_fDoorPos + (m_bRotatedDoor ? ROTATED_DOOR_OPEN_SPEED : DEFAULT_DOOR_OPEN_SPEED) * CTimer::GetTimeStep());
+ if (m_fDoorPos == m_fDoorHeight) {
+ m_eGarageState = GS_OPENED;
+ DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_OPENED, 1.0f);
+ }
+ UpdateDoorsHeight();
+ break;
+ //case GS_OPENEDCONTAINSCAR:
+ //case GS_CLOSEDCONTAINSCAR:
+ //case GS_AFTERDROPOFF:
+ default:
+ break;
+ }
+ break;
+ //case GARAGE_COLLECTORSITEMS:
+ //case GARAGE_60SECONDS:
+ default:
+ break;
+ }
+
}
-#if 0
-WRAPPER void CGarages::PrintMessages(void) { EAXJMP(0x426310); }
-#else
+WRAPPER bool CGarage::IsStaticPlayerCarEntirelyInside() { EAXJMP(0x4251C0); }
+WRAPPER bool CGarage::IsEntityEntirelyInside(CEntity*) { EAXJMP(0x425370); }
+WRAPPER bool CGarage::IsEntityEntirelyInside3D(CEntity*, float) { EAXJMP(0x4254F0); }
+WRAPPER bool CGarage::IsEntityEntirelyOutside(CEntity*, float) { EAXJMP(0x425740); }
+WRAPPER bool CGarage::IsGarageEmpty() { EAXJMP(0x425890); }
+WRAPPER bool CGarage::IsPlayerOutsideGarage() { EAXJMP(0x425910); }
+WRAPPER bool CGarage::IsEntityTouching3D(CEntity*) { EAXJMP(0x425950); }
+WRAPPER bool CGarage::EntityHasASphereWayOutsideGarage(CEntity*, float) { EAXJMP(0x425B30); }
+WRAPPER bool CGarage::IsAnyOtherCarTouchingGarage(CVehicle* pException) { EAXJMP(0x425C90); }
+WRAPPER bool CGarage::IsAnyOtherPedTouchingGarage(CPed* pException) { EAXJMP(0x425E20); }
+WRAPPER bool CGarage::IsAnyCarBlockingDoor() { EAXJMP(0x425FB0); }
+WRAPPER int32 CGarage::CountCarsWithCenterPointWithinGarage(CEntity* pException) { EAXJMP(0x426130); }
+WRAPPER void CGarage::RemoveCarsBlockingDoorNotInside() { EAXJMP(0x4261F0); }
+
void CGarages::PrintMessages()
{
if (CTimer::GetTimeInMilliseconds() > MessageStartTime && CTimer::GetTimeInMilliseconds() < MessageEndTime) {
@@ -187,4 +1194,219 @@ void CGarages::PrintMessages()
}
}
}
-#endif \ No newline at end of file
+
+WRAPPER bool CGarages::IsCarSprayable(CVehicle*) { EAXJMP(0x426700); }
+WRAPPER void CGarage::UpdateDoorsHeight() { EAXJMP(0x426730); }
+WRAPPER void CGarage::BuildRotatedDoorMatrix(CEntity*, float) { EAXJMP(0x4267C0); }
+
+void CGarage::UpdateCrusherAngle()
+{
+ RefreshDoorPointers(false);
+ m_pDoor2->GetMatrix().SetRotateXOnly(TWOPI - m_fDoorPos);
+ m_pDoor2->GetMatrix().UpdateRW();
+ m_pDoor2->UpdateRwFrame();
+}
+
+WRAPPER void CGarage::UpdateCrusherShake(float, float) { EAXJMP(0x4268E0); }
+
+// This is dumb but there is no way to avoid goto. What was there originally even?
+static bool DoINeedToRefreshPointer(CEntity* pDoor, bool bIsDummy, int8 nIndex)
+{
+ bool bNeedToFindDoorEntities = false;
+ if (pDoor) {
+ if (bIsDummy) {
+ if (CPools::GetDummyPool()->IsFreeSlot(CPools::GetDummyPool()->GetJustIndex((CDummy*)pDoor)))
+ return true;
+ if (nIndex != CPools::GetDummyPool()->GetIndex((CDummy*)pDoor))
+ bNeedToFindDoorEntities = true;
+ if (!CGarages::IsModelIndexADoor(pDoor->GetModelIndex()))
+ return true;
+ }
+ else {
+ if (CPools::GetObjectPool()->IsFreeSlot(CPools::GetObjectPool()->GetJustIndex((CObject*)pDoor)))
+ return true;
+ if (nIndex != CPools::GetObjectPool()->GetIndex((CObject*)pDoor))
+ bNeedToFindDoorEntities = true;
+ if (!CGarages::IsModelIndexADoor(pDoor->GetModelIndex()))
+ return true;
+ }
+ }
+ return bNeedToFindDoorEntities;
+}
+
+void CGarage::RefreshDoorPointers(bool bCreate)
+{
+ bool bNeedToFindDoorEntities = true;
+ if (!bCreate && !m_bRecreateDoorOnNextRefresh)
+ bNeedToFindDoorEntities = false;
+ if (DoINeedToRefreshPointer(m_pDoor1, m_bDoor1IsDummy, m_bDoor1PoolIndex))
+ bNeedToFindDoorEntities = true;
+ if (DoINeedToRefreshPointer(m_pDoor2, m_bDoor2IsDummy, m_bDoor2PoolIndex))
+ bNeedToFindDoorEntities = true;
+ if (bNeedToFindDoorEntities)
+ FindDoorsEntities();
+}
+
+WRAPPER void CGarages::TriggerMessage(const char* text, int16, uint16 time, int16) { EAXJMP(0x426B20); }
+WRAPPER void CGarages::SetTargetCarForMissonGarage(int16, CVehicle*) { EAXJMP(0x426BD0); }
+WRAPPER bool CGarages::HasCarBeenDroppedOffYet(int16) { EAXJMP(0x426C20); }
+WRAPPER void CGarages::DeActivateGarage(int16) { EAXJMP(0x426C40); }
+WRAPPER void CGarages::ActivateGarage(int16) { EAXJMP(0x426C60); }
+
+int32 CGarages::QueryCarsCollected(int16 garage)
+{
+ return 0;
+}
+
+bool CGarages::HasImportExportGarageCollectedThisCar(int16 garage, int8 car)
+{
+ return CarTypesCollected[GetCarsCollectedIndexForGarageType(aGarages[garage].m_eGarageType)] & (1 << car);
+}
+
+bool CGarages::IsGarageOpen(int16 garage)
+{
+ return aGarages[garage].IsOpen();
+}
+
+bool CGarages::IsGarageClosed(int16 garage)
+{
+ return aGarages[garage].IsClosed();
+}
+
+WRAPPER bool CGarages::HasThisCarBeenCollected(int16 garage, uint8 id) { EAXJMP(0x426D50); }
+WRAPPER bool CGarage::DoesCraigNeedThisCar(int32) { EAXJMP(0x426D90); }
+WRAPPER bool CGarage::HasCraigCollectedThisCar(int32) { EAXJMP(0x426DF0); }
+WRAPPER void CGarage::MarkThisCarAsCollectedForCraig(int32) { EAXJMP(0x426E50); }
+
+void CGarage::OpenThisGarage()
+{
+ if (m_eGarageState == GS_FULLYCLOSED || m_eGarageState == GS_CLOSING || m_eGarageState == GS_CLOSEDCONTAINSCAR)
+ m_eGarageState = GS_OPENING;
+}
+
+void CGarage::CloseThisGarage()
+{
+ if (m_eGarageState == GS_OPENED || m_eGarageState == GS_OPENING)
+ m_eGarageState = GS_CLOSING;
+}
+
+WRAPPER float CGarage::CalcDistToGarageRectangleSquared(float, float) { EAXJMP(0x426F50); }
+WRAPPER float CGarage::CalcSmallestDistToGarageDoorSquared(float, float) { EAXJMP(0x426FE0); }
+WRAPPER void CGarage::FindDoorsEntities() { EAXJMP(0x427060); }
+WRAPPER void CGarage::FindDoorsEntitiesSectorList(CPtrList&, bool) { EAXJMP(0x427300); }
+WRAPPER bool CGarages::HasResprayHappened(int16 garage) { EAXJMP(0x4274F0); }
+
+void CGarages::SetGarageDoorToRotate(int16 garage)
+{
+ if (aGarages[garage].m_bRotatedDoor)
+ return;
+ aGarages[garage].m_bRotatedDoor = true;
+ aGarages[garage].m_fDoorHeight /= 2.0f;
+ aGarages[garage].m_fDoorHeight -= 0.1f;
+}
+
+void CGarages::SetLeaveCameraForThisGarage(int16 garage)
+{
+ aGarages[garage].m_bCameraFollowsPlayer = true;
+}
+
+WRAPPER bool CGarages::IsThisCarWithinGarageArea(int16 garage, CEntity* pCar) { EAXJMP(0x427570); }
+
+bool CGarages::HasCarBeenCrushed(int32 handle)
+{
+ return CrushedCarId == handle;
+}
+
+WRAPPER void CStoredCar::StoreCar(CVehicle*) { EAXJMP(0x4275C0); }
+WRAPPER CVehicle* CStoredCar::RestoreCar() { EAXJMP(0x427690); }
+WRAPPER void CGarage::StoreAndRemoveCarsForThisHideout(CStoredCar*, int32) { EAXJMP(0x427840); }
+WRAPPER bool CGarage::RestoreCarsForThisHideout(CStoredCar*) { EAXJMP(0x427A40); }
+WRAPPER bool CGarages::IsPointInAGarageCameraZone(CVector) { EAXJMP(0x427AB0); }
+WRAPPER bool CGarages::CameraShouldBeOutside() { EAXJMP(0x427BC0); }
+
+void CGarages::GivePlayerDetonator()
+{
+ FindPlayerPed()->GiveWeapon(WEAPONTYPE_DETONATOR, 1);
+ FindPlayerPed()->GetWeapon(FindPlayerPed()->GetWeaponSlot(WEAPONTYPE_DETONATOR)).m_eWeaponState = WEAPONSTATE_READY;
+}
+
+WRAPPER float CGarages::FindDoorHeightForMI(int32) { EAXJMP(0x427C10); }
+WRAPPER void CGarage::TidyUpGarage() { EAXJMP(0x427C30); }
+WRAPPER void CGarage::TidyUpGarageClose() { EAXJMP(0x427D90); }
+WRAPPER void CGarages::PlayerArrestedOrDied() { EAXJMP(0x427F60); }
+WRAPPER void CGarage::PlayerArrestedOrDied() { EAXJMP(0x427FC0); }
+WRAPPER void CGarage::CenterCarInGarage(CVehicle*) { EAXJMP(0x428000); }
+WRAPPER void CGarages::CloseHideOutGaragesBeforeSave() { EAXJMP(0x428130); }
+WRAPPER int32 CGarages::CountCarsInHideoutGarage(eGarageType) { EAXJMP(0x4281E0); }
+WRAPPER int32 CGarages::FindMaxNumStoredCarsForGarage(eGarageType) { EAXJMP(0x428230); }
+WRAPPER bool CGarages::IsPointWithinHideOutGarage(CVector&) { EAXJMP(0x428260); }
+WRAPPER bool CGarages::IsPointWithinAnyGarage(CVector&) { EAXJMP(0x428320); }
+WRAPPER void CGarages::SetAllDoorsBackToOriginalHeight() { EAXJMP(0x4283D0); }
+WRAPPER void CGarages::Save(uint8* buf, uint32* size) { EAXJMP(0x4284E0); }
+
+CStoredCar::CStoredCar(const CStoredCar& other)
+{
+ m_nModelIndex = other.m_nModelIndex;
+ m_vecPos = other.m_vecPos;
+ m_vecAngle = other.m_vecAngle;
+ m_bBulletproof = other.m_bBulletproof;
+ m_bFireproof = other.m_bFireproof;
+ m_bExplosionproof = other.m_bExplosionproof;
+ m_bCollisionproof = other.m_bCollisionproof;
+ m_bMeleeproof = other.m_bMeleeproof;
+ m_nPrimaryColor = other.m_nPrimaryColor;
+ m_nSecondaryColor = other.m_nSecondaryColor;
+ m_nRadioStation = other.m_nRadioStation;
+ m_nVariationA = other.m_nVariationA;
+ m_nVariationB = other.m_nVariationB;
+ m_nCarBombType = other.m_nCarBombType;
+}
+
+WRAPPER void CGarages::Load(uint8* buf, uint32 size) { EAXJMP(0x428940); }
+
+bool
+CGarages::IsModelIndexADoor(uint32 id)
+{
+ return id == MI_GARAGEDOOR1 ||
+ id == MI_GARAGEDOOR2 ||
+ id == MI_GARAGEDOOR3 ||
+ id == MI_GARAGEDOOR4 ||
+ id == MI_GARAGEDOOR5 ||
+ id == MI_GARAGEDOOR6 ||
+ id == MI_GARAGEDOOR7 ||
+ id == MI_GARAGEDOOR9 ||
+ id == MI_GARAGEDOOR10 ||
+ id == MI_GARAGEDOOR11 ||
+ id == MI_GARAGEDOOR12 ||
+ id == MI_GARAGEDOOR13 ||
+ id == MI_GARAGEDOOR14 ||
+ id == MI_GARAGEDOOR15 ||
+ id == MI_GARAGEDOOR16 ||
+ id == MI_GARAGEDOOR17 ||
+ id == MI_GARAGEDOOR18 ||
+ id == MI_GARAGEDOOR19 ||
+ id == MI_GARAGEDOOR20 ||
+ id == MI_GARAGEDOOR21 ||
+ id == MI_GARAGEDOOR22 ||
+ id == MI_GARAGEDOOR23 ||
+ id == MI_GARAGEDOOR24 ||
+ id == MI_GARAGEDOOR25 ||
+ id == MI_GARAGEDOOR26 ||
+ id == MI_GARAGEDOOR27 ||
+ id == MI_GARAGEDOOR28 ||
+ id == MI_GARAGEDOOR29 ||
+ id == MI_GARAGEDOOR30 ||
+ id == MI_GARAGEDOOR31 ||
+ id == MI_GARAGEDOOR32 ||
+ id == MI_CRUSHERBODY ||
+ id == MI_CRUSHERLID;
+}
+
+
+STARTPATCHES
+ InjectHook(0x421C60, CGarages::Init, PATCH_JUMP);
+#ifndef PS2
+ InjectHook(0x421E10, CGarages::Shutdown, PATCH_JUMP);
+#endif
+ InjectHook(0x421E40, CGarages::Update, PATCH_JUMP);
+ENDPATCHES \ No newline at end of file
diff --git a/src/control/Garages.h b/src/control/Garages.h
index 5e106ade..e39a81fa 100644
--- a/src/control/Garages.h
+++ b/src/control/Garages.h
@@ -1,6 +1,7 @@
#pragma once
#include "Automobile.h"
#include "audio_enums.h"
+#include "Camera.h"
#include "config.h"
class CVehicle;
@@ -63,34 +64,42 @@ class CStoredCar
int8 m_nVariationA;
int8 m_nVariationB;
int8 m_nCarBombType;
+public:
+ void Init() { m_nModelIndex = 0; }
+ CStoredCar(const CStoredCar& other);
+ void StoreCar(CVehicle*);
+ CVehicle* RestoreCar();
};
static_assert(sizeof(CStoredCar) == 0x28, "CStoredCar");
+#define SWITCH_GARAGE_DISTANCE_CLOSE 40.0f
+
class CGarage
{
public:
eGarageType m_eGarageType;
eGarageState m_eGarageState;
char field_2;
- char m_bClosingWithoutTargetCar;
- char m_bDeactivated;
- char m_bResprayHappened;
- char field_6;
- char field_7;
+ bool m_bClosingWithoutTargetCar;
+ bool m_bDeactivated;
+ bool m_bResprayHappened;
int m_nTargetModelIndex;
CEntity *m_pDoor1;
CEntity *m_pDoor2;
- char m_bDoor1PoolIndex;
- char m_bDoor2PoolIndex;
- char m_bIsDoor1Object;
- char m_bIsDoor2Object;
- char field_24;
- char m_bRotatedDoor;
- char m_bCameraFollowsPlayer;
- char field_27;
- CVector m_vecInf;
- CVector m_vecSup;
+ uint8 m_bDoor1PoolIndex;
+ uint8 m_bDoor2PoolIndex;
+ bool m_bDoor1IsDummy;
+ bool m_bDoor2IsDummy;
+ bool m_bRecreateDoorOnNextRefresh;
+ bool m_bRotatedDoor;
+ bool m_bCameraFollowsPlayer;
+ float m_fX1;
+ float m_fX2;
+ float m_fY1;
+ float m_fY2;
+ float m_fZ1;
+ float m_fZ2;
float m_fDoorPos;
float m_fDoorHeight;
float m_fDoor1X;
@@ -99,7 +108,7 @@ public:
float m_fDoor2Y;
float m_fDoor1Z;
float m_fDoor2Z;
- int m_nDoorOpenTime;
+ uint32 m_nTimeToStartAction;
char m_bCollectedCarsState;
char field_89;
char field_90;
@@ -112,6 +121,51 @@ public:
void CloseThisGarage();
bool IsOpen() { return m_eGarageState == GS_OPENED || m_eGarageState == GS_OPENEDCONTAINSCAR; }
bool IsClosed() { return m_eGarageState == GS_FULLYCLOSED; }
+ bool IsUsed() { return m_eGarageType != GARAGE_NONE; }
+ void Update();
+ float GetGarageCenterX() { return (m_fX1 + m_fX2) / 2; }
+ float GetGarageCenterY() { return (m_fY1 + m_fY2) / 2; }
+ bool IsClose()
+ {
+#ifdef FIX_BUGS
+ return Abs(TheCamera.GetPosition().x - GetGarageCenterX()) > SWITCH_GARAGE_DISTANCE_CLOSE ||
+ Abs(TheCamera.GetPosition().y - GetGarageCenterY()) > SWITCH_GARAGE_DISTANCE_CLOSE;
+#else
+ return Abs(TheCamera.GetPosition().x - m_fX1) > SWITCH_GARAGE_DISTANCE_CLOSE ||
+ Abs(TheCamera.GetPosition().y - m_fY1) > SWITCH_GARAGE_DISTANCE_CLOSE;
+#endif
+ }
+ void TidyUpGarageClose();
+ void TidyUpGarage();
+ void RefreshDoorPointers(bool);
+ void UpdateCrusherAngle();
+ void UpdateDoorsHeight();
+ bool IsEntityEntirelyInside3D(CEntity*, float);
+ bool IsEntityEntirelyOutside(CEntity*, float);
+ bool IsEntityEntirelyInside(CEntity*);
+ float CalcDistToGarageRectangleSquared(float, float);
+ float CalcSmallestDistToGarageDoorSquared(float, float);
+ bool IsAnyOtherCarTouchingGarage(CVehicle* pException);
+ bool IsStaticPlayerCarEntirelyInside();
+ bool IsPlayerOutsideGarage();
+ bool IsAnyCarBlockingDoor();
+ void CenterCarInGarage(CVehicle*);
+ bool DoesCraigNeedThisCar(int32);
+ void MarkThisCarAsCollectedForCraig(int32);
+ bool HasCraigCollectedThisCar(int32);
+ bool IsGarageEmpty();
+ void UpdateCrusherShake(float, float);
+ int32 CountCarsWithCenterPointWithinGarage(CEntity* pException);
+ void RemoveCarsBlockingDoorNotInside();
+ void StoreAndRemoveCarsForThisHideout(CStoredCar*, int32);
+ bool RestoreCarsForThisHideout(CStoredCar*);
+ bool IsEntityTouching3D(CEntity*);
+ bool EntityHasASphereWayOutsideGarage(CEntity*, float);
+ bool IsAnyOtherPedTouchingGarage(CPed* pException);
+ void BuildRotatedDoorMatrix(CEntity*, float);
+ void FindDoorsEntities();
+ void FindDoorsEntitiesSectorList(CPtrList&, bool);
+ void PlayerArrestedOrDied();
};
static_assert(sizeof(CGarage) == 140, "CGarage");
@@ -135,9 +189,19 @@ public:
static bool &PlayerInGarage;
static int32 &PoliceCarsCollected;
static uint32 &GarageToBeTidied;
- static CGarage(&Garages)[NUM_GARAGES];
-
+ static CGarage(&aGarages)[NUM_GARAGES];
+ static CStoredCar(&aCarsInSafeHouse1)[NUM_GARAGE_STORED_CARS];
+ static CStoredCar(&aCarsInSafeHouse2)[NUM_GARAGE_STORED_CARS];
+ 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 bool IsModelIndexADoor(uint32 id);
static void TriggerMessage(const char *text, int16, uint16 time, int16);
static void PrintMessages(void);
@@ -145,11 +209,10 @@ public:
static bool IsPointWithinHideOutGarage(CVector&);
static bool IsPointWithinAnyGarage(CVector&);
static void PlayerArrestedOrDied();
- static void Init(void);
+
static void Update(void);
static void Load(uint8 *buf, uint32 size);
static void Save(uint8 *buf, uint32 *size);
- static int16 AddOne(float, float, float, float, float, float, uint8, uint32);
static void SetTargetCarForMissonGarage(int16, CVehicle*);
static bool HasCarBeenDroppedOffYet(int16);
static void ActivateGarage(int16);
@@ -165,6 +228,17 @@ public:
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 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; }
+
+private:
+ static float FindDoorHeightForMI(int32);
};
diff --git a/src/control/Replay.cpp b/src/control/Replay.cpp
index 3c0393aa..2e325249 100644
--- a/src/control/Replay.cpp
+++ b/src/control/Replay.cpp
@@ -113,9 +113,6 @@ static void(*CBArray_RE3[])(CAnimBlendAssociation*, void*) =
&CPed::PedLandCB, &FinishFuckUCB, &CPed::RestoreHeadingRateCB, &CPed::PedSetQuickDraggedOutCarPositionCB, &CPed::PedSetDraggedOutCarPositionCB
};
-#if 0
-WRAPPER uint8 FindCBFunctionID(void(*f)(CAnimBlendAssociation*, void*)) { EAXJMP(0x584E70); }
-#else
static uint8 FindCBFunctionID(void(*f)(CAnimBlendAssociation*, void*))
{
for (int i = 0; i < sizeof(CBArray) / sizeof(*CBArray); i++){
@@ -128,16 +125,12 @@ static uint8 FindCBFunctionID(void(*f)(CAnimBlendAssociation*, void*))
}
return 0;
}
-#endif
static void(*FindCBFunction(uint8 id))(CAnimBlendAssociation*, void*)
{
return CBArray_RE3[id];
}
-#if 0
-WRAPPER static void ApplyPanelDamageToCar(uint32, CAutomobile*, bool) { EAXJMP(0x584EA0); }
-#else
static void ApplyPanelDamageToCar(uint32 panels, CAutomobile* vehicle, bool flying)
{
if(vehicle->Damage.GetPanelStatus(VEHPANEL_FRONT_LEFT) != CDamageManager::GetPanelStatus(panels, VEHPANEL_FRONT_LEFT)){
@@ -169,7 +162,6 @@ static void ApplyPanelDamageToCar(uint32 panels, CAutomobile* vehicle, bool flyi
vehicle->SetPanelDamage(CAR_BUMP_REAR, VEHBUMPER_REAR, flying);
}
}
-#endif
void PrintElementsInPtrList(void)
{
@@ -262,9 +254,6 @@ void CReplay::Update(void)
}
}
-#if 0
-WRAPPER void CReplay::RecordThisFrame(void) { EAXJMP(0x5932B0); }
-#else
void CReplay::RecordThisFrame(void)
{
#ifdef FIX_REPLAY_BUGS
@@ -377,11 +366,7 @@ void CReplay::RecordThisFrame(void)
MarkEverythingAsNew();
#endif
}
-#endif
-#if 0
-WRAPPER void CReplay::StorePedUpdate(CPed *ped, int id) { EAXJMP(0x5935B0); }
-#else
void CReplay::StorePedUpdate(CPed *ped, int id)
{
tPedUpdatePacket* pp = (tPedUpdatePacket*)&Record.m_pBase[Record.m_nOffset];
@@ -399,11 +384,7 @@ void CReplay::StorePedUpdate(CPed *ped, int id)
StorePedAnimation(ped, &pp->anim_state);
Record.m_nOffset += sizeof(tPedUpdatePacket);
}
-#endif
-#if 0
-WRAPPER void CReplay::StorePedAnimation(CPed *ped, CStoredAnimationState *state) { EAXJMP(0x593670); }
-#else
void CReplay::StorePedAnimation(CPed *ped, CStoredAnimationState *state)
{
CAnimBlendAssociation* second;
@@ -442,11 +423,7 @@ void CReplay::StorePedAnimation(CPed *ped, CStoredAnimationState *state)
state->partBlendAmount = 0;
}
}
-#endif
-#if 0
-WRAPPER void CReplay::StoreDetailedPedAnimation(CPed *ped, CStoredDetailedAnimationState *state) { EAXJMP(0x593BB0); }
-#else
void CReplay::StoreDetailedPedAnimation(CPed *ped, CStoredDetailedAnimationState *state)
{
for (int i = 0; i < NUM_MAIN_ANIMS_IN_REPLAY; i++){
@@ -503,10 +480,7 @@ void CReplay::StoreDetailedPedAnimation(CPed *ped, CStoredDetailedAnimationState
}
}
}
-#endif
-#if 0
-WRAPPER void CReplay::ProcessPedUpdate(CPed *ped, float interpolation, CAddressInReplayBuffer *buffer) { EAXJMP(0x594050); }
-#else
+
void CReplay::ProcessPedUpdate(CPed *ped, float interpolation, CAddressInReplayBuffer *buffer)
{
tPedUpdatePacket *pp = (tPedUpdatePacket*)&buffer->m_pBase[buffer->m_nOffset];
@@ -543,11 +517,7 @@ void CReplay::ProcessPedUpdate(CPed *ped, float interpolation, CAddressInReplayB
CWorld::Add(ped);
buffer->m_nOffset += sizeof(tPedUpdatePacket);
}
-#endif
-#if 0
-WRAPPER void CReplay::RetrievePedAnimation(CPed *ped, CStoredAnimationState *state) { EAXJMP(0x5942A0); }
-#else
void CReplay::RetrievePedAnimation(CPed *ped, CStoredAnimationState *state)
{
CAnimBlendAssociation* anim1 = CAnimManager::BlendAnimation(
@@ -585,11 +555,7 @@ void CReplay::RetrievePedAnimation(CPed *ped, CStoredAnimationState *state)
}
}
}
-#endif
-#if 0
-WRAPPER void CReplay::RetrieveDetailedPedAnimation(CPed *ped, CStoredDetailedAnimationState *state) { EAXJMP(0x5944B0); }
-#else
void CReplay::RetrieveDetailedPedAnimation(CPed *ped, CStoredDetailedAnimationState *state)
{
#ifdef FIX_REPLAY_BUGS
@@ -658,11 +624,7 @@ void CReplay::RetrieveDetailedPedAnimation(CPed *ped, CStoredDetailedAnimationSt
anim->SetDeleteCallback(FindCBFunction(callback & 0x7F), ped);
}
}
-#endif
-#if 0
-WRAPPER void CReplay::PlaybackThisFrame(void) { EAXJMP(0x5946B0); }
-#else
void CReplay::PlaybackThisFrame(void)
{
static int FrameSloMo = 0;
@@ -687,7 +649,6 @@ void CReplay::PlaybackThisFrame(void)
DMAudio.SetEffectsFadeVol(0);
DMAudio.SetMusicFadeVol(0);
}
-#endif
// next two functions are only found in mobile version
// most likely they were optimized out for being unused
@@ -712,9 +673,6 @@ bool CReplay::FastForwardToTime(uint32 start)
return true;
}
-#if 0
-WRAPPER void CReplay::StoreCarUpdate(CVehicle *vehicle, int id) { EAXJMP(0x5947F0); }
-#else
void CReplay::StoreCarUpdate(CVehicle *vehicle, int id)
{
tVehicleUpdatePacket* vp = (tVehicleUpdatePacket*)&Record.m_pBase[Record.m_nOffset];
@@ -750,11 +708,7 @@ void CReplay::StoreCarUpdate(CVehicle *vehicle, int id)
}
Record.m_nOffset += sizeof(tVehicleUpdatePacket);
}
-#endif
-#if 0
-WRAPPER void CReplay::ProcessCarUpdate(CVehicle *vehicle, float interpolation, CAddressInReplayBuffer *buffer) { EAXJMP(0x594D10); }
-#else
void CReplay::ProcessCarUpdate(CVehicle *vehicle, float interpolation, CAddressInReplayBuffer *buffer)
{
tVehicleUpdatePacket* vp = (tVehicleUpdatePacket*)&buffer->m_pBase[buffer->m_nOffset];
@@ -824,11 +778,7 @@ void CReplay::ProcessCarUpdate(CVehicle *vehicle, float interpolation, CAddressI
((CBoat*)vehicle)->m_bIsAnchored = false;
}
}
-#endif
-#if 0
-WRAPPER bool CReplay::PlayBackThisFrameInterpolation(CAddressInReplayBuffer *buffer, float interpolation, uint32 *pTimer) { EAXJMP(0x595240); }
-#else
bool CReplay::PlayBackThisFrameInterpolation(CAddressInReplayBuffer *buffer, float interpolation, uint32 *pTimer){
/* Mistake. Not even sure what this is even doing here...
* PlayerWanted is a backup to restore at the end of replay.
@@ -1028,10 +978,7 @@ bool CReplay::PlayBackThisFrameInterpolation(CAddressInReplayBuffer *buffer, flo
ProcessReplayCamera();
return false;
}
-#endif
-#if 0
-WRAPPER void CReplay::FinishPlayback(void) { EAXJMP(0x595B20); }
-#else
+
void CReplay::FinishPlayback(void)
{
if (Mode != MODE_PLAYBACK)
@@ -1053,11 +1000,7 @@ void CReplay::FinishPlayback(void)
DMAudio.SetEffectsFadeVol(127);
DMAudio.SetMusicFadeVol(127);
}
-#endif
-#if 0
-WRAPPER void CReplay::EmptyReplayBuffer(void) { EAXJMP(0x595BD0); }
-#else
void CReplay::EmptyReplayBuffer(void)
{
if (Mode == MODE_PLAYBACK)
@@ -1072,11 +1015,7 @@ void CReplay::EmptyReplayBuffer(void)
Record.m_pBase[Record.m_nOffset] = 0;
MarkEverythingAsNew();
}
-#endif
-#if 0
-WRAPPER void CReplay::ProcessReplayCamera(void) { EAXJMP(0x595C40); }
-#else
void CReplay::ProcessReplayCamera(void)
{
switch (CameraMode) {
@@ -1120,11 +1059,7 @@ void CReplay::ProcessReplayCamera(void)
RwMatrixUpdate(RwFrameGetMatrix(RwCameraGetFrame(TheCamera.m_pRwCamera)));
RwFrameUpdateObjects(RwCameraGetFrame(TheCamera.m_pRwCamera));
}
-#endif
-#if 0
-WRAPPER void CReplay::TriggerPlayback(uint8 cam_mode, float cam_x, float cam_y, float cam_z, bool load_scene) { EAXJMP(0x596030); }
-#else
void CReplay::TriggerPlayback(uint8 cam_mode, float cam_x, float cam_y, float cam_z, bool load_scene)
{
if (Mode != MODE_RECORD)
@@ -1174,11 +1109,7 @@ void CReplay::TriggerPlayback(uint8 cam_mode, float cam_x, float cam_y, float ca
if (cam_mode == REPLAYCAMMODE_ASSTORED)
TheCamera.CarZoomIndicator = 5.0f;
}
-#endif
-#if 0
-WRAPPER void CReplay::StoreStuffInMem(void) { EAXJMP(0x5961F0); }
-#else
void CReplay::StoreStuffInMem(void)
{
CPools::GetVehiclePool()->Store(pBuf0, pBuf1);
@@ -1223,11 +1154,7 @@ void CReplay::StoreStuffInMem(void)
StoreDetailedPedAnimation(ped, &pPedAnims[i]);
}
}
-#endif
-#if 0
-WRAPPER void CReplay::RestoreStuffFromMem(void) { EAXJMP(0x5966E0); }
-#else
void CReplay::RestoreStuffFromMem(void)
{
CPools::GetVehiclePool()->CopyBack(pBuf0, pBuf1);
@@ -1388,11 +1315,7 @@ void CReplay::RestoreStuffFromMem(void)
DMAudio.SetRadioInCar(OldRadioStation);
DMAudio.ChangeMusicMode(MUSICMODE_GAME);
}
-#endif
-#if 0
-WRAPPER void CReplay::EmptyPedsAndVehiclePools(void) { EAXJMP(0x5970E0); }
-#else
void CReplay::EmptyPedsAndVehiclePools(void)
{
int i = CPools::GetVehiclePool()->GetSize();
@@ -1412,11 +1335,7 @@ void CReplay::EmptyPedsAndVehiclePools(void)
delete p;
}
}
-#endif
-#if 0
-WRAPPER void CReplay::EmptyAllPools(void) { EAXJMP(0x5971B0); }
-#else
void CReplay::EmptyAllPools(void)
{
EmptyPedsAndVehiclePools();
@@ -1437,11 +1356,7 @@ void CReplay::EmptyAllPools(void)
delete d;
}
}
-#endif
-#if 0
-WRAPPER void CReplay::MarkEverythingAsNew(void) { EAXJMP(0x597280); }
-#else
void CReplay::MarkEverythingAsNew(void)
{
int i = CPools::GetVehiclePool()->GetSize();
@@ -1459,11 +1374,7 @@ void CReplay::MarkEverythingAsNew(void)
p->bHasAlreadyBeenRecorded = false;
}
}
-#endif
-#if 0
-WRAPPER void CReplay::SaveReplayToHD(void) { EAXJMP(0x597330); }
-#else
void CReplay::SaveReplayToHD(void)
{
CFileMgr::SetDirMyDocuments();
@@ -1494,11 +1405,7 @@ void CReplay::SaveReplayToHD(void)
CFileMgr::CloseFile(fw);
CFileMgr::SetDir("");
}
-#endif
-#if 0
-WRAPPER void PlayReplayFromHD(void) { EAXJMP(0x597420); }
-#else
void PlayReplayFromHD(void)
{
CFileMgr::SetDirMyDocuments();
@@ -1530,11 +1437,7 @@ void PlayReplayFromHD(void)
CReplay::bAllowLookAroundCam = true;
CReplay::StreamAllNecessaryCarsAndPeds();
}
-#endif
-#if 0
-WRAPPER void CReplay::StreamAllNecessaryCarsAndPeds(void) { EAXJMP(0x597560); }
-#else
void CReplay::StreamAllNecessaryCarsAndPeds(void)
{
for (int slot = 0; slot < NUM_REPLAYBUFFERS; slot++) {
@@ -1555,11 +1458,7 @@ void CReplay::StreamAllNecessaryCarsAndPeds(void)
}
CStreaming::LoadAllRequestedModels(false);
}
-#endif
-#if 0
-WRAPPER void CReplay::FindFirstFocusCoordinate(CVector *coord) { EAXJMP(0x5975E0); }
-#else
void CReplay::FindFirstFocusCoordinate(CVector *coord)
{
*coord = CVector(0.0f, 0.0f, 0.0f);
@@ -1574,11 +1473,7 @@ void CReplay::FindFirstFocusCoordinate(CVector *coord)
}
}
}
-#endif
-#if 0
-WRAPPER bool CReplay::ShouldStandardCameraBeProcessed(void) { EAXJMP(0x597680); }
-#else
bool CReplay::ShouldStandardCameraBeProcessed(void)
{
if (Mode != MODE_PLAYBACK)
@@ -1587,11 +1482,7 @@ bool CReplay::ShouldStandardCameraBeProcessed(void)
return false;
return FindPlayerVehicle() != nil;
}
-#endif
-#if 0
-WRAPPER void CReplay::ProcessLookAroundCam(void) { EAXJMP(0x5976C0); }
-#else
void CReplay::ProcessLookAroundCam(void)
{
if (!bAllowLookAroundCam)
@@ -1647,11 +1538,7 @@ void CReplay::ProcessLookAroundCam(void)
RwMatrixUpdate(RwFrameGetMatrix(RwCameraGetFrame(TheCamera.m_pRwCamera)));
RwFrameUpdateObjects(RwCameraGetFrame(TheCamera.m_pRwCamera));
}
-#endif
-#if 0
-WRAPPER size_t CReplay::FindSizeOfPacket(uint8 type) { EAXJMP(0x597CC0); }
-#else
size_t CReplay::FindSizeOfPacket(uint8 type)
{
switch (type) {
@@ -1669,11 +1556,7 @@ size_t CReplay::FindSizeOfPacket(uint8 type)
}
return 0;
}
-#endif
-#if 0
-WRAPPER void CReplay::Display(void) { EAXJMP(0x595EE0); }
-#else
void CReplay::Display()
{
static int TimeCount = 0;
@@ -1691,7 +1574,6 @@ void CReplay::Display()
if (Mode == MODE_PLAYBACK)
CFont::PrintString(SCREEN_SCALE_X(63.5f), SCREEN_SCALE_Y(30.0f), TheText.Get("REPLAY"));
}
-#endif
STARTPATCHES
InjectHook(0x592FE0, &CReplay::Init, PATCH_JUMP);
diff --git a/src/control/Script.cpp b/src/control/Script.cpp
index 14f55734..2ea5ee24 100644
--- a/src/control/Script.cpp
+++ b/src/control/Script.cpp
@@ -2842,9 +2842,6 @@ int8 CRunningScript::ProcessCommands200To299(int32 command)
return -1;
}
-#if 0
-WRAPPER int8 CRunningScript::ProcessCommand300To399(int32 command) { EAXJMP(0x43ED30); }
-#else
int8 CRunningScript::ProcessCommands300To399(int32 command)
{
switch (command) {
@@ -3576,11 +3573,7 @@ int8 CRunningScript::ProcessCommands300To399(int32 command)
}
return -1;
}
-#endif
-#if 0
-WRAPPER int8 CRunningScript::ProcessCommands400To499(int32 command) { EAXJMP(0x440CB0); }
-#else
int8 CRunningScript::ProcessCommands400To499(int32 command)
{
switch (command) {
@@ -4370,11 +4363,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command)
}
return -1;
}
-#endif
-#if 0
-WRAPPER int8 CRunningScript::ProcessCommands500To599(int32 command) { EAXJMP(0x4429C0); }
-#else
int8 CRunningScript::ProcessCommands500To599(int32 command)
{
switch (command) {
@@ -4633,7 +4622,7 @@ int8 CRunningScript::ProcessCommands500To599(int32 command)
infZ = *(float*)&ScriptParams[5];
supZ = *(float*)&ScriptParams[2];
}
- ScriptParams[0] = CGarages::AddOne(infX, infY, infZ, supX, supY, supZ, ScriptParams[6], 0);
+ ScriptParams[0] = CGarages::AddOne(infX, infY, infZ, supX, supY, supZ, (eGarageType)ScriptParams[6], 0);
StoreParameters(&m_nIp, 1);
return 0;
}
@@ -4658,7 +4647,7 @@ int8 CRunningScript::ProcessCommands500To599(int32 command)
infZ = *(float*)&ScriptParams[5];
supZ = *(float*)&ScriptParams[2];
}
- ScriptParams[0] = CGarages::AddOne(infX, infY, infZ, supX, supY, supZ, ScriptParams[6], ScriptParams[7]);
+ ScriptParams[0] = CGarages::AddOne(infX, infY, infZ, supX, supY, supZ, (eGarageType)ScriptParams[6], ScriptParams[7]);
StoreParameters(&m_nIp, 1);
return 0;
}
@@ -5201,11 +5190,7 @@ int8 CRunningScript::ProcessCommands500To599(int32 command)
}
return -1;
}
-#endif
-#if 0
-WRAPPER int8 CRunningScript::ProcessCommands600To699(int32 command) { EAXJMP(0x444B20); }
-#else
int8 CRunningScript::ProcessCommands600To699(int32 command)
{
switch (command){
@@ -5559,11 +5544,7 @@ int8 CRunningScript::ProcessCommands600To699(int32 command)
}
return -1;
}
-#endif
-#if 0
-WRAPPER int8 CRunningScript::ProcessCommands700To799(int32 command) { EAXJMP(0x4458A0); }
-#else
int8 CRunningScript::ProcessCommands700To799(int32 command)
{
switch (command){
@@ -6429,11 +6410,6 @@ int8 CRunningScript::ProcessCommands700To799(int32 command)
}
return -1;
}
-#endif
-
-#if 0
-WRAPPER int8 CRunningScript::ProcessCommands800To899(int32 command) { EAXJMP(0x448240); }
-#else
int8 CRunningScript::ProcessCommands800To899(int32 command)
{
CMatrix tmp_matrix;
@@ -7134,13 +7110,13 @@ int8 CRunningScript::ProcessCommands800To899(int32 command)
case COMMAND_OPEN_GARAGE:
{
CollectParameters(&m_nIp, 1);
- CGarages::Garages[ScriptParams[0]].OpenThisGarage();
+ CGarages::aGarages[ScriptParams[0]].OpenThisGarage();
return 0;
}
case COMMAND_CLOSE_GARAGE:
{
CollectParameters(&m_nIp, 1);
- CGarages::Garages[ScriptParams[0]].CloseThisGarage();
+ CGarages::aGarages[ScriptParams[0]].CloseThisGarage();
return 0;
}
case COMMAND_WARP_CHAR_FROM_CAR_TO_COORD:
@@ -7515,11 +7491,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command)
}
return -1;
}
-#endif
-#if 0
-WRAPPER int8 CRunningScript::ProcessCommands900To999(int32 command) { EAXJMP(0x44CB80); }
-#else
int8 CRunningScript::ProcessCommands900To999(int32 command)
{
char str[52];
@@ -8420,7 +8392,6 @@ int8 CRunningScript::ProcessCommands900To999(int32 command)
}
return -1;
}
-#endif
int8 CRunningScript::ProcessCommands1000To1099(int32 command)
{
@@ -9819,7 +9790,7 @@ void CTheScripts::UndoBuildingSwaps()
}
}
-void CTheScripts::UndoEntityVisibilitySettings()
+void CTheScripts::UndoEntityInvisibilitySettings()
{
for (int i = 0; i < MAX_NUM_INVISIBILITY_SETTINGS; i++) {
if (InvisibilitySettingArray[i]) {
@@ -11657,7 +11628,7 @@ InjectHook(0x439040, &CTheScripts::Process, PATCH_JUMP);
InjectHook(0x439400, &CTheScripts::StartTestScript, PATCH_JUMP);
InjectHook(0x439410, &CTheScripts::IsPlayerOnAMission, PATCH_JUMP);
InjectHook(0x44FD10, &CTheScripts::UndoBuildingSwaps, PATCH_JUMP);
-InjectHook(0x44FD60, &CTheScripts::UndoEntityVisibilitySettings, PATCH_JUMP);
+InjectHook(0x44FD60, &CTheScripts::UndoEntityInvisibilitySettings, PATCH_JUMP);
InjectHook(0x4534E0, &CTheScripts::ScriptDebugLine3D, PATCH_JUMP);
InjectHook(0x453550, &CTheScripts::RenderTheScriptDebugLines, PATCH_JUMP);
InjectHook(0x4535E0, &CTheScripts::SaveAllScripts, PATCH_JUMP);
diff --git a/src/control/Script.h b/src/control/Script.h
index b6844b6c..fbcdce48 100644
--- a/src/control/Script.h
+++ b/src/control/Script.h
@@ -281,7 +281,7 @@ public:
static void ClearSpaceForMissionEntity(const CVector&, CEntity*);
static void UndoBuildingSwaps();
- static void UndoEntityVisibilitySettings();
+ static void UndoEntityInvisibilitySettings();
static void ScriptDebugLine3D(float x1, float y1, float z1, float x2, float y2, float z2, uint32 col, uint32 col2);
static void RenderTheScriptDebugLines();
diff --git a/src/core/Cam.cpp b/src/core/Cam.cpp
index 546dfde0..5844b61a 100644
--- a/src/core/Cam.cpp
+++ b/src/core/Cam.cpp
@@ -28,6 +28,7 @@ const float DefaultFOV = 70.0f; // beta: 80.0f
bool PrintDebugCode = false;
int16 &DebugCamMode = *(int16*)0x95CCF2;
+bool bFreeCam = false;
void
CCam::Init(void)
@@ -138,6 +139,11 @@ CCam::Process(void)
if(CCamera::m_bUseMouse3rdPerson)
Process_FollowPedWithMouse(CameraTarget, TargetOrientation, SpeedVar, TargetSpeedVar);
else
+#ifdef FREE_CAM
+ if(bFreeCam)
+ Process_FollowPed_Rotation(CameraTarget, TargetOrientation, SpeedVar, TargetSpeedVar);
+ else
+#endif
Process_FollowPed(CameraTarget, TargetOrientation, SpeedVar, TargetSpeedVar);
break;
// case MODE_AIMING:
@@ -4369,7 +4375,209 @@ CCam::Process_FollowPed_WithBinding(const CVector &CameraTarget, float TargetOri
GetVectorsReadyForRW();
}
+#ifdef FREE_CAM
+void
+CCam::Process_FollowPed_Rotation(const CVector &CameraTarget, float TargetOrientation, float, float)
+{
+ FOV = DefaultFOV;
+
+ const float MinDist = 2.0f;
+ const float MaxDist = 2.0f + TheCamera.m_fPedZoomValueSmooth;
+ const float BaseOffset = 0.75f; // base height of camera above target
+
+ CVector TargetCoors = CameraTarget;
+
+ TargetCoors.z += m_fSyphonModeTargetZOffSet;
+ TargetCoors = DoAverageOnVector(TargetCoors);
+ TargetCoors.z += BaseOffset; // add offset so alpha evens out to 0
+// TargetCoors.z += m_fRoadOffSet;
+
+ CVector Dist = Source - TargetCoors;
+ CVector ToCam;
+
+ bool Shooting = false;
+ if(((CPed*)CamTargetEntity)->GetWeapon()->m_eWeaponType != WEAPONTYPE_UNARMED)
+ if(CPad::GetPad(0)->GetWeapon())
+ Shooting = true;
+ if(((CPed*)CamTargetEntity)->GetWeapon()->m_eWeaponType == WEAPONTYPE_DETONATOR ||
+ ((CPed*)CamTargetEntity)->GetWeapon()->m_eWeaponType == WEAPONTYPE_BASEBALLBAT)
+ Shooting = false;
+
+
+ if(ResetStatics){
+ // Coming out of top down here probably
+ // so keep Beta, reset alpha and calculate vectors
+ Beta = CGeneral::GetATanOfXY(Dist.x, Dist.y);
+ Alpha = 0.0f;
+
+ Dist = MaxDist*CVector(Cos(Alpha) * Cos(Beta), Cos(Alpha) * Sin(Beta), Sin(Alpha));
+ Source = TargetCoors + Dist;
+
+ ResetStatics = false;
+ }
+
+ // Drag the camera along at the look-down offset
+ float CamDist = Dist.Magnitude();
+ if(CamDist == 0.0f)
+ Dist = CVector(1.0f, 1.0f, 0.0f);
+ else if(CamDist < MinDist)
+ Dist *= MinDist/CamDist;
+ else if(CamDist > MaxDist)
+ Dist *= MaxDist/CamDist;
+ CamDist = Dist.Magnitude();
+
+ // Beta = 0 is looking east, HALFPI is north, &c.
+ // Alpha positive is looking up
+ float GroundDist = Dist.Magnitude2D();
+ Beta = CGeneral::GetATanOfXY(-Dist.x, -Dist.y);
+ Alpha = CGeneral::GetATanOfXY(GroundDist, -Dist.z);
+ while(Beta >= PI) Beta -= 2.0f*PI;
+ while(Beta < -PI) Beta += 2.0f*PI;
+ while(Alpha >= PI) Alpha -= 2.0f*PI;
+ while(Alpha < -PI) Alpha += 2.0f*PI;
+
+ // Look around
+ bool UseMouse = false;
+ float MouseX = CPad::GetPad(0)->GetMouseX();
+ float MouseY = CPad::GetPad(0)->GetMouseY();
+ float LookLeftRight, LookUpDown;
+ if((MouseX != 0.0f || MouseY != 0.0f) && !CPad::GetPad(0)->ArePlayerControlsDisabled()){
+ UseMouse = true;
+ LookLeftRight = -2.5f*MouseX;
+ LookUpDown = 4.0f*MouseY;
+ }else{
+ LookLeftRight = -CPad::GetPad(0)->LookAroundLeftRight();
+ LookUpDown = CPad::GetPad(0)->LookAroundUpDown();
+ }
+ float AlphaOffset, BetaOffset;
+ if(UseMouse){
+ BetaOffset = LookLeftRight * TheCamera.m_fMouseAccelHorzntl * FOV/80.0f;
+ AlphaOffset = LookUpDown * TheCamera.m_fMouseAccelVertical * FOV/80.0f;
+ }else{
+ BetaOffset = LookLeftRight * fStickSens * (0.5f/10.0f) * FOV/80.0f * CTimer::GetTimeStep();
+ AlphaOffset = LookUpDown * fStickSens * (0.3f/10.0f) * FOV/80.0f * CTimer::GetTimeStep();
+ }
+
+ // Stop centering once stick has been touched
+ if(BetaOffset)
+ Rotating = false;
+
+ Beta += BetaOffset;
+ Alpha += AlphaOffset;
+ while(Beta >= PI) Beta -= 2.0f*PI;
+ while(Beta < -PI) Beta += 2.0f*PI;
+ if(Alpha > DEGTORAD(45.0f)) Alpha = DEGTORAD(45.0f);
+ if(Alpha < -DEGTORAD(89.5f)) Alpha = -DEGTORAD(89.5f);
+
+
+ float BetaDiff = TargetOrientation+PI - Beta;
+ while(BetaDiff >= PI) BetaDiff -= 2.0f*PI;
+ while(BetaDiff < -PI) BetaDiff += 2.0f*PI;
+ float TargetAlpha = Alpha;
+ // 12deg to account for our little height offset. we're not working on the true alpha here
+ const float AlphaLimitUp = DEGTORAD(15.0f) + DEGTORAD(12.0f);
+ const float AlphaLimitDown = -DEGTORAD(15.0f) + DEGTORAD(12.0f);
+ if(Abs(BetaDiff) < DEGTORAD(25.0f) && ((CPed*)CamTargetEntity)->GetMoveSpeed().Magnitude2D() > 0.01f){
+ // Limit alpha when player is walking towards camera
+ if(TargetAlpha > AlphaLimitUp) TargetAlpha = AlphaLimitUp;
+ if(TargetAlpha < AlphaLimitDown) TargetAlpha = AlphaLimitDown;
+ }
+
+ WellBufferMe(TargetAlpha, &Alpha, &AlphaSpeed, 0.2f, 0.1f, true);
+
+ if(CPad::GetPad(0)->ForceCameraBehindPlayer() || Shooting){
+ m_fTargetBeta = TargetOrientation;
+ Rotating = true;
+ }
+
+ if(Rotating){
+ WellBufferMe(m_fTargetBeta, &Beta, &BetaSpeed, 0.1f, 0.06f, true);
+ float DeltaBeta = m_fTargetBeta - Beta;
+ while(DeltaBeta >= PI) DeltaBeta -= 2*PI;
+ while(DeltaBeta < -PI) DeltaBeta += 2*PI;
+ if(Abs(DeltaBeta) < 0.06f)
+ Rotating = false;
+ }
+
+
+ Front = CVector(Cos(Alpha) * Cos(Beta), Cos(Alpha) * Sin(Beta), Sin(Alpha));
+ Source = TargetCoors - Front*CamDist;
+ TargetCoors.z -= BaseOffset; // now get back to the real target coors again
+
+ m_cvecTargetCoorsForFudgeInter = TargetCoors;
+
+
+ Front = TargetCoors - Source;
+ Front.Normalise();
+
+
+
+ /*
+ * Handle collisions - taken from FollowPedWithMouse
+ */
+
+ CEntity *entity;
+ CColPoint colPoint;
+ // Clip Source and fix near clip
+ CWorld::pIgnoreEntity = CamTargetEntity;
+ entity = nil;
+ if(CWorld::ProcessLineOfSight(TargetCoors, Source, colPoint, entity, true, true, true, true, false, false, true)){
+ float PedColDist = (TargetCoors - colPoint.point).Magnitude();
+ float ColCamDist = CamDist - PedColDist;
+ if(entity->IsPed() && ColCamDist > 1.0f){
+ // Ped in the way but not clipping through
+ if(CWorld::ProcessLineOfSight(colPoint.point, Source, colPoint, entity, true, true, true, true, false, false, true)){
+ PedColDist = (TargetCoors - colPoint.point).Magnitude();
+ Source = colPoint.point;
+ if(PedColDist < 0.9f + 0.3f)
+ RwCameraSetNearClipPlane(Scene.camera, max(PedColDist-0.3f, 0.05f));
+ }else{
+ RwCameraSetNearClipPlane(Scene.camera, min(ColCamDist-0.35f, 0.9f));
+ }
+ }else{
+ Source = colPoint.point;
+ if(PedColDist < 0.9f + 0.3f)
+ RwCameraSetNearClipPlane(Scene.camera, max(PedColDist-0.3f, 0.05f));
+ }
+ }
+ CWorld::pIgnoreEntity = nil;
+
+ float ViewPlaneHeight = Tan(DEGTORAD(FOV) / 2.0f);
+ float ViewPlaneWidth = ViewPlaneHeight * CDraw::FindAspectRatio() * fTweakFOV;
+ float Near = RwCameraGetNearClipPlane(Scene.camera);
+ float radius = ViewPlaneWidth*Near;
+ entity = CWorld::TestSphereAgainstWorld(Source + Front*Near, radius, nil, true, true, false, true, false, false);
+ int i = 0;
+ while(entity){
+ CVector CamToCol = gaTempSphereColPoints[0].point - Source;
+ float frontDist = DotProduct(CamToCol, Front);
+ float dist = (CamToCol - Front*frontDist).Magnitude() / ViewPlaneWidth;
+
+ // Try to decrease near clip
+ dist = max(min(Near, dist), 0.1f);
+ if(dist < Near)
+ RwCameraSetNearClipPlane(Scene.camera, dist);
+
+ // Move forward a bit
+ if(dist == 0.1f)
+ Source += (TargetCoors - Source)*0.3f;
+
+ // Keep testing
+ entity = CWorld::TestSphereAgainstWorld(Source + Front*Near, radius, nil, true, true, false, true, false, false);
+
+ i++;
+ if(i > 5)
+ entity = nil;
+ }
+
+ GetVectorsReadyForRW();
+}
+#endif
+
STARTPATCHES
+#ifdef FREE_CAM
+ Nop(0x468E7B, 0x468E90-0x468E7B); // disable first person
+#endif
InjectHook(0x456F40, WellBufferMe, PATCH_JUMP);
InjectHook(0x458410, &CCam::Init, PATCH_JUMP);
InjectHook(0x4582F0, &CCam::GetVectorsReadyForRW, PATCH_JUMP);
diff --git a/src/core/Camera.h b/src/core/Camera.h
index 982620a3..3dc74fe7 100644
--- a/src/core/Camera.h
+++ b/src/core/Camera.h
@@ -221,6 +221,9 @@ struct CCam
// CCam::Process_Blood_On_The_Tracks
// CCam::Process_Cam_Running_Side_Train
// CCam::Process_Cam_On_Train_Roof
+
+ // custom stuff
+ void Process_FollowPed_Rotation(const CVector &CameraTarget, float TargetOrientation, float, float);
};
static_assert(sizeof(CCam) == 0x1A4, "CCam: wrong size");
static_assert(offsetof(CCam, Alpha) == 0xA8, "CCam: error");
diff --git a/src/core/CutsceneMgr.cpp b/src/core/CutsceneMgr.cpp
index a3ff2fd0..283f34b8 100644
--- a/src/core/CutsceneMgr.cpp
+++ b/src/core/CutsceneMgr.cpp
@@ -183,7 +183,7 @@ CCutsceneMgr::LoadCutsceneData(const char *szCutsceneName)
ms_pCutsceneDir->ReadDirFile("ANIM\\CUTS.DIR");
CStreaming::RemoveUnusedModelsInLoadedList();
- CGame::DrasticTidyUpMemory();
+ CGame::DrasticTidyUpMemory(true);
strcpy(ms_cutsceneName, szCutsceneName);
file = CFileMgr::OpenFile("ANIM\\CUTS.IMG", "rb");
@@ -374,8 +374,7 @@ CCutsceneMgr::DeleteCutsceneData(void)
DMAudio.ChangeMusicMode(MUSICMODE_GAME);
}
CTimer::Stop();
- //TheCamera.GetScreenFadeStatus() == 2; // what for??
- CGame::DrasticTidyUpMemory();
+ CGame::DrasticTidyUpMemory(TheCamera.GetScreenFadeStatus() == 2);
CTimer::Update();
}
diff --git a/src/core/EventList.cpp b/src/core/EventList.cpp
index d72e32c4..d1c76f33 100644
--- a/src/core/EventList.cpp
+++ b/src/core/EventList.cpp
@@ -209,21 +209,9 @@ CEventList::ReportCrimeForEvent(eEventType type, int32 crimeId, bool copsDontCar
case EVENT_CAR_SET_ON_FIRE: crime = CRIME_VEHICLE_BURNED; break;
default: crime = CRIME_NONE; break;
}
-
-#ifdef VC_PED_PORTS
- if (crime == CRIME_HIT_PED && ((CPed*)crimeId)->IsPointerValid() &&
- FindPlayerPed()->m_pWanted->m_nWantedLevel == 0 && ((CPed*)crimeId)->bBeingChasedByPolice) {
-
- if(!((CPed*)crimeId)->DyingOrDead()) {
- sprintf(gString, "$50 Good Citizen Bonus!");
- AsciiToUnicode(gString, gUString);
- CMessages::AddBigMessage(gUString, 5000, 0);
- CWorld::Players[CWorld::PlayerInFocus].m_nMoney += 50;
- }
- } else
-#endif
- if(crime == CRIME_NONE)
- return;
+
+ if(crime == CRIME_NONE)
+ return;
CVector playerPedCoors = FindPlayerPed()->GetPosition();
CVector playerCoors = FindPlayerCoors();
diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp
index a002835b..72d7d912 100644
--- a/src/core/Frontend.cpp
+++ b/src/core/Frontend.cpp
@@ -1354,23 +1354,39 @@ void CMenuManager::DrawFrontEndNormal()
m_aFrontEndSprites[currentSprite].Draw(CRect(MENU_X_LEFT_ALIGNED(50.0f), MENU_Y(50.0f), MENU_X_RIGHT_ALIGNED(50.0f), SCREEN_SCALE_FROM_BOTTOM(95.0f)), CRGBA(255, 255, 255, m_nMenuFadeAlpha > 255 ? 255 : m_nMenuFadeAlpha));
+ static float fadeAlpha = 0.0f;
+ static int lastState = 0;
+
+ // reverseAlpha = PS2 fading (wait for 255->0, then change screen)
if (m_nMenuFadeAlpha < 255) {
- static uint32 LastFade = 0;
+ if (lastState == 1 && !reverseAlpha)
+ fadeAlpha = 0.f;
if (m_nMenuFadeAlpha <= 0 && reverseAlpha) {
reverseAlpha = false;
ChangeScreen(pendingScreen, pendingOption, true, false);
} else {
+ float timestep = CTimer::GetCurrentTimeInCycles() / (float)CTimer::GetCyclesPerMillisecond();
+
+ // +20 per every 33 ms (1000.f/30.f - original frame limiter fps)
if (!reverseAlpha)
- m_nMenuFadeAlpha += min((CTimer::GetTimeInMillisecondsPauseMode() - LastFade) / 33.0f, 1.0f) * 20.0f;
+ fadeAlpha += (timestep * 100.f) * 20.f / 33.f;
else
- m_nMenuFadeAlpha = max(0, m_nMenuFadeAlpha - min((CTimer::GetTimeInMillisecondsPauseMode() - LastFade) / 33.0f, 1.0f) * 30.0f);
+ fadeAlpha = max(0.0f, fadeAlpha - (timestep * 100.f) * 30.f / 33.f);
- LastFade = CTimer::GetTimeInMillisecondsPauseMode();
+ m_nMenuFadeAlpha = fadeAlpha;
}
+ lastState = 0;
} else {
- if (reverseAlpha)
- m_nMenuFadeAlpha -= 20;
+ if (lastState == 0) fadeAlpha = 255.f;
+
+ if (reverseAlpha) {
+ float timestep = CTimer::GetCurrentTimeInCycles() / (float)CTimer::GetCyclesPerMillisecond();
+ fadeAlpha -= (timestep * 100.f) * 30.f / 33.f;
+
+ m_nMenuFadeAlpha = fadeAlpha;
+ }
+ lastState = 1;
// TODO: what is this? waiting mouse?
if(field_518 == 4){
@@ -1568,13 +1584,20 @@ void CMenuManager::DrawFrontEndNormal()
}
if (m_nMenuFadeAlpha < 255) {
- static uint32 LastFade = 0;
- // Famous transparent menu bug. 33.0f = 1000.f/30.f (original frame limiter fps)
+ // Famous transparent menu bug
#ifdef FIX_BUGS
- m_nMenuFadeAlpha += min((CTimer::GetTimeInMillisecondsPauseMode() - LastFade) / 33.0f, 1.0f) * 20.0f;
- LastFade = CTimer::GetTimeInMillisecondsPauseMode();
+ static float fadeAlpha = 0.0f;
+ if (m_nMenuFadeAlpha == 0 && fadeAlpha > 1.0f) fadeAlpha = 0.0f;
+
+ float timestep = CTimer::GetCurrentTimeInCycles() / (float)CTimer::GetCyclesPerMillisecond();
+
+ // +20 per every 33 ms (1000.f/30.f - original frame limiter fps)
+ fadeAlpha += (timestep * 100.f) * 20.f / 33.f;
+ m_nMenuFadeAlpha = fadeAlpha;
#else
+ static uint32 LastFade = 0;
+
if(CTimer::GetTimeInMillisecondsPauseMode() - LastFade > 10){
m_nMenuFadeAlpha += 20;
LastFade = CTimer::GetTimeInMillisecondsPauseMode();
@@ -1694,9 +1717,6 @@ int CMenuManager::GetStartOptionsCntrlConfigScreens()
}
#endif
-#if DONT_USE_SUSPICIOUS_FUNCS
-WRAPPER void CMenuManager::InitialiseChangedLanguageSettings() { EAXJMP(0x47A4D0); }
-#else
void CMenuManager::InitialiseChangedLanguageSettings()
{
if (m_bFrontEnd_ReloadObrTxtGxt) {
@@ -1735,7 +1755,6 @@ void CMenuManager::InitialiseChangedLanguageSettings()
}
}
}
-#endif
void CMenuManager::LoadAllTextures()
{
diff --git a/src/core/Game.cpp b/src/core/Game.cpp
index 3170ab6c..8571e93e 100644
--- a/src/core/Game.cpp
+++ b/src/core/Game.cpp
@@ -1,7 +1,14 @@
+#pragma warning( push )
+#pragma warning( disable : 4005)
+#define DIRECTINPUT_VERSION 0x0800
+#include <dinput.h>
+#pragma warning( pop )
#include "common.h"
+#include "win.h"
#include "patcher.h"
#include "Game.h"
#include "main.h"
+#include "RwHelper.h"
#include "Accident.h"
#include "Antennas.h"
#include "Bridge.h"
@@ -17,6 +24,7 @@
#include "Cranes.h"
#include "Credits.h"
#include "CutsceneMgr.h"
+#include "DMAudio.h"
#include "Darkel.h"
#include "Debug.h"
#include "EventList.h"
@@ -28,26 +36,32 @@
#include "Frontend.h"
#include "GameLogic.h"
#include "Garages.h"
+#include "GenericGameStorage.h"
#include "Glass.h"
+#include "HandlingMgr.h"
#include "Heli.h"
+#include "Hud.h"
#include "IniFile.h"
+#include "Lights.h"
+#include "MBlur.h"
#include "Messages.h"
#include "Pad.h"
#include "Particle.h"
+#include "ParticleObject.h"
+#include "PedRoutes.h"
#include "Phones.h"
#include "Pickups.h"
#include "Plane.h"
+#include "PlayerSkin.h"
#include "Population.h"
+#include "Radar.h"
#include "Record.h"
+#include "References.h"
#include "Renderer.h"
#include "Replay.h"
-#include "References.h"
-#include "Radar.h"
#include "Restart.h"
#include "RoadBlocks.h"
-#include "PedRoutes.h"
#include "Rubbish.h"
-#include "RwHelper.h"
#include "SceneEdit.h"
#include "Script.h"
#include "Shadows.h"
@@ -56,11 +70,14 @@
#include "Sprite2d.h"
#include "Stats.h"
#include "Streaming.h"
+#include "SurfaceTable.h"
+#include "TempColModels.h"
#include "TimeCycle.h"
#include "TrafficLights.h"
#include "Train.h"
#include "TxdStore.h"
#include "User.h"
+#include "VisibilityPlugins.h"
#include "WaterCannon.h"
#include "WaterLevel.h"
#include "Weapon.h"
@@ -70,6 +87,10 @@
#include "ZoneCull.h"
#include "Zones.h"
+
+
+#define DEFAULT_VIEWWINDOW (0.7f)
+
eLevelName &CGame::currLevel = *(eLevelName*)0x941514;
bool &CGame::bDemoMode = *(bool*)0x5F4DD0;
bool &CGame::nastyGame = *(bool*)0x5F4DD4;
@@ -82,6 +103,7 @@ char *CGame::aDatFile = (char*)0x773A48;
bool CGame::russianGame = false;
#endif
+int &gameTxdSlot = *(int*)0x628D88;
bool
CGame::InitialiseOnceBeforeRW(void)
@@ -92,7 +114,139 @@ CGame::InitialiseOnceBeforeRW(void)
return true;
}
-int &gameTxdSlot = *(int*)0x628D88;
+bool
+CGame::InitialiseRenderWare(void)
+{
+ _TexturePoolsInitialise();
+
+ CTxdStore::Initialise();
+ CVisibilityPlugins::Initialise();
+
+ /* Create camera */
+ Scene.camera = CameraCreate(RsGlobal.width, RsGlobal.height, TRUE);
+ ASSERT(Scene.camera != nil);
+ if (!Scene.camera)
+ {
+ return (false);
+ }
+
+ RwCameraSetFarClipPlane(Scene.camera, 2000.0f);
+ RwCameraSetNearClipPlane(Scene.camera, 0.9f);
+
+ CameraSize(Scene.camera, nil, DEFAULT_VIEWWINDOW, DEFAULT_ASPECT_RATIO);
+
+ /* Create a world */
+ RwBBox bbox;
+
+ bbox.sup.x = bbox.sup.y = bbox.sup.z = 10000.0f;
+ bbox.inf.x = bbox.inf.y = bbox.inf.z = -10000.0f;
+
+ Scene.world = RpWorldCreate(&bbox);
+ ASSERT(Scene.world != nil);
+ if (!Scene.world)
+ {
+ CameraDestroy(Scene.camera);
+ Scene.camera = nil;
+ return (false);
+ }
+
+ /* Add the camera to the world */
+ RpWorldAddCamera(Scene.world, Scene.camera);
+ LightsCreate(Scene.world);
+
+ CreateDebugFont();
+
+ CFont::Initialise();
+ CHud::Initialise();
+ CPlayerSkin::Initialise();
+
+ return (true);
+}
+
+void CGame::ShutdownRenderWare(void)
+{
+ CMBlur::MotionBlurClose();
+ DestroySplashScreen();
+ CHud::Shutdown();
+ CFont::Shutdown();
+
+ for ( int32 i = 0; i < NUMPLAYERS; i++ )
+ CWorld::Players[i].DeletePlayerSkin();
+
+ CPlayerSkin::Shutdown();
+
+ DestroyDebugFont();
+
+ /* Destroy world */
+ LightsDestroy(Scene.world);
+ RpWorldRemoveCamera(Scene.world, Scene.camera);
+ RpWorldDestroy(Scene.world);
+
+ /* destroy camera */
+ CameraDestroy(Scene.camera);
+
+ Scene.world = nil;
+ Scene.camera = nil;
+
+ CVisibilityPlugins::Shutdown();
+
+ _TexturePoolsShutdown();
+}
+
+bool CGame::InitialiseOnceAfterRW(void)
+{
+ TheText.Load();
+ DMAudio.Initialise();
+ CTimer::Initialise();
+ CTempColModels::Initialise();
+ mod_HandlingManager.Initialise();
+ CSurfaceTable::Initialise("DATA\\SURFACE.DAT");
+ CPedStats::Initialise();
+ CTimeCycle::Initialise();
+
+ if ( DMAudio.GetNum3DProvidersAvailable() == 0 )
+ FrontEndMenuManager.m_nPrefsAudio3DProviderIndex = -1;
+
+ if ( FrontEndMenuManager.m_nPrefsAudio3DProviderIndex == -99 || FrontEndMenuManager.m_nPrefsAudio3DProviderIndex == -2 )
+ {
+ CMenuManager::m_PrefsSpeakers = 0;
+
+ for ( int32 i = 0; i < DMAudio.GetNum3DProvidersAvailable(); i++ )
+ {
+ wchar buff[64];
+
+ char *name = DMAudio.Get3DProviderName(i);
+ AsciiToUnicode(name, buff);
+ char *providername = UnicodeToAscii(buff);
+ strupr(providername);
+
+ if ( !strcmp(providername, "MILES FAST 2D POSITIONAL AUDIO") )
+ {
+ FrontEndMenuManager.m_nPrefsAudio3DProviderIndex = i;
+ break;
+ }
+ }
+ }
+
+ DMAudio.SetCurrent3DProvider(FrontEndMenuManager.m_nPrefsAudio3DProviderIndex);
+ DMAudio.SetSpeakerConfig(CMenuManager::m_PrefsSpeakers);
+ DMAudio.SetDynamicAcousticModelingStatus(CMenuManager::m_PrefsDMA);
+ DMAudio.SetMusicMasterVolume(CMenuManager::m_PrefsMusicVolume);
+ DMAudio.SetEffectsMasterVolume(CMenuManager::m_PrefsSfxVolume);
+ DMAudio.SetEffectsFadeVol(127);
+ DMAudio.SetMusicFadeVol(127);
+ CWorld::Players[0].SetPlayerSkin(CMenuManager::m_PrefsSkinFile);
+
+ return true;
+}
+
+void
+CGame::FinalShutdown(void)
+{
+ CTxdStore::Shutdown();
+ CPedStats::Shutdown();
+ CdStreamShutdown();
+}
bool CGame::Initialise(const char* datFile)
{
@@ -163,7 +317,7 @@ bool CGame::Initialise(const char* datFile)
CStreaming::Init();
} else {
CStreaming::Init();
- if (ConvertTextures()) {
+ if (CreateTxdImageForVideoCard()) {
CStreaming::Shutdown();
CdStreamAddImage("MODELS\\TXD.IMG");
CStreaming::Init();
@@ -201,7 +355,7 @@ bool CGame::Initialise(const char* datFile)
CSceneEdit::Init();
LoadingScreen("Loading the Game", "Load scripts", nil);
CTheScripts::Init();
- CGangs::Initialize();
+ CGangs::Initialise();
LoadingScreen("Loading the Game", "Setup game variables", nil);
CClock::Initialise(1000);
CHeli::InitHelis();
@@ -230,16 +384,227 @@ bool CGame::Initialise(const char* datFile)
CTheScripts::Process();
TheCamera.Process();
LoadingScreen("Loading the Game", "Load scene", nil);
- CModelInfo::RemoveColModelsFromOtherLevels(CGame::currLevel);
- CCollision::ms_collisionInMemory = CGame::currLevel;
+ CModelInfo::RemoveColModelsFromOtherLevels(currLevel);
+ CCollision::ms_collisionInMemory = currLevel;
for (int i = 0; i < MAX_PADS; i++)
CPad::GetPad(i)->Clear(true);
return true;
}
-#if 0
-WRAPPER void CGame::Process(void) { EAXJMP(0x48C850); }
-#else
+bool CGame::ShutDown(void)
+{
+ CReplay::FinishPlayback();
+ CPlane::Shutdown();
+ CTrain::Shutdown();
+ CSpecialFX::Shutdown();
+#ifndef PS2
+ CGarages::Shutdown();
+#endif
+ CMovingThings::Shutdown();
+ gPhoneInfo.Shutdown();
+ CWeapon::ShutdownWeapons();
+ CPedType::Shutdown();
+ CMBlur::MotionBlurClose();
+
+ for (int32 i = 0; i < NUMPLAYERS; i++)
+ {
+ if ( CWorld::Players[i].m_pPed )
+ {
+ CWorld::Remove(CWorld::Players[i].m_pPed);
+ delete CWorld::Players[i].m_pPed;
+ CWorld::Players[i].m_pPed = nil;
+ }
+
+ CWorld::Players[i].Clear();
+ }
+
+ CRenderer::Shutdown();
+ CWorld::ShutDown();
+ DMAudio.DestroyAllGameCreatedEntities();
+ CModelInfo::ShutDown();
+ CAnimManager::Shutdown();
+ CCutsceneMgr::Shutdown();
+ CVehicleModelInfo::DeleteVehicleColourTextures();
+ CVehicleModelInfo::ShutdownEnvironmentMaps();
+ CRadar::Shutdown();
+ CStreaming::Shutdown();
+ CTxdStore::GameShutdown();
+ CCollision::Shutdown();
+ CWaterLevel::Shutdown();
+ CRubbish::Shutdown();
+ CClouds::Shutdown();
+ CShadows::Shutdown();
+ CCoronas::Shutdown();
+ CSkidmarks::Shutdown();
+ CWeaponEffects::Shutdown();
+ CParticle::Shutdown();
+ CPools::ShutDown();
+ CTxdStore::RemoveTxdSlot(gameTxdSlot);
+ CdStreamRemoveImages();
+ return true;
+}
+
+void CGame::ReInitGameObjectVariables(void)
+{
+ CGameLogic::InitAtStartOfGame();
+ TheCamera.CCamera::Init();
+ TheCamera.SetRwCamera(Scene.camera);
+ CDebug::DebugInitTextBuffer();
+ CWeather::Init();
+ CUserDisplay::Init();
+ CMessages::Init();
+ CRestart::Initialise();
+ CWorld::bDoingCarCollisions = false;
+ CHud::ReInitialise();
+ CRadar::Initialise();
+ CCarCtrl::ReInit();
+ CTimeCycle::Initialise();
+ CDraw::SetFOV(120.0f);
+ CDraw::ms_fLODDistance = 500.0f;
+ CStreaming::RequestBigBuildings(LEVEL_NONE);
+ CStreaming::LoadAllRequestedModels(false);
+ CPed::Initialise();
+ CEventList::Initialise();
+ CWeapon::InitialiseWeapons();
+ CPopulation::Initialise();
+
+ for (int i = 0; i < NUMPLAYERS; i++)
+ CWorld::Players[i].Clear();
+
+ CWorld::PlayerInFocus = 0;
+ CAntennas::Init();
+ CGlass::Init();
+ gPhoneInfo.Initialise();
+ CTheScripts::Init();
+ CGangs::Initialise();
+ CTimer::Initialise();
+ CClock::Initialise(1000);
+ CTheCarGenerators::Init();
+ CHeli::InitHelis();
+ CMovingThings::Init();
+ CDarkel::Init();
+ CStats::Init();
+ CPickups::Init();
+ CPacManPickups::Init();
+ CGarages::Init();
+ CSpecialFX::Init();
+ CWaterCannons::Init();
+ CParticle::ReloadConfig();
+ CCullZones::ResolveVisibilities();
+
+ if ( !FrontEndMenuManager.m_bLoadingSavedGame )
+ {
+ CCranes::InitCranes();
+ CTheScripts::StartTestScript();
+ CTheScripts::Process();
+ TheCamera.Process();
+ CTrain::InitTrains();
+ CPlane::InitPlanes();
+ }
+
+ for (int32 i = 0; i < MAX_PADS; i++)
+ CPad::GetPad(i)->Clear(true);
+}
+
+void CGame::ReloadIPLs(void)
+{
+ CTimer::Stop();
+ CWorld::RemoveStaticObjects();
+ ThePaths.Init();
+ CCullZones::Init();
+ CFileLoader::ReloadPaths("GTA3.IDE");
+ CFileLoader::LoadScene("INDUST.IPL");
+ CFileLoader::LoadScene("COMMER.IPL");
+ CFileLoader::LoadScene("SUBURBAN.IPL");
+ CFileLoader::LoadScene("CULL.IPL");
+ ThePaths.PreparePathData();
+ CTrafficLights::ScanForLightsOnMap();
+ CRoadBlocks::Init();
+ CCranes::InitCranes();
+ CGarages::Init();
+ CWorld::RepositionCertainDynamicObjects();
+ CCullZones::ResolveVisibilities();
+ CRenderer::SortBIGBuildings();
+ CTimer::Update();
+}
+
+void CGame::ShutDownForRestart(void)
+{
+ CReplay::FinishPlayback();
+ CReplay::EmptyReplayBuffer();
+ DMAudio.DestroyAllGameCreatedEntities();
+
+ for (int i = 0; i < NUMPLAYERS; i++)
+ CWorld::Players[i].Clear();
+
+ CGarages::SetAllDoorsBackToOriginalHeight();
+ CTheScripts::UndoBuildingSwaps();
+ CTheScripts::UndoEntityInvisibilitySettings();
+ CWorld::ClearForRestart();
+ CTimer::Shutdown();
+ CStreaming::FlushRequestList();
+ CStreaming::DeleteAllRwObjects();
+ CStreaming::RemoveAllUnusedModels();
+ CStreaming::ms_disableStreaming = false;
+ CRadar::RemoveRadarSections();
+ FrontEndMenuManager.UnloadTextures();
+ CParticleObject::RemoveAllParticleObjects();
+ CPedType::Shutdown();
+ CSpecialFX::Shutdown();
+ TidyUpMemory(true, false);
+}
+
+void CGame::InitialiseWhenRestarting(void)
+{
+ CRect rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
+ CRGBA color(255, 255, 255, 255);
+
+ CTimer::Initialise();
+ CSprite2d::SetRecipNearClip();
+
+ b_FoundRecentSavedGameWantToLoad = false;
+
+ TheCamera.Init();
+
+ if ( FrontEndMenuManager.m_bLoadingSavedGame == true )
+ {
+ RestoreForStartLoad();
+ CStreaming::LoadScene(TheCamera.GetPosition());
+ }
+
+ ReInitGameObjectVariables();
+
+ if ( FrontEndMenuManager.m_bLoadingSavedGame == true )
+ {
+ if ( GenericLoad() == true )
+ {
+ DMAudio.ResetTimers(CTimer::GetTimeInMilliseconds());
+ CTrain::InitTrains();
+ CPlane::InitPlanes();
+ }
+ else
+ {
+ for ( int32 i = 0; i < 50; i++ )
+ {
+ HandleExit();
+ FrontEndMenuManager.MessageScreen("FED_LFL"); // Loading save game has failed. The game will restart now.
+ }
+
+ ShutDownForRestart();
+ CTimer::Stop();
+ CTimer::Initialise();
+ FrontEndMenuManager.m_bLoadingSavedGame = false;
+ ReInitGameObjectVariables();
+ currLevel = LEVEL_INDUSTRIAL;
+ CCollision::SortOutCollisionAfterLoad();
+ }
+ }
+
+ CTimer::Update();
+
+ DMAudio.ChangeMusicMode(MUSICMODE_GAME);
+}
+
extern void (*DebugMenuProcess)(void);
void CGame::Process(void)
{
@@ -315,50 +680,34 @@ void CGame::Process(void)
}
}
}
-#endif
-void CGame::ReloadIPLs(void)
+void CGame::DrasticTidyUpMemory(bool)
{
- CTimer::Stop();
- CWorld::RemoveStaticObjects();
- ThePaths.Init();
- CCullZones::Init();
- CFileLoader::ReloadPaths("GTA3.IDE");
- CFileLoader::LoadScene("INDUST.IPL");
- CFileLoader::LoadScene("COMMER.IPL");
- CFileLoader::LoadScene("SUBURBAN.IPL");
- CFileLoader::LoadScene("CULL.IPL");
- ThePaths.PreparePathData();
- CTrafficLights::ScanForLightsOnMap();
- CRoadBlocks::Init();
- CCranes::InitCranes();
- CGarages::Init();
- CWorld::RepositionCertainDynamicObjects();
- CCullZones::ResolveVisibilities();
- CRenderer::SortBIGBuildings();
- CTimer::Update();
+#ifdef PS2
+ // meow
+#endif
}
-#if 0
-WRAPPER void CGame::FinalShutdown(void) { EAXJMP(0x48BEC0); }
-#else
-void
-CGame::FinalShutdown(void)
+void CGame::TidyUpMemory(bool, bool)
{
- CTxdStore::Shutdown();
- CPedStats::Shutdown();
- CdStreamShutdown();
-}
+#ifdef PS2
+ // meow
#endif
-
-WRAPPER bool CGame::InitialiseRenderWare(void) { EAXJMP(0x48BBA0); }
-WRAPPER void CGame::ShutdownRenderWare(void) { EAXJMP(0x48BCB0); }
-WRAPPER void CGame::ShutDown(void) { EAXJMP(0x48C3A0); }
-WRAPPER void CGame::ShutDownForRestart(void) { EAXJMP(0x48C6B0); }
-WRAPPER void CGame::InitialiseWhenRestarting(void) { EAXJMP(0x48C740); }
-WRAPPER bool CGame::InitialiseOnceAfterRW(void) { EAXJMP(0x48BD50); }
+}
STARTPATCHES
- InjectHook(0x48C850, CGame::Process, PATCH_JUMP);
+ InjectHook(0x48BB80, CGame::InitialiseOnceBeforeRW, PATCH_JUMP);
+ InjectHook(0x48BBA0, CGame::InitialiseRenderWare, PATCH_JUMP);
+ InjectHook(0x48BCB0, CGame::ShutdownRenderWare, PATCH_JUMP);
+ InjectHook(0x48BD50, CGame::InitialiseOnceAfterRW, PATCH_JUMP);
InjectHook(0x48BEC0, CGame::FinalShutdown, PATCH_JUMP);
+ InjectHook(0x48BED0, CGame::Initialise, PATCH_JUMP);
+ InjectHook(0x48C3A0, CGame::ShutDown, PATCH_JUMP);
+ InjectHook(0x48C4B0, CGame::ReInitGameObjectVariables, PATCH_JUMP);
+ InjectHook(0x48C620, CGame::ReloadIPLs, PATCH_JUMP);
+ InjectHook(0x48C6B0, CGame::ShutDownForRestart, PATCH_JUMP);
+ InjectHook(0x48C740, CGame::InitialiseWhenRestarting, PATCH_JUMP);
+ InjectHook(0x48C850, CGame::Process, PATCH_JUMP);
+ InjectHook(0x48CA10, CGame::DrasticTidyUpMemory, PATCH_JUMP);
+ InjectHook(0x48CA20, CGame::TidyUpMemory, PATCH_JUMP);
ENDPATCHES
diff --git a/src/core/Game.h b/src/core/Game.h
index 991c8718..318ff54b 100644
--- a/src/core/Game.h
+++ b/src/core/Game.h
@@ -23,19 +23,20 @@ public:
static bool &playingIntro;
static char *aDatFile; //[32];
- static bool Initialise(const char *datFile);
static bool InitialiseOnceBeforeRW(void);
static bool InitialiseRenderWare(void);
- static bool InitialiseOnceAfterRW(void);
- static void InitialiseWhenRestarting(void);
- static void ShutDown(void);
static void ShutdownRenderWare(void);
+ static bool InitialiseOnceAfterRW(void);
static void FinalShutdown(void);
+ static bool Initialise(const char *datFile);
+ static bool ShutDown(void);
+ static void ReInitGameObjectVariables(void);
+ static void ReloadIPLs(void);
static void ShutDownForRestart(void);
+ static void InitialiseWhenRestarting(void);
static void Process(void);
- static void ReloadIPLs(void);
-
+
// NB: these do something on PS2
- static void TidyUpMemory(bool, bool) {}
- static void DrasticTidyUpMemory(void) {}
+ static void TidyUpMemory(bool, bool);
+ static void DrasticTidyUpMemory(bool);
};
diff --git a/src/core/Pad.h b/src/core/Pad.h
index 6cabdf54..84919f32 100644
--- a/src/core/Pad.h
+++ b/src/core/Pad.h
@@ -4,7 +4,7 @@ enum {
PLAYERCONTROL_ENABLED = 0,
PLAYERCONTROL_DISABLED_1 = 1,
PLAYERCONTROL_DISABLED_2 = 2,
- PLAYERCONTROL_DISABLED_4 = 4,
+ PLAYERCONTROL_GARAGE = 4,
PLAYERCONTROL_DISABLED_8 = 8,
PLAYERCONTROL_DISABLED_10 = 16,
PLAYERCONTROL_DISABLED_20 = 32, // used on CPlayerInfo::MakePlayerSafe
@@ -433,7 +433,10 @@ public:
int16 GetRightStickX(void) { return NewState.RightStickX; }
int16 GetRightStickY(void) { return NewState.RightStickY; }
- bool ArePlayerControlsDisabled(void) { return DisablePlayerControls != PLAYERCONTROL_ENABLED; }
+ bool ArePlayerControlsDisabled(void) { return DisablePlayerControls != PLAYERCONTROL_ENABLED; }
+ void SetDisablePlayerControls(uint8 who) { DisablePlayerControls |= who; }
+ void SetEnablePlayerControls(uint8 who) { DisablePlayerControls &= ~who; }
+ bool IsPlayerControlsDisabledBy(uint8 who) { return DisablePlayerControls & who; }
};
VALIDATE_SIZE(CPad, 0xFC);
diff --git a/src/core/Radar.cpp b/src/core/Radar.cpp
index 6421520b..1c634760 100644
--- a/src/core/Radar.cpp
+++ b/src/core/Radar.cpp
@@ -75,9 +75,6 @@ static_assert(RADAR_TILE_SIZE == (WORLD_SIZE_Y / RADAR_NUM_TILES), "CRadar: not
#define RADAR_MIN_SPEED (0.3f)
#define RADAR_MAX_SPEED (0.9f)
-#if 0
-WRAPPER void CRadar::CalculateBlipAlpha(float) { EAXJMP(0x4A4F90); }
-#else
uint8 CRadar::CalculateBlipAlpha(float dist)
{
if (dist <= 1.0f)
@@ -88,55 +85,35 @@ uint8 CRadar::CalculateBlipAlpha(float dist)
return 128;
}
-#endif
-#if 0
-WRAPPER void CRadar::ChangeBlipBrightness(int32, int32) { EAXJMP(0x4A57A0); }
-#else
void CRadar::ChangeBlipBrightness(int32 i, int32 bright)
{
int index = GetActualBlipArrayIndex(i);
if (index != -1)
ms_RadarTrace[index].m_bDim = bright != 1;
}
-#endif
-#if 0
-WRAPPER void CRadar::ChangeBlipColour(int32, int32) { EAXJMP(0x4A5770); }
-#else
void CRadar::ChangeBlipColour(int32 i, int32 color)
{
int index = GetActualBlipArrayIndex(i);
if (index != -1)
ms_RadarTrace[index].m_nColor = color;
}
-#endif
-#if 0
-WRAPPER void CRadar::ChangeBlipDisplay(int32, eBlipDisplay) { EAXJMP(0x4A5810); }
-#else
void CRadar::ChangeBlipDisplay(int32 i, eBlipDisplay display)
{
int index = GetActualBlipArrayIndex(i);
if (index != -1)
ms_RadarTrace[index].m_eBlipDisplay = display;
}
-#endif
-#if 0
-WRAPPER void CRadar::ChangeBlipScale(int32, int32) { EAXJMP(0x4A57E0); }
-#else
void CRadar::ChangeBlipScale(int32 i, int32 scale)
{
int index = GetActualBlipArrayIndex(i);
if (index != -1)
ms_RadarTrace[index].m_wScale = scale;
}
-#endif
-#if 0
-WRAPPER void CRadar::ClearBlip(int32) { EAXJMP(0x4A5720); }
-#else
void CRadar::ClearBlip(int32 i)
{
int index = GetActualBlipArrayIndex(i);
@@ -148,11 +125,7 @@ void CRadar::ClearBlip(int32 i)
ms_RadarTrace[index].m_IconID = RADAR_SPRITE_NONE;
}
}
-#endif
-#if 0
-WRAPPER void CRadar::ClearBlipForEntity(eBlipType, int32) { EAXJMP(0x4A56C0); }
-#else
void CRadar::ClearBlipForEntity(eBlipType type, int32 id)
{
for (int i = 0; i < NUMRADARBLIPS; i++) {
@@ -165,11 +138,7 @@ void CRadar::ClearBlipForEntity(eBlipType type, int32 id)
}
};
}
-#endif
-#if 0
-WRAPPER int CRadar::ClipRadarPoly(CVector2D *poly, const CVector2D *in) { EAXJMP(0x4A64A0); }
-#else
// Why not a proper clipping algorithm?
int CRadar::ClipRadarPoly(CVector2D *poly, const CVector2D *rect)
{
@@ -249,7 +218,6 @@ int CRadar::ClipRadarPoly(CVector2D *poly, const CVector2D *rect)
return n;
}
-#endif
bool CRadar::DisplayThisBlip(int32 counter)
{
@@ -263,9 +231,6 @@ bool CRadar::DisplayThisBlip(int32 counter)
}
}
-#if 0
-WRAPPER void CRadar::Draw3dMarkers() { EAXJMP(0x4A4C70); }
-#else
void CRadar::Draw3dMarkers()
{
for (int i = 0; i < NUMRADARBLIPS; i++) {
@@ -317,12 +282,7 @@ void CRadar::Draw3dMarkers()
}
}
}
-#endif
-
-#if 0
-WRAPPER void CRadar::DrawBlips() { EAXJMP(0x4A42F0); }
-#else
void CRadar::DrawBlips()
{
if (!TheCamera.m_WideScreenOn && CHud::m_Wants_To_Draw_Hud) {
@@ -580,12 +540,7 @@ void CRadar::DrawBlips()
}
}
}
-#endif
-
-#if 0
-WRAPPER void CRadar::DrawMap () { EAXJMP(0x4A4200); }
-#else
void CRadar::DrawMap()
{
if (!TheCamera.m_WideScreenOn && CHud::m_Wants_To_Draw_Hud) {
@@ -605,11 +560,7 @@ void CRadar::DrawMap()
DrawRadarMap();
}
}
-#endif
-#if 0
-WRAPPER void CRadar::DrawRadarMap() { EAXJMP(0x4A6C20); }
-#else
void CRadar::DrawRadarMap()
{
// Game calculates an unused CRect here
@@ -642,11 +593,7 @@ void CRadar::DrawRadarMap()
DrawRadarSection(x, y + 1);
DrawRadarSection(x + 1, y + 1);
}
-#endif
-#if 0
-WRAPPER void CRadar::DrawRadarMask() { EAXJMP(0x4A69C0); }
-#else
void CRadar::DrawRadarMask()
{
CVector2D corners[4] = {
@@ -690,11 +637,7 @@ void CRadar::DrawRadarMask()
RwD3D8SetRenderState(rwRENDERSTATESTENCILFUNCTION, rwSTENCILFUNCTIONGREATER);
}
-#endif
-#if 0
-WRAPPER void CRadar::DrawRadarSection(int32, int32) { EAXJMP(0x4A67E0); }
-#else
void CRadar::DrawRadarSection(int32 x, int32 y)
{
int i;
@@ -738,20 +681,12 @@ void CRadar::DrawRadarSection(int32 x, int32 y)
// if(numVertices > 2)
RwIm2DRenderPrimitive(rwPRIMTYPETRIFAN, CSprite2d::GetVertices(), numVertices);
}
-#endif
-#if 0
-WRAPPER void CRadar::DrawRadarSprite(uint16 sprite, float x, float y, uint8 alpha) { EAXJMP(0x4A5EF0); }
-#else
void CRadar::DrawRadarSprite(uint16 sprite, float x, float y, uint8 alpha)
{
RadarSprites[sprite]->Draw(CRect(x - SCREEN_SCALE_X(8.0f), y - SCREEN_SCALE_Y(8.0f), x + SCREEN_SCALE_X(8.0f), y + SCREEN_SCALE_Y(8.0f)), CRGBA(255, 255, 255, alpha));
}
-#endif
-#if 0
-WRAPPER void CRadar::DrawRotatingRadarSprite(CSprite2d* sprite, float x, float y, float angle, int32 alpha) { EAXJMP(0x4A5D10); }
-#else
void CRadar::DrawRotatingRadarSprite(CSprite2d* sprite, float x, float y, float angle, int32 alpha)
{
CVector curPosn[4];
@@ -778,11 +713,7 @@ void CRadar::DrawRotatingRadarSprite(CSprite2d* sprite, float x, float y, float
sprite->Draw(curPosn[2].x, curPosn[2].y, curPosn[3].x, curPosn[3].y, curPosn[0].x, curPosn[0].y, curPosn[1].x, curPosn[1].y, CRGBA(255, 255, 255, alpha));
}
-#endif
-#if 0
-WRAPPER int32 CRadar::GetActualBlipArrayIndex(int32) { EAXJMP(0x4A41C0); }
-#else
int32 CRadar::GetActualBlipArrayIndex(int32 i)
{
if (i == -1)
@@ -792,11 +723,7 @@ int32 CRadar::GetActualBlipArrayIndex(int32 i)
else
return (uint16)i;
}
-#endif
-#if 0
-WRAPPER int32 CRadar::GetNewUniqueBlipIndex(int32) { EAXJMP(0x4A4180); }
-#else
int32 CRadar::GetNewUniqueBlipIndex(int32 i)
{
if (ms_RadarTrace[i].m_BlipIndex >= UINT16_MAX - 1)
@@ -805,11 +732,7 @@ int32 CRadar::GetNewUniqueBlipIndex(int32 i)
ms_RadarTrace[i].m_BlipIndex++;
return i | (ms_RadarTrace[i].m_BlipIndex << 16);
}
-#endif
-#if 0
-WRAPPER uint32 CRadar::GetRadarTraceColour(uint32 color, bool bright) { EAXJMP(0x4A5BB0); }
-#else
uint32 CRadar::GetRadarTraceColour(uint32 color, bool bright)
{
int32 c;
@@ -862,7 +785,6 @@ uint32 CRadar::GetRadarTraceColour(uint32 color, bool bright)
};
return c;
}
-#endif
const char* gRadarTexNames[] = {
"radar00", "radar01", "radar02", "radar03", "radar04", "radar05", "radar06", "radar07",
@@ -875,9 +797,6 @@ const char* gRadarTexNames[] = {
"radar56", "radar57", "radar58", "radar59", "radar60", "radar61", "radar62", "radar63",
};
-#if 0
-WRAPPER void CRadar::Initialise() { EAXJMP(0x4A3EF0); }
-#else
void
CRadar::Initialise()
{
@@ -894,11 +813,7 @@ CRadar::Initialise()
for (int i = 0; i < 64; i++)
gRadarTxdIds[i] = CTxdStore::FindTxdSlot(gRadarTexNames[i]);
}
-#endif
-#if 0
-WRAPPER float CRadar::LimitRadarPoint(CVector2D &point) { EAXJMP(0x4A4F30); }
-#else
float CRadar::LimitRadarPoint(CVector2D &point)
{
float dist, invdist;
@@ -911,11 +826,7 @@ float CRadar::LimitRadarPoint(CVector2D &point)
}
return dist;
}
-#endif
-#if 0
-WRAPPER void CRadar::LoadAllRadarBlips(int32) { EAXJMP(0x4A6F30); }
-#else
void CRadar::LoadAllRadarBlips(uint8 *buf, uint32 size)
{
Initialise();
@@ -927,11 +838,7 @@ INITSAVEBUF
VALIDATESAVEBUF(size);
}
-#endif
-#if 0
-WRAPPER void CRadar::LoadTextures() { EAXJMP(0x4A4030); }
-#else
void
CRadar::LoadTextures()
{
@@ -959,42 +866,26 @@ CRadar::LoadTextures()
WeaponSprite.SetTexture("radar_weapon");
CTxdStore::PopCurrentTxd();
}
-#endif
-#if 0
-WRAPPER void RemoveMapSection(int32, int32) { EAXJMP(0x00); }
-#else
void RemoveMapSection(int32 x, int32 y)
{
if (x >= 0 && x <= 7 && y >= 0 && y <= 7)
CStreaming::RemoveTxd(gRadarTxdIds[x + RADAR_NUM_TILES * y]);
}
-#endif
-#if 0
-WRAPPER void CRadar::RemoveRadarSections() { EAXJMP(0x4A60E0); }
-#else
void CRadar::RemoveRadarSections()
{
for (int i = 0; i < 8; i++)
for (int j = 0; j < 8; j++)
RemoveMapSection(i, j);
}
-#endif
-#if 0
-WRAPPER void CRadar::RequestMapSection(int32, int32) { EAXJMP(0x00); }
-#else
void CRadar::RequestMapSection(int32 x, int32 y)
{
ClipRadarTileCoords(x, y);
CStreaming::RequestTxd(gRadarTxdIds[x + RADAR_NUM_TILES * y], STREAMFLAGS_DONT_REMOVE | STREAMFLAGS_DEPENDENCY);
}
-#endif
-#if 0
-WRAPPER void CRadar::SaveAllRadarBlips(uint8 *buf, uint32 *size) { EAXJMP(0x4A6E30); }
-#else
void CRadar::SaveAllRadarBlips(uint8 *buf, uint32 *size)
{
*size = SAVE_HEADER_SIZE + sizeof(ms_RadarTrace);
@@ -1006,11 +897,7 @@ INITSAVEBUF
VALIDATESAVEBUF(*size);
}
-#endif
-#if 0
-WRAPPER void CRadar::SetBlipSprite(int32, int32) { EAXJMP(0x4A5840); }
-#else
void CRadar::SetBlipSprite(int32 i, int32 icon)
{
int index = CRadar::GetActualBlipArrayIndex(i);
@@ -1018,11 +905,7 @@ void CRadar::SetBlipSprite(int32 i, int32 icon)
ms_RadarTrace[index].m_IconID = icon;
}
}
-#endif
-#if 0
-WRAPPER int32 CRadar::SetCoordBlip(eBlipType, CVector, int32, eBlipDisplay display) { EAXJMP(0x4A5590); }
-#else
int CRadar::SetCoordBlip(eBlipType type, CVector pos, int32 color, eBlipDisplay display)
{
int nextBlip;
@@ -1043,11 +926,7 @@ int CRadar::SetCoordBlip(eBlipType type, CVector pos, int32 color, eBlipDisplay
ms_RadarTrace[nextBlip].m_IconID = RADAR_SPRITE_NONE;
return CRadar::GetNewUniqueBlipIndex(nextBlip);
}
-#endif
-#if 0
-WRAPPER int CRadar::SetEntityBlip(eBlipType type, int32, int32, eBlipDisplay) { EAXJMP(0x4A5640); }
-#else
int CRadar::SetEntityBlip(eBlipType type, int32 handle, int32 color, eBlipDisplay display)
{
int nextBlip;
@@ -1066,11 +945,7 @@ int CRadar::SetEntityBlip(eBlipType type, int32 handle, int32 color, eBlipDispla
ms_RadarTrace[nextBlip].m_IconID = RADAR_SPRITE_NONE;
return GetNewUniqueBlipIndex(nextBlip);
}
-#endif
-#if 0
-WRAPPER void CRadar::SetRadarMarkerState(int32, bool) { EAXJMP(0x4A5C60); }
-#else
void CRadar::SetRadarMarkerState(int32 counter, bool flag)
{
CEntity *e;
@@ -1091,11 +966,7 @@ void CRadar::SetRadarMarkerState(int32 counter, bool flag)
if (e)
e->bHasBlip = flag;
}
-#endif
-#if 0
-WRAPPER void CRadar::ShowRadarMarker(CVector pos, uint32 color, float radius) { EAXJMP(0x4A59C0); }
-#else
void CRadar::ShowRadarMarker(CVector pos, uint32 color, float radius) {
float f1 = radius * 1.4f;
float f2 = radius * 0.5f;
@@ -1117,11 +988,7 @@ void CRadar::ShowRadarMarker(CVector pos, uint32 color, float radius) {
p2 = pos - TheCamera.GetRight()*f2;
CTheScripts::ScriptDebugLine3D(p1.x, p1.y, p1.z, p2.x, p2.y, p2.z, color, color);
}
-#endif
-#if 0
-WRAPPER void CRadar::ShowRadarTrace(float x, float y, uint32 size, uint8 red, uint8 green, uint8 blue, uint8 alpha) { EAXJMP(0x4A5870); }
-#else
void CRadar::ShowRadarTrace(float x, float y, uint32 size, uint8 red, uint8 green, uint8 blue, uint8 alpha)
{
if (!CHud::m_Wants_To_Draw_Hud || TheCamera.m_WideScreenOn)
@@ -1130,7 +997,6 @@ void CRadar::ShowRadarTrace(float x, float y, uint32 size, uint8 red, uint8 gree
CSprite2d::DrawRect(CRect(x - SCREEN_SCALE_X(size + 1.0f), y - SCREEN_SCALE_Y(size + 1.0f), SCREEN_SCALE_X(size + 1.0f) + x, SCREEN_SCALE_Y(size + 1.0f) + y), CRGBA(0, 0, 0, alpha));
CSprite2d::DrawRect(CRect(x - SCREEN_SCALE_X(size), y - SCREEN_SCALE_Y(size), SCREEN_SCALE_X(size) + x, SCREEN_SCALE_Y(size) + y), CRGBA(red, green, blue, alpha));
}
-#endif
void CRadar::ShowRadarTraceWithHeight(float x, float y, uint32 size, uint8 red, uint8 green, uint8 blue, uint8 alpha, uint8 mode)
{
@@ -1156,9 +1022,6 @@ void CRadar::ShowRadarTraceWithHeight(float x, float y, uint32 size, uint8 red,
}
}
-#if 0
-WRAPPER void CRadar::Shutdown() { EAXJMP(0x4A3F60); }
-#else
void CRadar::Shutdown()
{
AsukaSprite.Delete();
@@ -1183,20 +1046,12 @@ void CRadar::Shutdown()
WeaponSprite.Delete();
RemoveRadarSections();
}
-#endif
-#if 0
-WRAPPER void CRadar::StreamRadarSections(const CVector &posn) { EAXJMP(0x4A6B60); }
-#else
void CRadar::StreamRadarSections(const CVector &posn)
{
StreamRadarSections(floorf((2000.0f + posn.x) / 500.0f), ceilf(7.0f - (2000.0f + posn.y) / 500.0f));
}
-#endif
-#if 0
-WRAPPER void CRadar::StreamRadarSections(int32 x, int32 y) { EAXJMP(0x4A6100); }
-#else
void CRadar::StreamRadarSections(int32 x, int32 y)
{
for (int i = 0; i < RADAR_NUM_TILES; ++i) {
@@ -1208,11 +1063,7 @@ void CRadar::StreamRadarSections(int32 x, int32 y)
};
};
}
-#endif
-#if 0
-WRAPPER void CRadar::TransformRealWorldToTexCoordSpace(CVector2D &out, const CVector2D &in, int32 x, int32 y) { EAXJMP(0x4A5530); }
-#else
void CRadar::TransformRealWorldToTexCoordSpace(CVector2D &out, const CVector2D &in, int32 x, int32 y)
{
out.x = in.x - (x * RADAR_TILE_SIZE + WORLD_MIN_X);
@@ -1220,11 +1071,7 @@ void CRadar::TransformRealWorldToTexCoordSpace(CVector2D &out, const CVector2D &
out.x /= RADAR_TILE_SIZE;
out.y /= RADAR_TILE_SIZE;
}
-#endif
-#if 0
-WRAPPER void CRadar::TransformRadarPointToRealWorldSpace(CVector2D &out, const CVector2D &in) { EAXJMP(0x4A5300); }
-#else
void CRadar::TransformRadarPointToRealWorldSpace(CVector2D &out, const CVector2D &in)
{
float s, c;
@@ -1255,7 +1102,6 @@ void CRadar::TransformRadarPointToRealWorldSpace(CVector2D &out, const CVector2D
out = out * m_radarRange + vec2DRadarOrigin;
}
-#endif
// Radar space goes from -1.0 to 1.0 in x and y, top right is (1.0, 1.0)
void CRadar::TransformRadarPointToScreenSpace(CVector2D &out, const CVector2D &in)
@@ -1265,9 +1111,6 @@ void CRadar::TransformRadarPointToScreenSpace(CVector2D &out, const CVector2D &i
out.y = (1.0f - in.y)*0.5f*SCREEN_SCALE_Y(RADAR_HEIGHT) + SCREEN_SCALE_FROM_BOTTOM(RADAR_BOTTOM + RADAR_HEIGHT);
}
-#if 0
-WRAPPER void CRadar::TransformRealWorldPointToRadarSpace(CVector2D &out, const CVector2D &in) { EAXJMP(0x4A50D0); }
-#else
void CRadar::TransformRealWorldPointToRadarSpace(CVector2D &out, const CVector2D &in)
{
float s, c;
@@ -1299,11 +1142,7 @@ void CRadar::TransformRealWorldPointToRadarSpace(CVector2D &out, const CVector2D
out.x = s * y + c * x;
out.y = c * y - s * x;
}
-#endif
-#if 0
-WRAPPER void CRadar::GetTextureCorners(int32 x, int32 y, CVector2D *out) { EAXJMP(0x4A61C0); };
-#else
// Transform from section indices to world coordinates
void CRadar::GetTextureCorners(int32 x, int32 y, CVector2D *out)
{
@@ -1326,11 +1165,7 @@ void CRadar::GetTextureCorners(int32 x, int32 y, CVector2D *out)
out[3].x = RADAR_TILE_SIZE * (x);
out[3].y = RADAR_TILE_SIZE * (y);
}
-#endif
-#if 0
-WRAPPER void CRadar::ClipRadarTileCoords(int32 &, int32 &) { EAXJMP(0x00); };
-#else
void CRadar::ClipRadarTileCoords(int32 &x, int32 &y)
{
if (x < 0)
@@ -1342,24 +1177,16 @@ void CRadar::ClipRadarTileCoords(int32 &x, int32 &y)
if (y > RADAR_NUM_TILES-1)
y = RADAR_NUM_TILES-1;
}
-#endif
-#if 0
-WRAPPER bool CRadar::IsPointInsideRadar(const CVector2D &) { EAXJMP(0x4A6160); }
-#else
bool CRadar::IsPointInsideRadar(const CVector2D &point)
{
if (point.x < -1.0f || point.x > 1.0f) return false;
if (point.y < -1.0f || point.y > 1.0f) return false;
return true;
}
-#endif
// clip line p1,p2 against (-1.0, 1.0) in x and y, set out to clipped point closest to p1
-#if 0
-WRAPPER int CRadar::LineRadarBoxCollision(CVector2D &, const CVector2D &, const CVector2D &) { EAXJMP(0x4A6250); }
-#else
int CRadar::LineRadarBoxCollision(CVector2D &out, const CVector2D &p1, const CVector2D &p2)
{
float d1, d2;
@@ -1430,7 +1257,6 @@ int CRadar::LineRadarBoxCollision(CVector2D &out, const CVector2D &p1, const CVe
return edge;
}
-#endif
STARTPATCHES
InjectHook(0x4A3EF0, CRadar::Initialise, PATCH_JUMP);
diff --git a/src/core/RwHelper.cpp b/src/core/RwHelper.cpp
index 1030d69e..6325bf15 100644
--- a/src/core/RwHelper.cpp
+++ b/src/core/RwHelper.cpp
@@ -352,7 +352,25 @@ WRAPPER bool CheckVideoCardCaps(void) { EAXJMP(0x592740); }
WRAPPER void WriteVideoCardCapsFile(void) { EAXJMP(0x5927D0); }
WRAPPER void ConvertingTexturesScreen(uint32, uint32, const char*) { EAXJMP(0x592880); }
WRAPPER void DealWithTxdWriteError(uint32, uint32, const char*) { EAXJMP(0x592BF0); }
-WRAPPER bool ConvertTextures() { EAXJMP(0x592C70); }
+WRAPPER bool CreateTxdImageForVideoCard() { EAXJMP(0x592C70); }
+
+void CreateDebugFont()
+{
+ ;
+}
+
+void DestroyDebugFont()
+{
+ ;
+}
+
+void FlushObrsPrintfs()
+{
+ ;
+}
+
+WRAPPER void _TexturePoolsInitialise() { EAXJMP(0x598B10); }
+WRAPPER void _TexturePoolsShutdown() { EAXJMP(0x598B30); }
STARTPATCHES
//InjectHook(0x526450, GetFirstObjectCallback, PATCH_JUMP);
diff --git a/src/core/RwHelper.h b/src/core/RwHelper.h
index 1f0290cc..a9f0bdf4 100644
--- a/src/core/RwHelper.h
+++ b/src/core/RwHelper.h
@@ -3,6 +3,9 @@
void *RwMallocAlign(RwUInt32 size, RwUInt32 align);
void RwFreeAlign(void *mem);
+void CreateDebugFont();
+void DestroyDebugFont();
+void FlushObrsPrintfs();
void DefinedState(void);
RwFrame *GetFirstChild(RwFrame *frame);
RwObject *GetFirstObject(RwFrame *frame);
@@ -17,7 +20,7 @@ bool CheckVideoCardCaps(void);
void WriteVideoCardCapsFile(void);
void ConvertingTexturesScreen(uint32, uint32, const char*);
void DealWithTxdWriteError(uint32, uint32, const char*);
-bool ConvertTextures(); // not a real name
+bool CreateTxdImageForVideoCard();
bool RpClumpGtaStreamRead1(RwStream *stream);
RpClump *RpClumpGtaStreamRead2(RwStream *stream);
@@ -31,3 +34,7 @@ void CameraDestroy(RwCamera *camera);
RwCamera *CameraCreate(RwInt32 width,
RwInt32 height,
RwBool zBuffer);
+
+
+void _TexturePoolsInitialise();
+void _TexturePoolsShutdown(); \ No newline at end of file
diff --git a/src/core/Stats.cpp b/src/core/Stats.cpp
index 93eeb759..9478479b 100644
--- a/src/core/Stats.cpp
+++ b/src/core/Stats.cpp
@@ -48,6 +48,8 @@ int32& CStats::LongestFlightInDodo = *(int32*)0x8F5FE4;
int32& CStats::TimeTakenDefuseMission = *(int32*)0x880E24;
int32& CStats::TotalNumberKillFrenzies = *(int32*)0x8E2884;
int32& CStats::TotalNumberMissions = *(int32*)0x8E2820;
+int32& CStats::KgOfExplosivesUsed = *(int32*)0x8F2510;
+int32& CStats::CarsCrushed = *(int32*)0x943050;
int32(&CStats::FastestTimes)[CStats::TOTAL_FASTEST_TIMES] = *(int32(*)[CStats::TOTAL_FASTEST_TIMES])*(uintptr*)0x6E9128;
int32(&CStats::HighestScores)[CStats::TOTAL_HIGHEST_SCORES] = *(int32(*)[CStats::TOTAL_HIGHEST_SCORES]) * (uintptr*)0x8622B0;
diff --git a/src/core/Stats.h b/src/core/Stats.h
index 0a750d5e..1d220905 100644
--- a/src/core/Stats.h
+++ b/src/core/Stats.h
@@ -53,6 +53,8 @@ public:
static int32 &TotalNumberMissions;
static int32(&FastestTimes)[TOTAL_FASTEST_TIMES];
static int32(&HighestScores)[TOTAL_HIGHEST_SCORES];
+ static int32 &KgOfExplosivesUsed;
+ static int32 &CarsCrushed;
public:
static void RegisterFastestTime(int32, int32);
diff --git a/src/core/Timer.cpp b/src/core/Timer.cpp
index bcf84560..a46e1d8b 100644
--- a/src/core/Timer.cpp
+++ b/src/core/Timer.cpp
@@ -75,9 +75,6 @@ void CTimer::Shutdown(void)
;
}
-#if 0
-WRAPPER void CTimer::Update(void) { EAXJMP(0x4ACF70); }
-#else
void CTimer::Update(void)
{
m_snPreviousTimeInMilliseconds = m_snTimeInMilliseconds;
@@ -149,7 +146,6 @@ void CTimer::Update(void)
m_FrameCounter++;
}
-#endif
void CTimer::Suspend(void)
{
diff --git a/src/core/TxdStore.cpp b/src/core/TxdStore.cpp
index ab970b99..c751147d 100644
--- a/src/core/TxdStore.cpp
+++ b/src/core/TxdStore.cpp
@@ -10,7 +10,7 @@ CPool<TxdDef,TxdDef> *&CTxdStore::ms_pTxdPool = *(CPool<TxdDef,TxdDef>**)0x8F5FB
RwTexDictionary *&CTxdStore::ms_pStoredTxd = *(RwTexDictionary**)0x9405BC;
void
-CTxdStore::Initialize(void)
+CTxdStore::Initialise(void)
{
if(ms_pTxdPool == nil)
ms_pTxdPool = new CPool<TxdDef,TxdDef>(TXDSTORESIZE);
@@ -187,7 +187,7 @@ CTxdStore::RemoveTxd(int slot)
}
STARTPATCHES
- InjectHook(0x527440, CTxdStore::Initialize, PATCH_JUMP);
+ InjectHook(0x527440, CTxdStore::Initialise, PATCH_JUMP);
InjectHook(0x527470, CTxdStore::Shutdown, PATCH_JUMP);
InjectHook(0x527490, CTxdStore::GameShutdown, PATCH_JUMP);
InjectHook(0x5274E0, CTxdStore::AddTxdSlot, PATCH_JUMP);
diff --git a/src/core/TxdStore.h b/src/core/TxdStore.h
index a9e57d31..12ac708f 100644
--- a/src/core/TxdStore.h
+++ b/src/core/TxdStore.h
@@ -13,7 +13,7 @@ class CTxdStore
static CPool<TxdDef,TxdDef> *&ms_pTxdPool;
static RwTexDictionary *&ms_pStoredTxd;
public:
- static void Initialize(void);
+ static void Initialise(void);
static void Shutdown(void);
static void GameShutdown(void);
static int AddTxdSlot(const char *name);
diff --git a/src/core/Wanted.cpp b/src/core/Wanted.cpp
index 7af753e8..29294a2b 100644
--- a/src/core/Wanted.cpp
+++ b/src/core/Wanted.cpp
@@ -7,19 +7,16 @@
#include "ZoneCull.h"
#include "Darkel.h"
#include "DMAudio.h"
+#include "CopPed.h"
#include "Wanted.h"
+#include "General.h"
int32 &CWanted::MaximumWantedLevel = *(int32*)0x5F7714; // 6
int32 &CWanted::nMaximumWantedLevel = *(int32*)0x5F7718; // 6400
-WRAPPER void CWanted::Reset() { EAXJMP(0x4AD790) };
-WRAPPER void CWanted::Update() { EAXJMP(0x4AD7B0) };
-
void
CWanted::Initialise()
{
- int i;
-
m_nChaos = 0;
m_nLastUpdateTime = 0;
m_nLastWantedLevelChange = 0;
@@ -34,10 +31,12 @@ CWanted::Initialise()
m_bArmyRequired = false;
m_fCrimeSensitivity = 1.0f;
m_nWantedLevel = 0;
- m_CopsBeatingSuspect = 0;
- for(i = 0; i < 10; i++)
+ m_CopsBeatingSuspect = 0;
+
+ for (int i = 0; i < ARRAY_SIZE(m_pCops); i++)
m_pCops[i] = nil;
- ClearQdCrimes();
+
+ ClearQdCrimes();
}
bool
@@ -61,7 +60,7 @@ CWanted::AreArmyRequired()
int32
CWanted::NumOfHelisRequired()
{
- if (m_bIgnoredByCops)
+ if (m_bIgnoredByCops || m_bIgnoredByEveryone)
return 0;
switch (m_nWantedLevel) {
@@ -79,9 +78,10 @@ CWanted::NumOfHelisRequired()
void
CWanted::SetWantedLevel(int32 level)
{
- ClearQdCrimes();
if (level > MaximumWantedLevel)
level = MaximumWantedLevel;
+
+ ClearQdCrimes();
switch (level) {
case 0:
m_nChaos = 0;
@@ -360,10 +360,107 @@ CWanted::WorkOutPolicePresence(CVector posn, float radius)
return numPolice;
}
+void
+CWanted::Update(void)
+{
+ if (CTimer::GetTimeInMilliseconds() - m_nLastUpdateTime > 1000) {
+ if (m_nWantedLevel > 1) {
+ m_nLastUpdateTime = CTimer::GetTimeInMilliseconds();
+ } else {
+ float radius = 18.0f;
+ CVector playerPos = FindPlayerCoors();
+ if (WorkOutPolicePresence(playerPos, radius) == 0) {
+ m_nLastUpdateTime = CTimer::GetTimeInMilliseconds();
+ m_nChaos = max(0, m_nChaos - 1);
+ UpdateWantedLevel();
+ }
+ }
+ UpdateCrimesQ();
+ bool orderMessedUp = false;
+ int currCopNum = 0;
+ bool foundEmptySlot = false;
+ for (int i = 0; i < ARRAY_SIZE(m_pCops); i++) {
+ if (m_pCops[i]) {
+ ++currCopNum;
+ if (foundEmptySlot)
+ orderMessedUp = true;
+ } else {
+ foundEmptySlot = true;
+ }
+ }
+ if (currCopNum != m_CurrentCops) {
+ printf("CopPursuit total messed up: re-setting\n");
+ m_CurrentCops = currCopNum;
+ }
+ if (orderMessedUp) {
+ printf("CopPursuit pointer list messed up: re-sorting\n");
+ bool fixed = true;
+ for (int i = 0; i < ARRAY_SIZE(m_pCops); i++) {
+ if (!m_pCops[i]) {
+ for (int j = i; j < ARRAY_SIZE(m_pCops); j++) {
+ if (m_pCops[j]) {
+ m_pCops[i] = m_pCops[j];
+ m_pCops[j] = nil;
+ fixed = false;
+ break;
+ }
+ }
+ if (fixed)
+ break;
+ }
+ }
+ }
+ }
+}
+
+void
+CWanted::ResetPolicePursuit(void)
+{
+ for(int i = 0; i < ARRAY_SIZE(m_pCops); i++) {
+ CCopPed *cop = m_pCops[i];
+ if (!cop)
+ continue;
+
+ cop->m_bIsInPursuit = false;
+ cop->m_objective = OBJECTIVE_NONE;
+ cop->m_prevObjective = OBJECTIVE_NONE;
+ cop->m_nLastPedState = PED_NONE;
+ if (!cop->DyingOrDead()) {
+ cop->SetWanderPath(CGeneral::GetRandomNumberInRange(0.0f, 8.0f));
+ }
+ m_pCops[i] = nil;
+ }
+ m_CurrentCops = 0;
+}
+
+void
+CWanted::Reset(void)
+{
+ ResetPolicePursuit();
+ Initialise();
+}
+
+void
+CWanted::UpdateCrimesQ(void)
+{
+ for(int i = 0; i < ARRAY_SIZE(m_aCrimes); i++) {
+
+ CCrimeBeingQd &crime = m_aCrimes[i];
+ if (crime.m_nType != CRIME_NONE) {
+ if (CTimer::GetTimeInMilliseconds() > crime.m_nTime + 500 && !crime.m_bReported) {
+ ReportCrimeNow(crime.m_nType, crime.m_vecPosn, crime.m_bPoliceDoesntCare);
+ crime.m_bReported = true;
+ }
+ if (CTimer::GetTimeInMilliseconds() > crime.m_nTime + 10000)
+ crime.m_nType = CRIME_NONE;
+ }
+ }
+}
+
STARTPATCHES
InjectHook(0x4AD6E0, &CWanted::Initialise, PATCH_JUMP);
-// InjectHook(0x4AD790, &CWanted::Reset, PATCH_JUMP);
-// InjectHook(0x4AD7B0, &CWanted::Update, PATCH_JUMP);
+ InjectHook(0x4AD790, &CWanted::Reset, PATCH_JUMP);
+ InjectHook(0x4AD7B0, &CWanted::Update, PATCH_JUMP);
InjectHook(0x4AD900, &CWanted::UpdateWantedLevel, PATCH_JUMP);
InjectHook(0x4AD9F0, &CWanted::RegisterCrime, PATCH_JUMP);
InjectHook(0x4ADA10, &CWanted::RegisterCrime_Immediately, PATCH_JUMP);
@@ -374,10 +471,10 @@ STARTPATCHES
InjectHook(0x4ADBC0, &CWanted::AreFbiRequired, PATCH_JUMP);
InjectHook(0x4ADBE0, &CWanted::AreArmyRequired, PATCH_JUMP);
InjectHook(0x4ADC00, &CWanted::NumOfHelisRequired, PATCH_JUMP);
-// InjectHook(0x4ADC40, &CWanted::ResetPolicePursuit, PATCH_JUMP);
+ InjectHook(0x4ADC40, &CWanted::ResetPolicePursuit, PATCH_JUMP);
InjectHook(0x4ADD00, &CWanted::WorkOutPolicePresence, PATCH_JUMP);
InjectHook(0x4ADF20, &CWanted::ClearQdCrimes, PATCH_JUMP);
InjectHook(0x4ADFD0, &CWanted::AddCrimeToQ, PATCH_JUMP);
-// InjectHook(0x4AE090, &CWanted::UpdateCrimesQ, PATCH_JUMP);
+ InjectHook(0x4AE090, &CWanted::UpdateCrimesQ, PATCH_JUMP);
InjectHook(0x4AE110, &CWanted::ReportCrimeNow, PATCH_JUMP);
ENDPATCHES
diff --git a/src/core/Wanted.h b/src/core/Wanted.h
index f6dbe8d0..9823529c 100644
--- a/src/core/Wanted.h
+++ b/src/core/Wanted.h
@@ -30,7 +30,7 @@ class CCrimeBeingQd
public:
eCrimeType m_nType;
uint32 m_nId;
- int32 m_nTime;
+ uint32 m_nTime;
CVector m_vecPosn;
bool m_bReported;
bool m_bPoliceDoesntCare;
@@ -78,6 +78,8 @@ public:
void ReportCrimeNow(eCrimeType type, const CVector &coors, bool policeDoesntCare);
void UpdateWantedLevel();
void Reset();
+ void ResetPolicePursuit();
+ void UpdateCrimesQ();
void Update();
bool IsIgnored(void) { return m_bIgnoredByCops || m_bIgnoredByEveryone; }
diff --git a/src/core/World.cpp b/src/core/World.cpp
index 1dda1056..4a0230ce 100644
--- a/src/core/World.cpp
+++ b/src/core/World.cpp
@@ -19,6 +19,7 @@
#include "Messages.h"
#include "Replay.h"
#include "Population.h"
+#include "Fire.h"
CColPoint *gaTempSphereColPoints = (CColPoint*)0x6E64C0; // [32]
@@ -39,6 +40,7 @@ bool &CWorld::bProcessCutsceneOnly = *(bool*)0x95CD8B;
bool &CWorld::bDoingCarCollisions = *(bool*)0x95CD8C;
bool &CWorld::bIncludeCarTyres = *(bool*)0x95CDAA;
+WRAPPER void CWorld::ClearForRestart(void) { EAXJMP(0x4AE850); }
WRAPPER void CWorld::AddParticles(void) { EAXJMP(0x4B4010); }
WRAPPER void CWorld::ShutDown(void) { EAXJMP(0x4AE450); }
WRAPPER void CWorld::RepositionCertainDynamicObjects() { EAXJMP(0x4B42B0); }
@@ -53,6 +55,7 @@ WRAPPER void CWorld::FindObjectsOfTypeInRangeSectorList(uint32, CPtrList&, CVect
WRAPPER void CWorld::FindMissionEntitiesIntersectingCube(const CVector&, const CVector&, int16*, int16, CEntity**, bool, bool, bool) { EAXJMP(0x4B3680); }
WRAPPER void CWorld::ClearCarsFromArea(float, float, float, float, float, float) { EAXJMP(0x4B50E0); }
WRAPPER void CWorld::ClearPedsFromArea(float, float, float, float, float, float) { EAXJMP(0x4B52B0); }
+WRAPPER void CWorld::CallOffChaseForArea(float, float, float, float) { EAXJMP(0x4B5530); }
void
CWorld::Initialise()
@@ -1052,6 +1055,19 @@ CWorld::ExtinguishAllCarFiresInArea(CVector point, float range)
}
void
+CWorld::SetCarsOnFire(float x, float y, float z, float radius, CEntity *reason)
+{
+ int poolSize = CPools::GetVehiclePool()->GetSize();
+ for (int poolIndex = poolSize - 1; poolIndex >= 0; poolIndex--) {
+ CVehicle *veh = CPools::GetVehiclePool()->GetSlot(poolIndex);
+ if (veh && veh->m_status != STATUS_WRECKED && !veh->m_pCarFire && !veh->bFireProof) {
+ if (Abs(veh->GetPosition().z - z) < 5.0f && Abs(veh->GetPosition().x - x) < radius && Abs(veh->GetPosition().y - y) < radius)
+ gFireManager.StartFire(veh, reason, 0.8f, true);
+ }
+ }
+}
+
+void
CWorld::Process(void)
{
if (!(CTimer::GetFrameCounter() & 63))
diff --git a/src/core/World.h b/src/core/World.h
index 4b19e629..c4103eb2 100644
--- a/src/core/World.h
+++ b/src/core/World.h
@@ -115,6 +115,7 @@ public:
static void FindMissionEntitiesIntersectingCube(const CVector&, const CVector&, int16*, int16, CEntity**, bool, bool, bool);
static void ClearCarsFromArea(float, float, float, float, float, float);
static void ClearPedsFromArea(float, float, float, float, float, float);
+ static void CallOffChaseForArea(float, float, float, float);
static float GetSectorX(float f) { return ((f - WORLD_MIN_X)/SECTOR_SIZE_X); }
static float GetSectorY(float f) { return ((f - WORLD_MIN_Y)/SECTOR_SIZE_Y); }
@@ -130,10 +131,12 @@ public:
static void StopAllLawEnforcersInTheirTracks();
static void SetAllCarsCanBeDamaged(bool);
static void ExtinguishAllCarFiresInArea(CVector, float);
+ static void SetCarsOnFire(float, float, float, float, CEntity*);
static void Initialise();
static void AddParticles();
static void ShutDown();
+ static void ClearForRestart(void);
static void RepositionCertainDynamicObjects();
static void RemoveStaticObjects();
static void Process();
diff --git a/src/core/config.h b/src/core/config.h
index 4015e868..b4f3b7b2 100644
--- a/src/core/config.h
+++ b/src/core/config.h
@@ -100,6 +100,7 @@ enum Config {
NUMPHONES = 50,
NUMPEDGROUPS = 31,
NUMMODELSPERPEDGROUP = 8,
+ NUMSHOTINFOS = 100,
NUMROADBLOCKS = 600,
@@ -116,6 +117,8 @@ enum Config {
NUM_AUDIO_REFLECTIONS = 5,
NUM_SCRIPT_MAX_ENTITIES = 40,
+
+ NUM_GARAGE_STORED_CARS = 6
};
// We'll use this once we're ready to become independent of the game
@@ -207,4 +210,6 @@ enum Config {
// #define NEW_WALK_AROUND_ALGORITHM // to make walking around vehicles/objects less awkward
#define CANCELLABLE_CAR_ENTER
+// Camera
#define IMPROVED_CAMERA // Better Debug cam, and maybe more in the future
+//#define FREE_CAM // Rotating cam
diff --git a/src/core/main.cpp b/src/core/main.cpp
index 663b09da..50543b1e 100644
--- a/src/core/main.cpp
+++ b/src/core/main.cpp
@@ -90,7 +90,6 @@ void DoFade(void);
void Render2dStuffAfterFade(void);
CSprite2d *LoadSplash(const char *name);
-void DestroySplashScreen(void);
extern void (*DebugMenuProcess)(void);
@@ -327,7 +326,7 @@ DoRWStuffEndOfFrame(void)
{
CDebug::DisplayScreenStrings(); // custom
CDebug::DebugDisplayTextBuffer();
- // FlushObrsPrintfs();
+ FlushObrsPrintfs();
RwCameraEndUpdate(Scene.camera);
RsCameraShowRaster(Scene.camera);
}
diff --git a/src/core/main.h b/src/core/main.h
index 570189b3..5e9401b9 100644
--- a/src/core/main.h
+++ b/src/core/main.h
@@ -28,6 +28,7 @@ void InitialiseGame(void);
void LoadingScreen(const char *str1, const char *str2, const char *splashscreen);
void LoadingIslandScreen(const char *levelName);
CSprite2d *LoadSplash(const char *name);
+void DestroySplashScreen(void);
char *GetLevelSplashScreen(int level);
char *GetRandomSplashScreen(void);
void LittleTest(void);
diff --git a/src/core/re3.cpp b/src/core/re3.cpp
index a65e6d76..500bf230 100644
--- a/src/core/re3.cpp
+++ b/src/core/re3.cpp
@@ -372,6 +372,10 @@ DebugMenuPopulate(void)
extern bool PrintDebugCode;
extern int16 &DebugCamMode;
+#ifdef FREE_CAM
+ extern bool bFreeCam;
+ DebugMenuAddVarBool8("Cam", "Free Cam", (int8*)&bFreeCam, nil);
+#endif
DebugMenuAddVarBool8("Cam", "Print Debug Code", (int8*)&PrintDebugCode, nil);
DebugMenuAddVar("Cam", "Cam Mode", &DebugCamMode, nil, 1, 0, CCam::MODE_EDITOR, nil);
DebugMenuAddCmd("Cam", "Normal", []() { DebugCamMode = 0; });
diff --git a/src/modelinfo/VehicleModelInfo.cpp b/src/modelinfo/VehicleModelInfo.cpp
index 87f01177..42ad635b 100644
--- a/src/modelinfo/VehicleModelInfo.cpp
+++ b/src/modelinfo/VehicleModelInfo.cpp
@@ -1113,6 +1113,8 @@ public:
};
STARTPATCHES
+ InjectHook(0x427820, &CVehicleModelInfo::SetComponentsToUse, PATCH_JUMP);
+
InjectHook(0x51FDC0, &CVehicleModelInfo_::DeleteRwObject_, PATCH_JUMP);
InjectHook(0x51FCB0, &CVehicleModelInfo_::CreateInstance_, PATCH_JUMP);
InjectHook(0x51FC60, &CVehicleModelInfo_::SetClump_, PATCH_JUMP);
diff --git a/src/modelinfo/VehicleModelInfo.h b/src/modelinfo/VehicleModelInfo.h
index 1a6d6a55..5969c4ca 100644
--- a/src/modelinfo/VehicleModelInfo.h
+++ b/src/modelinfo/VehicleModelInfo.h
@@ -132,5 +132,6 @@ public:
static void ShutdownEnvironmentMaps(void);
static int GetMaximumNumberOfPassengersFromNumberOfDoors(int id);
+ static void SetComponentsToUse(int8 c1, int8 c2) { ms_compsToUse[0] = c1; ms_compsToUse[1] = c2; }
};
static_assert(sizeof(CVehicleModelInfo) == 0x1F8, "CVehicleModelInfo: error");
diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp
index 8b83d976..f43feae5 100644
--- a/src/peds/Ped.cpp
+++ b/src/peds/Ped.cpp
@@ -3619,11 +3619,11 @@ CPed::InflictDamage(CEntity *damagedBy, eWeaponType method, float damage, ePedPi
if (DyingOrDead())
return false;
- if (!bUsesCollision && method != WEAPONTYPE_WATER)
+ if (!bUsesCollision && method != WEAPONTYPE_DROWNING)
return false;
if (bOnlyDamagedByPlayer && damagedBy != player && damagedBy != FindPlayerVehicle() &&
- method != WEAPONTYPE_WATER && method != WEAPONTYPE_EXPLOSION)
+ method != WEAPONTYPE_DROWNING && method != WEAPONTYPE_EXPLOSION)
return false;
float healthImpact;
@@ -3969,10 +3969,10 @@ CPed::InflictDamage(CEntity *damagedBy, eWeaponType method, float damage, ePedPi
}
}
break;
- case WEAPONTYPE_WATER:
+ case WEAPONTYPE_DROWNING:
dieAnim = ANIM_DROWN;
break;
- case WEAPONTYPE_FALL_DAMAGE:
+ case WEAPONTYPE_FALL:
if (bCollisionProof)
return false;
@@ -3998,7 +3998,7 @@ CPed::InflictDamage(CEntity *damagedBy, eWeaponType method, float damage, ePedPi
}
}
- if (m_fArmour != 0.0f && method != WEAPONTYPE_WATER) {
+ if (m_fArmour != 0.0f && method != WEAPONTYPE_DROWNING) {
if (player == this)
CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastArmourLoss = CTimer::GetTimeInMilliseconds();
@@ -4024,7 +4024,7 @@ CPed::InflictDamage(CEntity *damagedBy, eWeaponType method, float damage, ePedPi
}
if (bInVehicle) {
- if (method != WEAPONTYPE_WATER) {
+ if (method != WEAPONTYPE_DROWNING) {
#ifdef VC_PED_PORTS
if (m_pMyVehicle) {
if (m_pMyVehicle->IsCar() && m_pMyVehicle->pDriver == this) {
@@ -4091,7 +4091,7 @@ CPed::InflictDamage(CEntity *damagedBy, eWeaponType method, float damage, ePedPi
} else {
CDarkel::RegisterKillNotByPlayer(this, method);
}
- if (method == WEAPONTYPE_WATER)
+ if (method == WEAPONTYPE_DROWNING)
bIsInTheAir = false;
return true;
@@ -14575,7 +14575,7 @@ CPed::ProcessEntityCollision(CEntity *collidingEnt, CColPoint *collidingPoints)
|| m_pCollidingEntity == collidingEnt) {
if (RpAnimBlendClumpGetAssociation(GetClump(), ANIM_FALL_FALL) && -0.016f * CTimer::GetTimeStep() > m_vecMoveSpeed.z) {
- InflictDamage(collidingEnt, WEAPONTYPE_FALL_DAMAGE, 15.0f, PEDPIECE_TORSO, 2);
+ InflictDamage(collidingEnt, WEAPONTYPE_FALL, 15.0f, PEDPIECE_TORSO, 2);
}
} else {
float damage = 100.0f * max(speed - 0.25f, 0.0f);
@@ -14588,7 +14588,7 @@ CPed::ProcessEntityCollision(CEntity *collidingEnt, CColPoint *collidingPoints)
CVector2D offset = -m_vecMoveSpeed;
dir = GetLocalDirection(offset);
}
- InflictDamage(collidingEnt, WEAPONTYPE_FALL_DAMAGE, damage, PEDPIECE_TORSO, dir);
+ InflictDamage(collidingEnt, WEAPONTYPE_FALL, damage, PEDPIECE_TORSO, dir);
if (IsPlayer() && damage2 > 5.0f)
Say(SOUND_PED_LAND);
}
@@ -14599,7 +14599,7 @@ CPed::ProcessEntityCollision(CEntity *collidingEnt, CColPoint *collidingPoints)
if (m_vecMoveSpeed.z >= -0.25f && (speedSqr = m_vecMoveSpeed.MagnitudeSqr()) <= sq(0.5f)) {
if (RpAnimBlendClumpGetAssociation(GetClump(), ANIM_FALL_FALL) && -0.016f * CTimer::GetTimeStep() > m_vecMoveSpeed.z) {
- InflictDamage(collidingEnt, WEAPONTYPE_FALL_DAMAGE, 15.0f, PEDPIECE_TORSO, 2);
+ InflictDamage(collidingEnt, WEAPONTYPE_FALL, 15.0f, PEDPIECE_TORSO, 2);
}
} else {
if (speedSqr == 0.0f)
@@ -14610,7 +14610,7 @@ CPed::ProcessEntityCollision(CEntity *collidingEnt, CColPoint *collidingPoints)
CVector2D offset = -m_vecMoveSpeed;
dir = GetLocalDirection(offset);
}
- InflictDamage(collidingEnt, WEAPONTYPE_FALL_DAMAGE, 350.0f * sq(speedSqr), PEDPIECE_TORSO, dir);
+ InflictDamage(collidingEnt, WEAPONTYPE_FALL, 350.0f * sq(speedSqr), PEDPIECE_TORSO, dir);
}
}
#endif
@@ -15036,7 +15036,7 @@ CPed::ProcessBuoyancy(void)
CVector pos = GetPosition();
if (PlacePedOnDryLand()) {
if (m_fHealth > 20.0f)
- InflictDamage(nil, WEAPONTYPE_WATER, 15.0f, PEDPIECE_TORSO, false);
+ InflictDamage(nil, WEAPONTYPE_DROWNING, 15.0f, PEDPIECE_TORSO, false);
if (bIsInTheAir) {
RpAnimBlendClumpSetBlendDeltas(GetClump(), ASSOC_PARTIAL, -1000.0f);
@@ -15058,7 +15058,7 @@ CPed::ProcessBuoyancy(void)
m_vecMoveSpeed.y *= speedMult;
m_vecMoveSpeed.z *= speedMult;
bIsStanding = false;
- InflictDamage(nil, WEAPONTYPE_WATER, 3.0f * CTimer::GetTimeStep(), PEDPIECE_TORSO, 0);
+ InflictDamage(nil, WEAPONTYPE_DROWNING, 3.0f * CTimer::GetTimeStep(), PEDPIECE_TORSO, 0);
}
if (buoyancyImpulse.z / m_fMass > 0.002f * CTimer::GetTimeStep()) {
if (speedMult == 0.0f) {
diff --git a/src/render/Coronas.cpp b/src/render/Coronas.cpp
index b0868d0a..c934540b 100644
--- a/src/render/Coronas.cpp
+++ b/src/render/Coronas.cpp
@@ -59,9 +59,6 @@ int &CCoronas::bChangeBrightnessImmediately = *(int*)0x8E2C30;
CRegisteredCorona *CCoronas::aCoronas = (CRegisteredCorona*)0x72E518;
-//WRAPPER void CCoronas::Render(void) { EAXJMP(0x4F8FB0); }
-//WRAPPER void CCoronas::RenderReflections(void) { EAXJMP(0x4F9B40); }
-
const char aCoronaSpriteNames[][32] = {
"coronastar",
"corona",
diff --git a/src/render/Hud.cpp b/src/render/Hud.cpp
index 51aa390f..2f523e17 100644
--- a/src/render/Hud.cpp
+++ b/src/render/Hud.cpp
@@ -103,9 +103,6 @@ struct
RwTexture *&gpSniperSightTex = *(RwTexture**)0x8F5834;
RwTexture *&gpRocketSightTex = *(RwTexture**)0x8E2C20;
-#if 0
-WRAPPER void CHud::Draw(void) { EAXJMP(0x5052A0); }
-#else
void CHud::Draw()
{
// disable hud via second controller
@@ -1004,12 +1001,7 @@ void CHud::Draw()
}
}
}
-#endif
-
-#if 0
-WRAPPER void CHud::DrawAfterFade(void) { EAXJMP(0x509030); }
-#else
void CHud::DrawAfterFade()
{
if (CTimer::GetIsUserPaused() || CReplay::IsPlayingBack())
@@ -1261,11 +1253,7 @@ void CHud::DrawAfterFade()
BigMessageInUse[1] = 0.0f;
}
}
-#endif
-#if 0
-WRAPPER void CHud::GetRidOfAllHudMessages(void) { EAXJMP(0x504F90); }
-#else
void CHud::GetRidOfAllHudMessages()
{
m_ZoneState = 0;
@@ -1301,7 +1289,6 @@ void CHud::GetRidOfAllHudMessages()
m_BigMessage[i][j] = 0;
}
}
-#endif
void CHud::Initialise()
{
@@ -1343,9 +1330,6 @@ void CHud::Initialise()
CTxdStore::PopCurrentTxd();
}
-#if 0
-WRAPPER void CHud::ReInitialise(void) { EAXJMP(0x504CC0); }
-#else
void CHud::ReInitialise() {
m_Wants_To_Draw_Hud = true;
m_Wants_To_Draw_3dMarkers = true;
@@ -1367,12 +1351,9 @@ void CHud::ReInitialise() {
PagerSoundPlayed = 0;
PagerXOffset = 150.0f;
}
-#endif
wchar LastBigMessage[6][128];
-#if 0
-WRAPPER void CHud::SetBigMessage(wchar *message, int16 style) { EAXJMP(0x50A250); }
-#else
+
void CHud::SetBigMessage(wchar *message, int16 style)
{
int i = 0;
@@ -1400,11 +1381,7 @@ void CHud::SetBigMessage(wchar *message, int16 style)
LastBigMessage[style][i] = 0;
m_BigMessage[style][i] = 0;
}
-#endif
-#if 0
-WRAPPER void CHud::SetHelpMessage(wchar *message, bool quick) { EAXJMP(0x5051E0); }
-#else
void CHud::SetHelpMessage(wchar *message, bool quick)
{
if (!CReplay::IsPlayingBack()) {
@@ -1419,11 +1396,7 @@ void CHud::SetHelpMessage(wchar *message, bool quick)
m_HelpMessageQuick = quick;
}
}
-#endif
-#if 0
-WRAPPER void CHud::SetMessage(wchar *message) { EAXJMP(0x50A210); }
-#else
void CHud::SetMessage(wchar *message)
{
int i = 0;
@@ -1435,11 +1408,7 @@ void CHud::SetMessage(wchar *message)
}
m_Message[i] = 0;
}
-#endif
-#if 0
-WRAPPER void CHud::SetPagerMessage(wchar *message) { EAXJMP(0x50A320); }
-#else
void CHud::SetPagerMessage(wchar *message)
{
int i = 0;
@@ -1451,25 +1420,16 @@ void CHud::SetPagerMessage(wchar *message)
}
m_PagerMessage[i] = 0;
}
-#endif
-#if 0
-WRAPPER void CHud::SetVehicleName(wchar *name) { EAXJMP(0x505290); }
-#else
void CHud::SetVehicleName(wchar *name)
{
m_VehicleName = name;
}
-#endif
-#if 0
-WRAPPER void CHud::SetZoneName(wchar *name) { EAXJMP(0x5051D0); }
-#else
void CHud::SetZoneName(wchar *name)
{
m_pZoneName = name;
}
-#endif
void CHud::Shutdown()
{
diff --git a/src/render/Rubbish.cpp b/src/render/Rubbish.cpp
index c336eb47..a52e59a0 100644
--- a/src/render/Rubbish.cpp
+++ b/src/render/Rubbish.cpp
@@ -7,3 +7,4 @@ WRAPPER void CRubbish::StirUp(CVehicle *veh) { EAXJMP(0x512690); }
WRAPPER void CRubbish::Update(void) { EAXJMP(0x511B90); }
WRAPPER void CRubbish::SetVisibility(bool) { EAXJMP(0x512AA0); }
WRAPPER void CRubbish::Init(void) { EAXJMP(0x511940); }
+WRAPPER void CRubbish::Shutdown(void) { EAXJMP(0x511B50); }
diff --git a/src/render/Rubbish.h b/src/render/Rubbish.h
index c94ff303..17323694 100644
--- a/src/render/Rubbish.h
+++ b/src/render/Rubbish.h
@@ -10,4 +10,5 @@ public:
static void Update(void);
static void SetVisibility(bool);
static void Init(void);
+ static void Shutdown(void);
};
diff --git a/src/render/Skidmarks.cpp b/src/render/Skidmarks.cpp
index deb5a648..c2725ed6 100644
--- a/src/render/Skidmarks.cpp
+++ b/src/render/Skidmarks.cpp
@@ -9,3 +9,4 @@ WRAPPER void CSkidmarks::Render(void) { EAXJMP(0x5182E0); }
WRAPPER void CSkidmarks::RegisterOne(uint32 id, CVector pos, float fwdx, float fwdY, bool *isMuddy, bool *isBloddy) { EAXJMP(0x5185C0); }
WRAPPER void CSkidmarks::Init(void) { EAXJMP(0x517D70); }
+WRAPPER void CSkidmarks::Shutdown(void) { EAXJMP(0x518100); }
diff --git a/src/render/Skidmarks.h b/src/render/Skidmarks.h
index 2f669575..bf2da7e4 100644
--- a/src/render/Skidmarks.h
+++ b/src/render/Skidmarks.h
@@ -8,4 +8,5 @@ public:
static void Render(void);
static void RegisterOne(uint32 id, CVector pos, float fwdx, float fwdY, bool *isMuddy, bool *isBloddy);
static void Init(void);
+ static void Shutdown(void);
};
diff --git a/src/render/SpecialFX.cpp b/src/render/SpecialFX.cpp
index 8ec2d9a1..301ae265 100644
--- a/src/render/SpecialFX.cpp
+++ b/src/render/SpecialFX.cpp
@@ -20,6 +20,7 @@
WRAPPER void CSpecialFX::Render(void) { EAXJMP(0x518DC0); }
WRAPPER void CSpecialFX::Update(void) { EAXJMP(0x518D40); }
WRAPPER void CSpecialFX::Init(void) { EAXJMP(0x5189E0); }
+WRAPPER void CSpecialFX::Shutdown(void) { EAXJMP(0x518BE0); }
WRAPPER void CMotionBlurStreaks::RegisterStreak(int32 id, uint8 r, uint8 g, uint8 b, CVector p1, CVector p2) { EAXJMP(0x519460); }
diff --git a/src/render/SpecialFX.h b/src/render/SpecialFX.h
index 701b89a0..fc155a53 100644
--- a/src/render/SpecialFX.h
+++ b/src/render/SpecialFX.h
@@ -6,6 +6,7 @@ public:
static void Render(void);
static void Update(void);
static void Init(void);
+ static void Shutdown(void);
};
class CMotionBlurStreaks
diff --git a/src/render/WeaponEffects.cpp b/src/render/WeaponEffects.cpp
index 932c661e..2ed9e662 100644
--- a/src/render/WeaponEffects.cpp
+++ b/src/render/WeaponEffects.cpp
@@ -1,45 +1,106 @@
#include "common.h"
#include "patcher.h"
#include "WeaponEffects.h"
-
#include "TxdStore.h"
+#include "Sprite.h"
-WRAPPER void CWeaponEffects::Render(void) { EAXJMP(0x564D70); }
+RwTexture *gpCrossHairTex;
+RwRaster *gpCrossHairRaster;
-CWeaponEffects &gCrossHair = *(CWeaponEffects*)0x6503BC;
+CWeaponEffects gCrossHair;
+
+CWeaponEffects::CWeaponEffects()
+{
+
+}
+
+CWeaponEffects::~CWeaponEffects()
+{
+
+}
void
-CWeaponEffects::ClearCrossHair()
+CWeaponEffects::Init(void)
{
- gCrossHair.m_bCrosshair = false;
+ gCrossHair.m_bActive = false;
+ gCrossHair.m_vecPos = CVector(0.0f, 0.0f, 0.0f);
+ gCrossHair.m_nRed = 0;
+ gCrossHair.m_nGreen = 0;
+ gCrossHair.m_nBlue = 0;
+ gCrossHair.m_nAlpha = 255;
+ gCrossHair.m_fSize = 1.0f;
+ gCrossHair.m_fRotation = 0.0f;
+
+
+ CTxdStore::PushCurrentTxd();
+ int32 slot = CTxdStore::FindTxdSlot("particle");
+ CTxdStore::SetCurrentTxd(slot);
+
+ gpCrossHairTex = RwTextureRead("crosshair", nil);
+ gpCrossHairRaster = RwTextureGetRaster(gpCrossHairTex);
+
+ CTxdStore::PopCurrentTxd();
+}
+
+void
+CWeaponEffects::Shutdown(void)
+{
+ RwTextureDestroy(gpCrossHairTex);
}
void
CWeaponEffects::MarkTarget(CVector pos, uint8 red, uint8 green, uint8 blue, uint8 alpha, float size)
{
- gCrossHair.m_bCrosshair = true;
- gCrossHair.m_vecPos = pos;
- gCrossHair.m_red = red;
- gCrossHair.m_green = green;
- gCrossHair.m_blue = blue;
- gCrossHair.m_alpha = alpha;
- gCrossHair.m_size = size;
+ gCrossHair.m_bActive = true;
+ gCrossHair.m_vecPos = pos;
+ gCrossHair.m_nRed = red;
+ gCrossHair.m_nGreen = green;
+ gCrossHair.m_nBlue = blue;
+ gCrossHair.m_nAlpha = alpha;
+ gCrossHair.m_fSize = size;
+}
+
+void
+CWeaponEffects::ClearCrossHair(void)
+{
+ gCrossHair.m_bActive = false;
}
void
-CWeaponEffects::Init()
+CWeaponEffects::Render(void)
{
- gCrossHair.m_bCrosshair = false;
- gCrossHair.m_vecPos = CVector(0.0f, 0.0f, 0.0f);
- gCrossHair.m_red = 0;
- gCrossHair.m_green = 0;
- gCrossHair.m_blue = 0;
- gCrossHair.m_alpha = 255;
- gCrossHair.m_size = 1.0f;
- gCrossHair.field_24 = 0;
- CTxdStore::PushCurrentTxd();
- CTxdStore::SetCurrentTxd(CTxdStore::FindTxdSlot("particle"));
- gCrossHair.m_pTexture = RwTextureRead("crosshair", nil);
- gCrossHair.m_pRaster = gCrossHair.m_pTexture->raster;
- CTxdStore::PopCurrentTxd();
+ if ( gCrossHair.m_bActive )
+ {
+ RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void *)FALSE);
+ RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void *)TRUE);
+ RwRenderStateSet(rwRENDERSTATESRCBLEND, (void *)rwBLENDONE);
+ RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void *)rwBLENDONE);
+ RwRenderStateSet(rwRENDERSTATETEXTURERASTER, (void *)gpCrossHairRaster);
+
+ RwV3d pos;
+ float w, h;
+ if ( CSprite::CalcScreenCoors(gCrossHair.m_vecPos, &pos, &w, &h, true) )
+ {
+ float recipz = 1.0f / pos.z;
+ CSprite::RenderOneXLUSprite(pos.x, pos.y, pos.z,
+ gCrossHair.m_fSize * w, gCrossHair.m_fSize * h,
+ gCrossHair.m_nRed, gCrossHair.m_nGreen, gCrossHair.m_nBlue, 255,
+ recipz, 255);
+ }
+
+ RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void *)FALSE);
+ RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void *)FALSE);
+ RwRenderStateSet(rwRENDERSTATESRCBLEND, (void *)rwBLENDSRCALPHA);
+ RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void *)rwBLENDINVSRCALPHA);
+ }
}
+
+STARTPATCHES
+ //InjectHook(0x564C40, CWeaponEffects::CWeaponEffects, PATCH_JUMP);
+ //InjectHook(0x564C50, CWeaponEffects::~CWeaponEffects, PATCH_JUMP);
+ InjectHook(0x564C60, CWeaponEffects::Init, PATCH_JUMP);
+ InjectHook(0x564CF0, CWeaponEffects::Shutdown, PATCH_JUMP);
+ InjectHook(0x564D00, CWeaponEffects::MarkTarget, PATCH_JUMP);
+ InjectHook(0x564D60, CWeaponEffects::ClearCrossHair, PATCH_JUMP);
+ InjectHook(0x564D70, CWeaponEffects::Render, PATCH_JUMP);
+ENDPATCHES \ No newline at end of file
diff --git a/src/render/WeaponEffects.h b/src/render/WeaponEffects.h
index e4d0461a..31c5a309 100644
--- a/src/render/WeaponEffects.h
+++ b/src/render/WeaponEffects.h
@@ -3,21 +3,25 @@
class CWeaponEffects
{
public:
- bool m_bCrosshair;
- int8 gap_1[3];
+ bool m_bActive;
+ char _pad[3];
CVector m_vecPos;
- uint8 m_red;
- uint8 m_green;
- uint8 m_blue;
- uint8 m_alpha;
- float m_size;
- int32 field_24;
- RwTexture *m_pTexture;
- RwRaster *m_pRaster;
+ uint8 m_nRed;
+ uint8 m_nGreen;
+ uint8 m_nBlue;
+ uint8 m_nAlpha;
+ float m_fSize;
+ float m_fRotation;
public:
- static void Render(void);
- static void ClearCrossHair();
- static void MarkTarget(CVector, uint8, uint8, uint8, uint8, float);
+ CWeaponEffects();
+ ~CWeaponEffects();
+
static void Init(void);
+ static void Shutdown(void);
+ static void MarkTarget(CVector pos, uint8 red, uint8 green, uint8 blue, uint8 alpha, float size);
+ static void ClearCrossHair(void);
+ static void Render(void);
};
+
+VALIDATE_SIZE(CWeaponEffects, 0x1C); \ No newline at end of file
diff --git a/src/save/GenericGameStorage.cpp b/src/save/GenericGameStorage.cpp
index 2d5cfae2..d71b0c22 100644
--- a/src/save/GenericGameStorage.cpp
+++ b/src/save/GenericGameStorage.cpp
@@ -51,7 +51,6 @@ CDate &CompileDateAndTime = *(CDate*)0x72BCB8;
#define ReadDataFromBufferPointer(buf, to) memcpy(&to, buf, sizeof(to)); buf += align4bytes(sizeof(to));
#define WriteDataToBufferPointer(buf, from) memcpy(buf, &from, sizeof(from)); buf += align4bytes(sizeof(from));
-//WRAPPER bool GenericSave(int file) { EAXJMP(0x58F8D0); }
WRAPPER bool GenericLoad() { EAXJMP(0x590A00); }
diff --git a/src/skel/win/win.cpp b/src/skel/win/win.cpp
index 4e5dccff..7993426a 100644
--- a/src/skel/win/win.cpp
+++ b/src/skel/win/win.cpp
@@ -2056,13 +2056,7 @@ _WinMain(HINSTANCE instance,
{
GetWindowPlacement(PSGLOBAL(window), &wp);
- // Famous transparent menu bug. Also see the fix in Frontend.cpp
-#ifdef FIX_BUGS
- float ms = (float)CTimer::GetCurrentTimeInCycles() / (float)CTimer::GetCyclesPerMillisecond();
- if ((1000.0f / 100.0f) < ms && wp.showCmd != SW_SHOWMINIMIZED)
-#else
if (wp.showCmd != SW_SHOWMINIMIZED)
-#endif
RsEventHandler(rsFRONTENDIDLE, nil);
if ( !FrontEndMenuManager.m_bMenuActive || FrontEndMenuManager.m_bLoadingSavedGame )
diff --git a/src/vehicles/Automobile.cpp b/src/vehicles/Automobile.cpp
index 8cb0cfa4..e709a87f 100644
--- a/src/vehicles/Automobile.cpp
+++ b/src/vehicles/Automobile.cpp
@@ -2823,13 +2823,13 @@ CAutomobile::ProcessBuoyancy(void)
if(pDriver){
pDriver->bIsInWater = true;
if(pDriver->IsPlayer() || !bWaterTight)
- pDriver->InflictDamage(nil, WEAPONTYPE_WATER, CTimer::GetTimeStep(), PEDPIECE_TORSO, 0);
+ pDriver->InflictDamage(nil, WEAPONTYPE_DROWNING, CTimer::GetTimeStep(), PEDPIECE_TORSO, 0);
}
for(i = 0; i < m_nNumMaxPassengers; i++)
if(pPassengers[i]){
pPassengers[i]->bIsInWater = true;
if(pPassengers[i]->IsPlayer() || !bWaterTight)
- pPassengers[i]->InflictDamage(nil, WEAPONTYPE_WATER, CTimer::GetTimeStep(), PEDPIECE_TORSO, 0);
+ pPassengers[i]->InflictDamage(nil, WEAPONTYPE_DROWNING, CTimer::GetTimeStep(), PEDPIECE_TORSO, 0);
}
}else
bIsInWater = false;
diff --git a/src/vehicles/Vehicle.cpp b/src/vehicles/Vehicle.cpp
index 54bc2c01..1fe02953 100644
--- a/src/vehicles/Vehicle.cpp
+++ b/src/vehicles/Vehicle.cpp
@@ -17,6 +17,7 @@
#include "DMAudio.h"
#include "Radar.h"
#include "Fire.h"
+#include "Darkel.h"
bool &CVehicle::bWheelsOnlyCheat = *(bool *)0x95CD78;
bool &CVehicle::bAllDodosCheat = *(bool *)0x95CD75;
@@ -765,6 +766,29 @@ CVehicle::IsSphereTouchingVehicle(float sx, float sy, float sz, float radius)
return true;
}
+void
+DestroyVehicleAndDriverAndPassengers(CVehicle* pVehicle)
+{
+ if (pVehicle->pDriver) {
+#ifndef FIX_BUGS
+ // this just isn't fair
+ CDarkel::RegisterKillByPlayer(pVehicle->pDriver, WEAPONTYPE_UNIDENTIFIED);
+#endif
+ pVehicle->pDriver->FlagToDestroyWhenNextProcessed();
+ }
+ for (int i = 0; i < pVehicle->m_nNumMaxPassengers; i++) {
+ if (pVehicle->pPassengers[i]) {
+#ifndef FIX_BUGS
+ // this just isn't fair
+ CDarkel::RegisterKillByPlayer(pVehicle->pPassengers[i], WEAPONTYPE_UNIDENTIFIED);
+#endif
+ pVehicle->pPassengers[i]->FlagToDestroyWhenNextProcessed();
+ }
+ }
+ CWorld::Remove(pVehicle);
+ delete pVehicle;
+}
+
class CVehicle_ : public CVehicle
{
diff --git a/src/vehicles/Vehicle.h b/src/vehicles/Vehicle.h
index 68b7b2ca..2ca97841 100644
--- a/src/vehicles/Vehicle.h
+++ b/src/vehicles/Vehicle.h
@@ -301,3 +301,5 @@ public:
};
static_assert(sizeof(cVehicleParams) == 0x18, "cVehicleParams: error");
+
+void DestroyVehicleAndDriverAndPassengers(CVehicle* pVehicle);
diff --git a/src/weapons/Explosion.cpp b/src/weapons/Explosion.cpp
index 05087335..e99dc918 100644
--- a/src/weapons/Explosion.cpp
+++ b/src/weapons/Explosion.cpp
@@ -6,8 +6,6 @@
CExplosion(&gaExplosion)[48] = *(CExplosion(*)[48])*(uintptr*)0x64E208;
WRAPPER void CExplosion::AddExplosion(CEntity *explodingEntity, CEntity *culprit, eExplosionType type, const CVector &pos, uint32) { EAXJMP(0x5591C0); }
-//WRAPPER void CExplosion::RemoveAllExplosionsInArea(CVector, float) { EAXJMP(0x55AD40); }
-//WRAPPER bool CExplosion::TestForExplosionInArea(eExplosionType, float, float, float, float, float, float) { EAXJMP(0x55AC80); }
int AudioHandle = AEHANDLE_NONE;
diff --git a/src/weapons/ShotInfo.cpp b/src/weapons/ShotInfo.cpp
new file mode 100644
index 00000000..43d0579d
--- /dev/null
+++ b/src/weapons/ShotInfo.cpp
@@ -0,0 +1,140 @@
+#include "common.h"
+#include "patcher.h"
+#include "ShotInfo.h"
+#include "Entity.h"
+#include "Weapon.h"
+#include "World.h"
+#include "WeaponInfo.h"
+#include "General.h"
+#include "Timer.h"
+#include "Ped.h"
+#include "Fire.h"
+
+CShotInfo gaShotInfo[NUMSHOTINFOS];
+float CShotInfo::ms_afRandTable[20];
+
+// CShotInfo (&gaShotInfo)[100] = *(CShotInfo(*)[100])*(uintptr*)0x64F0D0;
+// float (&CShotInfo::ms_afRandTable)[20] = *(float(*)[20])*(uintptr*)0x6E9878;
+
+/*
+ Used for flamethrower. I don't know why it's name is CShotInfo.
+ Has no relation with any visual, just calculates the area fire affects
+ (including spreading and slowing of fire) and make entities burn/flee.
+*/
+
+void
+CShotInfo::Initialise()
+{
+ debug("Initialising CShotInfo...\n");
+ for(int i=0; i<ARRAY_SIZE(gaShotInfo); i++) {
+ gaShotInfo[i].m_inUse = false;
+ gaShotInfo[i].m_weapon = WEAPONTYPE_COLT45;
+ gaShotInfo[i].m_startPos = CVector(0.0f, 0.0f, 0.0f);
+ gaShotInfo[i].m_areaAffected = CVector(0.0f, 0.0f, 0.0f);
+ gaShotInfo[i].m_radius = 1.0f;
+ gaShotInfo[i].m_sourceEntity = nil;
+ gaShotInfo[i].m_timeout = 0;
+ }
+
+ // Not random for sure
+ float nextVal = -0.05f;
+ for (int i = 0; i < ARRAY_SIZE(ms_afRandTable); i++) {
+ ms_afRandTable[i] = nextVal;
+ nextVal += 0.005f;
+ }
+ debug("CShotInfo ready\n");
+}
+
+bool
+CShotInfo::AddShot(CEntity *sourceEntity, eWeaponType weapon, CVector startPos, CVector endPos)
+{
+ CWeaponInfo *weaponInfo = CWeaponInfo::GetWeaponInfo(weapon);
+
+ int slot;
+ for (slot = 0; slot < ARRAY_SIZE(gaShotInfo) && gaShotInfo[slot].m_inUse; slot++);
+
+ if (slot == ARRAY_SIZE(gaShotInfo))
+ return false;
+
+ gaShotInfo[slot].m_inUse = true;
+ gaShotInfo[slot].m_weapon = weapon;
+ gaShotInfo[slot].m_startPos = startPos;
+ gaShotInfo[slot].m_areaAffected = endPos - startPos;
+ gaShotInfo[slot].m_radius = weaponInfo->m_fRadius;
+
+ if (weaponInfo->m_fSpread != 0.0f) {
+ gaShotInfo[slot].m_areaAffected.x += CShotInfo::ms_afRandTable[CGeneral::GetRandomNumber() % ARRAY_SIZE(ms_afRandTable)] * weaponInfo->m_fSpread;
+ gaShotInfo[slot].m_areaAffected.y += CShotInfo::ms_afRandTable[CGeneral::GetRandomNumber() % ARRAY_SIZE(ms_afRandTable)] * weaponInfo->m_fSpread;
+ gaShotInfo[slot].m_areaAffected.z += CShotInfo::ms_afRandTable[CGeneral::GetRandomNumber() % ARRAY_SIZE(ms_afRandTable)];
+ }
+ gaShotInfo[slot].m_areaAffected.Normalise();
+ if (weaponInfo->m_bRandSpeed)
+ gaShotInfo[slot].m_areaAffected *= CShotInfo::ms_afRandTable[CGeneral::GetRandomNumber() % ARRAY_SIZE(ms_afRandTable)] + weaponInfo->m_fSpeed;
+ else
+ gaShotInfo[slot].m_areaAffected *= weaponInfo->m_fSpeed;
+
+ gaShotInfo[slot].m_sourceEntity = sourceEntity;
+ gaShotInfo[slot].m_timeout = CTimer::GetTimeInMilliseconds() + weaponInfo->m_fLifespan;
+
+ return true;
+}
+
+void
+CShotInfo::Shutdown()
+{
+ debug("Shutting down CShotInfo...\n");
+ debug("CShotInfo shut down\n");
+}
+
+void
+CShotInfo::Update()
+{
+ for (int slot = 0; slot < ARRAY_SIZE(gaShotInfo); slot++) {
+ CShotInfo &shot = gaShotInfo[slot];
+ if (shot.m_sourceEntity && shot.m_sourceEntity->IsPed() && !((CPed*)shot.m_sourceEntity)->IsPointerValid())
+ shot.m_sourceEntity = nil;
+
+ if (!shot.m_inUse)
+ continue;
+
+ CWeaponInfo *weaponInfo = CWeaponInfo::GetWeaponInfo(shot.m_weapon);
+ if (CTimer::GetTimeInMilliseconds() > shot.m_timeout)
+ shot.m_inUse = false;
+
+ if (weaponInfo->m_bSlowsDown)
+ shot.m_areaAffected *= pow(0.96, CTimer::GetTimeStep()); // FRAMERATE
+
+ if (weaponInfo->m_bExpands)
+ shot.m_radius += 0.075f * CTimer::GetTimeStep();
+
+ shot.m_startPos += CTimer::GetTimeStep() * shot.m_areaAffected;
+ if (shot.m_sourceEntity) {
+ assert(shot.m_sourceEntity->IsPed());
+ CPed *ped = (CPed*) shot.m_sourceEntity;
+ float radius = max(1.0f, shot.m_radius);
+
+ for (int i = 0; i < ped->m_numNearPeds; ++i) {
+ CPed *nearPed = ped->m_nearPeds[i];
+ if (nearPed->IsPointerValid()) {
+ if (nearPed->IsPedInControl() && (nearPed->GetPosition() - shot.m_startPos).MagnitudeSqr() < radius && !nearPed->bFireProof) {
+
+ if (!nearPed->IsPlayer()) {
+ nearPed->SetFindPathAndFlee(shot.m_sourceEntity, 10000);
+ nearPed->SetMoveState(PEDMOVE_SPRINT);
+ }
+ gFireManager.StartFire(nearPed, shot.m_sourceEntity, 0.8f, true);
+ }
+ }
+ }
+ }
+ if (!((CTimer::GetFrameCounter() + slot) & 3))
+ CWorld::SetCarsOnFire(shot.m_startPos.x, shot.m_startPos.y, shot.m_startPos.z, 4.0f, shot.m_sourceEntity);
+ }
+}
+
+STARTPATCHES
+ InjectHook(0x55BFF0, &CShotInfo::Update, PATCH_JUMP);
+ InjectHook(0x55BD70, &CShotInfo::AddShot, PATCH_JUMP);
+ InjectHook(0x55BC60, &CShotInfo::Initialise, PATCH_JUMP);
+ InjectHook(0x55BD50, &CShotInfo::Shutdown, PATCH_JUMP);
+ENDPATCHES \ No newline at end of file
diff --git a/src/weapons/ShotInfo.h b/src/weapons/ShotInfo.h
new file mode 100644
index 00000000..a5e5fd35
--- /dev/null
+++ b/src/weapons/ShotInfo.h
@@ -0,0 +1,23 @@
+#pragma once
+
+class CEntity;
+enum eWeaponType;
+
+class CShotInfo
+{
+public:
+ eWeaponType m_weapon;
+ CVector m_startPos;
+ CVector m_areaAffected;
+ float m_radius;
+ CEntity *m_sourceEntity;
+ float m_timeout;
+ bool m_inUse;
+
+ static float ms_afRandTable[20];
+
+ static void Initialise(void);
+ static bool AddShot(CEntity*, eWeaponType, CVector, CVector);
+ static void Shutdown(void);
+ static void Update(void);
+};
diff --git a/src/weapons/Weapon.cpp b/src/weapons/Weapon.cpp
index 8019a1cf..09844c23 100644
--- a/src/weapons/Weapon.cpp
+++ b/src/weapons/Weapon.cpp
@@ -6,6 +6,7 @@
#include "Ped.h"
#include "World.h"
+WRAPPER void CWeapon::ShutdownWeapons(void) { EAXJMP(0x55C2F0); }
WRAPPER void CWeapon::UpdateWeapons(void) { EAXJMP(0x55C310); }
WRAPPER bool CWeapon::Fire(CEntity*, CVector*) { EAXJMP(0x55C380); }
WRAPPER void CWeapon::FireFromCar(CAutomobile *car, bool left) { EAXJMP(0x55C940); }
diff --git a/src/weapons/Weapon.h b/src/weapons/Weapon.h
index 1db66720..74145564 100644
--- a/src/weapons/Weapon.h
+++ b/src/weapons/Weapon.h
@@ -15,17 +15,19 @@ enum eWeaponType
WEAPONTYPE_MOLOTOV,
WEAPONTYPE_GRENADE,
WEAPONTYPE_DETONATOR,
- WEAPONTYPE_TOTAL_INVENTORY_WEAPONS = 13,
- WEAPONTYPE_HELICANNON = 13,
- WEAPONTYPE_TOTALWEAPONS,
+ WEAPONTYPE_HELICANNON,
+ WEAPONTYPE_LAST_WEAPONTYPE,
WEAPONTYPE_ARMOUR,
WEAPONTYPE_RAMMEDBYCAR,
WEAPONTYPE_RUNOVERBYCAR,
WEAPONTYPE_EXPLOSION,
WEAPONTYPE_UZI_DRIVEBY,
- WEAPONTYPE_WATER,
- WEAPONTYPE_FALL_DAMAGE,
+ WEAPONTYPE_DROWNING,
+ WEAPONTYPE_FALL,
WEAPONTYPE_UNIDENTIFIED,
+
+ WEAPONTYPE_TOTALWEAPONS = WEAPONTYPE_LAST_WEAPONTYPE,
+ WEAPONTYPE_TOTAL_INVENTORY_WEAPONS = 13,
};
enum eWeaponFire {
@@ -63,6 +65,7 @@ public:
m_bAddRotOffset = false;
}
+ static void ShutdownWeapons(void);
void Initialise(eWeaponType type, int ammo);
void Update(int32 audioEntity);
void Reload(void);