summaryrefslogtreecommitdiffstats
path: root/src/Generating
diff options
context:
space:
mode:
Diffstat (limited to 'src/Generating')
-rw-r--r--src/Generating/BioGen.cpp5
-rw-r--r--src/Generating/CompoGenBiomal.cpp14
-rw-r--r--src/Generating/ComposableGenerator.cpp5
-rw-r--r--src/Generating/FinishGen.cpp175
-rw-r--r--src/Generating/FinishGen.h23
-rw-r--r--src/Generating/HeiGen.cpp64
-rw-r--r--src/Generating/ProtIntGen.h344
-rw-r--r--src/Generating/Trees.cpp16
8 files changed, 589 insertions, 57 deletions
diff --git a/src/Generating/BioGen.cpp b/src/Generating/BioGen.cpp
index 2cc810d3b..265db30ad 100644
--- a/src/Generating/BioGen.cpp
+++ b/src/Generating/BioGen.cpp
@@ -205,8 +205,7 @@ void cBiomeGenList::InitializeBiomes(const AString & a_Biomes)
int Count = 1;
if (Split2.size() >= 2)
{
- Count = atol(Split2[1].c_str());
- if (Count <= 0)
+ if (!StringToInteger(Split2[1], Count))
{
LOGWARNING("Cannot decode biome count: \"%s\"; using 1.", Split2[1].c_str());
Count = 1;
@@ -1037,7 +1036,7 @@ protected:
////////////////////////////////////////////////////////////////////////////////
-// cBioGenGrown:
+// cBioGenProtGrown:
class cBioGenProtGrown:
public cBiomeGen
diff --git a/src/Generating/CompoGenBiomal.cpp b/src/Generating/CompoGenBiomal.cpp
index 030c2baa5..3140bd754 100644
--- a/src/Generating/CompoGenBiomal.cpp
+++ b/src/Generating/CompoGenBiomal.cpp
@@ -542,6 +542,20 @@ protected:
HasHadWater = true;
} // for y
a_ChunkDesc.SetBlockType(a_RelX, 0, a_RelZ, E_BLOCK_BEDROCK);
+
+ EMCSBiome MesaVersion = a_ChunkDesc.GetBiome(a_RelX, a_RelZ);
+ if ((MesaVersion == biMesaPlateauF) || (MesaVersion == biMesaPlateauFM))
+ {
+ if (Top < 95 + static_cast<int>(m_MesaFloor.CubicNoise2D(NoiseY * 2, NoiseX * 2) * 6))
+ {
+ return;
+ }
+
+ BLOCKTYPE Block = (m_MesaFloor.CubicNoise2D(NoiseX * 4, NoiseY * 4) < 0) ? E_BLOCK_DIRT : E_BLOCK_GRASS;
+ NIBBLETYPE Meta = (Block == E_BLOCK_GRASS) ? 0 : 1;
+
+ a_ChunkDesc.SetBlockTypeMeta(a_RelX, Top, a_RelZ, Block, Meta);
+ }
}
diff --git a/src/Generating/ComposableGenerator.cpp b/src/Generating/ComposableGenerator.cpp
index bda45ad92..4a670b064 100644
--- a/src/Generating/ComposableGenerator.cpp
+++ b/src/Generating/ComposableGenerator.cpp
@@ -616,6 +616,11 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile)
int MaxDensity = a_IniFile.GetValueSetI("Generator", "VillageMaxDensity", 80);
m_FinishGens.push_back(std::make_shared<cVillageGen>(Seed, GridSize, MaxOffset, MaxDepth, MaxSize, MinDensity, MaxDensity, m_BiomeGen, m_CompositedHeightCache));
}
+ else if (NoCaseCompare(*itr, "Vines") == 0)
+ {
+ int Level = a_IniFile.GetValueSetI("Generator", "VinesLevel", 40);
+ m_FinishGens.push_back(std::make_shared<cFinishGenVines>(Seed, Level));
+ }
else if (NoCaseCompare(*itr, "WaterLakes") == 0)
{
int Probability = a_IniFile.GetValueSetI("Generator", "WaterLakesProbability", 25);
diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp
index e10cb00f8..260253d62 100644
--- a/src/Generating/FinishGen.cpp
+++ b/src/Generating/FinishGen.cpp
@@ -244,6 +244,100 @@ void cFinishGenTallGrass::GenFinish(cChunkDesc & a_ChunkDesc)
////////////////////////////////////////////////////////////////////////////////
+// cFinishGenVines
+
+bool cFinishGenVines::IsJungleVariant(EMCSBiome a_Biome)
+{
+ switch (a_Biome)
+ {
+ case biJungle:
+ case biJungleEdge:
+ case biJungleEdgeM:
+ case biJungleHills:
+ case biJungleM:
+ {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+
+
+
+
+void cFinishGenVines::GenFinish(cChunkDesc & a_ChunkDesc)
+{
+ for (int x = 0; x < cChunkDef::Width; x++)
+ {
+ int xx = x + a_ChunkDesc.GetChunkX() * cChunkDef::Width;
+ for (int z = 0; z < cChunkDef::Width; z++)
+ {
+ int zz = z + a_ChunkDesc.GetChunkZ() * cChunkDef::Width;
+ if (!IsJungleVariant(a_ChunkDesc.GetBiome(x, z)))
+ {
+ // Current biome isn't a jungle
+ continue;
+ }
+
+ if ((m_Noise.IntNoise2DInt(xx, zz) % 101) < 50)
+ {
+ continue;
+ }
+
+ int Height = a_ChunkDesc.GetHeight(x, z);
+ for (int y = Height; y > m_Level; y--)
+ {
+ if (a_ChunkDesc.GetBlockType(x, y, z) != E_BLOCK_AIR)
+ {
+ // Can't place vines in non-air blocks
+ continue;
+ }
+
+ if ((m_Noise.IntNoise3DInt(xx, y, zz) % 101) < 50)
+ {
+ continue;
+ }
+
+ std::vector<NIBBLETYPE> Places;
+ if ((x + 1 < cChunkDef::Width) && cBlockInfo::FullyOccupiesVoxel(a_ChunkDesc.GetBlockType(x + 1, y, z)))
+ {
+ Places.push_back(8);
+ }
+
+ if ((x - 1 > 0) && cBlockInfo::FullyOccupiesVoxel(a_ChunkDesc.GetBlockType(x - 1, y, z)))
+ {
+ Places.push_back(2);
+ }
+
+ if ((z + 1 < cChunkDef::Width) && cBlockInfo::FullyOccupiesVoxel(a_ChunkDesc.GetBlockType(x, y, z + 1)))
+ {
+ Places.push_back(1);
+ }
+
+ if ((z - 1 > 0) && cBlockInfo::FullyOccupiesVoxel(a_ChunkDesc.GetBlockType(x, y, z - 1)))
+ {
+ Places.push_back(4);
+ }
+
+ if (Places.size() == 0)
+ {
+ continue;
+ }
+
+ NIBBLETYPE Meta = Places[m_Noise.IntNoise3DInt(xx, y, zz) % Places.size()];
+ a_ChunkDesc.SetBlockTypeMeta(x, y, z, E_BLOCK_VINES, Meta);
+ }
+ }
+ }
+}
+
+
+
+
+
+////////////////////////////////////////////////////////////////////////////////
// cFinishGenSprinkleFoliage:
bool cFinishGenSprinkleFoliage::TryAddSugarcane(cChunkDesc & a_ChunkDesc, int a_RelX, int a_RelY, int a_RelZ)
@@ -470,30 +564,22 @@ void cFinishGenSnow::GenFinish(cChunkDesc & a_ChunkDesc)
{
for (int x = 0; x < cChunkDef::Width; x++)
{
- switch (a_ChunkDesc.GetBiome(x, z))
+ int Height = a_ChunkDesc.GetHeight(x, z);
+ if (GetSnowStartHeight(a_ChunkDesc.GetBiome(x, z)) > Height)
{
- case biIcePlains:
- case biIceMountains:
- case biTaiga:
- case biTaigaHills:
- case biFrozenRiver:
- case biFrozenOcean:
- {
- int Height = a_ChunkDesc.GetHeight(x, z);
- if (cBlockInfo::IsSnowable(a_ChunkDesc.GetBlockType(x, Height, z)) && (Height < cChunkDef::Height - 1))
- {
- a_ChunkDesc.SetBlockType(x, Height + 1, z, E_BLOCK_SNOW);
- a_ChunkDesc.SetHeight(x, z, Height + 1);
- }
- break;
- }
- default:
- {
- // There's no snow in the other biomes.
- break;
- }
+ // Height isn't high enough for snow to start forming.
+ continue;
}
- }
+
+ if (!cBlockInfo::IsSnowable(a_ChunkDesc.GetBlockType(x, Height, z)) && (Height < cChunkDef::Height - 1))
+ {
+ // The top block can't be snown over.
+ continue;
+ }
+
+ a_ChunkDesc.SetBlockType(x, Height + 1, z, E_BLOCK_SNOW);
+ a_ChunkDesc.SetHeight(x, z, Height + 1);
+ } // for x
} // for z
}
@@ -511,34 +597,27 @@ void cFinishGenIce::GenFinish(cChunkDesc & a_ChunkDesc)
{
for (int x = 0; x < cChunkDef::Width; x++)
{
- switch (a_ChunkDesc.GetBiome(x, z))
+ int Height = a_ChunkDesc.GetHeight(x, z);
+ if (GetSnowStartHeight(a_ChunkDesc.GetBiome(x, z)) > Height)
{
- case biIcePlains:
- case biIceMountains:
- case biTaiga:
- case biTaigaHills:
- case biFrozenRiver:
- case biFrozenOcean:
- {
- int Height = a_ChunkDesc.GetHeight(x, z);
- switch (a_ChunkDesc.GetBlockType(x, Height, z))
- {
- case E_BLOCK_WATER:
- case E_BLOCK_STATIONARY_WATER:
- {
- a_ChunkDesc.SetBlockType(x, Height, z, E_BLOCK_ICE);
- break;
- }
- }
- break;
- }
- default:
- {
- // No icy water in other biomes.
- break;
- }
+ // Height isn't high enough for snow to start forming.
+ continue;
}
- }
+
+ if (!IsBlockWater(a_ChunkDesc.GetBlockType(x, Height, z)))
+ {
+ // The block isn't a water block.
+ continue;
+ }
+
+ if (a_ChunkDesc.GetBlockMeta(x, Height, z) != 0)
+ {
+ // The water block isn't a source block.
+ continue;
+ }
+
+ a_ChunkDesc.SetBlockType(x, Height, z, E_BLOCK_ICE);
+ } // for x
} // for z
}
diff --git a/src/Generating/FinishGen.h b/src/Generating/FinishGen.h
index ae6dee590..70696c4f8 100644
--- a/src/Generating/FinishGen.h
+++ b/src/Generating/FinishGen.h
@@ -118,6 +118,29 @@ protected:
+class cFinishGenVines :
+ public cFinishGen
+{
+public:
+ cFinishGenVines(int a_Seed, int a_Level) :
+ m_Noise(a_Seed),
+ m_Level(a_Level)
+ {
+ }
+
+ bool IsJungleVariant(EMCSBiome a_Biome);
+
+protected:
+ cNoise m_Noise;
+ int m_Level;
+
+ virtual void GenFinish(cChunkDesc & a_ChunkDesc) override;
+};
+
+
+
+
+
class cFinishGenSoulsandRims :
public cFinishGen
{
diff --git a/src/Generating/HeiGen.cpp b/src/Generating/HeiGen.cpp
index 61d087c17..54567cb4d 100644
--- a/src/Generating/HeiGen.cpp
+++ b/src/Generating/HeiGen.cpp
@@ -10,6 +10,66 @@
#include "DistortedHeightmap.h"
#include "EndGen.h"
#include "Noise3DGenerator.h"
+#include "ProtIntGen.h"
+
+
+
+
+
+////////////////////////////////////////////////////////////////////////////////
+// cHeiGenSteppy:
+
+class cHeiGenSteppy:
+ public cTerrainHeightGen
+{
+public:
+ cHeiGenSteppy(int a_Seed) :
+ m_Seed(a_Seed)
+ {
+ m_Gen =
+ std::make_shared<cProtIntGenWeightAvg<16, 1, 0>>(
+ std::make_shared<cProtIntGenSmooth> (a_Seed + 1,
+ std::make_shared<cProtIntGenZoom> (a_Seed + 2,
+ std::make_shared<cProtIntGenSmooth> (a_Seed + 3,
+ std::make_shared<cProtIntGenZoom> (a_Seed + 4,
+ std::make_shared<cProtIntGenAddRnd> (a_Seed + 5, 1,
+ std::make_shared<cProtIntGenSmooth> (a_Seed + 6,
+ std::make_shared<cProtIntGenZoom> (a_Seed + 7,
+ std::make_shared<cProtIntGenRndBetween> (a_Seed + 8, 60,
+ std::make_shared<cProtIntGenAddRnd> (a_Seed + 9, 1,
+ std::make_shared<cProtIntGenSmooth> (a_Seed + 1,
+ std::make_shared<cProtIntGenZoom> (a_Seed + 2,
+ std::make_shared<cProtIntGenRndBetween> (a_Seed + 3, 60,
+ std::make_shared<cProtIntGenSmooth> (a_Seed + 4,
+ std::make_shared<cProtIntGenZoom> (a_Seed + 5,
+ std::make_shared<cProtIntGenRndBetween> (a_Seed + 6, 60,
+ std::make_shared<cProtIntGenRndChoice> (a_Seed + 7, 10, 50, 50,
+ std::make_shared<cProtIntGenSmooth> (a_Seed + 8,
+ std::make_shared<cProtIntGenZoom> (a_Seed + 9,
+ std::make_shared<cProtIntGenRndChoice> (a_Seed + 1, 10, 50, 50,
+ std::make_shared<cProtIntGenAddRnd> (a_Seed + 2, 2,
+ std::make_shared<cProtIntGenZoom> (a_Seed + 3,
+ std::make_shared<cProtIntGenZoom> (a_Seed + 4,
+ std::make_shared<cProtIntGenChoice> (a_Seed + 5, 10)
+ )))))))))))))))))))))));
+ }
+
+ // cTerrainHeightGen overrides:
+ virtual void GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap & a_HeightMap) override
+ {
+ int heights[cChunkDef::Width * cChunkDef::Width];
+ m_Gen->GetInts(a_ChunkX * cChunkDef::Width, a_ChunkZ * cChunkDef::Width, cChunkDef::Width, cChunkDef::Width, heights);
+ for (size_t i = 0; i < ARRAYCOUNT(heights); i++)
+ {
+ a_HeightMap[i] = static_cast<HEIGHTTYPE>(std::max(std::min(60 + heights[i], cChunkDef::Height - 60), 40));
+ }
+ }
+
+protected:
+ int m_Seed;
+
+ SharedPtr<cProtIntGen> m_Gen;
+};
@@ -821,6 +881,10 @@ cTerrainHeightGenPtr cTerrainHeightGen::CreateHeightGen(cIniFile & a_IniFile, cB
// Return an empty pointer, the caller will create the proper generator:
return cTerrainHeightGenPtr();
}
+ else if (NoCaseCompare(HeightGenName, "Steppy") == 0)
+ {
+ res = std::make_shared<cHeiGenSteppy>(a_Seed);
+ }
else if (NoCaseCompare(HeightGenName, "Noise3D") == 0)
{
// Not a heightmap-based generator, but it used to be accessible via HeightGen, so we need to skip making the default out of it
diff --git a/src/Generating/ProtIntGen.h b/src/Generating/ProtIntGen.h
index 73ed27096..e709222fe 100644
--- a/src/Generating/ProtIntGen.h
+++ b/src/Generating/ProtIntGen.h
@@ -318,6 +318,350 @@ protected:
+/** Averages the values of the underlying 2 * 2 neighbors. */
+class cProtIntGenAvgValues :
+ public cProtIntGen
+{
+ typedef cProtIntGen super;
+
+public:
+ cProtIntGenAvgValues(Underlying a_Underlying) :
+ m_Underlying(a_Underlying)
+ {
+ }
+
+
+ virtual void GetInts(int a_MinX, int a_MinZ, int a_SizeX, int a_SizeZ, int * a_Values) override
+ {
+ // Generate the underlying values:
+ int lowerSizeX = a_SizeX + 1;
+ int lowerSizeZ = a_SizeZ + 1;
+ ASSERT(lowerSizeX * lowerSizeZ <= m_BufferSize);
+ int lowerData[m_BufferSize];
+ m_Underlying->GetInts(a_MinX, a_MinZ, lowerSizeX, lowerSizeZ, lowerData);
+
+ // Average - add all 4 "neighbors" and divide by 4:
+ for (int z = 0; z < a_SizeZ; z++)
+ {
+ for (int x = 0; x < a_SizeX; x++)
+ {
+ int idxLower = x + lowerSizeX * z;
+ a_Values[x + a_SizeX * z] = (
+ lowerData[idxLower] + lowerData[idxLower + 1] +
+ lowerData[idxLower + lowerSizeX] + lowerData[idxLower + lowerSizeX + 1]
+ ) / 4;
+ }
+ }
+ }
+
+protected:
+ Underlying m_Underlying;
+};
+
+
+
+
+
+/** Averages the values of the underlying 4 * 4 neighbors. */
+class cProtIntGenAvg4Values :
+ public cProtIntGen
+{
+ typedef cProtIntGen super;
+
+public:
+ cProtIntGenAvg4Values(Underlying a_Underlying) :
+ m_Underlying(a_Underlying)
+ {
+ }
+
+
+ virtual void GetInts(int a_MinX, int a_MinZ, int a_SizeX, int a_SizeZ, int * a_Values) override
+ {
+ // Generate the underlying values:
+ int lowerSizeX = a_SizeX + 4;
+ int lowerSizeZ = a_SizeZ + 4;
+ ASSERT(lowerSizeX * lowerSizeZ <= m_BufferSize);
+ int lowerData[m_BufferSize];
+ m_Underlying->GetInts(a_MinX - 1, a_MinZ - 1, lowerSizeX, lowerSizeZ, lowerData);
+
+ // Calculate the weighted average of all 16 "neighbors":
+ for (int z = 0; z < a_SizeZ; z++)
+ {
+ for (int x = 0; x < a_SizeX; x++)
+ {
+ int idxLower1 = x + lowerSizeX * z;
+ int idxLower2 = idxLower1 + lowerSizeX;
+ int idxLower3 = idxLower1 + 2 * lowerSizeX;
+ int idxLower4 = idxLower1 + 3 * lowerSizeX;
+ a_Values[x + a_SizeX * z] = (
+ 1 * lowerData[idxLower1] + 2 * lowerData[idxLower1 + 1] + 2 * lowerData[idxLower1 + 2] + 1 * lowerData[idxLower1 + 3] +
+ 2 * lowerData[idxLower2] + 32 * lowerData[idxLower2 + 1] + 32 * lowerData[idxLower2 + 2] + 2 * lowerData[idxLower2 + 3] +
+ 2 * lowerData[idxLower3] + 32 * lowerData[idxLower3 + 1] + 32 * lowerData[idxLower3 + 2] + 2 * lowerData[idxLower3 + 3] +
+ 1 * lowerData[idxLower4] + 2 * lowerData[idxLower4 + 1] + 2 * lowerData[idxLower4 + 2] + 1 * lowerData[idxLower4 + 3]
+ ) / 148;
+ }
+ }
+ }
+
+protected:
+ Underlying m_Underlying;
+};
+
+
+
+
+
+/** Averages the values of the underlying 3 * 3 neighbors with custom weight. */
+template <int WeightCenter, int WeightCardinal, int WeightDiagonal>
+class cProtIntGenWeightAvg :
+ public cProtIntGen
+{
+ typedef cProtIntGen super;
+
+public:
+ cProtIntGenWeightAvg(Underlying a_Underlying) :
+ m_Underlying(a_Underlying)
+ {
+ }
+
+
+ virtual void GetInts(int a_MinX, int a_MinZ, int a_SizeX, int a_SizeZ, int * a_Values) override
+ {
+ // Generate the underlying values:
+ int lowerSizeX = a_SizeX + 3;
+ int lowerSizeZ = a_SizeZ + 3;
+ ASSERT(lowerSizeX * lowerSizeZ <= m_BufferSize);
+ int lowerData[m_BufferSize];
+ m_Underlying->GetInts(a_MinX, a_MinZ, lowerSizeX, lowerSizeZ, lowerData);
+
+ // Calculate the weighted average the neighbors:
+ for (int z = 0; z < a_SizeZ; z++)
+ {
+ for (int x = 0; x < a_SizeX; x++)
+ {
+ int idxLower1 = x + lowerSizeX * z;
+ int idxLower2 = idxLower1 + lowerSizeX;
+ int idxLower3 = idxLower1 + 2 * lowerSizeX;
+ a_Values[x + a_SizeX * z] = (
+ WeightDiagonal * lowerData[idxLower1] + WeightCardinal * lowerData[idxLower1 + 1] + WeightDiagonal * lowerData[idxLower1 + 2] +
+ WeightCardinal * lowerData[idxLower2] + WeightCenter * lowerData[idxLower2 + 1] + WeightCardinal * lowerData[idxLower2 + 2] +
+ WeightDiagonal * lowerData[idxLower3] + WeightCardinal * lowerData[idxLower3 + 1] + WeightDiagonal * lowerData[idxLower3 + 2]
+ ) / (4 * WeightDiagonal + 4 * WeightCardinal + WeightCenter);
+ }
+ }
+ }
+
+protected:
+ Underlying m_Underlying;
+};
+
+
+
+
+
+/** Replaces random values of the underlying data with random integers in the specified range [Min .. Min + Range). */
+class cProtIntGenRndChoice :
+ public cProtIntGenWithNoise
+{
+ typedef cProtIntGenWithNoise super;
+
+public:
+ cProtIntGenRndChoice(int a_Seed, int a_ChancePct, int a_Min, int a_Range, Underlying a_Underlying) :
+ super(a_Seed),
+ m_ChancePct(a_ChancePct),
+ m_Min(a_Min),
+ m_Range(a_Range),
+ m_Underlying(a_Underlying)
+ {
+ }
+
+
+ virtual void GetInts(int a_MinX, int a_MinZ, int a_SizeX, int a_SizeZ, int * a_Values) override
+ {
+ // Generate the underlying values:
+ m_Underlying->GetInts(a_MinX, a_MinZ, a_SizeX, a_SizeZ, a_Values);
+
+ // Replace random values:
+ for (int z = 0; z < a_SizeZ; z++)
+ {
+ int BaseZ = a_MinZ + z;
+ for (int x = 0; x < a_SizeX; x++)
+ {
+ if (((super::m_Noise.IntNoise2DInt(BaseZ, a_MinX + x) / 13) % 101) < m_ChancePct)
+ {
+ a_Values[x + a_SizeX * z] = m_Min + (super::m_Noise.IntNoise2DInt(a_MinX + x, BaseZ) / 7) % m_Range;
+ }
+ } // for x
+ } // for z
+ }
+
+protected:
+ int m_ChancePct;
+ int m_Min;
+ int m_Range;
+ Underlying m_Underlying;
+};
+
+
+
+
+
+/** Adds a random value in range [-a_HalfRange, +a_HalfRange] to each of the underlying values. */
+class cProtIntGenAddRnd :
+ public cProtIntGenWithNoise
+{
+ typedef cProtIntGenWithNoise super;
+
+public:
+ cProtIntGenAddRnd(int a_Seed, int a_HalfRange, Underlying a_Underlying) :
+ super(a_Seed),
+ m_Range(a_HalfRange * 2 + 1),
+ m_HalfRange(a_HalfRange),
+ m_Underlying(a_Underlying)
+ {
+ }
+
+
+ virtual void GetInts(int a_MinX, int a_MinZ, int a_SizeX, int a_SizeZ, int * a_Values) override
+ {
+ // Generate the underlying values:
+ m_Underlying->GetInts(a_MinX, a_MinZ, a_SizeX, a_SizeZ, a_Values);
+
+ // Add the random values:
+ for (int z = 0; z < a_SizeZ; z++)
+ {
+ int NoiseZ = a_MinZ + z;
+ for (int x = 0; x < a_SizeX; x++)
+ {
+ int noiseVal = ((super::m_Noise.IntNoise2DInt(a_MinX + x, NoiseZ) / 7) % m_Range) - m_HalfRange;
+ a_Values[x + z * a_SizeX] += noiseVal;
+ }
+ }
+ }
+
+protected:
+ int m_Range;
+ int m_HalfRange;
+ Underlying m_Underlying;
+};
+
+
+
+
+
+/** Replaces random underlying values with the average of the neighbors. */
+class cProtIntGenRndAvg :
+ public cProtIntGenWithNoise
+{
+ typedef cProtIntGenWithNoise super;
+
+public:
+ cProtIntGenRndAvg(int a_Seed, int a_AvgChancePct, Underlying a_Underlying) :
+ super(a_Seed),
+ m_AvgChancePct(a_AvgChancePct),
+ m_Underlying(a_Underlying)
+ {
+ }
+
+
+ virtual void GetInts(int a_MinX, int a_MinZ, int a_SizeX, int a_SizeZ, int * a_Values) override
+ {
+ // Generate the underlying values:
+ int lowerSizeX = a_SizeX + 2;
+ int lowerSizeZ = a_SizeZ + 2;
+ ASSERT(lowerSizeX * lowerSizeZ <= m_BufferSize);
+ int lowerData[m_BufferSize];
+ m_Underlying->GetInts(a_MinX - 1, a_MinZ - 1, lowerSizeX, lowerSizeZ, lowerData);
+
+ // Average random values:
+ for (int z = 0; z < a_SizeZ; z++)
+ {
+ int NoiseZ = a_MinZ + z;
+ for (int x = 0; x < a_SizeX; x++)
+ {
+ int idxLower = x + 1 + lowerSizeX * (z + 1);
+ if (((super::m_Noise.IntNoise2DInt(a_MinX + x, NoiseZ) / 7) % 100) > m_AvgChancePct)
+ {
+ // Average the 4 neighbors:
+ a_Values[x + z * a_SizeX] = (
+ lowerData[idxLower - 1] + lowerData[idxLower + 1] +
+ lowerData[idxLower - lowerSizeX] + lowerData[idxLower + lowerSizeX]
+ ) / 4;
+ }
+ else
+ {
+ // Keep the underlying value:
+ a_Values[x + z * a_SizeX] = lowerData[idxLower];
+ }
+ }
+ }
+ }
+
+protected:
+ int m_AvgChancePct;
+ Underlying m_Underlying;
+};
+
+
+
+
+
+/** Replaces random underlying values with a random value in between the max and min of the neighbors. */
+class cProtIntGenRndBetween :
+ public cProtIntGenWithNoise
+{
+ typedef cProtIntGenWithNoise super;
+
+public:
+ cProtIntGenRndBetween(int a_Seed, int a_AvgChancePct, Underlying a_Underlying) :
+ super(a_Seed),
+ m_AvgChancePct(a_AvgChancePct),
+ m_Underlying(a_Underlying)
+ {
+ }
+
+
+ virtual void GetInts(int a_MinX, int a_MinZ, int a_SizeX, int a_SizeZ, int * a_Values) override
+ {
+ // Generate the underlying values:
+ int lowerSizeX = a_SizeX + 2;
+ int lowerSizeZ = a_SizeZ + 2;
+ ASSERT(lowerSizeX * lowerSizeZ <= m_BufferSize);
+ int lowerData[m_BufferSize];
+ m_Underlying->GetInts(a_MinX - 1, a_MinZ - 1, lowerSizeX, lowerSizeZ, lowerData);
+
+ // Average random values:
+ for (int z = 0; z < a_SizeZ; z++)
+ {
+ int NoiseZ = a_MinZ + z;
+ for (int x = 0; x < a_SizeX; x++)
+ {
+ int idxLower = x + 1 + lowerSizeX * (z + 1);
+ if (((super::m_Noise.IntNoise2DInt(a_MinX + x, NoiseZ) / 7) % 100) > m_AvgChancePct)
+ {
+ // Chose a value in between the min and max neighbor:
+ int min = std::min(std::min(lowerData[idxLower - 1], lowerData[idxLower + 1]), std::min(lowerData[idxLower - lowerSizeX], lowerData[idxLower + lowerSizeX]));
+ int max = std::max(std::max(lowerData[idxLower - 1], lowerData[idxLower + 1]), std::max(lowerData[idxLower - lowerSizeX], lowerData[idxLower + lowerSizeX]));
+ a_Values[x + z * a_SizeX] = min + ((super::m_Noise.IntNoise2DInt(a_MinX + x, NoiseZ + 10) / 7) % (max - min + 1));
+ }
+ else
+ {
+ // Keep the underlying value:
+ a_Values[x + z * a_SizeX] = lowerData[idxLower];
+ }
+ }
+ }
+ }
+
+protected:
+ int m_AvgChancePct;
+ Underlying m_Underlying;
+};
+
+
+
+
+
/** Converts land biomes at the edge of an ocean into the respective beach biome. */
class cProtIntGenBeaches :
public cProtIntGen
diff --git a/src/Generating/Trees.cpp b/src/Generating/Trees.cpp
index a10e0f4f1..9e72a688f 100644
--- a/src/Generating/Trees.cpp
+++ b/src/Generating/Trees.cpp
@@ -224,9 +224,6 @@ void GetTreeImageByBiome(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_No
case biMegaTaiga:
case biMegaTaigaHills:
case biExtremeHillsPlus:
- case biMesa:
- case biMesaPlateauF:
- case biMesaPlateau:
case biSunflowerPlains:
case biDesertM:
case biExtremeHillsM:
@@ -239,9 +236,6 @@ void GetTreeImageByBiome(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_No
case biMegaSpruceTaiga:
case biMegaSpruceTaigaHills:
case biExtremeHillsPlusM:
- case biMesaBryce:
- case biMesaPlateauFM:
- case biMesaPlateauM:
{
// TODO: These need their special trees
GetBirchTreeImage(a_BlockX, a_BlockY, a_BlockZ, a_Noise, a_Seq, a_LogBlocks, a_OtherBlocks);
@@ -264,6 +258,16 @@ void GetTreeImageByBiome(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_No
return;
}
+ case biMesa:
+ case biMesaPlateauF:
+ case biMesaPlateau:
+ case biMesaBryce:
+ case biMesaPlateauFM:
+ case biMesaPlateauM:
+ {
+ GetSmallAppleTreeImage(a_BlockX, a_BlockY, a_BlockZ, a_Noise, a_Seq, a_LogBlocks, a_OtherBlocks);
+ }
+
case biDesert:
case biDesertHills:
case biRiver: