summaryrefslogtreecommitdiffstats
path: root/src/Generating/FinishGen.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Generating/FinishGen.cpp')
-rw-r--r--src/Generating/FinishGen.cpp350
1 files changed, 175 insertions, 175 deletions
diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp
index b8575f4f8..296e92139 100644
--- a/src/Generating/FinishGen.cpp
+++ b/src/Generating/FinishGen.cpp
@@ -402,7 +402,7 @@ void cFinishGenSoulsandRims::GenFinish(cChunkDesc & a_ChunkDesc)
int ChunkZ = a_ChunkDesc.GetChunkZ() * cChunkDef::Width;
HEIGHTTYPE MaxHeight = a_ChunkDesc.GetMaxHeight();
- for (int x = 0; x < 16; x++)
+ for (int x = 0; x < 16; x++)
{
int xx = ChunkX + x;
for (int z = 0; z < 16; z++)
@@ -950,34 +950,34 @@ bool cFinishGenFluidSprings::TryPlaceSpring(cChunkDesc & a_ChunkDesc, int x, int
// cFinishGenPassiveMobs:
cFinishGenPassiveMobs::cFinishGenPassiveMobs(int a_Seed, cIniFile & a_IniFile, eDimension a_Dimension) :
- m_Noise(a_Seed)
+ m_Noise(a_Seed)
{
- AString SectionName = "Animals";
- int DefaultAnimalSpawnChunkPercentage = DEF_ANIMAL_SPAWN_PERCENT;
- switch (a_Dimension)
- {
- case dimOverworld:
- {
- DefaultAnimalSpawnChunkPercentage = DEF_ANIMAL_SPAWN_PERCENT;
- break;
- }
- case dimNether:
- case dimEnd: // No nether or end animals (currently)
- {
- DefaultAnimalSpawnChunkPercentage = DEF_NO_ANIMALS;
- break;
- }
- default:
- {
- ASSERT(!"Unhandled world dimension");
- break;
- }
- } // switch (dimension)
- m_AnimalProbability = a_IniFile.GetValueSetI(SectionName, "AnimalSpawnChunkPercentage", DefaultAnimalSpawnChunkPercentage);
- if (m_AnimalProbability < 0 || m_AnimalProbability > 100)
- {
- LOGWARNING("[Animals]: AnimalSpawnChunkPercentage is invalid, using the default of \"%d\".", DefaultAnimalSpawnChunkPercentage);
- }
+ AString SectionName = "Animals";
+ int DefaultAnimalSpawnChunkPercentage = DEF_ANIMAL_SPAWN_PERCENT;
+ switch (a_Dimension)
+ {
+ case dimOverworld:
+ {
+ DefaultAnimalSpawnChunkPercentage = DEF_ANIMAL_SPAWN_PERCENT;
+ break;
+ }
+ case dimNether:
+ case dimEnd:// No nether or end animals (currently)
+ {
+ DefaultAnimalSpawnChunkPercentage = DEF_NO_ANIMALS;
+ break;
+ }
+ default:
+ {
+ ASSERT(!"Unhandled world dimension");
+ break;
+ }
+ }// switch (dimension)
+ m_AnimalProbability = a_IniFile.GetValueSetI(SectionName, "AnimalSpawnChunkPercentage", DefaultAnimalSpawnChunkPercentage);
+ if (m_AnimalProbability < 0 || m_AnimalProbability > 100)
+ {
+ LOGWARNING("[Animals]: AnimalSpawnChunkPercentage is invalid, using the default of \"%d\".", DefaultAnimalSpawnChunkPercentage);
+ }
}
@@ -986,37 +986,37 @@ cFinishGenPassiveMobs::cFinishGenPassiveMobs(int a_Seed, cIniFile & a_IniFile, e
void cFinishGenPassiveMobs::GenFinish(cChunkDesc & a_ChunkDesc)
{
- int ChanceRnd = m_Random.NextInt(100);
- if (ChanceRnd > m_AnimalProbability)
- {
- return;
- }
-
- eMonsterType RandomMob = GetRandomMob(a_ChunkDesc);
- if (RandomMob == mtInvalidType)
- {
- LOGWARNING("Attempted to spawn invalid mob type.");
- return;
- }
-
- // Try spawning a pack center 10 times, should get roughly the same probability
- for (int Tries = 0; Tries < 10; Tries++)
- {
- int PackCenterX = m_Random.NextInt(cChunkDef::Width - 1);
- int PackCenterZ = m_Random.NextInt(cChunkDef::Width - 1);
- if (TrySpawnAnimals(a_ChunkDesc, PackCenterX, a_ChunkDesc.GetHeight(PackCenterX, PackCenterZ), PackCenterZ, RandomMob))
- {
- for (int i = 0; i < 5; i++)
- {
- int OffsetX = m_Random.NextInt(cChunkDef::Width - 1);
- int OffsetZ = m_Random.NextInt(cChunkDef::Width - 1);
- TrySpawnAnimals(a_ChunkDesc, OffsetX, a_ChunkDesc.GetHeight(OffsetX, OffsetZ), OffsetZ, RandomMob);
- }
-
- return;
-
- } // if pack center spawn successful
- } // for tries
+ int ChanceRnd = m_Random.NextInt(100);
+ if (ChanceRnd > m_AnimalProbability)
+ {
+ return;
+ }
+
+ eMonsterType RandomMob = GetRandomMob(a_ChunkDesc);
+ if (RandomMob == mtInvalidType)
+ {
+ LOGWARNING("Attempted to spawn invalid mob type.");
+ return;
+ }
+
+ // Try spawning a pack center 10 times, should get roughly the same probability
+ for (int Tries = 0; Tries < 10; Tries++)
+ {
+ int PackCenterX = m_Random.NextInt(cChunkDef::Width - 1);
+ int PackCenterZ = m_Random.NextInt(cChunkDef::Width - 1);
+ if (TrySpawnAnimals(a_ChunkDesc, PackCenterX, a_ChunkDesc.GetHeight(PackCenterX, PackCenterZ), PackCenterZ, RandomMob))
+ {
+ for (int i = 0; i < 5; i++)
+ {
+ int OffsetX = m_Random.NextInt(cChunkDef::Width - 1);
+ int OffsetZ = m_Random.NextInt(cChunkDef::Width - 1);
+ TrySpawnAnimals(a_ChunkDesc, OffsetX, a_ChunkDesc.GetHeight(OffsetX, OffsetZ), OffsetZ, RandomMob);
+ }
+
+ return;
+
+ }// if pack center spawn successful
+ }// for tries
}
@@ -1025,48 +1025,48 @@ void cFinishGenPassiveMobs::GenFinish(cChunkDesc & a_ChunkDesc)
bool cFinishGenPassiveMobs::TrySpawnAnimals(cChunkDesc & a_ChunkDesc, int a_RelX, int a_RelY, int a_RelZ, eMonsterType AnimalToSpawn)
{
- 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)
- if (AnimalToSpawn == mtSquid && BlockAtFeet != E_BLOCK_WATER)
- {
- return false;
- }
- if (
- (AnimalToSpawn != mtSquid) &&
- (BlockAtHead != E_BLOCK_AIR) &&
- (BlockAtFeet != E_BLOCK_AIR) &&
- (!cBlockInfo::IsTransparent(BlockUnderFeet))
- )
- {
- return false;
- }
- if (
- (BlockUnderFeet != E_BLOCK_GRASS) &&
- (
- (AnimalToSpawn == mtSheep) ||
- (AnimalToSpawn == mtChicken) ||
- (AnimalToSpawn == mtPig)
- )
- )
- {
- return false;
- }
-
- int AnimalX, AnimalY, AnimalZ;
- AnimalX = (double)(a_ChunkDesc.GetChunkX()*cChunkDef::Width + a_RelX + 0.5);
- AnimalY = a_RelY;
- AnimalZ = (double)(a_ChunkDesc.GetChunkZ()*cChunkDef::Width + a_RelZ + 0.5);
-
- cEntityList ChunkEntities = a_ChunkDesc.GetEntities();
- cMonster * NewMob = cMonster::NewMonsterFromType(AnimalToSpawn);
- NewMob->SetPosition(AnimalX, AnimalY, AnimalZ);
- ChunkEntities.push_back(NewMob);
- LOGD("Spawning %s #%i at {%d, %d, %d}", NewMob->GetClass(), NewMob->GetUniqueID(), AnimalX, AnimalY, AnimalZ);
-
- return true;
+ 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)
+ if (AnimalToSpawn == mtSquid && BlockAtFeet != E_BLOCK_WATER)
+ {
+ return false;
+ }
+ if (
+ (AnimalToSpawn != mtSquid) &&
+ (BlockAtHead != E_BLOCK_AIR) &&
+ (BlockAtFeet != E_BLOCK_AIR) &&
+ (!cBlockInfo::IsTransparent(BlockUnderFeet))
+ )
+ {
+ return false;
+ }
+ if (
+ (BlockUnderFeet != E_BLOCK_GRASS) &&
+ (
+ (AnimalToSpawn == mtSheep) ||
+ (AnimalToSpawn == mtChicken) ||
+ (AnimalToSpawn == mtPig)
+ )
+ )
+ {
+ return false;
+ }
+
+ int AnimalX, AnimalY, AnimalZ;
+ AnimalX = (double)(a_ChunkDesc.GetChunkX()*cChunkDef::Width + a_RelX + 0.5);
+ AnimalY = a_RelY;
+ AnimalZ = (double)(a_ChunkDesc.GetChunkZ()*cChunkDef::Width + a_RelZ + 0.5);
+
+ cEntityList ChunkEntities = a_ChunkDesc.GetEntities();
+ cMonster * NewMob = cMonster::NewMonsterFromType(AnimalToSpawn);
+ NewMob->SetPosition(AnimalX, AnimalY, AnimalZ);
+ ChunkEntities.push_back(NewMob);
+ LOGD("Spawning %s #%i at {%d, %d, %d}", NewMob->GetClass(), NewMob->GetUniqueID(), AnimalX, AnimalY, AnimalZ);
+
+ return true;
}
@@ -1076,80 +1076,80 @@ bool cFinishGenPassiveMobs::TrySpawnAnimals(cChunkDesc & a_ChunkDesc, int a_RelX
eMonsterType cFinishGenPassiveMobs::GetRandomMob(cChunkDesc & a_ChunkDesc)
{
- std::set<eMonsterType> ListOfSpawnables;
- std::set<eMonsterType>::iterator MobIter = ListOfSpawnables.begin();
- int x = m_Random.NextInt(cChunkDef::Width - 1);
- int z = m_Random.NextInt(cChunkDef::Width - 1);
-
- // Check biomes first to get a list of animals
- switch (a_ChunkDesc.GetBiome(x, z))
- {
- // 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.size() == 0)
- {
- LOGD("Tried to spawn an animal from an empty list.");
- return mtInvalidType;
- }
-
- int RandMob = m_Random.NextInt(ListOfSpawnables.size());
- MobIter=ListOfSpawnables.begin();
- for (int i = 0; i < RandMob; i++)
- {
- ++MobIter;
- }
-
- return *MobIter;
+ std::set<eMonsterType> ListOfSpawnables;
+ std::set<eMonsterType>::iterator MobIter = ListOfSpawnables.begin();
+ int x = m_Random.NextInt(cChunkDef::Width - 1);
+ int z = m_Random.NextInt(cChunkDef::Width - 1);
+
+ // Check biomes first to get a list of animals
+ switch (a_ChunkDesc.GetBiome(x, z))
+ {
+ // 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.size() == 0)
+ {
+ LOGD("Tried to spawn an animal from an empty list.");
+ return mtInvalidType;
+ }
+
+ int RandMob = m_Random.NextInt(ListOfSpawnables.size());
+ MobIter=ListOfSpawnables.begin();
+ for (int i = 0; i < RandMob; i++)
+ {
+ ++MobIter;
+ }
+
+ return *MobIter;
}