diff options
Diffstat (limited to '')
53 files changed, 344 insertions, 65 deletions
diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index d32d4207..b82c650c 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -7376,12 +7376,12 @@ bool cAudioManager::ProcessTrainNoise(cVehicleParams *params) { CTrain *train; - int32 emittingVol; + uint8 emittingVol; float speedMultipler; if(params->m_fDistance >= 90000.f) return 0; - if(params->m_fVelocityChange <= 0.0f) { + if(params->m_fVelocityChange > 0.0f) { CalculateDistance((bool *)params, params->m_fDistance); train = (CTrain *)params->m_pVehicle; speedMultipler = min(1.0f, train->m_fSpeed * 250.f / 51.f); @@ -7427,11 +7427,8 @@ cAudioManager::ProcessTrainNoise(cVehicleParams *params) 100 * m_sQueueSample.m_nEntityIndex % 987; m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_bEmittingVolume = emittingVol; - m_sQueueSample.m_nLoopStart = - SampleManager.GetSampleLoopStartOffset( - m_sQueueSample.m_nSampleIndex); - m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset( - m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); + m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.field_48 = 6.0f; m_sQueueSample.m_fSoundIntensity = 70.0f; m_sQueueSample.field_56 = 0; diff --git a/src/audio/sampman.cpp b/src/audio/sampman.cpp index de222493..9bb2687d 100644 --- a/src/audio/sampman.cpp +++ b/src/audio/sampman.cpp @@ -1280,9 +1280,8 @@ cSampleManager::Terminate(void) bool cSampleManager::CheckForAnAudioFileOnCD(void) { - char filepath[MAX_PATH]; - #if !defined(GTA3_STEAM_PATCH) && !defined(NO_CDCHECK) + char filepath[MAX_PATH]; #if defined(GTA3_1_1_PATCH) if (_bUseHDDAudio) diff --git a/src/control/AccidentManager.cpp b/src/control/AccidentManager.cpp index e2b1f6d0..46d254fc 100644 --- a/src/control/AccidentManager.cpp +++ b/src/control/AccidentManager.cpp @@ -6,6 +6,8 @@ CAccidentManager& gAccidentManager = *(CAccidentManager*)0x87FD10; +WRAPPER void CAccidentManager::Update(void) { EAXJMP(0x456710); } + uint16 CAccidentManager::CountActiveAccidents() { uint16 accidents = 0; diff --git a/src/control/AccidentManager.h b/src/control/AccidentManager.h index 999abddc..6d7f25c8 100644 --- a/src/control/AccidentManager.h +++ b/src/control/AccidentManager.h @@ -22,6 +22,7 @@ class CAccidentManager public: uint16 CountActiveAccidents(); CAccident* FindNearestAccident(CVector, float*); + void Update(void); }; extern CAccidentManager& gAccidentManager;
\ No newline at end of file diff --git a/src/control/Cranes.cpp b/src/control/Cranes.cpp index ebdbf957..291e147f 100644 --- a/src/control/Cranes.cpp +++ b/src/control/Cranes.cpp @@ -5,4 +5,6 @@ WRAPPER bool CCranes::IsThisCarBeingTargettedByAnyCrane(CVehicle*) { EAXJMP(0x5451E0); } WRAPPER bool CCranes::IsThisCarBeingCarriedByAnyCrane(CVehicle*) { EAXJMP(0x545190); } WRAPPER void CCranes::ActivateCrane(float, float, float, float, float, float, float, float, bool, bool, float, float) { EAXJMP(0x543650); } -WRAPPER void CCranes::DeActivateCrane(float, float) { EAXJMP(0x543890); }
\ No newline at end of file +WRAPPER void CCranes::DeActivateCrane(float, float) { EAXJMP(0x543890); } +WRAPPER void CCranes::InitCranes(void) { EAXJMP(0x543360); } +WRAPPER void CCranes::UpdateCranes(void) { EAXJMP(0x5439E0); }
\ No newline at end of file diff --git a/src/control/Cranes.h b/src/control/Cranes.h index be586398..956e2e84 100644 --- a/src/control/Cranes.h +++ b/src/control/Cranes.h @@ -10,4 +10,6 @@ public: static bool IsThisCarBeingCarriedByAnyCrane(CVehicle*); static void ActivateCrane(float, float, float, float, float, float, float, float, bool, bool, float, float); static void DeActivateCrane(float, float); + static void InitCranes(void); + static void UpdateCranes(void); }; diff --git a/src/control/GameLogic.cpp b/src/control/GameLogic.cpp index 16727960..ed101cad 100644 --- a/src/control/GameLogic.cpp +++ b/src/control/GameLogic.cpp @@ -67,7 +67,7 @@ CGameLogic::Update() CVector vecRestartPos;
float fRestartFloat;
- if (CCutsceneMgr::ms_cutsceneProcessing) return;
+ if (CCutsceneMgr::IsCutsceneProcessing()) return;
CPlayerInfo &pPlayerInfo = CWorld::Players[CWorld::PlayerInFocus];
switch (pPlayerInfo.m_WBState) {
diff --git a/src/control/Gangs.cpp b/src/control/Gangs.cpp index 9ff40ef3..f6f9261e 100644 --- a/src/control/Gangs.cpp +++ b/src/control/Gangs.cpp @@ -3,7 +3,7 @@ #include "ModelIndices.h" #include "Gangs.h" -CGangInfo(&CGangs::Gang)[NUM_GANGS] = *(CGangInfo(*)[9])*(uintptr*)0x6EDF78; +CGangInfo(&CGangs::Gang)[NUM_GANGS] = *(CGangInfo(*)[NUM_GANGS])*(uintptr*)0x6EDF78; CGangInfo::CGangInfo() : m_nVehicleMI(MI_BUS), @@ -47,53 +47,37 @@ int8 CGangs::GetGangPedModelOverride(int16 gang) return GetGangInfo(gang)->m_nPedModelOverride; } -void CGangs::SaveAllGangData(uint8 *buffer, uint32 *size) +void CGangs::SaveAllGangData(uint8 *buf, uint32 *size) { - buffer[0] = 'G'; - buffer[1] = 'N'; - buffer[2] = 'G'; - buffer[3] = '\0'; - *size = 8 + NUM_GANGS * 16; - *(uint32*)(buffer + 4) = *size - 8; - buffer += 8; - for (int i = 0; i < NUM_GANGS; i++) { - *(uint32*)(buffer) = GetGangInfo(i)->m_nVehicleMI; - *(int8*)(buffer + 4) = GetGangInfo(i)->m_nPedModelOverride; - *(int8*)(buffer + 5) = GetGangInfo(i)->field_5; - *(int16*)(buffer + 6) = GetGangInfo(i)->field_6; - *(eWeaponType*)(buffer + 8) = GetGangInfo(i)->m_Weapon1; - *(eWeaponType*)(buffer + 12) = GetGangInfo(i)->m_Weapon2; - buffer += 16; - } +INITSAVEBUF + + *size = SAVE_HEADER_SIZE + sizeof(Gang);
+ WriteSaveHeader(buf, 'G','N','G','\0', *size - SAVE_HEADER_SIZE); + for (int i = 0; i < NUM_GANGS; i++)
+ WriteSaveBuf(buf, Gang[i]);
+
+VALIDATESAVEBUF(*size); } -void CGangs::LoadAllGangData(uint8 *buffer, uint32 size) +void CGangs::LoadAllGangData(uint8 *buf, uint32 size) { - Initialize(); - assert(size == 8 + NUM_GANGS * 16); - assert(buffer[0] == 'G'); - assert(buffer[1] == 'N'); - assert(buffer[2] == 'G'); - assert(buffer[3] == '\0'); - assert(*(uint32*)(buffer + 4) == size - 8); - buffer += 8; - for (int i = 0; i < NUM_GANGS; i++){ - GetGangInfo(i)->m_nVehicleMI = *(uint32*)(buffer); - GetGangInfo(i)->m_nPedModelOverride = *(int8*)(buffer + 4); - GetGangInfo(i)->field_5 = *(int8*)(buffer + 5); - GetGangInfo(i)->field_6 = *(int16*)(buffer + 6); - GetGangInfo(i)->m_Weapon1 = *(eWeaponType*)(buffer + 8); - GetGangInfo(i)->m_Weapon2 = *(eWeaponType*)(buffer + 12); - buffer += 16; - } + Initialize();
+
+INITSAVEBUF
+
+ WriteSaveHeader(buf, 'G','N','G','\0', size - SAVE_HEADER_SIZE); + for (int i = 0; i < NUM_GANGS; i++) + Gang[i] = ReadSaveBuf<CGangInfo>(buf); + +VALIDATESAVEBUF(size); } STARTPATCHES -InjectHook(0x4C3FB0, CGangs::Initialize, PATCH_JUMP); -InjectHook(0x4C4010, CGangs::SetGangVehicleModel, PATCH_JUMP); -InjectHook(0x4C4030, CGangs::SetGangWeapons, PATCH_JUMP); -InjectHook(0x4C4050, CGangs::SetGangPedModelOverride, PATCH_JUMP); -InjectHook(0x4C4070, CGangs::GetGangPedModelOverride, PATCH_JUMP); -InjectHook(0x4C4080, CGangs::SaveAllGangData, PATCH_JUMP); -InjectHook(0x4C4100, CGangs::LoadAllGangData, PATCH_JUMP); + InjectHook(0x4C3FB0, CGangs::Initialize, PATCH_JUMP); + InjectHook(0x4C4010, CGangs::SetGangVehicleModel, PATCH_JUMP); + InjectHook(0x4C4030, CGangs::SetGangWeapons, PATCH_JUMP); + InjectHook(0x4C4050, CGangs::SetGangPedModelOverride, PATCH_JUMP); + InjectHook(0x4C4070, CGangs::GetGangPedModelOverride, PATCH_JUMP); + InjectHook(0x4C4080, CGangs::SaveAllGangData, PATCH_JUMP); + InjectHook(0x4C4100, CGangs::LoadAllGangData, PATCH_JUMP); ENDPATCHES diff --git a/src/control/Garages.cpp b/src/control/Garages.cpp index 5f55ae66..b5ad37f4 100644 --- a/src/control/Garages.cpp +++ b/src/control/Garages.cpp @@ -25,6 +25,9 @@ bool &CGarages::PlayerInGarage = *(bool *)0x95CD83; int32 &CGarages::PoliceCarsCollected = *(int32 *)0x941444; uint32 &CGarages::GarageToBeTidied = *(uint32 *)0x623570; +WRAPPER void CGarages::Init(void) { EAXJMP(0x421C60); } +WRAPPER void CGarages::Update(void) { EAXJMP(0x421E40); } + bool CGarages::IsModelIndexADoor(uint32 id) { @@ -116,4 +119,4 @@ void CGarages::PrintMessages() } } } -#endif +#endif
\ No newline at end of file diff --git a/src/control/Garages.h b/src/control/Garages.h index bcd966e8..41c6b5ad 100644 --- a/src/control/Garages.h +++ b/src/control/Garages.h @@ -28,4 +28,6 @@ public: static bool IsPointWithinHideOutGarage(CVector&); static bool IsPointWithinAnyGarage(CVector&); static void PlayerArrestedOrDied(); + static void Init(void); + static void Update(void); }; diff --git a/src/control/Phones.cpp b/src/control/Phones.cpp index 074718db..ef978868 100644 --- a/src/control/Phones.cpp +++ b/src/control/Phones.cpp @@ -15,6 +15,8 @@ CPhone *&CPhoneInfo::pickedUpPhone = *(CPhone**)0x6283B0; bool &CPhoneInfo::isPhoneBeingPickedUp = *(bool*)0x6283B4; CPed *&CPhoneInfo::pedWhoPickingUpPhone = *(CPed**)0x6283B8; +WRAPPER void CPhoneInfo::Update(void) { EAXJMP(0x42F7A0); } + int CPhoneInfo::FindNearestFreePhone(CVector *pos) { diff --git a/src/control/Phones.h b/src/control/Phones.h index 6842eef4..99ec520c 100644 --- a/src/control/Phones.h +++ b/src/control/Phones.h @@ -56,6 +56,7 @@ public: int GrabPhone(float, float); void Initialise(void); void Shutdown(void); + void Update(void); }; extern CPhoneInfo &gPhoneInfo; diff --git a/src/control/Pickups.cpp b/src/control/Pickups.cpp index c1a85af4..91fd889c 100644 --- a/src/control/Pickups.cpp +++ b/src/control/Pickups.cpp @@ -47,6 +47,7 @@ uint8 aWeaponBlues[] = { 0, 0, 255, 0, 255, 255, 0, 128, 255, 0, 255, 0, 128, 25 float aWeaponScale[] = { 1.0f, 2.0f, 1.5f, 1.0f, 1.0f, 1.5f, 1.0f, 2.0f, 1.0f, 2.0f, 2.5f, 1.0f, 1.0f, 1.0f, 1.0f };
WRAPPER void CPacManPickups::Render(void) { EAXJMP(0x432F60); }
+WRAPPER void CPacManPickups::Update(void) { EAXJMP(0x432800); }
void
@@ -986,7 +987,7 @@ VALIDATESAVEBUF(size) void
CPickups::Save(uint8 *buf, uint32 *size)
{
- *size = sizeof(CPickup) * NUMPICKUPS + sizeof(uint16) + sizeof(uint16) + sizeof(uint32) * NUMCOLLECTEDPICKUPS;
+ *size = sizeof(aPickUps) + sizeof(uint16) + sizeof(uint16) + sizeof(aPickUpsCollected);
INITSAVEBUF
diff --git a/src/control/Pickups.h b/src/control/Pickups.h index cbf3f245..5f9814c3 100644 --- a/src/control/Pickups.h +++ b/src/control/Pickups.h @@ -106,4 +106,5 @@ class CPacManPickups {
public:
static void Render(void);
+ static void Update(void);
};
diff --git a/src/control/Population.cpp b/src/control/Population.cpp index 3e7ab427..a98721ac 100644 --- a/src/control/Population.cpp +++ b/src/control/Population.cpp @@ -11,15 +11,74 @@ int32 &CPopulation::m_AllRandomPedsThisType = *(int32*)0x5FA570; float &CPopulation::PedDensityMultiplier = *(float*)0x5FA56C; uint32 &CPopulation::ms_nTotalMissionPeds = *(uint32*)0x8F5F70; int32 &CPopulation::MaxNumberOfPedsInUse = *(int32*)0x5FA574; +uint32& CPopulation::ms_nNumCivMale = *(uint32*)0x8F2548; +uint32& CPopulation::ms_nNumCivFemale = *(uint32*)0x8F5F44; +uint32& CPopulation::ms_nNumCop = *(uint32*)0x885AFC; +bool& CPopulation::bZoneChangeHasHappened = *(bool*)0x95CD79; +uint32& CPopulation::ms_nNumEmergency = *(uint32*)0x94071C; +uint32& CPopulation::m_CountDownToPedsAtStart = *(uint32*)0x95CD4F; +uint32& CPopulation::ms_nNumGang1 = *(uint32*)0x8F1B1C; +uint32& CPopulation::ms_nNumGang2 = *(uint32*)0x8F1B14; +uint32& CPopulation::ms_nTotalPeds = *(uint32*)0x95CB50; +uint32& CPopulation::ms_nNumGang3 = *(uint32*)0x8F2548; +uint32& CPopulation::ms_nTotalGangPeds = *(uint32*)0x885AF0; +uint32& CPopulation::ms_nNumGang4 = *(uint32*)0x8F1B2C; +uint32& CPopulation::ms_nTotalCivPeds = *(uint32*)0x8F2C3C; +uint32& CPopulation::ms_nNumGang5 = *(uint32*)0x8F1B30; +uint32& CPopulation::ms_nNumDummy = *(uint32*)0x8F1A98; +uint32& CPopulation::ms_nNumGang6 = *(uint32*)0x8F1B20; +uint32& CPopulation::ms_nNumGang9 = *(uint32*)0x8F1B10; +uint32& CPopulation::ms_nNumGang7 = *(uint32*)0x8F1B28; +uint32& CPopulation::ms_nNumGang8 = *(uint32*)0x8F1B0C; +WRAPPER void CPopulation::Update(void) { EAXJMP(0x4F39A0); } +WRAPPER void CPopulation::LoadPedGroups() { EAXJMP(0x4F3870); } WRAPPER void CPopulation::UpdatePedCount(uint32, bool) { EAXJMP(0x4F5A60); } WRAPPER void CPopulation::DealWithZoneChange(eLevelName oldLevel, eLevelName newLevel, bool) { EAXJMP(0x4F6200); } WRAPPER CPed *CPopulation::AddPedInCar(CVehicle *vehicle) { EAXJMP(0x4F5800); } WRAPPER bool CPopulation::IsPointInSafeZone(CVector *coors) { EAXJMP(0x4F60C0); } void +CPopulation::Initialise() +{ + debug("Initialising CPopulation...\n"); + + ms_nNumCivMale = 0; + m_AllRandomPedsThisType = -1; + ms_nNumCivFemale = 0; + PedDensityMultiplier = 1.0; + ms_nNumCop = 0; + bZoneChangeHasHappened = 0; + ms_nNumEmergency = 0; + m_CountDownToPedsAtStart = 2; + ms_nNumGang1 = 0; + ms_nTotalMissionPeds = 0; + ms_nNumGang2 = 0; + ms_nTotalPeds = 0; + ms_nNumGang3 = 0; + ms_nTotalGangPeds = 0; + ms_nNumGang4 = 0; + ms_nTotalCivPeds = 0; + ms_nNumGang5 = 0; + ms_nNumDummy = 0; + ms_nNumGang6 = 0; + ms_nNumGang9 = 0; + ms_nNumGang7 = 0; + ms_nNumGang8 = 0; + + LoadPedGroups(); + DealWithZoneChange(LEVEL_COMMERCIAL, LEVEL_INDUSTRIAL, true); + + debug("CPopulation ready\n"); +} + +void CPopulation::RemovePed(CEntity* ent) { CWorld::Remove(ent); delete ent; } + +STARTPATCHES +InjectHook(0x4F3770, CPopulation::Initialise, PATCH_JUMP); +ENDPATCHES
\ No newline at end of file diff --git a/src/control/Population.h b/src/control/Population.h index 7757a7a6..006e6104 100644 --- a/src/control/Population.h +++ b/src/control/Population.h @@ -19,7 +19,29 @@ public: static float &PedDensityMultiplier; static uint32 &ms_nTotalMissionPeds; static int32 &MaxNumberOfPedsInUse; + static uint32& ms_nNumCivMale; + static uint32 &ms_nNumCivFemale; + static uint32 &ms_nNumCop; + static bool &bZoneChangeHasHappened; + static uint32 &ms_nNumEmergency; + static uint32& m_CountDownToPedsAtStart; + static uint32& ms_nNumGang1; + static uint32& ms_nNumGang2; + static uint32& ms_nTotalPeds; + static uint32& ms_nNumGang3; + static uint32& ms_nTotalGangPeds; + static uint32& ms_nNumGang4; + static uint32& ms_nTotalCivPeds; + static uint32& ms_nNumGang5; + static uint32& ms_nNumDummy; + static uint32& ms_nNumGang6; + static uint32& ms_nNumGang9; + static uint32& ms_nNumGang7; + static uint32& ms_nNumGang8; + static void Initialise(); + static void Update(void); + static void LoadPedGroups(); static void UpdatePedCount(uint32, bool); static void DealWithZoneChange(eLevelName oldLevel, eLevelName newLevel, bool); static CPed *AddPedInCar(CVehicle *vehicle); diff --git a/src/control/Record.cpp b/src/control/Record.cpp index cff4a19b..802ca516 100644 --- a/src/control/Record.cpp +++ b/src/control/Record.cpp @@ -6,5 +6,8 @@ uint16 &CRecordDataForGame::RecordingState = *(uint16*)0x95CC24; uint8 &CRecordDataForChase::Status = *(uint8*)0x95CDCE; +WRAPPER void CRecordDataForGame::SaveOrRetrieveDataForThisFrame(void) { EAXJMP(0x4341F0); } + +WRAPPER void CRecordDataForChase::SaveOrRetrieveDataForThisFrame(void) { EAXJMP(0x4347F0); } WRAPPER void CRecordDataForChase::ProcessControlCars(void) { EAXJMP(0x435540); } WRAPPER void CRecordDataForChase::SaveOrRetrieveCarPositions(void) { EAXJMP(0x434B20); }
\ No newline at end of file diff --git a/src/control/Record.h b/src/control/Record.h index 08e9f7c8..9f396c96 100644 --- a/src/control/Record.h +++ b/src/control/Record.h @@ -11,6 +11,7 @@ class CRecordDataForChase public: static uint8 &Status; + static void SaveOrRetrieveDataForThisFrame(void); static void ProcessControlCars(void); static void SaveOrRetrieveCarPositions(void); }; @@ -20,4 +21,6 @@ class CRecordDataForGame { public: static uint16 &RecordingState; + + static void SaveOrRetrieveDataForThisFrame(void); }; diff --git a/src/control/RoadBlocks.cpp b/src/control/RoadBlocks.cpp index 3683ff28..ed092391 100644 --- a/src/control/RoadBlocks.cpp +++ b/src/control/RoadBlocks.cpp @@ -2,4 +2,6 @@ #include "patcher.h" #include "RoadBlocks.h" +WRAPPER void CRoadBlocks::Init(void) { EAXJMP(0x436F50); } WRAPPER void CRoadBlocks::GenerateRoadBlockCopsForCar(CVehicle*, int32, int16) { EAXJMP(0x4376A0); } +WRAPPER void CRoadBlocks::GenerateRoadBlocks(void) { EAXJMP(0x436FA0); }
\ No newline at end of file diff --git a/src/control/RoadBlocks.h b/src/control/RoadBlocks.h index 0d965e48..b1bb3589 100644 --- a/src/control/RoadBlocks.h +++ b/src/control/RoadBlocks.h @@ -6,5 +6,7 @@ class CVehicle; class CRoadBlocks { public: + static void Init(void); static void GenerateRoadBlockCopsForCar(CVehicle*, int32, int16); + static void GenerateRoadBlocks(void); }; diff --git a/src/control/SceneEdit.cpp b/src/control/SceneEdit.cpp new file mode 100644 index 00000000..287b3c98 --- /dev/null +++ b/src/control/SceneEdit.cpp @@ -0,0 +1,5 @@ +#include "common.h" +#include "patcher.h" +#include "SceneEdit.h" + +WRAPPER void CSceneEdit::Update(void) { EAXJMP(0x585570); } diff --git a/src/control/SceneEdit.h b/src/control/SceneEdit.h new file mode 100644 index 00000000..f44b0011 --- /dev/null +++ b/src/control/SceneEdit.h @@ -0,0 +1,7 @@ +#pragma once + +class CSceneEdit +{ +public: + static void Update(void); +}; diff --git a/src/control/TrafficLights.cpp b/src/control/TrafficLights.cpp index 61c941b8..2cd09a03 100644 --- a/src/control/TrafficLights.cpp +++ b/src/control/TrafficLights.cpp @@ -5,6 +5,7 @@ #include "Vehicle.h" WRAPPER void CTrafficLights::DisplayActualLight(CEntity *ent) { EAXJMP(0x455800); } +WRAPPER void CTrafficLights::ScanForLightsOnMap(void) { EAXJMP(0x454F40); } WRAPPER bool CTrafficLights::ShouldCarStopForLight(CVehicle*, bool) { EAXJMP(0x455350); } WRAPPER bool CTrafficLights::ShouldCarStopForBridge(CVehicle*) { EAXJMP(0x456460); } diff --git a/src/control/TrafficLights.h b/src/control/TrafficLights.h index f0d0248d..06505ed6 100644 --- a/src/control/TrafficLights.h +++ b/src/control/TrafficLights.h @@ -13,6 +13,7 @@ class CTrafficLights { public: static void DisplayActualLight(CEntity *ent); + static void ScanForLightsOnMap(void); static uint8 LightForPeds(void); static bool ShouldCarStopForLight(CVehicle*, bool); static bool ShouldCarStopForBridge(CVehicle*); diff --git a/src/core/CutsceneMgr.cpp b/src/core/CutsceneMgr.cpp index b446cd5d..95abfcc9 100644 --- a/src/core/CutsceneMgr.cpp +++ b/src/core/CutsceneMgr.cpp @@ -107,8 +107,7 @@ const struct { int FindCutsceneAudioTrackId(const char *szCutsceneName) { - for (int i = 0; musicNameIdAssoc[i].szTrackName; i++) - { + for (int i = 0; musicNameIdAssoc[i].szTrackName; i++) { if (!strcmpi(musicNameIdAssoc[i].szTrackName, szCutsceneName)) return musicNameIdAssoc[i].iTrackId; } diff --git a/src/core/CutsceneMgr.h b/src/core/CutsceneMgr.h index 7215a123..8c4a918b 100644 --- a/src/core/CutsceneMgr.h +++ b/src/core/CutsceneMgr.h @@ -21,10 +21,10 @@ class CCutsceneMgr static CAnimBlendAssocGroup &ms_cutsceneAssociations; static CVector &ms_cutsceneOffset; static float &ms_cutsceneTimer; + static bool &ms_cutsceneProcessing; public: static CDirectory *&ms_pCutsceneDir; static uint32 &ms_cutsceneLoadStatus; - static bool &ms_cutsceneProcessing; static bool IsRunning(void) { return ms_running; } static bool IsCutsceneProcessing(void) { return ms_cutsceneProcessing; } diff --git a/src/core/FileLoader.cpp b/src/core/FileLoader.cpp index e9c06201..6f3b0971 100644 --- a/src/core/FileLoader.cpp +++ b/src/core/FileLoader.cpp @@ -25,6 +25,8 @@ #include "CdStream.h" #include "FileLoader.h" +WRAPPER void CFileLoader::ReloadPaths(const char *filename) { EAXJMP(0x476DB0); } + char CFileLoader::ms_line[256]; const char* diff --git a/src/core/FileLoader.h b/src/core/FileLoader.h index f9121ace..c3f5fe52 100644 --- a/src/core/FileLoader.h +++ b/src/core/FileLoader.h @@ -39,4 +39,6 @@ public: static void LoadPickup(const char *line); static void LoadMapZones(const char *filename); + + static void ReloadPaths(const char *filename); }; diff --git a/src/core/Fire.cpp b/src/core/Fire.cpp index 2181f91c..0317ccbe 100644 --- a/src/core/Fire.cpp +++ b/src/core/Fire.cpp @@ -32,4 +32,5 @@ CFire* CFireManager::FindNearestFire(CVector vecPos, float* pDistance) } WRAPPER void CFireManager::StartFire(CEntity *entityOnFire, CEntity *culprit, float, uint32) { EAXJMP(0x479590); } +WRAPPER void CFireManager::Update(void) { EAXJMP(0x479310); } WRAPPER CFire *CFireManager::FindFurthestFire_NeverMindFireMen(CVector coors, float, float) { EAXJMP(0x479430); } diff --git a/src/core/Fire.h b/src/core/Fire.h index 5080fd89..c752b2a6 100644 --- a/src/core/Fire.h +++ b/src/core/Fire.h @@ -31,6 +31,7 @@ class CFireManager CFire m_aFires[NUM_FIRES]; public: void StartFire(CEntity *entityOnFire, CEntity *culprit, float, uint32); + void Update(void); CFire *FindFurthestFire_NeverMindFireMen(CVector coors, float, float); CFire *FindNearestFire(CVector, float*); uint32 GetTotalActiveFires() const { return m_nTotalFires; } diff --git a/src/core/Game.cpp b/src/core/Game.cpp index b488a217..3ac4acb0 100644 --- a/src/core/Game.cpp +++ b/src/core/Game.cpp @@ -2,8 +2,59 @@ #include "patcher.h" #include "Game.h" #include "main.h" +#include "AccidentManager.h" +#include "Antennas.h" +#include "Bridge.h" +#include "Camera.h" +#include "CarCtrl.h" +#include "CarGen.h" #include "CdStream.h" +#include "Clock.h" +#include "Clouds.h" +#include "Collision.h" +#include "Coronas.h" +#include "Cranes.h" +#include "CutsceneMgr.h" +#include "Darkel.h" +#include "EventList.h" +#include "FileLoader.h" #include "FileMgr.h" +#include "Fire.h" +#include "Fluff.h" +#include "Font.h" +#include "Frontend.h" +#include "GameLogic.h" +#include "Garages.h" +#include "Glass.h" +#include "Heli.h" +#include "Pad.h" +#include "Particle.h" +#include "Phones.h" +#include "Pickups.h" +#include "Plane.h" +#include "Population.h" +#include "Record.h" +#include "Renderer.h" +#include "Replay.h" +#include "RoadBlocks.h" +#include "Rubbish.h" +#include "SceneEdit.h" +#include "Script.h" +#include "Shadows.h" +#include "Skidmarks.h" +#include "SpecialFX.h" +#include "Sprite2d.h" +#include "Streaming.h" +#include "TimeCycle.h" +#include "TrafficLights.h" +#include "Train.h" +#include "User.h" +#include "WaterCannon.h" +#include "Weapon.h" +#include "Weather.h" +#include "World.h" +#include "ZoneCull.h" +#include "Zones.h" eLevelName &CGame::currLevel = *(eLevelName*)0x941514; bool &CGame::bDemoMode = *(bool*)0x5F4DD0; @@ -25,9 +76,104 @@ CGame::InitialiseOnceBeforeRW(void) } WRAPPER void CGame::Initialise(const char *datFile) { EAXJMP(0x48BED0); } +#if 0 WRAPPER void CGame::Process(void) { EAXJMP(0x48C850); } +#else +void CGame::Process(void) +{ + CPad::UpdatePads(); + TheCamera.SetMotionBlurAlpha(0); + if (TheCamera.m_BlurType == MBLUR_NONE || TheCamera.m_BlurType == MBLUR_SNIPER || TheCamera.m_BlurType == MBLUR_NORMAL) + TheCamera.SetMotionBlur(0, 0, 0, 0, MBLUR_NONE); + CCutsceneMgr::Update(); + if (!CCutsceneMgr::IsCutsceneProcessing() && !CTimer::GetIsCodePaused()) + FrontEndMenuManager.Process(); + CStreaming::Update(); + if (!CTimer::GetIsPaused()) + { + CTheZones::Update(); + CSprite2d::SetRecipNearClip(); + CSprite2d::InitPerFrame(); + CFont::InitPerFrame(); + CRecordDataForGame::SaveOrRetrieveDataForThisFrame(); + CRecordDataForChase::SaveOrRetrieveDataForThisFrame(); + CPad::DoCheats(); + CClock::Update(); + CWeather::Update(); + CTheScripts::Process(); + CCollision::Update(); + CTrain::UpdateTrains(); + CPlane::UpdatePlanes(); + CHeli::UpdateHelis(); + CDarkel::Update(); + CSkidmarks::Update(); + CAntennas::Update(); + CGlass::Update(); + CSceneEdit::Update(); + CEventList::Update(); + CParticle::Update(); + gFireManager.Update(); + CPopulation::Update(); + CWeapon::UpdateWeapons(); + if (!CCutsceneMgr::IsRunning()) + CTheCarGenerators::Process(); + if (!CReplay::IsPlayingBack()) + CCranes::UpdateCranes(); + CClouds::Update(); + CMovingThings::Update(); + CWaterCannons::Update(); + CUserDisplay::Process(); + CReplay::Update(); + CWorld::Process(); + gAccidentManager.Update(); + CPacManPickups::Update(); + CPickups::Update(); + CGarages::Update(); + CRubbish::Update(); + CSpecialFX::Update(); + CTimeCycle::Update(); + if (CReplay::ShouldStandardCameraBeProcessed()) + TheCamera.Process(); + CCullZones::Update(); + if (!CReplay::IsPlayingBack()) + CGameLogic::Update(); + CBridge::Update(); + CCoronas::DoSunAndMoon(); + CCoronas::Update(); + CShadows::UpdateStaticShadows(); + CShadows::UpdatePermanentShadows(); + gPhoneInfo.Update(); + if (!CReplay::IsPlayingBack()) + { + CCarCtrl::GenerateRandomCars(); + CRoadBlocks::GenerateRoadBlocks(); + CCarCtrl::RemoveDistantCars(); + } + } +} +#endif - +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(); +} WRAPPER bool CGame::InitialiseRenderWare(void) { EAXJMP(0x48BBA0); } WRAPPER void CGame::ShutdownRenderWare(void) { EAXJMP(0x48BCB0); } @@ -36,3 +182,7 @@ 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); +ENDPATCHES diff --git a/src/core/Game.h b/src/core/Game.h index 3bc3e633..dca38bdb 100644 --- a/src/core/Game.h +++ b/src/core/Game.h @@ -30,6 +30,7 @@ public: static void FinalShutdown(void); static void ShutDownForRestart(void); static void Process(void); + static void ReloadIPLs(void); // NB: these do something on PS2 static void TidyUpMemory(bool, bool) {} diff --git a/src/core/User.cpp b/src/core/User.cpp index f40a06db..693333b7 100644 --- a/src/core/User.cpp +++ b/src/core/User.cpp @@ -15,6 +15,8 @@ CCurrentVehicle& CUserDisplay::CurrentVehicle = *(CCurrentVehicle*)0x8F5FE8; WRAPPER void CPager::AddMessage(wchar*, uint16, uint16, uint16) { EAXJMP(0x52B940); } +WRAPPER void CUserDisplay::Process(void) { EAXJMP(0x4AD690); } + void COnscreenTimer::Init() { m_bDisabled = false; for(uint32 i = 0; i < NUMONSCREENTIMERENTRIES; i++) { @@ -125,8 +127,7 @@ void COnscreenTimerEntry::Process() { *timerPtr = (uint32)newTime; uint32 oldTimeSeconds = oldTime / 1000; if(oldTimeSeconds <= 11 && newTime / 1000 != oldTimeSeconds) { - // TODO: use an enum here - DMAudio.PlayFrontEndSound(0x93, newTime / 1000); + DMAudio.PlayFrontEndSound(SOUND_CLOCK_TICK, newTime / 1000); } } } diff --git a/src/core/User.h b/src/core/User.h index cac2a318..27bb7f9e 100644 --- a/src/core/User.h +++ b/src/core/User.h @@ -63,4 +63,6 @@ public: static COnscreenTimer &OnscnTimer; static CPager &Pager; static CCurrentVehicle &CurrentVehicle; + + static void Process(void); }; diff --git a/src/core/Wanted.h b/src/core/Wanted.h index 1303365d..15bff1a5 100644 --- a/src/core/Wanted.h +++ b/src/core/Wanted.h @@ -43,7 +43,7 @@ class CWanted public: int32 m_nChaos; int32 m_nLastUpdateTime; - int32 m_nLastWantedLevelChange; + uint32 m_nLastWantedLevelChange; float m_fCrimeSensitivity; uint8 m_CurrentCops; uint8 m_MaxCops; diff --git a/src/core/World.cpp b/src/core/World.cpp index 3a8367f1..5dea09bd 100644 --- a/src/core/World.cpp +++ b/src/core/World.cpp @@ -39,6 +39,8 @@ bool &CWorld::bDoingCarCollisions = *(bool*)0x95CD8C; bool &CWorld::bIncludeCarTyres = *(bool*)0x95CDAA; WRAPPER void CWorld::ShutDown(void) { EAXJMP(0x4AE450); } +WRAPPER void CWorld::RepositionCertainDynamicObjects() { EAXJMP(0x4B42B0); } +WRAPPER void CWorld::RemoveStaticObjects() { EAXJMP(0x4B4D50); } WRAPPER void CWorld::RemoveReferencesToDeletedObject(CEntity*) { EAXJMP(0x4B3BF0); } WRAPPER void CWorld::FindObjectsKindaColliding(const CVector &, float, bool, int16*, int16, CEntity **, bool, bool, bool, bool, bool){ EAXJMP(0x4B2A30); } WRAPPER void CWorld::ClearExcitingStuffFromArea(const CVector &pos, float radius, uint8) { EAXJMP(0x4B4E70) }; diff --git a/src/core/World.h b/src/core/World.h index f420207c..a1aa0376 100644 --- a/src/core/World.h +++ b/src/core/World.h @@ -122,6 +122,8 @@ public: static void Initialise(); static void ShutDown(); + static void RepositionCertainDynamicObjects(); + static void RemoveStaticObjects(); static void Process(); }; diff --git a/src/peds/PlayerPed.cpp b/src/peds/PlayerPed.cpp index 55906c38..69cc316a 100644 --- a/src/peds/PlayerPed.cpp +++ b/src/peds/PlayerPed.cpp @@ -100,7 +100,7 @@ CPlayerPed::ClearAdrenaline(void) { if (m_bAdrenalineActive && m_nAdrenalineTime != 0) { m_nAdrenalineTime = 0; - CTimer::SetTimeStep(1.0f); + CTimer::SetTimeScale(1.0f); } } diff --git a/src/render/Glass.cpp b/src/render/Glass.cpp index 9a233584..5d7dcc86 100644 --- a/src/render/Glass.cpp +++ b/src/render/Glass.cpp @@ -17,3 +17,4 @@ CGlass::WindowRespondsToSoftCollision(CEntity *ent, float amount) } WRAPPER void CGlass::Render(void) { EAXJMP(0x502350); } +WRAPPER void CGlass::Update(void) { EAXJMP(0x502050); } diff --git a/src/render/Glass.h b/src/render/Glass.h index 60592c39..b29cf173 100644 --- a/src/render/Glass.h +++ b/src/render/Glass.h @@ -9,4 +9,5 @@ public: static void WindowRespondsToCollision(CEntity *ent, float amount, CVector speed, CVector point, bool foo); static void WindowRespondsToSoftCollision(CEntity *ent, float amount); static void Render(void); + static void Update(void); }; diff --git a/src/render/Hud.cpp b/src/render/Hud.cpp index d74816bf..a9215cb7 100644 --- a/src/render/Hud.cpp +++ b/src/render/Hud.cpp @@ -755,7 +755,7 @@ void CHud::Draw() PagerXOffset -= fStep * CTimer::GetTimeStep(); } if (!PagerSoundPlayed) { - DMAudio.PlayFrontEndSound(96, 0); + DMAudio.PlayFrontEndSound(SOUND_PAGER, 0); PagerSoundPlayed = 1; } } diff --git a/src/render/Rubbish.cpp b/src/render/Rubbish.cpp index c925df1c..05d6b544 100644 --- a/src/render/Rubbish.cpp +++ b/src/render/Rubbish.cpp @@ -4,3 +4,4 @@ WRAPPER void CRubbish::Render(void) { EAXJMP(0x512190); } WRAPPER void CRubbish::StirUp(CVehicle *veh) { EAXJMP(0x512690); } +WRAPPER void CRubbish::Update(void) { EAXJMP(0x511B90); } diff --git a/src/render/Rubbish.h b/src/render/Rubbish.h index 9f946dc2..0bc7c397 100644 --- a/src/render/Rubbish.h +++ b/src/render/Rubbish.h @@ -7,4 +7,5 @@ class CRubbish public: static void Render(void); static void StirUp(CVehicle *veh); // CAutomobile on PS2 + static void Update(void); }; diff --git a/src/render/Skidmarks.cpp b/src/render/Skidmarks.cpp index bbadd54c..7489f7cd 100644 --- a/src/render/Skidmarks.cpp +++ b/src/render/Skidmarks.cpp @@ -3,6 +3,7 @@ #include "Skidmarks.h" WRAPPER void CSkidmarks::Clear(void) { EAXJMP(0x518130); } +WRAPPER void CSkidmarks::Update() { EAXJMP(0x518200); } 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); } diff --git a/src/render/Skidmarks.h b/src/render/Skidmarks.h index 280150a7..e5372136 100644 --- a/src/render/Skidmarks.h +++ b/src/render/Skidmarks.h @@ -4,6 +4,7 @@ class CSkidmarks { public: static void Clear(void); + static void Update(void); static void Render(void); static void RegisterOne(uint32 id, CVector pos, float fwdx, float fwdY, bool *isMuddy, bool *isBloddy); }; diff --git a/src/render/SpecialFX.cpp b/src/render/SpecialFX.cpp index 44e1e029..6f21e06c 100644 --- a/src/render/SpecialFX.cpp +++ b/src/render/SpecialFX.cpp @@ -7,6 +7,7 @@ #include "Text.h" WRAPPER void CSpecialFX::Render(void) { EAXJMP(0x518DC0); } +WRAPPER void CSpecialFX::Update(void) { EAXJMP(0x518D40); } 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 bdd74bee..6f4e636f 100644 --- a/src/render/SpecialFX.h +++ b/src/render/SpecialFX.h @@ -4,6 +4,7 @@ class CSpecialFX { public: static void Render(void); + static void Update(void); }; class CMotionBlurStreaks diff --git a/src/render/WaterCannon.cpp b/src/render/WaterCannon.cpp index 9398c847..7f44116b 100644 --- a/src/render/WaterCannon.cpp +++ b/src/render/WaterCannon.cpp @@ -2,5 +2,6 @@ #include "patcher.h" #include "WaterCannon.h" +WRAPPER void CWaterCannons::Update(void) { EAXJMP(0x522510); } WRAPPER void CWaterCannons::UpdateOne(uint32 id, CVector *pos, CVector *dir) { EAXJMP(0x522470); } WRAPPER void CWaterCannons::Render(void) { EAXJMP(0x522550); } diff --git a/src/render/WaterCannon.h b/src/render/WaterCannon.h index 55949803..de9d0344 100644 --- a/src/render/WaterCannon.h +++ b/src/render/WaterCannon.h @@ -3,6 +3,7 @@ class CWaterCannons { public: + static void Update(void); static void UpdateOne(uint32 id, CVector *pos, CVector *dir); static void Render(void); }; diff --git a/src/render/Weather.cpp b/src/render/Weather.cpp index 452eca92..db1bc80b 100644 --- a/src/render/Weather.cpp +++ b/src/render/Weather.cpp @@ -28,6 +28,7 @@ bool &CWeather::bScriptsForceRain = *(bool*)0x95CD7D; bool &CWeather::Stored_StateStored = *(bool*)0x95CDC1; WRAPPER void CWeather::RenderRainStreaks(void) { EAXJMP(0x524550); } +WRAPPER void CWeather::Update(void) { EAXJMP(0x522C10); } void CWeather::ReleaseWeather() { diff --git a/src/render/Weather.h b/src/render/Weather.h index bbf8498e..41cc5c0e 100644 --- a/src/render/Weather.h +++ b/src/render/Weather.h @@ -34,6 +34,7 @@ public: static bool &Stored_StateStored; static void RenderRainStreaks(void); + static void Update(void); static void ReleaseWeather(); static void ForceWeather(int16); diff --git a/src/weapons/Weapon.cpp b/src/weapons/Weapon.cpp index 3f511358..860e3ab2 100644 --- a/src/weapons/Weapon.cpp +++ b/src/weapons/Weapon.cpp @@ -6,6 +6,7 @@ #include "Ped.h" #include "World.h" +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); } WRAPPER void CWeapon::AddGunshell(CEntity*, CVector const&, CVector2D const&, float) { EAXJMP(0x55F770); } diff --git a/src/weapons/Weapon.h b/src/weapons/Weapon.h index 2f277c62..1663ee0d 100644 --- a/src/weapons/Weapon.h +++ b/src/weapons/Weapon.h @@ -73,5 +73,6 @@ public: static void DoTankDoomAiming(CEntity *playerVehicle, CEntity *playerPed, CVector *start, CVector *end); bool HitsGround(CEntity* holder, CVector* firePos, CEntity* aimingTo); static void InitialiseWeapons(void); + static void UpdateWeapons(void); }; static_assert(sizeof(CWeapon) == 0x18, "CWeapon: error"); |