summaryrefslogtreecommitdiffstats
path: root/src/Generating/FinishGen.cpp
diff options
context:
space:
mode:
authorBond-009 <bond.009@outlook.com>2018-04-11 13:17:30 +0200
committerAlexander Harkness <me@bearbin.net>2018-04-11 13:17:30 +0200
commit98d807187bbaec4cd65dbe7c1ecac0435efb6df0 (patch)
treed917cf6bc68e013ff1229303d3668c2947b2682b /src/Generating/FinishGen.cpp
parentUpdate m_LastSentPosition in TeleportToCoords and DoMoveToWorld. (#4211) (diff)
downloadcuberite-98d807187bbaec4cd65dbe7c1ecac0435efb6df0.tar
cuberite-98d807187bbaec4cd65dbe7c1ecac0435efb6df0.tar.gz
cuberite-98d807187bbaec4cd65dbe7c1ecac0435efb6df0.tar.bz2
cuberite-98d807187bbaec4cd65dbe7c1ecac0435efb6df0.tar.lz
cuberite-98d807187bbaec4cd65dbe7c1ecac0435efb6df0.tar.xz
cuberite-98d807187bbaec4cd65dbe7c1ecac0435efb6df0.tar.zst
cuberite-98d807187bbaec4cd65dbe7c1ecac0435efb6df0.zip
Diffstat (limited to '')
-rw-r--r--src/Generating/FinishGen.cpp87
1 files changed, 7 insertions, 80 deletions
diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp
index a79973a9d..8c54be0d0 100644
--- a/src/Generating/FinishGen.cpp
+++ b/src/Generating/FinishGen.cpp
@@ -14,6 +14,7 @@
#include "../Simulator/FireSimulator.h"
#include "../World.h"
#include "../IniFile.h"
+#include "../MobSpawner.h"
@@ -1504,101 +1505,27 @@ bool cFinishGenPassiveMobs::TrySpawnAnimals(cChunkDesc & a_ChunkDesc, int a_RelX
eMonsterType cFinishGenPassiveMobs::GetRandomMob(cChunkDesc & a_ChunkDesc)
{
-
- std::set<eMonsterType> ListOfSpawnables;
+ std::vector<eMonsterType> ListOfSpawnables;
int chunkX = a_ChunkDesc.GetChunkX();
int chunkZ = a_ChunkDesc.GetChunkZ();
int x = (m_Noise.IntNoise2DInt(chunkX, chunkZ + 10) / 7) % cChunkDef::Width;
int z = (m_Noise.IntNoise2DInt(chunkX + chunkZ, chunkZ) / 7) % cChunkDef::Width;
- // Check biomes first to get a list of animals
- switch (a_ChunkDesc.GetBiome(x, z))
+ for (auto MobType : cMobSpawner::GetAllowedMobTypes(a_ChunkDesc.GetBiome(x, z)))
{
- // No animals in deserts or non-overworld dimensions
- case biNether:
- case biEnd:
- case biDesertHills:
- case biDesert:
- case biDesertM:
- {
- return mtInvalidType;
- }
-
- // Mooshroom only - no other mobs on mushroom islands
- case biMushroomIsland:
- case biMushroomShore:
- {
- return mtMooshroom;
- }
-
- // Add squid in ocean biomes
- case biOcean:
- case biFrozenOcean:
- case biFrozenRiver:
- case biRiver:
- case biDeepOcean:
- {
- ListOfSpawnables.insert(mtSquid);
- break;
- }
-
- // Add ocelots in jungle biomes
- case biJungle:
- case biJungleHills:
- case biJungleEdge:
- case biJungleM:
- case biJungleEdgeM:
- {
- ListOfSpawnables.insert(mtOcelot);
- break;
- }
-
- // Add horses in plains-like biomes
- case biPlains:
- case biSunflowerPlains:
- case biSavanna:
- case biSavannaPlateau:
- case biSavannaM:
- case biSavannaPlateauM:
+ if (cMonster::FamilyFromType(MobType) == cMonster::eFamily::mfPassive)
{
- ListOfSpawnables.insert(mtHorse);
- break;
- }
-
- // Add wolves in taiga biomes
- case biTaiga:
- case biMegaTaiga:
- case biColdTaiga:
- case biColdTaigaM:
- {
- ListOfSpawnables.insert(mtWolf);
- break;
- }
- // Nothing special about this biome
- default:
- {
- break;
+ ListOfSpawnables.push_back(MobType);
}
}
- ListOfSpawnables.insert(mtChicken);
- ListOfSpawnables.insert(mtCow);
- ListOfSpawnables.insert(mtPig);
- ListOfSpawnables.insert(mtSheep);
if (ListOfSpawnables.empty())
{
return mtInvalidType;
}
- auto MobIter = ListOfSpawnables.begin();
- using diff_type =
- std::iterator_traits<decltype(MobIter)>::difference_type;
- diff_type RandMob = static_cast<diff_type>
- (static_cast<size_t>(m_Noise.IntNoise2DInt(chunkX - chunkZ + 2, chunkX + 5) / 7)
- % ListOfSpawnables.size());
- std::advance(MobIter, RandMob);
-
- return *MobIter;
+ auto RandMob = (static_cast<size_t>(m_Noise.IntNoise2DInt(chunkX - chunkZ + 2, chunkX + 5) / 7) % ListOfSpawnables.size());
+ return ListOfSpawnables[RandMob];
}