From 0fd6fb1ff4b849a857ba1023421aa9232ba5ce15 Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Sun, 23 Aug 2020 12:27:24 +0300 Subject: fixed a few embarassing mistakes --- src/control/CarCtrl.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/control/CarCtrl.cpp b/src/control/CarCtrl.cpp index 64049793..5b2454ac 100644 --- a/src/control/CarCtrl.cpp +++ b/src/control/CarCtrl.cpp @@ -161,7 +161,7 @@ CCarCtrl::GenerateOneRandomCar() carModel = ChoosePoliceCarModel(); }else{ carModel = ChooseModel(&zone, &vecTargetPos, &carClass); - if (carClass == COPS && pWanted->m_nWantedLevel >= 1 || carModel < 0) + if (carModel == -1 || (carClass == COPS && pWanted->m_nWantedLevel >= 1)) /* All cop spawns with wanted level are handled by condition above. */ /* In particular it means that cop cars never spawn if player has wanted level of 1. */ return; @@ -761,7 +761,8 @@ CCarCtrl::ChooseCarRating(CZoneInfo* pZoneInfo) int32 CCarCtrl::ChooseModel(CZoneInfo* pZone, CVector* pPos, int* pClass) { int32 model = -1; - for (int i = 0; i < 10 && (model == -1 || !CStreaming::HasModelLoaded(model)); i++) { + int32 i; + for (i = 10; i > 0 && (model == -1 || !CStreaming::HasModelLoaded(model)); i--) { int rnd = CGeneral::GetRandomNumberInRange(0, 1000); if (rnd < pZone->copThreshold) { @@ -770,9 +771,9 @@ CCarCtrl::ChooseModel(CZoneInfo* pZone, CVector* pPos, int* pClass) { continue; } - int j; + int32 j; for (j = 0; j < NUM_GANG_CAR_CLASSES; j++) { - if (rnd < pZone->gangThreshold[i]) { + if (rnd < pZone->gangThreshold[j]) { *pClass = j + FIRST_GANG_CAR_RATING; model = ChooseGangCarModel(j); break; @@ -785,6 +786,8 @@ CCarCtrl::ChooseModel(CZoneInfo* pZone, CVector* pPos, int* pClass) { *pClass = ChooseCarRating(pZone); model = ChooseCarModel(*pClass); } + if (i == 0) + return -1; return model; } -- cgit v1.2.3