summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-03-19 11:14:57 +0100
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-03-19 11:14:57 +0100
commitd43026ddc28829310ba6baf607adce1f54b4f323 (patch)
tree017248e5f1d0b894ae5a42d6ce7d0c409810d30b
parentThe subgenerators use cChunkDesc instead of raw arrays. cChunkDesc is based on cBlockArea. Initial version of Lakes generator. (diff)
downloadcuberite-d43026ddc28829310ba6baf607adce1f54b4f323.tar
cuberite-d43026ddc28829310ba6baf607adce1f54b4f323.tar.gz
cuberite-d43026ddc28829310ba6baf607adce1f54b4f323.tar.bz2
cuberite-d43026ddc28829310ba6baf607adce1f54b4f323.tar.lz
cuberite-d43026ddc28829310ba6baf607adce1f54b4f323.tar.xz
cuberite-d43026ddc28829310ba6baf607adce1f54b4f323.tar.zst
cuberite-d43026ddc28829310ba6baf607adce1f54b4f323.zip
-rw-r--r--source/Generating/ComposableGenerator.cpp6
-rw-r--r--source/Generating/StructGen.cpp21
-rw-r--r--source/Generating/StructGen.h6
3 files changed, 22 insertions, 11 deletions
diff --git a/source/Generating/ComposableGenerator.cpp b/source/Generating/ComposableGenerator.cpp
index e349d73f7..6e72af302 100644
--- a/source/Generating/ComposableGenerator.cpp
+++ b/source/Generating/ComposableGenerator.cpp
@@ -335,11 +335,13 @@ void cComposableGenerator::InitStructureGens(cIniFile & a_IniFile)
}
else if (NoCaseCompare(*itr, "waterlakes") == 0)
{
- m_StructureGens.push_back(new cStructGenLakes(Seed * 3 + 652, E_BLOCK_STATIONARY_WATER, *m_HeightGen));
+ int Probability = a_IniFile.GetValueSetI("Generator", "WaterLakesProbability", 25);
+ m_StructureGens.push_back(new cStructGenLakes(Seed * 3 + 652, E_BLOCK_STATIONARY_WATER, *m_HeightGen, Probability));
}
else if (NoCaseCompare(*itr, "lavalakes") == 0)
{
- m_StructureGens.push_back(new cStructGenLakes(Seed * 5 + 16873, E_BLOCK_STATIONARY_LAVA, *m_HeightGen));
+ int Probability = a_IniFile.GetValueSetI("Generator", "LavaLakesProbability", 10);
+ m_StructureGens.push_back(new cStructGenLakes(Seed * 5 + 16873, E_BLOCK_STATIONARY_LAVA, *m_HeightGen, Probability));
}
else
{
diff --git a/source/Generating/StructGen.cpp b/source/Generating/StructGen.cpp
index 6c5bf6491..583ee867a 100644
--- a/source/Generating/StructGen.cpp
+++ b/source/Generating/StructGen.cpp
@@ -400,6 +400,11 @@ void cStructGenLakes::GenStructures(cChunkDesc & a_ChunkDesc)
for (int z = -1; z < 2; z++) for (int x = -1; x < 2; x++)
{
+ if (((m_Noise.IntNoise2DInt(ChunkX + x, ChunkZ + z) / 17) % 100) > m_Probability)
+ {
+ continue;
+ }
+
cBlockArea Lake;
CreateLakeImage(ChunkX + x, ChunkZ + z, Lake);
@@ -420,19 +425,20 @@ void cStructGenLakes::CreateLakeImage(int a_ChunkX, int a_ChunkZ, cBlockArea & a
a_Lake.Create(16, 8, 16);
a_Lake.Fill(cBlockArea::baTypes, E_BLOCK_SPONGE); // Sponge is the NOP blocktype for lake merging strategy
- // Find the maximum height in this chunk:
+ // Find the minimum height in this chunk:
cChunkDef::HeightMap HeightMap;
m_HeiGen.GenHeightMap(a_ChunkX, a_ChunkZ, HeightMap);
- HEIGHTTYPE MaxHeight = HeightMap[0];
+ HEIGHTTYPE MinHeight = HeightMap[0];
for (int i = 1; i < ARRAYCOUNT(HeightMap); i++)
{
- if (HeightMap[i] > MaxHeight)
+ if (HeightMap[i] < MinHeight)
{
- MaxHeight = HeightMap[i];
+ MinHeight = HeightMap[i];
}
}
- // Make a random position in the chunk by using a random 16 block XZ offset and random height up to chunk's max height
+ // Make a random position in the chunk by using a random 16 block XZ offset and random height up to chunk's max height minus 6
+ MinHeight = std::max(MinHeight - 6, 2);
int Rnd = m_Noise.IntNoise3DInt(a_ChunkX, 128, a_ChunkZ) / 11;
// Random offset [-8 .. 8], with higher probability around 0; add up four three-bit-wide randoms [0 .. 28], divide and subtract to get range
int OffsetX = 4 * ((Rnd & 0x07) + ((Rnd & 0x38) >> 3) + ((Rnd & 0x1c0) >> 6) + ((Rnd & 0xe00) >> 9)) / 7 - 8;
@@ -440,8 +446,9 @@ void cStructGenLakes::CreateLakeImage(int a_ChunkX, int a_ChunkZ, cBlockArea & a
// Random offset [-8 .. 8], with higher probability around 0; add up four three-bit-wide randoms [0 .. 28], divide and subtract to get range
int OffsetZ = 4 * ((Rnd & 0x07) + ((Rnd & 0x38) >> 3) + ((Rnd & 0x1c0) >> 6) + ((Rnd & 0xe00) >> 9)) / 7 - 8;
Rnd = m_Noise.IntNoise3DInt(a_ChunkX, 512, a_ChunkZ) / 13;
- // Random height [0 .. MaxHeight] with preference to center heights
- int HeightY = (((Rnd & 0x1ff) % (MaxHeight + 1)) + (((Rnd >> 9) & 0x1ff) % (MaxHeight + 1))) / 2;
+ // Random height [1 .. MinHeight] with preference to center heights
+ int HeightY = 1 + (((Rnd & 0x1ff) % MinHeight) + (((Rnd >> 9) & 0x1ff) % MinHeight)) / 2;
+
a_Lake.SetOrigin(OffsetX, HeightY, OffsetZ);
// Hollow out a few bubbles inside the blockarea:
diff --git a/source/Generating/StructGen.h b/source/Generating/StructGen.h
index ffb62e327..44f2fc213 100644
--- a/source/Generating/StructGen.h
+++ b/source/Generating/StructGen.h
@@ -96,11 +96,12 @@ class cStructGenLakes :
public cStructureGen
{
public:
- cStructGenLakes(int a_Seed, BLOCKTYPE a_Fluid, cTerrainHeightGen & a_HeiGen) :
+ cStructGenLakes(int a_Seed, BLOCKTYPE a_Fluid, cTerrainHeightGen & a_HeiGen, int a_Probability) :
m_Noise(a_Seed),
m_Seed(a_Seed),
m_Fluid(a_Fluid),
- m_HeiGen(a_HeiGen)
+ m_HeiGen(a_HeiGen),
+ m_Probability(a_Probability)
{
}
@@ -109,6 +110,7 @@ protected:
int m_Seed;
BLOCKTYPE m_Fluid;
cTerrainHeightGen & m_HeiGen;
+ int m_Probability; ///< Chance, 0 .. 100, of a chunk having the lake
// cStructureGen override:
virtual void GenStructures(cChunkDesc & a_ChunkDesc) override;