1515#include < array>
1616#include < unordered_set>
1717
18-
1918/*
2019--ZONES--
2120
@@ -59,7 +58,8 @@ std::array<std::vector<short>, 16> vehWantedVariations[212];
5958
6059std::vector<short > currentVehVariations[212 ];
6160
62- BYTE pedWepVariationTypes[300 ] = {};
61+ std::map<short , BYTE > pedWepVariationTypes;
62+
6363BYTE vehNumVariations[212 ] = {};
6464
6565std::stack<CPed*> pedStack;
@@ -468,11 +468,13 @@ class ModelVariations {
468468 std::sort (pedVariations[i][15 ].begin (), pedVariations[i][15 ].end ());
469469 vectorUnion (pedVariations[i][15 ], pedVariations[i][14 ], vec);
470470 pedVariations[i][15 ] = vec;
471+ }
471472
472-
473- int wepVariationType = iniWeap.ReadInteger (std::to_string (i), " VariationType" , -1 );
473+ for (short i = 0 ; i < 32000 ; i++)
474+ {
475+ BYTE wepVariationType = iniWeap.ReadInteger (std::to_string (i), " VariationType" , -1 );
474476 if (wepVariationType == 1 || wepVariationType == 2 )
475- pedWepVariationTypes[i] = wepVariationType;
477+ pedWepVariationTypes. insert ( std::make_pair (i, wepVariationType)) ;
476478 }
477479
478480 if (enableVehicles = iniVeh.ReadInteger (" Settings" , " Enable" , 0 ))
@@ -549,10 +551,11 @@ class ModelVariations {
549551 {
550552 CPed* ped = pedStack.top ();
551553 pedStack.pop ();
552- if (ped->m_nModelIndex >= 0 && ped->m_nModelIndex < 300 && pedWepVariationTypes[ped->m_nModelIndex ] > 0 )
554+ auto it = pedWepVariationTypes.find (ped->m_nModelIndex );
555+ if (it != pedWepVariationTypes.end ())
553556 {
554557 int activeSlot = ped->m_nActiveWeaponSlot ;
555- int loopMax = pedWepVariationTypes[ped-> m_nModelIndex ] == 1 ? 13 : 47 ;
558+ int loopMax = it-> second == 1 ? 13 : 47 ;
556559
557560 for (int i = 0 ; i < loopMax; i++)
558561 {
@@ -562,7 +565,7 @@ class ModelVariations {
562565 {
563566 int slot = i;
564567 int random = CGeneral::GetRandomNumberInRange (0 , wvec.size ());
565- if (pedWepVariationTypes[ped-> m_nModelIndex ] == 2 )
568+ if (it-> second == 2 )
566569 slot = ped->GetWeaponSlot ((eWeaponType)i);
567570
568571 if (ped->m_aWeapons [slot].m_nType > 0 && ped->m_aWeapons [slot].m_nType != wvec[random])
0 commit comments