summaryrefslogtreecommitdiffstats
path: root/src/Generating
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Generating/ComposableGenerator.cpp32
-rw-r--r--src/Generating/FinishGen.cpp23
-rw-r--r--src/Generating/FinishGen.h59
3 files changed, 92 insertions, 22 deletions
diff --git a/src/Generating/ComposableGenerator.cpp b/src/Generating/ComposableGenerator.cpp
index 0d9bedf45..a0355ff8d 100644
--- a/src/Generating/ComposableGenerator.cpp
+++ b/src/Generating/ComposableGenerator.cpp
@@ -324,7 +324,25 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile)
}
else if (NoCaseCompare(*itr, "DeadBushes") == 0)
{
- m_FinishGens.push_back(new cFinishGenSingleBiomeSingleTopBlock(Seed, E_BLOCK_DEAD_BUSH, biDesert, 2, E_BLOCK_SAND, E_BLOCK_SAND));
+ // A list with all the allowed biomes.
+ cFinishGenSingleTopBlock::BiomeList AllowedBiomes;
+ AllowedBiomes.push_back(biDesert);
+ AllowedBiomes.push_back(biDesertHills);
+ AllowedBiomes.push_back(biDesertM);
+ AllowedBiomes.push_back(biMesa);
+ AllowedBiomes.push_back(biMesaBryce);
+ AllowedBiomes.push_back(biMesaPlateau);
+ AllowedBiomes.push_back(biMesaPlateauF);
+ AllowedBiomes.push_back(biMesaPlateauFM);
+ AllowedBiomes.push_back(biMesaPlateauM);
+
+ // A list with all the allowed blocks that can be below the dead bush.
+ cFinishGenSingleTopBlock::BlockList AllowedBlocks;
+ AllowedBlocks.push_back(E_BLOCK_SAND);
+ AllowedBlocks.push_back(E_BLOCK_HARDENED_CLAY);
+ AllowedBlocks.push_back(E_BLOCK_STAINED_CLAY);
+
+ m_FinishGens.push_back(new cFinishGenSingleTopBlock(Seed, E_BLOCK_DEAD_BUSH, AllowedBiomes, 2, AllowedBlocks));
}
else if (NoCaseCompare(*itr, "DirectOverhangs") == 0)
{
@@ -371,7 +389,17 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile)
}
else if (NoCaseCompare(*itr, "Lilypads") == 0)
{
- m_FinishGens.push_back(new cFinishGenSingleBiomeSingleTopBlock(Seed, E_BLOCK_LILY_PAD, biSwampland, 4, E_BLOCK_WATER, E_BLOCK_STATIONARY_WATER));
+ // A list with all the allowed biomes.
+ cFinishGenSingleTopBlock::BiomeList AllowedBiomes;
+ AllowedBiomes.push_back(biSwampland);
+ AllowedBiomes.push_back(biSwamplandM);
+
+ // A list with all the allowed blocks that can be below the lilypad.
+ cFinishGenSingleTopBlock::BlockList AllowedBlocks;
+ AllowedBlocks.push_back(E_BLOCK_WATER);
+ AllowedBlocks.push_back(E_BLOCK_STATIONARY_WATER);
+
+ m_FinishGens.push_back(new cFinishGenSingleTopBlock(Seed, E_BLOCK_LILY_PAD, AllowedBiomes, 4, AllowedBlocks));
}
else if (NoCaseCompare(*itr, "NetherClumpFoliage") == 0)
{
diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp
index 9f0c8f3fa..842c9ccc5 100644
--- a/src/Generating/FinishGen.cpp
+++ b/src/Generating/FinishGen.cpp
@@ -454,14 +454,14 @@ void cFinishGenIce::GenFinish(cChunkDesc & a_ChunkDesc)
////////////////////////////////////////////////////////////////////////////////
-// cFinishGenLilypads:
+// cFinishGenSingleTopBlock:
-int cFinishGenSingleBiomeSingleTopBlock::GetNumToGen(const cChunkDef::BiomeMap & a_BiomeMap)
+int cFinishGenSingleTopBlock::GetNumToGen(const cChunkDef::BiomeMap & a_BiomeMap)
{
int res = 0;
for (size_t i = 0; i < ARRAYCOUNT(a_BiomeMap); i++)
{
- if (a_BiomeMap[i] == m_Biome)
+ if (IsAllowedBiome(a_BiomeMap[i]))
{
res++;
}
@@ -473,7 +473,7 @@ int cFinishGenSingleBiomeSingleTopBlock::GetNumToGen(const cChunkDef::BiomeMap &
-void cFinishGenSingleBiomeSingleTopBlock::GenFinish(cChunkDesc & a_ChunkDesc)
+void cFinishGenSingleTopBlock::GenFinish(cChunkDesc & a_ChunkDesc)
{
// Add Lilypads on top of water surface in Swampland
@@ -486,11 +486,13 @@ void cFinishGenSingleBiomeSingleTopBlock::GenFinish(cChunkDesc & a_ChunkDesc)
int z = (m_Noise.IntNoise3DInt(ChunkX - ChunkZ, i, ChunkZ) / 11) % cChunkDef::Width;
// Place the block at {x, z} if possible:
- if (a_ChunkDesc.GetBiome(x, z) != m_Biome)
+ EMCSBiome Biome = a_ChunkDesc.GetBiome(x, z);
+ if (!IsAllowedBiome(Biome))
{
// Incorrect biome
continue;
}
+
int Height = a_ChunkDesc.GetHeight(x, z);
if (Height >= cChunkDef::Height)
{
@@ -502,13 +504,16 @@ void cFinishGenSingleBiomeSingleTopBlock::GenFinish(cChunkDesc & a_ChunkDesc)
// Not an empty block
continue;
}
+
BLOCKTYPE BlockBelow = a_ChunkDesc.GetBlockType(x, Height, z);
- if ((BlockBelow == m_AllowedBelow1) || (BlockBelow == m_AllowedBelow2))
+ if (!IsAllowedBlockBelow(BlockBelow))
{
- a_ChunkDesc.SetBlockType(x, Height + 1, z, m_BlockType);
- a_ChunkDesc.SetHeight(x, z, Height + 1);
+ continue;
}
- } // for i
+
+ a_ChunkDesc.SetBlockType(x, Height + 1, z, m_BlockType);
+ a_ChunkDesc.SetHeight(x, z, Height + 1);
+ }
}
diff --git a/src/Generating/FinishGen.h b/src/Generating/FinishGen.h
index 810bb4a91..ed32768b3 100644
--- a/src/Generating/FinishGen.h
+++ b/src/Generating/FinishGen.h
@@ -143,32 +143,69 @@ Used for:
- Lilypads finisher
- DeadBushes finisher
*/
-class cFinishGenSingleBiomeSingleTopBlock :
+class cFinishGenSingleTopBlock :
public cFinishGen
{
public:
- cFinishGenSingleBiomeSingleTopBlock(
- int a_Seed, BLOCKTYPE a_BlockType, EMCSBiome a_Biome, int a_Amount,
- BLOCKTYPE a_AllowedBelow1, BLOCKTYPE a_AllowedBelow2
+ typedef std::vector<BLOCKTYPE> BlockList;
+ bool m_IsAllowedBelow[256];
+
+ typedef std::vector<EMCSBiome> BiomeList;
+ bool m_IsBiomeAllowed[256];
+
+
+ cFinishGenSingleTopBlock(
+ int a_Seed, BLOCKTYPE a_BlockType, BiomeList a_Biomes, int a_Amount,
+ BlockList a_AllowedBelow
) :
m_Noise(a_Seed),
m_BlockType(a_BlockType),
- m_Biome(a_Biome),
- m_Amount(a_Amount),
- m_AllowedBelow1(a_AllowedBelow1),
- m_AllowedBelow2(a_AllowedBelow2)
+ m_Amount(a_Amount)
{
+ // Initialize all the block types.
+ for (int idx = 0; idx < ARRAYCOUNT(m_IsAllowedBelow); ++idx)
+ {
+ m_IsAllowedBelow[idx] = false;
+ }
+
+ // Load the allowed blocks into m_IsAllowedBelow
+ for (BlockList::iterator itr = a_AllowedBelow.begin(); itr != a_AllowedBelow.end(); ++itr)
+ {
+ m_IsAllowedBelow[*itr] = true;
+ }
+
+ // Initialize all the biome types.
+ for (int idx = 0; idx < ARRAYCOUNT(m_IsBiomeAllowed); ++idx)
+ {
+ m_IsBiomeAllowed[idx] = false;
+ }
+
+ // Load the allowed biomes into m_IsBiomeAllowed
+ for (BiomeList::iterator itr = a_Biomes.begin(); itr != a_Biomes.end(); ++itr)
+ {
+ m_IsBiomeAllowed[*itr] = true;
+ }
}
protected:
cNoise m_Noise;
BLOCKTYPE m_BlockType;
- EMCSBiome m_Biome;
int m_Amount; ///< Relative amount of blocks to try adding. 1 = one block per 256 biome columns.
- BLOCKTYPE m_AllowedBelow1; ///< First of the two blocktypes that are allowed below m_BlockType
- BLOCKTYPE m_AllowedBelow2; ///< Second of the two blocktypes that are allowed below m_BlockType
int GetNumToGen(const cChunkDef::BiomeMap & a_BiomeMap);
+
+ // Returns true if the given biome is a biome that is allowed.
+ inline bool IsAllowedBiome(EMCSBiome a_Biome)
+ {
+ return m_IsBiomeAllowed[a_Biome];
+ }
+
+ // Returns true if the given blocktype may be below m_BlockType
+ inline bool IsAllowedBlockBelow(BLOCKTYPE a_BlockBelow)
+ {
+ return m_IsAllowedBelow[a_BlockBelow];
+ }
+
// cFinishGen override:
virtual void GenFinish(cChunkDesc & a_ChunkDesc) override;