summaryrefslogtreecommitdiffstats
path: root/src/Generating/FinishGen.cpp
diff options
context:
space:
mode:
authorp-mcgowan <mickeymcgowan@shaw.ca>2014-12-04 10:08:17 +0100
committerp-mcgowan <mickeymcgowan@shaw.ca>2014-12-04 10:08:17 +0100
commit83d4bec369643c82c3f13e2e1c6d13009a2a0bd9 (patch)
tree183479b41018daf3839e765efb33d7a03785334c /src/Generating/FinishGen.cpp
parentclass description and doxy-commenting (diff)
downloadcuberite-83d4bec369643c82c3f13e2e1c6d13009a2a0bd9.tar
cuberite-83d4bec369643c82c3f13e2e1c6d13009a2a0bd9.tar.gz
cuberite-83d4bec369643c82c3f13e2e1c6d13009a2a0bd9.tar.bz2
cuberite-83d4bec369643c82c3f13e2e1c6d13009a2a0bd9.tar.lz
cuberite-83d4bec369643c82c3f13e2e1c6d13009a2a0bd9.tar.xz
cuberite-83d4bec369643c82c3f13e2e1c6d13009a2a0bd9.tar.zst
cuberite-83d4bec369643c82c3f13e2e1c6d13009a2a0bd9.zip
Diffstat (limited to 'src/Generating/FinishGen.cpp')
-rw-r--r--src/Generating/FinishGen.cpp35
1 files changed, 24 insertions, 11 deletions
diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp
index d938c34bd..e9cdfe91e 100644
--- a/src/Generating/FinishGen.cpp
+++ b/src/Generating/FinishGen.cpp
@@ -974,7 +974,7 @@ cFinishGenPassiveMobs::cFinishGenPassiveMobs(int a_Seed, cIniFile & a_IniFile, e
}
} // switch (dimension)
m_AnimalProbability = a_IniFile.GetValueSetI(SectionName, "AnimalSpawnChunkPercentage", DefaultAnimalSpawnChunkPercentage);
- if (m_AnimalProbability < 0 || m_AnimalProbability > 100)
+ if ((m_AnimalProbability < 0) || (m_AnimalProbability > 100))
{
LOGWARNING("[Animals]: AnimalSpawnChunkPercentage is invalid, using the default of \"%d\".", DefaultAnimalSpawnChunkPercentage);
}
@@ -1001,7 +1001,7 @@ void cFinishGenPassiveMobs::GenFinish(cChunkDesc & a_ChunkDesc)
return;
}
- /** Try spawning a pack center 10 times, should get roughly the same probability */
+ // Try spawning a pack center 10 times, should get roughly the same probability
for (int Tries = 0; Tries < 10; Tries++)
{
int PackCenterX = (m_Noise.IntNoise2DInt(chunkX, chunkZ) / 7) % cChunkDef::Width;
@@ -1010,8 +1010,8 @@ void cFinishGenPassiveMobs::GenFinish(cChunkDesc & a_ChunkDesc)
{
for (int i = 0; i < 5; i++)
{
- int OffsetX = (m_Noise.IntNoise2DInt(chunkX, chunkZ) / 7) % cChunkDef::Width;
- int OffsetZ = (m_Noise.IntNoise2DInt(chunkX, chunkZ) / 7) % cChunkDef::Width;
+ int OffsetX = (m_Noise.IntNoise2DInt(chunkX + chunkZ, Tries) / 7) % cChunkDef::Width;
+ int OffsetZ = (m_Noise.IntNoise2DInt(chunkX, chunkZ + Tries) / 7) % cChunkDef::Width;
TrySpawnAnimals(a_ChunkDesc, OffsetX, a_ChunkDesc.GetHeight(OffsetX, OffsetZ), OffsetZ, RandomMob);
}
return;
@@ -1026,11 +1026,16 @@ void cFinishGenPassiveMobs::GenFinish(cChunkDesc & a_ChunkDesc)
bool cFinishGenPassiveMobs::TrySpawnAnimals(cChunkDesc & a_ChunkDesc, int a_RelX, int a_RelY, int a_RelZ, eMonsterType AnimalToSpawn)
{
+ if ((a_RelY >= cChunkDef::Height - 1) || (a_RelY <= 0))
+ {
+ return false;
+ }
+
BLOCKTYPE BlockAtHead = a_ChunkDesc.GetBlockType(a_RelX, a_RelY + 1, a_RelZ);
BLOCKTYPE BlockAtFeet = a_ChunkDesc.GetBlockType(a_RelX, a_RelY, a_RelZ);
BLOCKTYPE BlockUnderFeet = a_ChunkDesc.GetBlockType(a_RelX, a_RelY - 1, a_RelZ);
- /** Check block below (opaque, grass, water), and above (air) */
+ // Check block below (opaque, grass, water), and above (air)
if (AnimalToSpawn == mtSquid && BlockAtFeet != E_BLOCK_WATER)
{
return false;
@@ -1087,53 +1092,61 @@ eMonsterType cFinishGenPassiveMobs::GetRandomMob(cChunkDesc & a_ChunkDesc)
// No animals
case biNether:
case biEnd:
+ {
return mtInvalidType;
-
+ }
// Squid only
case biOcean:
case biFrozenOcean:
case biFrozenRiver:
case biRiver:
case biDeepOcean:
+ {
ListOfSpawnables.insert(MobIter, mtSquid);
break;
-
+ }
// Mooshroom only
case biMushroomIsland:
case biMushroomShore:
+ {
ListOfSpawnables.insert(MobIter, mtMooshroom);
break;
-
+ }
case biJungle:
case biJungleHills:
case biJungleEdge:
case biJungleM:
case biJungleEdgeM:
+ {
ListOfSpawnables.insert(MobIter, mtOcelot);
-
+ }
case biPlains:
case biSunflowerPlains:
case biSavanna:
case biSavannaPlateau:
case biSavannaM:
case biSavannaPlateauM:
+ {
ListOfSpawnables.insert(MobIter, mtHorse);
// ListOfSpawnables.insert(mtDonkey);
-
+ }
// Wolves only
case biForest:
case biTaiga:
case biMegaTaiga:
case biColdTaiga:
case biColdTaigaM:
+ {
ListOfSpawnables.insert(MobIter, mtWolf);
-
+ }
// All other mobs
default:
+ {
ListOfSpawnables.insert(MobIter, mtChicken);
ListOfSpawnables.insert(MobIter, mtCow);
ListOfSpawnables.insert(MobIter, mtPig);
ListOfSpawnables.insert(MobIter, mtSheep);
+ }
}
if (ListOfSpawnables.empty())