From b8fbba5eb92cda32b13d65f3704adf778da82f38 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Wed, 11 Nov 2015 10:32:42 +0100 Subject: Added PieceStructures generator. --- src/Generating/GridStructGen.cpp | 49 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'src/Generating/GridStructGen.cpp') 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(a_GeneratorParams, "GridSizeX", m_GridSizeX); + m_GridSizeZ = GetStringMapInteger(a_GeneratorParams, "GridSizeZ", m_GridSizeZ); + m_MaxOffsetX = GetStringMapInteger(a_GeneratorParams, "MaxOffsetX", m_MaxOffsetX); + m_MaxOffsetZ = GetStringMapInteger(a_GeneratorParams, "MaxOffsetZ", m_MaxOffsetZ); + m_MaxStructureSizeX = GetStringMapInteger(a_GeneratorParams, "MaxStructureSizeX", m_MaxStructureSizeX); + m_MaxStructureSizeZ = GetStringMapInteger(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(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: -- cgit v1.2.3