summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/FastRandom.h16
-rw-r--r--src/MobSpawner.cpp14
-rw-r--r--src/MobSpawner.h4
3 files changed, 15 insertions, 19 deletions
diff --git a/src/FastRandom.h b/src/FastRandom.h
index 77bafc217..7c3048118 100644
--- a/src/FastRandom.h
+++ b/src/FastRandom.h
@@ -77,8 +77,8 @@ public:
/** Return a random IntType in the range [a_Min, a_Max]. */
- template <class IntType = int, class ArgType>
- IntType RandInt(ArgType a_Min, ArgType a_Max)
+ template <class IntType = int>
+ IntType RandInt(IntType a_Min, IntType a_Max)
{
ASSERT(
(a_Max >= a_Min) &&
@@ -97,8 +97,8 @@ public:
/** Return a random IntType in the range [0, a_Max]. */
- template <class IntType = int, class ArgType>
- IntType RandInt(ArgType a_Max)
+ template <class IntType = int>
+ IntType RandInt(IntType a_Max)
{
ASSERT((a_Max >= 0) && (a_Max <= std::numeric_limits<IntType>::max()));
Detail::cUniform<IntType> dist(IntType(0), static_cast<IntType>(a_Max));
@@ -122,8 +122,8 @@ public:
/** Return a random RealType in the range [a_Min, a_Max). */
- template <class RealType = float, class ArgType>
- RealType RandReal(ArgType a_Min, ArgType a_Max)
+ template <class RealType = float>
+ RealType RandReal(RealType a_Min, RealType a_Max)
{
std::uniform_real_distribution<RealType> dist(a_Min, a_Max);
return dist(m_Engine);
@@ -134,8 +134,8 @@ public:
/** Return a random RealType in the range [0, a_Max). */
- template <class RealType = float, class ArgType>
- RealType RandReal(ArgType a_Max)
+ template <class RealType = float>
+ RealType RandReal(RealType a_Max)
{
std::uniform_real_distribution<RealType> dist(RealType(0), a_Max);
return dist(m_Engine);
diff --git a/src/MobSpawner.cpp b/src/MobSpawner.cpp
index 2ddf60bbd..e3f5298e4 100644
--- a/src/MobSpawner.cpp
+++ b/src/MobSpawner.cpp
@@ -45,12 +45,12 @@ bool cMobSpawner::CheckPackCenter(BLOCKTYPE a_BlockType)
-void cMobSpawner::addIfAllowed(eMonsterType toAdd, std::set<eMonsterType>& toAddIn)
+void cMobSpawner::addIfAllowed(eMonsterType toAdd, std::vector<eMonsterType> & toAddIn)
{
std::set<eMonsterType>::iterator itr = m_AllowedTypes.find(toAdd);
if (itr != m_AllowedTypes.end())
{
- toAddIn.insert(toAdd);
+ toAddIn.push_back(toAdd);
}
}
@@ -60,7 +60,7 @@ void cMobSpawner::addIfAllowed(eMonsterType toAdd, std::set<eMonsterType>& toAdd
eMonsterType cMobSpawner::ChooseMobType(EMCSBiome a_Biome)
{
- std::set<eMonsterType> allowedMobs;
+ std::vector<eMonsterType> allowedMobs;
if ((a_Biome == biMushroomIsland) || (a_Biome == biMushroomShore))
{
@@ -107,15 +107,11 @@ eMonsterType cMobSpawner::ChooseMobType(EMCSBiome a_Biome)
}
}
+ // Pick a random mob from the options:
size_t allowedMobsSize = allowedMobs.size();
if (allowedMobsSize > 0)
{
- std::set<eMonsterType>::iterator itr = allowedMobs.begin();
-
- using DiffType = decltype(itr)::difference_type;
- std::advance(itr, GetRandomProvider().RandInt<DiffType>(allowedMobsSize - 1));
-
- return *itr;
+ return allowedMobs[GetRandomProvider().RandInt(allowedMobsSize - 1)];
}
return mtInvalidType;
}
diff --git a/src/MobSpawner.h b/src/MobSpawner.h
index dd5b64fba..5802a2b1c 100644
--- a/src/MobSpawner.h
+++ b/src/MobSpawner.h
@@ -58,13 +58,13 @@ protected :
eMonsterType ChooseMobType(EMCSBiome a_Biome);
/** Adds toAdd into toAddIn, if toAdd is in m_AllowedTypes */
- void addIfAllowed(eMonsterType toAdd, std::set<eMonsterType> & toAddIn);
+ void addIfAllowed(eMonsterType toAdd, std::vector<eMonsterType> & toAddIn);
cMonster::eFamily m_MonsterFamily;
std::set<eMonsterType> m_AllowedTypes;
bool m_NewPack;
eMonsterType m_MobType;
- std::set<cMonster*> m_Spawned;
+ std::set<cMonster *> m_Spawned;
} ;