Fix `CCarCtrl::ChooseCarModelToLoad` (#1106)

Co-authored-by: Pirulax <patrikjankovics7@gmail.com>
This commit is contained in:
Grinch_ 2025-06-08 06:24:39 +06:00 committed by GitHub
parent 9ee2431657
commit ced11a69da
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 11 deletions

View File

@ -134,17 +134,14 @@ int32 CCarCtrl::ChooseBoatModel() {
}
// 0x421900
int32 CCarCtrl::ChooseCarModelToLoad(int32 arg1) {
for (auto i = 0; i < 16; i++) { // TODO: Why 16?
const auto numCarsInGroup = CPopulation::m_nNumCarsInGroup[i];
#ifdef FIX_BUGS
if (!numCarsInGroup) {
continue;
}
#endif
const auto model = CPopulation::m_CarGroups[i][CGeneral::GetRandomNumberInRange(numCarsInGroup)];
if (!CStreaming::IsModelLoaded(model)) {
return model;
int32 CCarCtrl::ChooseCarModelToLoad(int32 groupID) {
const auto numCarsInGroup = CPopulation::m_nNumCarsInGroup[groupID];
if (numCarsInGroup > 0) {
for (auto i = 0; i < 16; i++) { // 16 tries
const auto model = CPopulation::m_CarGroups[groupID][CGeneral::GetRandomNumberInRange(numCarsInGroup)];
if (!CStreaming::IsModelLoaded(model)) {
return model;
}
}
}
return -1;