diff options
-rw-r--r-- | src/control/CarCtrl.cpp | 4 | ||||
-rw-r--r-- | src/control/Garages.cpp | 5 | ||||
-rw-r--r-- | src/control/Script.cpp | 39 | ||||
-rw-r--r-- | src/core/Collision.cpp | 33 | ||||
-rw-r--r-- | src/core/Frontend.h | 6 | ||||
-rw-r--r-- | src/core/Pad.cpp | 4 | ||||
-rw-r--r-- | src/core/Streaming.cpp | 8 | ||||
-rw-r--r-- | src/modelinfo/ModelInfo.cpp | 4 | ||||
-rw-r--r-- | src/peds/Ped.cpp | 6 | ||||
-rw-r--r-- | src/peds/Population.cpp | 3 | ||||
-rw-r--r-- | src/save/GenericGameStorage.cpp | 8 |
11 files changed, 54 insertions, 66 deletions
diff --git a/src/control/CarCtrl.cpp b/src/control/CarCtrl.cpp index 5db674cd..c6d90dd9 100644 --- a/src/control/CarCtrl.cpp +++ b/src/control/CarCtrl.cpp @@ -726,6 +726,10 @@ CCarCtrl::RemoveDistantCars() void CCarCtrl::PossiblyRemoveVehicle(CVehicle* pVehicle) { +#ifdef FIX_BUGS + if (pVehicle->bIsLocked) + return; +#endif CVector vecPlayerPos = FindPlayerCentreOfWorld(CWorld::PlayerInFocus); /* BUG: this variable is initialized only in if-block below but can be used outside of it. */ if (!IsThisVehicleInteresting(pVehicle) && !pVehicle->bIsLocked && diff --git a/src/control/Garages.cpp b/src/control/Garages.cpp index 33675ecf..c9112f81 100644 --- a/src/control/Garages.cpp +++ b/src/control/Garages.cpp @@ -1384,7 +1384,7 @@ void CGarage::RemoveCarsBlockingDoorNotInside() if (pVehicle->GetPosition().x < m_fX1 || pVehicle->GetPosition().x > m_fX2 || pVehicle->GetPosition().y < m_fY1 || pVehicle->GetPosition().y > m_fY2 || pVehicle->GetPosition().z < m_fZ1 || pVehicle->GetPosition().z > m_fZ2) { - if (pVehicle->bIsLocked && pVehicle->CanBeDeleted()) { + if (!pVehicle->bIsLocked && pVehicle->CanBeDeleted()) { CWorld::Remove(pVehicle); delete pVehicle; return; // WHY? @@ -1884,8 +1884,9 @@ CVehicle* CStoredCar::RestoreCar() pVehicle->m_nRadioStation = m_nRadioStation; pVehicle->bFreebies = false; #ifdef FIX_BUGS - ((CAutomobile*)pVehicle)->m_bombType = m_nCarBombType; + if (pVehicle->IsCar()) #endif + ((CAutomobile*)pVehicle)->m_bombType = m_nCarBombType; pVehicle->bHasBeenOwnedByPlayer = true; pVehicle->m_nDoorLock = CARLOCK_UNLOCKED; pVehicle->bBulletProof = m_bBulletproof; diff --git a/src/control/Script.cpp b/src/control/Script.cpp index fa0fb463..e9808643 100644 --- a/src/control/Script.cpp +++ b/src/control/Script.cpp @@ -9700,7 +9700,7 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) return 0; CVehicle* car; if (!CModelInfo::IsBikeModel(model)) - car = new CAutomobile(model, MISSION_VEHICLE); + car = new CAutomobile(model, RANDOM_VEHICLE); CVector pos = *(CVector*)&ScriptParams[0]; pos.z += car->GetDistanceFromCentreOfMassToBaseOfModel(); car->SetPosition(pos); @@ -10017,17 +10017,13 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) CollectParameters(&m_nIp, 1); CTimer::Stop(); CGame::currLevel = (eLevelName)ScriptParams[0]; -#ifdef NO_ISLAND_LOADING - if (CMenuManager::m_PrefsIslandLoading == CMenuManager::ISLAND_LOADING_LOW) -#endif + ISLAND_LOADING_IS(LOW) { CStreaming::RemoveUnusedBigBuildings(CGame::currLevel); CStreaming::RemoveUnusedBuildings(CGame::currLevel); } CCollision::SortOutCollisionAfterLoad(); -#ifdef NO_ISLAND_LOADING - if (CMenuManager::m_PrefsIslandLoading != CMenuManager::ISLAND_LOADING_HIGH) -#endif + ISLAND_LOADING_ISNT(HIGH) { CStreaming::RequestIslands(CGame::currLevel); CStreaming::LoadAllRequestedModels(true); @@ -10647,9 +10643,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) CTimer::Stop(); CGame::currLevel = (eLevelName)ScriptParams[0]; if (CGame::currLevel != CCollision::ms_collisionInMemory) { -#ifdef NO_ISLAND_LOADING - if (CMenuManager::m_PrefsIslandLoading == CMenuManager::ISLAND_LOADING_LOW) -#endif + ISLAND_LOADING_IS(LOW) { DMAudio.SetEffectsFadeVol(0); CPad::StopPadsShaking(); @@ -10657,29 +10651,24 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) DMAudio.Service(); } CPopulation::DealWithZoneChange(CCollision::ms_collisionInMemory, CGame::currLevel, false); -#ifdef NO_ISLAND_LOADING - if (CMenuManager::m_PrefsIslandLoading == CMenuManager::ISLAND_LOADING_LOW) -#endif + + ISLAND_LOADING_IS(LOW) { CStreaming::RemoveUnusedBigBuildings(CGame::currLevel); CStreaming::RemoveUnusedBuildings(CGame::currLevel); } CCollision::SortOutCollisionAfterLoad(); -#ifdef NO_ISLAND_LOADING - if (CMenuManager::m_PrefsIslandLoading != CMenuManager::ISLAND_LOADING_HIGH) -#endif + + ISLAND_LOADING_ISNT(HIGH) CStreaming::RequestIslands(CGame::currLevel); -#ifdef NO_ISLAND_LOADING - if (CMenuManager::m_PrefsIslandLoading == CMenuManager::ISLAND_LOADING_LOW) -#endif + + ISLAND_LOADING_IS(LOW) CStreaming::RequestBigBuildings(CGame::currLevel); -#ifdef NO_ISLAND_LOADING - if (CMenuManager::m_PrefsIslandLoading != CMenuManager::ISLAND_LOADING_HIGH) -#endif + + ISLAND_LOADING_ISNT(HIGH) CStreaming::LoadAllRequestedModels(true); -#ifdef NO_ISLAND_LOADING - if (CMenuManager::m_PrefsIslandLoading == CMenuManager::ISLAND_LOADING_LOW) -#endif + + ISLAND_LOADING_IS(LOW) DMAudio.SetEffectsFadeVol(127); } CTimer::Update(); diff --git a/src/core/Collision.cpp b/src/core/Collision.cpp index bd0dfb92..d8603cd8 100644 --- a/src/core/Collision.cpp +++ b/src/core/Collision.cpp @@ -521,10 +521,12 @@ CCollision::LoadCollisionWhenINeedIt(bool forceChange) } if (level == CGame::currLevel || forceChange) { +#ifdef FIX_BUGS + CTimer::Suspend(); +#else CTimer::Stop(); -#ifdef NO_ISLAND_LOADING - if (CMenuManager::m_PrefsIslandLoading == CMenuManager::ISLAND_LOADING_LOW) #endif + ISLAND_LOADING_IS(LOW) { DMAudio.SetEffectsFadeVol(0); CPad::StopPadsShaking(); @@ -534,17 +536,13 @@ CCollision::LoadCollisionWhenINeedIt(bool forceChange) CPopulation::DealWithZoneChange(ms_collisionInMemory, CGame::currLevel, false); -#ifdef NO_ISLAND_LOADING - if (CMenuManager::m_PrefsIslandLoading != CMenuManager::ISLAND_LOADING_HIGH) -#endif + ISLAND_LOADING_ISNT(HIGH) { CStreaming::RemoveIslandsNotUsed(LEVEL_INDUSTRIAL); CStreaming::RemoveIslandsNotUsed(LEVEL_COMMERCIAL); CStreaming::RemoveIslandsNotUsed(LEVEL_SUBURBAN); } -#ifdef NO_ISLAND_LOADING - if (CMenuManager::m_PrefsIslandLoading == CMenuManager::ISLAND_LOADING_LOW) -#endif + ISLAND_LOADING_IS(LOW) { CStreaming::RemoveBigBuildings(LEVEL_INDUSTRIAL); CStreaming::RemoveBigBuildings(LEVEL_COMMERCIAL); @@ -557,9 +555,7 @@ CCollision::LoadCollisionWhenINeedIt(bool forceChange) ms_collisionInMemory = CGame::currLevel; CReplay::EmptyReplayBuffer(); -#ifdef NO_ISLAND_LOADING - if (CMenuManager::m_PrefsIslandLoading == CMenuManager::ISLAND_LOADING_LOW) -#endif + ISLAND_LOADING_IS(LOW) { if (CGame::currLevel != LEVEL_GENERIC) LoadSplash(GetLevelSplashScreen(CGame::currLevel)); @@ -572,18 +568,19 @@ CCollision::LoadCollisionWhenINeedIt(bool forceChange) CStreaming::RequestIslands(CGame::currLevel); #endif CStreaming::LoadAllRequestedModels(true); -#ifdef NO_ISLAND_LOADING - if (CMenuManager::m_PrefsIslandLoading == CMenuManager::ISLAND_LOADING_LOW) -#endif + + ISLAND_LOADING_IS(LOW) { CStreaming::HaveAllBigBuildingsLoaded(CGame::currLevel); CGame::TidyUpMemory(true, true); } +#ifdef FIX_BUGS + CTimer::Resume(); +#else CTimer::Update(); -#ifdef NO_ISLAND_LOADING - if (CMenuManager::m_PrefsIslandLoading == CMenuManager::ISLAND_LOADING_LOW) #endif + ISLAND_LOADING_IS(LOW) DMAudio.SetEffectsFadeVol(127); } } @@ -596,9 +593,7 @@ CCollision::SortOutCollisionAfterLoad(void) { if(ms_collisionInMemory == CGame::currLevel) return; -#ifdef NO_ISLAND_LOADING - if (CMenuManager::m_PrefsIslandLoading == CMenuManager::ISLAND_LOADING_LOW) -#endif + ISLAND_LOADING_IS(LOW) CModelInfo::RemoveColModelsFromOtherLevels(CGame::currLevel); if (CGame::currLevel != LEVEL_GENERIC) { diff --git a/src/core/Frontend.h b/src/core/Frontend.h index d631a7d1..cf112b3d 100644 --- a/src/core/Frontend.h +++ b/src/core/Frontend.h @@ -635,6 +635,12 @@ public: static int8 m_DisplayIslandLoading; static int8 m_PrefsIslandLoading; + + #define ISLAND_LOADING_IS(p) if (CMenuManager::m_PrefsIslandLoading == CMenuManager::ISLAND_LOADING_##p) + #define ISLAND_LOADING_ISNT(p) if (CMenuManager::m_PrefsIslandLoading != CMenuManager::ISLAND_LOADING_##p) +#else + #define ISLAND_LOADING_IS(p) + #define ISLAND_LOADING_ISNT(p) #endif public: diff --git a/src/core/Pad.cpp b/src/core/Pad.cpp index d4ffc5ea..3b46a110 100644 --- a/src/core/Pad.cpp +++ b/src/core/Pad.cpp @@ -11,7 +11,11 @@ #include "platform.h" #ifdef XINPUT #include <xinput.h> +#if !defined(PSAPI_VERSION) || (PSAPI_VERSION > 1) #pragma comment( lib, "Xinput9_1_0.lib" ) +#else +#pragma comment( lib, "Xinput.lib" ) +#endif #endif #include "Pad.h" diff --git a/src/core/Streaming.cpp b/src/core/Streaming.cpp index 089e8b23..1892bf57 100644 --- a/src/core/Streaming.cpp +++ b/src/core/Streaming.cpp @@ -743,9 +743,7 @@ CStreaming::RequestBigBuildings(eLevelName level) void CStreaming::RequestIslands(eLevelName level) { -#ifdef NO_ISLAND_LOADING - if (CMenuManager::m_PrefsIslandLoading != CMenuManager::ISLAND_LOADING_HIGH) -#endif + ISLAND_LOADING_ISNT(HIGH) switch(level){ case LEVEL_INDUSTRIAL: RequestModel(islandLODcomInd, BIGBUILDINGFLAGS); @@ -946,9 +944,7 @@ CStreaming::RemoveBuildings(eLevelName level) void CStreaming::RemoveUnusedBigBuildings(eLevelName level) { -#ifdef NO_ISLAND_LOADING - if (CMenuManager::m_PrefsIslandLoading == CMenuManager::ISLAND_LOADING_LOW) -#endif + ISLAND_LOADING_IS(LOW) { if (level != LEVEL_INDUSTRIAL) RemoveBigBuildings(LEVEL_INDUSTRIAL); diff --git a/src/modelinfo/ModelInfo.cpp b/src/modelinfo/ModelInfo.cpp index 5d9c7700..4ee8e72b 100644 --- a/src/modelinfo/ModelInfo.cpp +++ b/src/modelinfo/ModelInfo.cpp @@ -218,9 +218,7 @@ CModelInfo::IsBikeModel(int32 id) void CModelInfo::RemoveColModelsFromOtherLevels(eLevelName level) { -#ifdef NO_ISLAND_LOADING - if (CMenuManager::m_PrefsIslandLoading == CMenuManager::ISLAND_LOADING_LOW) -#endif + ISLAND_LOADING_IS(LOW) { int i; CBaseModelInfo *mi; diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index a15927ff..bfcb52e4 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -13363,7 +13363,7 @@ CPed::ProcessObjective(void) if (m_pMyVehicle) { m_pMyVehicle->AutoPilot.m_nCruiseSpeed = 0; } else { - float closestVehDist = 3600.0f; + float closestVehDist = SQR(60.0f); int16 lastVehicle; CEntity* vehicles[8]; CWorld::FindObjectsInRange(GetPosition(), 25.0f, true, &lastVehicle, 6, vehicles, false, true, false, false, false); @@ -13376,11 +13376,11 @@ CPed::ProcessObjective(void) CVector ourSpeed = GetSpeed(); */ CVector vehDistVec = nearVeh->GetPosition() - GetPosition(); - if (vehDistVec.Magnitude() < closestVehDist + if (vehDistVec.MagnitudeSqr() < closestVehDist && m_pedInObjective->m_pMyVehicle != nearVeh) { foundVeh = nearVeh; - closestVehDist = vehDistVec.Magnitude(); + closestVehDist = vehDistVec.MagnitudeSqr(); } } m_pMyVehicle = foundVeh; diff --git a/src/peds/Population.cpp b/src/peds/Population.cpp index 0756df38..a1bde005 100644 --- a/src/peds/Population.cpp +++ b/src/peds/Population.cpp @@ -117,8 +117,7 @@ CPopulation::Initialise() void CPopulation::RemovePed(CPed *ent) { - // CPed dtor already does that - // CWorld::Remove((CEntity*)ent); + CWorld::Remove((CEntity*)ent); delete ent; } diff --git a/src/save/GenericGameStorage.cpp b/src/save/GenericGameStorage.cpp index 516c8d46..81bcb6b0 100644 --- a/src/save/GenericGameStorage.cpp +++ b/src/save/GenericGameStorage.cpp @@ -562,17 +562,13 @@ RestoreForStartLoad() ReadDataFromBufferPointer(_buf, TheCamera.GetMatrix().GetPosition().x); ReadDataFromBufferPointer(_buf, TheCamera.GetMatrix().GetPosition().y); ReadDataFromBufferPointer(_buf, TheCamera.GetMatrix().GetPosition().z); -#ifdef NO_ISLAND_LOADING - if (CMenuManager::m_PrefsIslandLoading == CMenuManager::ISLAND_LOADING_LOW) -#endif + ISLAND_LOADING_IS(LOW) { CStreaming::RemoveUnusedBigBuildings(CGame::currLevel); CStreaming::RemoveUnusedBuildings(CGame::currLevel); } CCollision::SortOutCollisionAfterLoad(); -#ifdef NO_ISLAND_LOADING - if (CMenuManager::m_PrefsIslandLoading == CMenuManager::ISLAND_LOADING_LOW) -#endif + ISLAND_LOADING_IS(LOW) { CStreaming::RequestBigBuildings(CGame::currLevel); CStreaming::LoadAllRequestedModels(false); |