diff options
author | Nikolay Korolev <nickvnuk@gmail.com> | 2020-08-23 11:27:24 +0200 |
---|---|---|
committer | Nikolay Korolev <nickvnuk@gmail.com> | 2020-08-23 11:27:24 +0200 |
commit | 0fd6fb1ff4b849a857ba1023421aa9232ba5ce15 (patch) | |
tree | 43b49782696259ebd68a5241d1f7b69e59c36c3b /src/control/CarCtrl.cpp | |
parent | ... (diff) | |
download | re3-0fd6fb1ff4b849a857ba1023421aa9232ba5ce15.tar re3-0fd6fb1ff4b849a857ba1023421aa9232ba5ce15.tar.gz re3-0fd6fb1ff4b849a857ba1023421aa9232ba5ce15.tar.bz2 re3-0fd6fb1ff4b849a857ba1023421aa9232ba5ce15.tar.lz re3-0fd6fb1ff4b849a857ba1023421aa9232ba5ce15.tar.xz re3-0fd6fb1ff4b849a857ba1023421aa9232ba5ce15.tar.zst re3-0fd6fb1ff4b849a857ba1023421aa9232ba5ce15.zip |
Diffstat (limited to 'src/control/CarCtrl.cpp')
-rw-r--r-- | src/control/CarCtrl.cpp | 11 |
1 files 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; } |