diff options
author | Mattes D <github@xoft.cz> | 2015-11-11 10:32:42 +0100 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2015-12-01 10:35:07 +0100 |
commit | b8fbba5eb92cda32b13d65f3704adf778da82f38 (patch) | |
tree | 0c6e8f47ae152e5ffade6f0a7457505101764753 /src/Generating/GridStructGen.cpp | |
parent | Merge pull request #2696 from Gargaj/breeding (diff) | |
download | cuberite-b8fbba5eb92cda32b13d65f3704adf778da82f38.tar cuberite-b8fbba5eb92cda32b13d65f3704adf778da82f38.tar.gz cuberite-b8fbba5eb92cda32b13d65f3704adf778da82f38.tar.bz2 cuberite-b8fbba5eb92cda32b13d65f3704adf778da82f38.tar.lz cuberite-b8fbba5eb92cda32b13d65f3704adf778da82f38.tar.xz cuberite-b8fbba5eb92cda32b13d65f3704adf778da82f38.tar.zst cuberite-b8fbba5eb92cda32b13d65f3704adf778da82f38.zip |
Diffstat (limited to 'src/Generating/GridStructGen.cpp')
-rw-r--r-- | src/Generating/GridStructGen.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/Generating/GridStructGen.cpp b/src/Generating/GridStructGen.cpp index 5adc60c4f..bcf66795c 100644 --- a/src/Generating/GridStructGen.cpp +++ b/src/Generating/GridStructGen.cpp @@ -9,6 +9,7 @@ + //////////////////////////////////////////////////////////////////////////////// // cEmptyStructure: @@ -79,6 +80,54 @@ cGridStructGen::cGridStructGen( +cGridStructGen::cGridStructGen(int a_Seed): + m_BaseSeed(a_Seed), + m_Seed(a_Seed), + m_Noise(a_Seed), + m_GridSizeX(256), + m_GridSizeZ(256), + m_MaxOffsetX(128), + m_MaxOffsetZ(128), + m_MaxStructureSizeX(128), + m_MaxStructureSizeZ(128), + m_MaxCacheSize(256) +{ +} + + + + + +void cGridStructGen::SetGeneratorParams(const AStringMap & a_GeneratorParams) +{ + ASSERT(m_Cache.empty()); // No changing the params after chunks are generated + m_GridSizeX = GetStringMapInteger<int>(a_GeneratorParams, "GridSizeX", m_GridSizeX); + m_GridSizeZ = GetStringMapInteger<int>(a_GeneratorParams, "GridSizeZ", m_GridSizeZ); + m_MaxOffsetX = GetStringMapInteger<int>(a_GeneratorParams, "MaxOffsetX", m_MaxOffsetX); + m_MaxOffsetZ = GetStringMapInteger<int>(a_GeneratorParams, "MaxOffsetZ", m_MaxOffsetZ); + m_MaxStructureSizeX = GetStringMapInteger<int>(a_GeneratorParams, "MaxStructureSizeX", m_MaxStructureSizeX); + m_MaxStructureSizeZ = GetStringMapInteger<int>(a_GeneratorParams, "MaxStructureSizeZ", m_MaxStructureSizeZ); + + // Silently fix out-of-range parameters: + if (m_MaxOffsetX < 1) + { + m_MaxOffsetX = 1; + } + if (m_MaxOffsetZ < 1) + { + m_MaxOffsetZ = 1; + } + + // Set the seed based on the seed offset from the parameters: + auto seedOffset = GetStringMapInteger<int>(a_GeneratorParams, "SeedOffset", 0); + m_Seed = m_BaseSeed + seedOffset; + m_Noise.SetSeed(m_Seed); +} + + + + + void cGridStructGen::GetStructuresForChunk(int a_ChunkX, int a_ChunkZ, cStructurePtrs & a_Structures) { // Calculate the min and max grid coords of the structures to be returned: |