Skip to content

Commit

Permalink
Weapon Stats Randomizer: Fix incorrect model group selection
Browse files Browse the repository at this point in the history
  • Loading branch information
Parik27 committed Jun 5, 2021
1 parent 0523931 commit 1df7e88
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
14 changes: 14 additions & 0 deletions src/common/parser.hh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <type_traits>
#include <tuple>
#include <array>
#include <unordered_map>
#include <utility>

/* A randomizer to randomize a field between its min/max value */
Expand Down Expand Up @@ -110,6 +111,19 @@ public:
}
}

/*******************************************************/
void
RandomizeObject (uint32_t identifier, Type &out)
{
static std::unordered_map<uint32_t, Type> sm_Identifiers;
sm_Identifiers.insert (std::make_pair (identifier, out));

uint32_t model = sm_Identifiers[identifier];
RandomizeObject (model);

out = model;
}

/*******************************************************/
void
AddSample (const Type value)
Expand Down
3 changes: 2 additions & 1 deletion src/weapons/stats.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ class WeaponStatsRandomizer
for (CItemInfo *i : CWeaponInfoManager::sm_Instance->aItemInfos)
{
if (i->Model != -1 && i->Model)
sm_WeaponModelRandomizer.RandomizeObject (i->Model);
sm_WeaponModelRandomizer.RandomizeObject (i->Name,
i->Model);

std::uint32_t hash;
if (sample)
Expand Down

0 comments on commit 1df7e88

Please sign in to comment.