@@ -62,6 +62,8 @@ std::map<unsigned short, std::array<std::vector<unsigned short>, 6>> vehGroupWan
6262
6363std::set<unsigned short > parkedCars;
6464std::set<unsigned short > vehUseOnlyGroups;
65+ std::set<unsigned short > pedMergeZones;
66+ std::set<unsigned short > vehMergeZones;
6567
6668std::stack<CPed*> pedStack;
6769std::stack<CVehicle*> vehStack;
@@ -198,11 +200,11 @@ void drugDealerFix(void)
198200 }
199201}
200202
201- void updateVariations (CZone * zInfo, CIniReader *iniPed, CIniReader *pIniVeh )
203+ void updateVariations (CZone* zInfo, CIniReader* iniPed )
202204{
203205 // zInfo->m_szTextKey = BLUEB | zInfo->m_szLabel = BLUEB1
204206
205- if (zInfo == NULL || iniPed == NULL || pIniVeh == NULL )
207+ if (zInfo == NULL || iniPed == NULL )
206208 return ;
207209
208210 currentTown = (BYTE)CTheZones::m_CurrLevel;
@@ -228,54 +230,64 @@ void updateVariations(CZone *zInfo, CIniReader *iniPed, CIniReader *pIniVeh)
228230 currentTown = 15 ;
229231
230232
231- for (int i = 0 ; i < 300 ; i++)
232- {
233- vectorUnion (pedVariations[i][4 ], pedVariations[i][currentTown], pedCurrentVariations[i]);
234- CWanted* wanted = FindPlayerWanted (-1 );
233+ CWanted* wanted = FindPlayerWanted (-1 );
235234
236- std::vector< unsigned short > vecPed = iniLineParser ( std::to_string (i), zInfo-> m_szLabel , iniPed);
237- if (!vecPed. empty () )
235+ for ( auto & i : iniPed-> data )
236+ if (i. first [ 0 ] >= ' 0 ' && i. first [ 0 ] <= ' 9 ' )
238237 {
239- std::vector< unsigned short > vec2 ;
240- vectorUnion (pedCurrentVariations[i], vecPed, vec2);
241- pedCurrentVariations[i] = vec2;
242- }
238+ int modelid = std::stoi (i. first ) ;
239+ if (modelid > 0 && modelid < 300 )
240+ {
241+ vectorUnion (pedVariations[modelid][ 4 ], pedVariations[modelid][currentTown], pedCurrentVariations[modelid]);
243242
244- vecPed = iniLineParser (std::to_string (i), currentInterior, iniPed);
245- if (!vecPed.empty ())
246- {
247- std::vector<unsigned short > vec2;
248- vectorUnion (pedCurrentVariations[i], vecPed, vec2);
249- pedCurrentVariations[i] = vec2;
250- }
243+ std::vector<unsigned short > vec = iniLineParser (i.first , zInfo->m_szLabel , iniPed);
244+ if (!vec.empty ())
245+ {
246+ if (pedMergeZones.find (modelid) != pedMergeZones.end ())
247+ pedCurrentVariations[modelid] = vectorUnion (pedCurrentVariations[modelid], vec);
248+ else
249+ pedCurrentVariations[modelid] = vec;
250+ }
251251
252- if (wanted)
253- {
254- unsigned int wantedLevel = (wanted->m_nWantedLevel > 0 ) ? (wanted->m_nWantedLevel - 1 ) : (wanted->m_nWantedLevel );
255- if (!pedWantedVariations[i][wantedLevel].empty () && !pedCurrentVariations[i].empty ())
256- filterWantedVariations (pedCurrentVariations[i], pedWantedVariations[i][wantedLevel]);
252+ vec = iniLineParser (i.first , currentInterior, iniPed);
253+ if (!vec.empty ())
254+ pedCurrentVariations[modelid] = vectorUnion (pedCurrentVariations[modelid], vec);
255+
256+ if (wanted)
257+ {
258+ unsigned int wantedLevel = (wanted->m_nWantedLevel > 0 ) ? (wanted->m_nWantedLevel - 1 ) : (wanted->m_nWantedLevel );
259+ if (!pedWantedVariations[modelid][wantedLevel].empty () && !pedCurrentVariations[modelid].empty ())
260+ filterWantedVariations (pedCurrentVariations[modelid], pedWantedVariations[modelid][wantedLevel]);
261+ }
262+ }
257263 }
258264
259- if (i < 212 )
260- {
261- vectorUnion (vehVariations[i][4 ], vehVariations[i][currentTown], vehCurrentVariations[i]);
262265
263- std::vector<unsigned short > vec = iniLineParser (std::to_string (i+400 ), zInfo->m_szLabel , pIniVeh);
264- if (!vec.empty ())
266+ for (auto & i : iniVeh.data )
267+ if (i.first [0 ] >= ' 0' && i.first [0 ] <= ' 9' )
268+ {
269+ int modelid = std::stoi (i.first ) - 400 ;
270+ if (modelid > 0 && modelid < 212 )
265271 {
266- std::vector<unsigned short > vec2;
267- vectorUnion (vehCurrentVariations[i], vec, vec2);
268- vehCurrentVariations[i] = vec2;
269- }
272+ vectorUnion (vehVariations[modelid][4 ], vehVariations[modelid][currentTown], vehCurrentVariations[modelid]);
270273
271- if (wanted)
272- {
273- unsigned int wantedLevel = (wanted->m_nWantedLevel > 0 ) ? (wanted->m_nWantedLevel - 1 ) : (wanted->m_nWantedLevel );
274- if (!vehWantedVariations[i][wantedLevel].empty () && !vehCurrentVariations[i].empty ())
275- filterWantedVariations (vehCurrentVariations[i], vehWantedVariations[i][wantedLevel]);
274+ std::vector<unsigned short > vec = iniLineParser (i.first , zInfo->m_szLabel , &iniVeh);
275+ if (!vec.empty ())
276+ {
277+ if (vehMergeZones.find (modelid) != vehMergeZones.end ())
278+ vehCurrentVariations[modelid] = vectorUnion (vehCurrentVariations[modelid], vec);
279+ else
280+ vehCurrentVariations[modelid] = vec;
281+ }
282+
283+ if (wanted)
284+ {
285+ unsigned int wantedLevel = (wanted->m_nWantedLevel > 0 ) ? (wanted->m_nWantedLevel - 1 ) : (wanted->m_nWantedLevel );
286+ if (!vehWantedVariations[modelid][wantedLevel].empty () && !vehCurrentVariations[modelid].empty ())
287+ filterWantedVariations (vehCurrentVariations[modelid], vehWantedVariations[modelid][wantedLevel]);
288+ }
276289 }
277290 }
278- }
279291}
280292
281293void printCurrentVariations ()
@@ -431,6 +443,9 @@ class ModelVariations {
431443 for (unsigned int k = 0 ; k < pedVariations[i][j].size (); k++)
432444 if (pedVariations[i][j][k] > 0 && pedVariations[i][j][k] < 32000 && pedVariations[i][j][k] != i)
433445 pedOriginalModels.insert ({ pedVariations[i][j][k], i });
446+
447+ if (iniPed.ReadInteger (section, " MergeZonesWithCities" , 0 ) == 1 )
448+ pedMergeZones.insert (i);
434449 }
435450 }
436451
@@ -591,7 +606,7 @@ class ModelVariations {
591606 }
592607
593608 strncpy (lastInterior, currentInterior, 15 );
594- updateVariations (zInfo, &iniPed, &iniVeh );
609+ updateVariations (zInfo, &iniPed);
595610
596611 if (enableLog == 1 )
597612 printCurrentVariations ();
@@ -611,7 +626,7 @@ class ModelVariations {
611626 }
612627
613628 currentWanted = (int )wanted->m_nWantedLevel ;
614- updateVariations (zInfo, &iniPed, &iniVeh );
629+ updateVariations (zInfo, &iniPed);
615630
616631 if (enableLog == 1 )
617632 printCurrentVariations ();
@@ -631,7 +646,7 @@ class ModelVariations {
631646 }
632647
633648 strncpy (currentZone, zInfo->m_szLabel , 7 );
634- updateVariations (zInfo, &iniPed, &iniVeh );
649+ updateVariations (zInfo, &iniPed);
635650
636651 if (enableLog == 1 )
637652 printCurrentVariations ();
0 commit comments