diff options
author | Mattes D <github@xoft.cz> | 2017-07-21 12:06:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-21 12:06:21 +0200 |
commit | 895987a1112100a209b345eab002366fee39d7aa (patch) | |
tree | 3e6db769934b8648324bc05eac6bc6427b110bbc /src/MobSpawner.cpp | |
parent | Break the cactus block when it grows next to a block. (#3851) (diff) | |
download | cuberite-895987a1112100a209b345eab002366fee39d7aa.tar cuberite-895987a1112100a209b345eab002366fee39d7aa.tar.gz cuberite-895987a1112100a209b345eab002366fee39d7aa.tar.bz2 cuberite-895987a1112100a209b345eab002366fee39d7aa.tar.lz cuberite-895987a1112100a209b345eab002366fee39d7aa.tar.xz cuberite-895987a1112100a209b345eab002366fee39d7aa.tar.zst cuberite-895987a1112100a209b345eab002366fee39d7aa.zip |
Diffstat (limited to 'src/MobSpawner.cpp')
-rw-r--r-- | src/MobSpawner.cpp | 14 |
1 files changed, 5 insertions, 9 deletions
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; } |