@@ -184,46 +184,44 @@ bool IdExists(std::vector<unsigned short>& vec, int id)
184184 return false ;
185185}
186186
187- void drugDealerFix (void )
187+ void drugDealerFix ()
188188{
189189 bool enableFix = false ;
190190
191- for (unsigned int i = 0 ; i < 6 ; i++)
191+ for (unsigned int i = 0 ; i < 16 ; i++)
192192 if (!pedVariations[28 ][i].empty () || !pedVariations[29 ][i].empty () || !pedVariations[30 ][i].empty () || !pedVariations[254 ][i].empty ())
193193 enableFix = true ;
194194
195195 if (!enableFix)
196196 return ;
197197
198198 std::vector<unsigned short > totalVariations;
199+ std::set<unsigned short > drugDealers;
199200
200- for (unsigned int i = 0 ; i < 6 ; i++)
201+ for (unsigned int i = 0 ; i < 16 ; i++)
201202 totalVariations.insert (totalVariations.end (), pedVariations[28 ][i].begin (), pedVariations[28 ][i].end ());
202203
203- for (unsigned int i = 0 ; i < 6 ; i++)
204+ for (unsigned int i = 0 ; i < 16 ; i++)
204205 totalVariations.insert (totalVariations.end (), pedVariations[29 ][i].begin (), pedVariations[29 ][i].end ());
205206
206- for (unsigned int i = 0 ; i < 6 ; i++)
207- totalVariations.insert (totalVariations.end (), pedVariations[30 ][i].begin (), pedVariations[30 ][0 ].end ());
207+ for (unsigned int i = 0 ; i < 16 ; i++)
208+ totalVariations.insert (totalVariations.end (), pedVariations[30 ][i].begin (), pedVariations[30 ][i ].end ());
208209
209- for (unsigned int i = 0 ; i < 6 ; i++)
210- totalVariations.insert (totalVariations.end (), pedVariations[254 ][i].begin (), pedVariations[254 ][0 ].end ());
210+ for (unsigned int i = 0 ; i < 16 ; i++)
211+ totalVariations.insert (totalVariations.end (), pedVariations[254 ][i].begin (), pedVariations[254 ][i ].end ());
211212
212- std::vector< unsigned short > variationsProcessed;
213+
213214
214- for (unsigned int i = 0 ; i < totalVariations.size (); i++)
215- {
216- unsigned short variationModel = totalVariations[i];
217- if (variationModel > 300 && IdExists (variationsProcessed, variationModel) == false )
218- variationsProcessed.push_back (variationModel);
219- }
215+ for (auto &i : totalVariations)
216+ if (i > 300 )
217+ drugDealers.insert (i);
220218
221- for (unsigned int i = 0 ; i < variationsProcessed. size (); i++ )
219+ for (auto &i : drugDealers )
222220 {
223221 if (enableLog == 1 )
224- logfile << variationsProcessed[i] << " \n " ;
225- Command<COMMAND_ALLOCATE_STREAMED_SCRIPT_TO_RANDOM_PED>(19 , variationsProcessed[i] , 100 );
226- Command<COMMAND_ATTACH_ANIMS_TO_MODEL>(variationsProcessed[i] , " DEALER" );
222+ logfile << i << " \n " ;
223+ Command<COMMAND_ALLOCATE_STREAMED_SCRIPT_TO_RANDOM_PED>(19 , i , 100 );
224+ // Command<COMMAND_ATTACH_ANIMS_TO_MODEL>(i , "DEALER");
227225 }
228226}
229227
@@ -260,61 +258,70 @@ void updateVariations(CZone* zInfo)
260258 CWanted* wanted = FindPlayerWanted (-1 );
261259
262260 for (auto & i : iniPed.data )
261+ {
262+ int modelid = 0 ;
263263 if (i.first [0 ] >= ' 0' && i.first [0 ] <= ' 9' )
264- {
265- int modelid = std::stoi (i.first );
266- if (modelid > 0 && modelid < 300 )
267- {
268- vectorUnion (pedVariations[modelid][4 ], pedVariations[modelid][currentTown], pedCurrentVariations[modelid]);
264+ modelid = std::stoi (i.first );
265+ else
266+ CModelInfo::GetModelInfo ((char *)i.first .c_str (), &modelid);
269267
270- std::vector<unsigned short > vec = iniLineParser (i.first , ((lastZone[0 ] == 0 ) ? zInfo->m_szLabel : lastZone), &iniPed);
271- if (!vec.empty ())
272- {
273- if (pedMergeZones.find ((unsigned short )modelid) != pedMergeZones.end ())
274- pedCurrentVariations[modelid] = vectorUnion (pedCurrentVariations[modelid], vec);
275- else
276- pedCurrentVariations[modelid] = vec;
277- }
268+ if (modelid > 0 && modelid < 300 )
269+ {
270+ vectorUnion (pedVariations[modelid][4 ], pedVariations[modelid][currentTown], pedCurrentVariations[modelid]);
278271
279- vec = iniLineParser (i.first , currentInterior, &iniPed);
280- if (!vec.empty ())
272+ std::vector<unsigned short > vec = iniLineParser (i.first , ((lastZone[0 ] == 0 ) ? zInfo->m_szLabel : lastZone), &iniPed);
273+ if (!vec.empty ())
274+ {
275+ if (pedMergeZones.find ((unsigned short )modelid) != pedMergeZones.end ())
281276 pedCurrentVariations[modelid] = vectorUnion (pedCurrentVariations[modelid], vec);
277+ else
278+ pedCurrentVariations[modelid] = vec;
279+ }
282280
283- if (wanted)
284- {
285- unsigned int wantedLevel = (wanted->m_nWantedLevel > 0 ) ? (wanted->m_nWantedLevel - 1 ) : (wanted->m_nWantedLevel );
286- if (!pedWantedVariations[modelid][wantedLevel].empty () && !pedCurrentVariations[modelid].empty ())
287- filterWantedVariations (pedCurrentVariations[modelid], pedWantedVariations[modelid][wantedLevel]);
288- }
281+ vec = iniLineParser (i.first , currentInterior, &iniPed);
282+ if (!vec.empty ())
283+ pedCurrentVariations[modelid] = vectorUnion (pedCurrentVariations[modelid], vec);
284+
285+ if (wanted)
286+ {
287+ unsigned int wantedLevel = (wanted->m_nWantedLevel > 0 ) ? (wanted->m_nWantedLevel - 1 ) : (wanted->m_nWantedLevel );
288+ if (!pedWantedVariations[modelid][wantedLevel].empty () && !pedCurrentVariations[modelid].empty ())
289+ filterWantedVariations (pedCurrentVariations[modelid], pedWantedVariations[modelid][wantedLevel]);
289290 }
290291 }
292+ }
291293
292294
293295 for (auto & i : iniVeh.data )
296+ {
297+ int modelid = 0 ;
294298 if (i.first [0 ] >= ' 0' && i.first [0 ] <= ' 9' )
299+ modelid = std::stoi (i.first );
300+ else
301+ CModelInfo::GetModelInfo ((char *)i.first .c_str (), &modelid);
302+
303+ modelid -= 400 ;
304+ if (modelid > 0 && modelid < 212 )
295305 {
296- int modelid = std::stoi (i.first ) - 400 ;
297- if (modelid > 0 && modelid < 212 )
298- {
299- vectorUnion (vehVariations[modelid][4 ], vehVariations[modelid][currentTown], vehCurrentVariations[modelid]);
306+ vectorUnion (vehVariations[modelid][4 ], vehVariations[modelid][currentTown], vehCurrentVariations[modelid]);
300307
301- std::vector<unsigned short > vec = iniLineParser (i.first , ((lastZone[0 ] == 0 ) ? zInfo->m_szLabel : lastZone), &iniVeh);
302- if (!vec.empty ())
303- {
304- if (vehMergeZones.find ((unsigned short )modelid) != vehMergeZones.end ())
305- vehCurrentVariations[modelid] = vectorUnion (vehCurrentVariations[modelid], vec);
306- else
307- vehCurrentVariations[modelid] = vec;
308- }
308+ std::vector<unsigned short > vec = iniLineParser (i.first , ((lastZone[0 ] == 0 ) ? zInfo->m_szLabel : lastZone), &iniVeh);
309+ if (!vec.empty ())
310+ {
311+ if (vehMergeZones.find ((unsigned short )modelid) != vehMergeZones.end ())
312+ vehCurrentVariations[modelid] = vectorUnion (vehCurrentVariations[modelid], vec);
313+ else
314+ vehCurrentVariations[modelid] = vec;
315+ }
309316
310- if (wanted)
311- {
312- unsigned int wantedLevel = (wanted->m_nWantedLevel > 0 ) ? (wanted->m_nWantedLevel - 1 ) : (wanted->m_nWantedLevel );
313- if (!vehWantedVariations[modelid][wantedLevel].empty () && !vehCurrentVariations[modelid].empty ())
314- filterWantedVariations (vehCurrentVariations[modelid], vehWantedVariations[modelid][wantedLevel]);
315- }
317+ if (wanted)
318+ {
319+ unsigned int wantedLevel = (wanted->m_nWantedLevel > 0 ) ? (wanted->m_nWantedLevel - 1 ) : (wanted->m_nWantedLevel );
320+ if (!vehWantedVariations[modelid][wantedLevel].empty () && !vehCurrentVariations[modelid].empty ())
321+ filterWantedVariations (vehCurrentVariations[modelid], vehWantedVariations[modelid][wantedLevel]);
316322 }
317- }
323+ }
324+ }
318325}
319326
320327void printCurrentVariations ()
@@ -414,12 +421,18 @@ void installHooks()
414421
415422void loadIniData (bool firstTime)
416423{
417-
418- for (unsigned short i = 0 ; i < 300 ; i++ )
424+ // for (unsigned short i = 0; i < 300; i++)
425+ for (auto &iniData : iniPed. data )
419426 {
420- std::string section = std::to_string (i);
427+ int i = 0 ;
428+ std::string section = iniData.first ;
429+
430+ if (section[0 ] >= ' 0' && section[0 ] <= ' 9' )
431+ i = std::stoi (iniData.first );
432+ else
433+ CModelInfo::GetModelInfo ((char *)section.c_str (), &i);
421434
422- if (iniPed. data . find (section) != iniPed. data . end () )
435+ if (i > 0 && i < 300 )
423436 {
424437 pedVariations[i][0 ] = iniLineParser (section, " Countryside" , &iniPed);
425438 pedVariations[i][1 ] = iniLineParser (section, " LosSantos" , &iniPed);
@@ -473,7 +486,7 @@ void loadIniData(bool firstTime)
473486 pedOriginalModels.insert ({ pedVariations[i][j][k], i });
474487
475488 if (iniPed.ReadInteger (section, " MergeZonesWithCities" , 0 ) == 1 )
476- pedMergeZones.insert (i);
489+ pedMergeZones.insert (( unsigned short ) i);
477490 }
478491 }
479492
@@ -682,6 +695,8 @@ class ModelVariations {
682695
683696 Events::initScriptsEvent += []
684697 {
698+ loadIniData (false );
699+
685700 if (loadAllVehicles)
686701 for (int i = 400 ; i < 612 ; i++)
687702 CStreaming::RequestModel (i, KEEP_IN_MEMORY);
0 commit comments