From 5b1ffb09124c7427b7efb421091179ddecc725c4 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Thu, 17 Oct 2019 00:53:25 +0300 Subject: Some CPool and CPools funcs, restoring original logic of pool lookup loops --- src/control/Bridge.cpp | 3 +-- src/control/CarAI.cpp | 2 +- src/control/CarCtrl.cpp | 6 ++---- src/control/Phones.cpp | 4 ++-- src/control/Pickups.cpp | 4 ++-- src/control/Replay.cpp | 20 ++++++++++---------- 6 files changed, 18 insertions(+), 21 deletions(-) (limited to 'src/control') diff --git a/src/control/Bridge.cpp b/src/control/Bridge.cpp index 81f43f32..dacb7aab 100644 --- a/src/control/Bridge.cpp +++ b/src/control/Bridge.cpp @@ -123,8 +123,7 @@ void CBridge::FindBridgeEntities() pLiftRoad = nil; pLiftPart = nil; - for (int i = 1; i < CPools::GetBuildingPool()->GetSize(); ++i) - { + for (int i = CPools::GetBuildingPool()->GetSize()-1; i >= 0; i--) { CBuilding* entry = CPools::GetBuildingPool()->GetSlot(i); if (entry) { diff --git a/src/control/CarAI.cpp b/src/control/CarAI.cpp index bb0c1ec3..b4dd8777 100644 --- a/src/control/CarAI.cpp +++ b/src/control/CarAI.cpp @@ -588,7 +588,7 @@ void CCarAI::MakeWayForCarWithSiren(CVehicle *pVehicle) CVector2D forward = pVehicle->GetMoveSpeed() / flatSpeed; float projection = flatSpeed * 45 + 20; int i = CPools::GetVehiclePool()->GetSize(); - while (i--) { + while (--i >= 0) { CVehicle* vehicle = CPools::GetVehiclePool()->GetSlot(i); if (!vehicle) continue; diff --git a/src/control/CarCtrl.cpp b/src/control/CarCtrl.cpp index fd6d8057..cf77b5a4 100644 --- a/src/control/CarCtrl.cpp +++ b/src/control/CarCtrl.cpp @@ -648,8 +648,7 @@ CCarCtrl::AddToCarArray(int32 id, int32 vehclass) void CCarCtrl::RemoveDistantCars() { - uint32 i = CPools::GetVehiclePool()->GetSize(); - while (--i){ + for (int i = CPools::GetVehiclePool()->GetSize()-1; i >= 0; i--) { CVehicle* pVehicle = CPools::GetVehiclePool()->GetSlot(i); if (!pVehicle) continue; @@ -733,8 +732,7 @@ int32 CCarCtrl::CountCarsOfType(int32 mi) { int32 total = 0; - uint32 i = CPools::GetVehiclePool()->GetSize(); - while (i--){ + for (int i = CPools::GetVehiclePool()->GetSize()-1; i >= 0; i--) { CVehicle* pVehicle = CPools::GetVehiclePool()->GetSlot(i); if (!pVehicle) continue; diff --git a/src/control/Phones.cpp b/src/control/Phones.cpp index f8005899..074718db 100644 --- a/src/control/Phones.cpp +++ b/src/control/Phones.cpp @@ -151,8 +151,8 @@ CPhoneInfo::Initialise(void) pickedUpPhone = nil; m_nMax = 0; m_nNum = 0; - for (int v5 = pool->GetSize() - 1; v5 >= 0; v5--) { - CBuilding *building = pool->GetSlot(v5); + for (int i = pool->GetSize() - 1; i >= 0; i--) { + CBuilding *building = pool->GetSlot(i); if (building) { if (building->m_modelIndex == MI_PHONEBOOTH1) { CPhone *maxPhone = &m_aPhones[m_nMax]; diff --git a/src/control/Pickups.cpp b/src/control/Pickups.cpp index 3ba01e46..c1a85af4 100644 --- a/src/control/Pickups.cpp +++ b/src/control/Pickups.cpp @@ -296,7 +296,7 @@ CPickup::Update(CPlayerPed *player, CVehicle *vehicle, int playerId) m_pObject->UpdateRwFrame(); bool touched = false; - for (int32 i = CPools::GetVehiclePool()->GetSize(); i > 0; i--) { // TODO: check if i > 0 is not a R* mistake + for (int32 i = CPools::GetVehiclePool()->GetSize()-1; i >= 0; i--) { CVehicle *vehicle = CPools::GetVehiclePool()->GetSlot(i); if (vehicle != nil && vehicle->IsSphereTouchingVehicle(m_pObject->GetPosition().x, m_pObject->GetPosition().y, m_pObject->GetPosition().z, 1.5f)) { touched = true; @@ -323,7 +323,7 @@ CPickup::Update(CPlayerPed *player, CVehicle *vehicle, int playerId) if (CTimer::GetTimeInMilliseconds() > m_nTimer) explode = true; else {// added else here since vehicle lookup is useless - for (int32 i = CPools::GetVehiclePool()->GetSize(); i > 0; i--) { // TODO: check if i > 0 is not a R* mistake + for (int32 i = CPools::GetVehiclePool()->GetSize()-1; i >= 0; i--) { CVehicle *vehicle = CPools::GetVehiclePool()->GetSlot(i); if (vehicle != nil && vehicle->IsSphereTouchingVehicle(m_pObject->GetPosition().x, m_pObject->GetPosition().y, m_pObject->GetPosition().z, 1.5f)) { explode = true; diff --git a/src/control/Replay.cpp b/src/control/Replay.cpp index 65ee2840..473b13d3 100644 --- a/src/control/Replay.cpp +++ b/src/control/Replay.cpp @@ -1156,7 +1156,7 @@ void CReplay::RestoreStuffFromMem(void) FindPlayerPed()->m_pWanted = new CWanted(PlayerWanted); /* Nice memory leak */ CWorld::Players[0] = PlayerInfo; int i = CPools::GetPedPool()->GetSize(); - while (i--){ + while (--i >= 0) { CPed* ped = CPools::GetPedPool()->GetSlot(i); if (!ped) continue; @@ -1174,7 +1174,7 @@ void CReplay::RestoreStuffFromMem(void) ped->AddWeaponModel(ped->m_wepModelID); } i = CPools::GetVehiclePool()->GetSize(); - while (i--){ + while (--i >= 0) { CVehicle* vehicle = CPools::GetVehiclePool()->GetSlot(i); if (!vehicle) continue; @@ -1233,7 +1233,7 @@ void CReplay::RestoreStuffFromMem(void) } PrintElementsInPtrList(); i = CPools::GetObjectPool()->GetSize(); - while (i--){ + while (--i >= 0) { CObject* object = CPools::GetObjectPool()->GetSlot(i); if (!object) continue; @@ -1248,7 +1248,7 @@ void CReplay::RestoreStuffFromMem(void) object->GetMatrix().AttachRW(RwFrameGetMatrix(RpAtomicGetFrame(object->m_rwObject)), false); } i = CPools::GetDummyPool()->GetSize(); - while (i--){ + while (--i >= 0) { CDummy* dummy = CPools::GetDummyPool()->GetSlot(i); if (!dummy) continue; @@ -1294,7 +1294,7 @@ WRAPPER void CReplay::EmptyPedsAndVehiclePools(void) { EAXJMP(0x5970E0); } void CReplay::EmptyPedsAndVehiclePools(void) { int i = CPools::GetVehiclePool()->GetSize(); - while (i--) { + while (--i >= 0) { CVehicle* v = CPools::GetVehiclePool()->GetSlot(i); if (!v) continue; @@ -1302,7 +1302,7 @@ void CReplay::EmptyPedsAndVehiclePools(void) delete v; } i = CPools::GetPedPool()->GetSize(); - while (i--) { + while (--i >= 0) { CPed* p = CPools::GetPedPool()->GetSlot(i); if (!p) continue; @@ -1319,7 +1319,7 @@ void CReplay::EmptyAllPools(void) { EmptyPedsAndVehiclePools(); int i = CPools::GetObjectPool()->GetSize(); - while (i--) { + while (--i >= 0) { CObject* o = CPools::GetObjectPool()->GetSlot(i); if (!o) continue; @@ -1327,7 +1327,7 @@ void CReplay::EmptyAllPools(void) delete o; } i = CPools::GetDummyPool()->GetSize(); - while (i--) { + while (--i >= 0) { CDummy* d = CPools::GetDummyPool()->GetSlot(i); if (!d) continue; @@ -1343,14 +1343,14 @@ WRAPPER void CReplay::MarkEverythingAsNew(void) { EAXJMP(0x597280); } void CReplay::MarkEverythingAsNew(void) { int i = CPools::GetVehiclePool()->GetSize(); - while (i--) { + while (--i >= 0) { CVehicle* v = CPools::GetVehiclePool()->GetSlot(i); if (!v) continue; v->bHasAlreadyBeenRecorded = false; } i = CPools::GetPedPool()->GetSize(); - while (i--) { + while (--i >= 0) { CPed* p = CPools::GetPedPool()->GetSlot(i); if (!p) continue; -- cgit v1.2.3 From 32f2f3511c1a6d74c1347542f8c1b76f40677e01 Mon Sep 17 00:00:00 2001 From: nmzik Date: Fri, 18 Oct 2019 15:36:40 +0300 Subject: CPopulation::Initialise() --- src/control/Population.cpp | 58 ++++++++++++++++++++++++++++++++++++++++++++++ src/control/Population.h | 21 +++++++++++++++++ 2 files changed, 79 insertions(+) (limited to 'src/control') diff --git a/src/control/Population.cpp b/src/control/Population.cpp index 3e7ab427..39c2b57d 100644 --- a/src/control/Population.cpp +++ b/src/control/Population.cpp @@ -11,15 +11,73 @@ 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::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..09218f1b 100644 --- a/src/control/Population.h +++ b/src/control/Population.h @@ -19,7 +19,28 @@ 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 LoadPedGroups(); static void UpdatePedCount(uint32, bool); static void DealWithZoneChange(eLevelName oldLevel, eLevelName newLevel, bool); static CPed *AddPedInCar(CVehicle *vehicle); -- cgit v1.2.3 From f56684d04e06af21f423ad4bc1c47bc2b09fccea Mon Sep 17 00:00:00 2001 From: nmzik Date: Sat, 19 Oct 2019 01:23:40 +0300 Subject: CGame::Process() && CGame::ReloadIPLs --- src/control/AccidentManager.cpp | 2 ++ src/control/AccidentManager.h | 1 + src/control/Cranes.cpp | 4 +++- src/control/Cranes.h | 2 ++ src/control/Garages.cpp | 5 ++++- src/control/Garages.h | 2 ++ src/control/Phones.cpp | 2 ++ src/control/Phones.h | 1 + src/control/Pickups.cpp | 1 + src/control/Pickups.h | 1 + src/control/Population.cpp | 1 + src/control/Population.h | 1 + src/control/Record.cpp | 3 +++ src/control/Record.h | 3 +++ src/control/RoadBlocks.cpp | 2 ++ src/control/RoadBlocks.h | 2 ++ src/control/SceneEdit.cpp | 5 +++++ src/control/SceneEdit.h | 7 +++++++ src/control/TrafficLights.cpp | 1 + src/control/TrafficLights.h | 1 + 20 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 src/control/SceneEdit.cpp create mode 100644 src/control/SceneEdit.h (limited to 'src/control') 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/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 f8005899..fcab63a2 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 e095ec8e..a2440235 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 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 39c2b57d..a98721ac 100644 --- a/src/control/Population.cpp +++ b/src/control/Population.cpp @@ -31,6 +31,7 @@ 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); } diff --git a/src/control/Population.h b/src/control/Population.h index 09218f1b..006e6104 100644 --- a/src/control/Population.h +++ b/src/control/Population.h @@ -40,6 +40,7 @@ public: 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); 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*); -- cgit v1.2.3 From e35780df43d5bd17f1e2a6ae731a63d034d1c5c4 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Mon, 21 Oct 2019 01:08:26 +0300 Subject: Full Messages --- src/control/Script.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/control') diff --git a/src/control/Script.cpp b/src/control/Script.cpp index 777acb12..ced06f1e 100644 --- a/src/control/Script.cpp +++ b/src/control/Script.cpp @@ -662,12 +662,12 @@ void CRunningScript::Process() if (!CPad::GetPad(0)->GetCrossJustDown()) return; m_nWakeTime = 0; - for (int i = 0; i < 6; i++){ /* TODO: add constant for number of messages */ - if (CMessages::BIGMessages[i].m_Current.m_pText) - CMessages::BIGMessages[i].m_Current.m_nStartTime = 0; - if (CMessages::BriefMessages[0].m_pText) - CMessages::BriefMessages[0].m_nStartTime = 0; + for (int i = 0; i < NUMBIGMESSAGES; i++){ + if (CMessages::BIGMessages[i].m_Stack[0].m_pText != nil) + CMessages::BIGMessages[i].m_Stack[0].m_nStartTime = 0; } + if (CMessages::BriefMessages[0].m_pText != nil) + CMessages::BriefMessages[0].m_nStartTime = 0; } int8 CRunningScript::ProcessOneCommand() @@ -2183,7 +2183,7 @@ int8 CRunningScript::ProcessCommandsFrom100To199(int32 command) wchar* key = TheText.Get((char*)&CTheScripts::ScriptSpace[m_nIp]); m_nIp += 8; CollectParameters(&m_nIp, 2); - CMessages::AddMessage(key, ScriptParams[0], ScriptParams[1]); + CMessages::AddMessageSoon(key, ScriptParams[0], ScriptParams[1]); return 0; } case COMMAND_CLEAR_PRINTS: -- cgit v1.2.3 From 12ee71e4f732c883b33b9165c448302ea726186b Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Fri, 30 Aug 2019 00:44:57 +0200 Subject: audio7 --- src/control/PathFind.cpp | 51 +++++++++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 22 deletions(-) (limited to 'src/control') diff --git a/src/control/PathFind.cpp b/src/control/PathFind.cpp index 3c16202b..700a89f1 100644 --- a/src/control/PathFind.cpp +++ b/src/control/PathFind.cpp @@ -1278,39 +1278,51 @@ CPathFind::DoPathSearch(uint8 type, CVector start, int32 startNodeId, CVector ta targetNode = FindNodeClosestToCoors(target, type, distLimit); else targetNode = forcedTargetNode; - if(targetNode < 0) - goto fail; + if(targetNode < 0) { + *pNumNodes = 0; + if(pDist) *pDist = 100000.0f; + return; + } // Find start int numPathsToTry; CTreadable *startObj; - if(startNodeId < 0){ + if(startNodeId < 0) { if(vehicle == nil || (startObj = vehicle->m_treadable[type]) == nil) startObj = FindRoadObjectClosestToCoors(start, type); numPathsToTry = 0; - for(i = 0; i < 12; i++){ - if(startObj->m_nodeIndices[type][i] < 0) - break; - if(m_pathNodes[startObj->m_nodeIndices[type][i]].group == m_pathNodes[targetNode].group) + for(i = 0; i < 12; i++) { + if(startObj->m_nodeIndices[type][i] < 0) break; + if(m_pathNodes[startObj->m_nodeIndices[type][i]].group == + m_pathNodes[targetNode].group) numPathsToTry++; } - }else{ + } else { numPathsToTry = 1; startObj = m_mapObjects[m_pathNodes[startNodeId].objectIndex]; } - if(numPathsToTry == 0) - goto fail; + if(numPathsToTry == 0) { + *pNumNodes = 0; + if(pDist) *pDist = 100000.0f; + return; + } - if(startNodeId < 0){ + if(startNodeId < 0) { // why only check node 0? - if(m_pathNodes[startObj->m_nodeIndices[type][0]].group != m_pathNodes[targetNode].group) - goto fail; - }else{ - if(m_pathNodes[startNodeId].group != m_pathNodes[targetNode].group) - goto fail; + if(m_pathNodes[startObj->m_nodeIndices[type][0]].group != + m_pathNodes[targetNode].group) { + *pNumNodes = 0; + if(pDist) *pDist = 100000.0f; + return; + } + } else { + if(m_pathNodes[startNodeId].group != m_pathNodes[targetNode].group) { + *pNumNodes = 0; + if(pDist) *pDist = 100000.0f; + return; + } } - for(i = 0; i < 512; i++) m_searchNodes[i].next = nil; AddNodeToList(&m_pathNodes[targetNode], 0); @@ -1388,11 +1400,6 @@ CPathFind::DoPathSearch(uint8 type, CVector start, int32 startNodeId, CVector ta for(i = 0; i < numNodesToBeCleared; i++) apNodesToBeCleared[i]->distance = MAX_DIST; return; - -fail: - *pNumNodes = 0; - if(pDist) - *pDist = 100000.0f; } static CPathNode *pNodeList[32]; -- cgit v1.2.3 From 43866a4f7033fbb2ea1d515c037f291e0f377165 Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Sat, 12 Oct 2019 22:36:45 +0200 Subject: Fix rebasing --- src/control/CarAI.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/control') diff --git a/src/control/CarAI.cpp b/src/control/CarAI.cpp index b4dd8777..c2f2bb43 100644 --- a/src/control/CarAI.cpp +++ b/src/control/CarAI.cpp @@ -592,7 +592,7 @@ void CCarAI::MakeWayForCarWithSiren(CVehicle *pVehicle) CVehicle* vehicle = CPools::GetVehiclePool()->GetSlot(i); if (!vehicle) continue; - if (vehicle->m_vehType != VEHICLE_TYPE_CAR && vehicle->m_vehType != VEHICLE_TYPE_BIKE) + if (vehicle->m_vehType != VEHICLE_TYPE_AUTOMOBILE && vehicle->m_vehType != VEHICLE_TYPE_BIKE) continue; if (vehicle->m_status != STATUS_SIMPLE && vehicle->m_status != STATUS_PHYSICS) continue; -- cgit v1.2.3 From d822417cfce5ce0120481bd37271ebde6117b14c Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Sun, 13 Oct 2019 00:35:01 +0200 Subject: Fixes for nitpicks --- src/control/PathFind.cpp | 51 +++++++++++++++++++++--------------------------- 1 file changed, 22 insertions(+), 29 deletions(-) (limited to 'src/control') diff --git a/src/control/PathFind.cpp b/src/control/PathFind.cpp index 700a89f1..3c16202b 100644 --- a/src/control/PathFind.cpp +++ b/src/control/PathFind.cpp @@ -1278,51 +1278,39 @@ CPathFind::DoPathSearch(uint8 type, CVector start, int32 startNodeId, CVector ta targetNode = FindNodeClosestToCoors(target, type, distLimit); else targetNode = forcedTargetNode; - if(targetNode < 0) { - *pNumNodes = 0; - if(pDist) *pDist = 100000.0f; - return; - } + if(targetNode < 0) + goto fail; // Find start int numPathsToTry; CTreadable *startObj; - if(startNodeId < 0) { + if(startNodeId < 0){ if(vehicle == nil || (startObj = vehicle->m_treadable[type]) == nil) startObj = FindRoadObjectClosestToCoors(start, type); numPathsToTry = 0; - for(i = 0; i < 12; i++) { - if(startObj->m_nodeIndices[type][i] < 0) break; - if(m_pathNodes[startObj->m_nodeIndices[type][i]].group == - m_pathNodes[targetNode].group) + for(i = 0; i < 12; i++){ + if(startObj->m_nodeIndices[type][i] < 0) + break; + if(m_pathNodes[startObj->m_nodeIndices[type][i]].group == m_pathNodes[targetNode].group) numPathsToTry++; } - } else { + }else{ numPathsToTry = 1; startObj = m_mapObjects[m_pathNodes[startNodeId].objectIndex]; } - if(numPathsToTry == 0) { - *pNumNodes = 0; - if(pDist) *pDist = 100000.0f; - return; - } + if(numPathsToTry == 0) + goto fail; - if(startNodeId < 0) { + if(startNodeId < 0){ // why only check node 0? - if(m_pathNodes[startObj->m_nodeIndices[type][0]].group != - m_pathNodes[targetNode].group) { - *pNumNodes = 0; - if(pDist) *pDist = 100000.0f; - return; - } - } else { - if(m_pathNodes[startNodeId].group != m_pathNodes[targetNode].group) { - *pNumNodes = 0; - if(pDist) *pDist = 100000.0f; - return; - } + if(m_pathNodes[startObj->m_nodeIndices[type][0]].group != m_pathNodes[targetNode].group) + goto fail; + }else{ + if(m_pathNodes[startNodeId].group != m_pathNodes[targetNode].group) + goto fail; } + for(i = 0; i < 512; i++) m_searchNodes[i].next = nil; AddNodeToList(&m_pathNodes[targetNode], 0); @@ -1400,6 +1388,11 @@ CPathFind::DoPathSearch(uint8 type, CVector start, int32 startNodeId, CVector ta for(i = 0; i < numNodesToBeCleared; i++) apNodesToBeCleared[i]->distance = MAX_DIST; return; + +fail: + *pNumNodes = 0; + if(pDist) + *pDist = 100000.0f; } static CPathNode *pNodeList[32]; -- cgit v1.2.3 From 8808e6fdfe5604022a64e72df3ee60d8ed10e9d6 Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Fri, 25 Oct 2019 18:39:26 +0200 Subject: Fixes for aap review (audio8) --- src/control/CarAI.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/control') diff --git a/src/control/CarAI.cpp b/src/control/CarAI.cpp index c2f2bb43..b4dd8777 100644 --- a/src/control/CarAI.cpp +++ b/src/control/CarAI.cpp @@ -592,7 +592,7 @@ void CCarAI::MakeWayForCarWithSiren(CVehicle *pVehicle) CVehicle* vehicle = CPools::GetVehiclePool()->GetSlot(i); if (!vehicle) continue; - if (vehicle->m_vehType != VEHICLE_TYPE_AUTOMOBILE && vehicle->m_vehType != VEHICLE_TYPE_BIKE) + if (vehicle->m_vehType != VEHICLE_TYPE_CAR && vehicle->m_vehType != VEHICLE_TYPE_BIKE) continue; if (vehicle->m_status != STATUS_SIMPLE && vehicle->m_status != STATUS_PHYSICS) continue; -- cgit v1.2.3 From b6cb716452eaf9cdffed3055c032ca443e179f57 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 26 Oct 2019 14:35:45 +0300 Subject: Fixed CGameLogic::PassTime types --- src/control/GameLogic.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/control') diff --git a/src/control/GameLogic.cpp b/src/control/GameLogic.cpp index ed101cad..0ed5d5cf 100644 --- a/src/control/GameLogic.cpp +++ b/src/control/GameLogic.cpp @@ -30,7 +30,7 @@ CGameLogic::InitAtStartOfGame() void CGameLogic::PassTime(uint32 time) { - uint8 minutes, hours, days; + int32 minutes, hours, days; minutes = time + CClock::GetMinutes(); hours = CClock::GetHours(); -- cgit v1.2.3 From d5a72fa597e7d0885f7a398e204c4085aff5c241 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 26 Oct 2019 15:20:12 +0300 Subject: Audio stuff moved around, removed MusicManager dependencies, eMusicMode used for ChangeMusicMode --- src/control/Replay.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/control') diff --git a/src/control/Replay.cpp b/src/control/Replay.cpp index 473b13d3..1bd1bf4b 100644 --- a/src/control/Replay.cpp +++ b/src/control/Replay.cpp @@ -1036,7 +1036,7 @@ void CReplay::TriggerPlayback(uint8 cam_mode, float cam_x, float cam_y, float ca bAllowLookAroundCam = true; bPlayingBackFromFile = false; OldRadioStation = DMAudio.GetRadioInCar(); - DMAudio.ChangeMusicMode(0); + DMAudio.ChangeMusicMode(MUSICMODE_FRONTEND); DMAudio.SetEffectsFadeVol(0); DMAudio.SetMusicFadeVol(0); int current; @@ -1282,9 +1282,9 @@ void CReplay::RestoreStuffFromMem(void) } delete[] pPedAnims; pPedAnims = nil; - DMAudio.ChangeMusicMode(0); + DMAudio.ChangeMusicMode(MUSICMODE_FRONTEND); DMAudio.SetRadioInCar(OldRadioStation); - DMAudio.ChangeMusicMode(1); + DMAudio.ChangeMusicMode(MUSICMODE_GAME); } #endif -- cgit v1.2.3