From 75943a57b2b9aa5cce36b2c387418acce1fe1c24 Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Fri, 8 May 2020 18:48:44 +0300 Subject: [PATCH 1/2] gang --- src/control/CarCtrl.cpp | 10 +++++++--- src/core/Streaming.cpp | 17 +++++++++-------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/control/CarCtrl.cpp b/src/control/CarCtrl.cpp index 2c5751a3..ed14c6a0 100644 --- a/src/control/CarCtrl.cpp +++ b/src/control/CarCtrl.cpp @@ -597,7 +597,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++) { + int i; + for (i = 0; i < 10 && (model == -1 || !CStreaming::HasModelLoaded(model)); i++) { int rnd = CGeneral::GetRandomNumberInRange(0, 1000); if (rnd < pZone->copThreshold) { @@ -606,14 +607,17 @@ CCarCtrl::ChooseModel(CZoneInfo* pZone, CVector* pPos, int* pClass) { continue; } - for (int i = 0; i < NUM_GANG_CAR_CLASSES; i++) { + for (i = 0; i < NUM_GANG_CAR_CLASSES; i++) { if (rnd < pZone->gangThreshold[i]) { *pClass = i + FIRST_GANG_CAR_RATING; model = ChooseGangCarModel(i); - continue; + break; } } + if (i != NUM_GANG_CAR_CLASSES) + continue; + *pClass = ChooseCarRating(pZone); model = ChooseCarModel(*pClass); } diff --git a/src/core/Streaming.cpp b/src/core/Streaming.cpp index 6620065c..c7bd961c 100644 --- a/src/core/Streaming.cpp +++ b/src/core/Streaming.cpp @@ -1342,10 +1342,11 @@ CStreaming::StreamZoneModels(const CVector &pos) for(i = 0; i < NUMMODELSPERPEDGROUP; i++){ if(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i] == -1) break; - RequestModel(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i], STREAMFLAGS_DONT_REMOVE); + RequestModel(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i], STREAMFLAGS_DEPENDENCY); } } RequestModel(MI_MALE01, STREAMFLAGS_DONT_REMOVE); + //RequestModel(MI_HMOCA, STREAMFLAGS_DONT_REMOVE); gangsToLoad = 0; gangCarsToLoad = 0; @@ -1369,8 +1370,8 @@ CStreaming::StreamZoneModels(const CVector &pos) bit = 1<m_nVehicleMI < 0) - continue; + // TODO(MIAMI): check this + if(CGangs::GetGangInfo(i)->m_nVehicleMI < 0) + continue; - if(gangCarsToLoad & bit && (ms_loadedGangCars & bit) == 0){ - RequestModel(CGangs::GetGangInfo(i)->m_nVehicleMI, STREAMFLAGS_DONT_REMOVE); + if((gangCarsToLoad & bit) && (ms_loadedGangCars & bit) == 0){ + RequestModel(CGangs::GetGangInfo(i)->m_nVehicleMI, STREAMFLAGS_DEPENDENCY); }else if((gangCarsToLoad & bit) == 0 && ms_loadedGangCars & bit){ SetModelIsDeletable(CGangs::GetGangInfo(i)->m_nVehicleMI); SetModelTxdIsDeletable(CGangs::GetGangInfo(i)->m_nVehicleMI); From f902136b6af53ec75eb3df44f06e0d0972a7e7f6 Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Fri, 8 May 2020 18:50:16 +0300 Subject: [PATCH 2/2] fix --- src/control/CarCtrl.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/control/CarCtrl.cpp b/src/control/CarCtrl.cpp index ed14c6a0..66e29b6c 100644 --- a/src/control/CarCtrl.cpp +++ b/src/control/CarCtrl.cpp @@ -597,8 +597,7 @@ CCarCtrl::ChooseCarRating(CZoneInfo* pZoneInfo) int32 CCarCtrl::ChooseModel(CZoneInfo* pZone, CVector* pPos, int* pClass) { int32 model = -1; - int i; - for (i = 0; i < 10 && (model == -1 || !CStreaming::HasModelLoaded(model)); i++) { + for (int i = 0; i < 10 && (model == -1 || !CStreaming::HasModelLoaded(model)); i++) { int rnd = CGeneral::GetRandomNumberInRange(0, 1000); if (rnd < pZone->copThreshold) { @@ -607,15 +606,16 @@ CCarCtrl::ChooseModel(CZoneInfo* pZone, CVector* pPos, int* pClass) { continue; } - for (i = 0; i < NUM_GANG_CAR_CLASSES; i++) { + int j; + for (j = 0; j < NUM_GANG_CAR_CLASSES; j++) { if (rnd < pZone->gangThreshold[i]) { - *pClass = i + FIRST_GANG_CAR_RATING; - model = ChooseGangCarModel(i); + *pClass = j + FIRST_GANG_CAR_RATING; + model = ChooseGangCarModel(j); break; } } - if (i != NUM_GANG_CAR_CLASSES) + if (j != NUM_GANG_CAR_CLASSES) continue; *pClass = ChooseCarRating(pZone);