From 835fa4e74b1014ca1ccef83979f039cafb75e3a4 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Fri, 23 Jul 2021 21:07:44 +0300 Subject: [PATCH 1/3] Make cars and peds to not despawn when you look away # Conflicts: # src/control/CarCtrl.cpp # src/core/config.h # src/peds/Population.cpp --- src/audio/DMAudio.cpp | 2 +- src/control/CarCtrl.cpp | 7 ++++++- src/core/config.h | 4 ++++ src/peds/Population.cpp | 9 ++++++--- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/audio/DMAudio.cpp b/src/audio/DMAudio.cpp index f5b08c71..3843007d 100644 --- a/src/audio/DMAudio.cpp +++ b/src/audio/DMAudio.cpp @@ -65,7 +65,7 @@ cDMAudio::DestroyAllGameCreatedEntities(void) void cDMAudio::SetOutputMode(bool8 surround) { - return AudioManager.SetOutputMode(surround); + AudioManager.SetOutputMode(surround); } void diff --git a/src/control/CarCtrl.cpp b/src/control/CarCtrl.cpp index 5e4e62ee..870669e8 100644 --- a/src/control/CarCtrl.cpp +++ b/src/control/CarCtrl.cpp @@ -964,6 +964,7 @@ CCarCtrl::PossiblyRemoveVehicle(CVehicle* pVehicle) } float distanceToPlayer = (pVehicle->GetPosition() - vecPlayerPos).Magnitude2D(); float threshold = OFFSCREEN_DESPAWN_RANGE; +#ifndef EXTENDED_OFFSCREEN_DESPAWN_RANGE if (pVehicle->GetIsOnScreen() || TheCamera.Cams[TheCamera.ActiveCam].LookingLeft || TheCamera.Cams[TheCamera.ActiveCam].LookingRight || @@ -975,11 +976,15 @@ CCarCtrl::PossiblyRemoveVehicle(CVehicle* pVehicle) pVehicle->bIsLawEnforcer || pVehicle->bIsCarParkVehicle || CTimer::GetTimeInMilliseconds() < pVehicle->m_nSetPieceExtendedRangeTime - ){ + ) +#endif + { threshold = ONSCREEN_DESPAWN_RANGE * TheCamera.GenerationDistMultiplier; } +#ifndef EXTENDED_OFFSCREEN_DESPAWN_RANGE if (TheCamera.GetForward().z < -0.9f) threshold = 70.0f; +#endif if (pVehicle->bExtendedRange) threshold *= EXTENDED_RANGE_DESPAWN_MULTIPLIER; if (distanceToPlayer > threshold && !CGarages::IsPointWithinHideOutGarage(pVehicle->GetPosition())){ diff --git a/src/core/config.h b/src/core/config.h index 307f55d3..9a1b9846 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -274,6 +274,9 @@ enum Config { #define NO_MOVIES // add option to disable intro videos +#define EXTENDED_OFFSCREEN_DESPAWN_RANGE // Use onscreen despawn range for offscreen peds and vehicles to avoid them despawning in the distance when you look + // away + #if defined(__LP64__) || defined(_WIN64) #define FIX_BUGS_64 // Must have fixes to be able to run 64 bit build #endif @@ -449,6 +452,7 @@ static_assert(false, "SUPPORT_XBOX_SCRIPT and SUPPORT_MOBILE_SCRIPT are mutually #undef PS2_ALPHA_TEST #undef NO_ISLAND_LOADING #undef PS2_AUDIO_CHANNELS + #undef EXTENDED_OFFSCREEN_DESPAWN_RANGE #endif // if these defines are enabled saves are not vanilla compatible without COMPATIBLE_SAVES diff --git a/src/peds/Population.cpp b/src/peds/Population.cpp index 384cef99..b9347256 100644 --- a/src/peds/Population.cpp +++ b/src/peds/Population.cpp @@ -1105,8 +1105,9 @@ CPopulation::ManagePopulation(void) if (PedCreationDistMultiplier() * (PED_REMOVE_DIST_SPECIAL * TheCamera.GenerationDistMultiplier) < dist || (!ped->bCullExtraFarAway && PedCreationDistMultiplier() * PED_REMOVE_DIST * TheCamera.GenerationDistMultiplier < dist)) { pedIsFarAway = true; - - } else if (PedCreationDistMultiplier() * (MIN_CREATION_DIST + CREATION_RANGE) * OFFSCREEN_CREATION_MULT < dist) { + } +#ifndef EXTENDED_OFFSCREEN_DESPAWN_RANGE + else if (PedCreationDistMultiplier() * (MIN_CREATION_DIST + CREATION_RANGE) * OFFSCREEN_CREATION_MULT < dist) { if (CTimer::GetTimeInMilliseconds() > ped->m_nExtendedRangeTimer && !ped->GetIsOnScreen()) { if (TheCamera.Cams[TheCamera.ActiveCam].Mode != CCam::MODE_SNIPER && TheCamera.Cams[TheCamera.ActiveCam].Mode != CCam::MODE_SNIPER_RUNABOUT @@ -1118,7 +1119,9 @@ CPopulation::ManagePopulation(void) } } - } else { + } +#endif + else { ped->m_nExtendedRangeTimer = ped->m_nPedType == PEDTYPE_COP ? CTimer::GetTimeInMilliseconds() + 10000 : CTimer::GetTimeInMilliseconds() + 4000; } From d923cd2f240d29a062c91a2b00c110f74986f281 Mon Sep 17 00:00:00 2001 From: Magnus Larsen Date: Mon, 26 Jul 2021 19:23:37 -0700 Subject: [PATCH 2/3] Allow sector ped count to exceed gap-list size This solves the gnNumTempPedList assertion. To prove this works, change gapTempPedList's length to 12, and visit the Triad's basketball court. # Conflicts: # src/peds/Ped.cpp --- src/peds/Ped.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index eadd9d64..7194d824 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -511,8 +511,20 @@ CPed::BuildPedLists(void) continue; deadsRegistered++; } +#ifdef FIX_BUGS + // If the gap ped list is full, sort it and truncate it + // before pushing more unsorted peds + if( gnNumTempPedList == ARRAY_SIZE(gapTempPedList) - 1 ) + { + gapTempPedList[gnNumTempPedList] = nil; + SortPeds(gapTempPedList, 0, gnNumTempPedList - 1); + gnNumTempPedList = ARRAY_SIZE(m_nearPeds); + } +#endif + gapTempPedList[gnNumTempPedList] = ped; gnNumTempPedList++; + // NOTE: We cannot absolutely fill the gap list, as the list is null-terminated before being passed to SortPeds assert(gnNumTempPedList < ARRAY_SIZE(gapTempPedList)); } } From e80cbf8bb2abbe3edb7a604ae5b0af366bf10a9a Mon Sep 17 00:00:00 2001 From: erorcun Date: Sat, 31 Jul 2021 22:57:54 +0300 Subject: [PATCH 3/3] Fix radio scroll when player controls disabled --- src/audio/MusicManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/audio/MusicManager.cpp b/src/audio/MusicManager.cpp index 8f5fb5b8..a099f10d 100644 --- a/src/audio/MusicManager.cpp +++ b/src/audio/MusicManager.cpp @@ -561,7 +561,7 @@ cMusicManager::ServiceGameMode() } } #ifdef RADIO_SCROLL_TO_PREV_STATION - else if(CPad::GetPad(0)->GetMouseWheelDownJustDown() || CPad::GetPad(0)->GetMouseWheelUpJustDown()) { + else if(!CPad::GetPad(0)->ArePlayerControlsDisabled() && (CPad::GetPad(0)->GetMouseWheelDownJustDown() || CPad::GetPad(0)->GetMouseWheelUpJustDown())) { if(!UsesPoliceRadio(vehicle) && !UsesTaxiRadio(vehicle)) { int scrollNext = ControlsManager.GetControllerKeyAssociatedWithAction(VEHICLE_CHANGE_RADIO_STATION, MOUSE); int scrollPrev = scrollNext == rsMOUSEWHEELUPBUTTON ? rsMOUSEWHEELDOWNBUTTON