summaryrefslogtreecommitdiffstats
path: root/src/Generating
diff options
context:
space:
mode:
authorpeterbell10 <peterbell10@live.co.uk>2020-05-10 18:16:49 +0200
committerGitHub <noreply@github.com>2020-05-10 18:16:49 +0200
commit84289a2ba996b41815f148f27aecc52a7864066d (patch)
tree7434a6b14dde1597bd687e0a71a28135a1d31adc /src/Generating
parentCleanup unneeded globals (#4736) (diff)
downloadcuberite-84289a2ba996b41815f148f27aecc52a7864066d.tar
cuberite-84289a2ba996b41815f148f27aecc52a7864066d.tar.gz
cuberite-84289a2ba996b41815f148f27aecc52a7864066d.tar.bz2
cuberite-84289a2ba996b41815f148f27aecc52a7864066d.tar.lz
cuberite-84289a2ba996b41815f148f27aecc52a7864066d.tar.xz
cuberite-84289a2ba996b41815f148f27aecc52a7864066d.tar.zst
cuberite-84289a2ba996b41815f148f27aecc52a7864066d.zip
Diffstat (limited to '')
-rw-r--r--src/Generating/CMakeLists.txt4
-rw-r--r--src/Generating/CompoGenBiomal.cpp68
2 files changed, 23 insertions, 49 deletions
diff --git a/src/Generating/CMakeLists.txt b/src/Generating/CMakeLists.txt
index f01647d0e..713e5b8c9 100644
--- a/src/Generating/CMakeLists.txt
+++ b/src/Generating/CMakeLists.txt
@@ -67,10 +67,6 @@ SET (HDRS
VillageGen.h
)
-if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
- set_source_files_properties(CompoGenBiomal.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=global-constructors")
-endif()
-
if(NOT MSVC)
add_library(Generating ${SRCS} ${HDRS})
target_link_libraries(Generating fmt::fmt OSSupport Blocks Bindings)
diff --git a/src/Generating/CompoGenBiomal.cpp b/src/Generating/CompoGenBiomal.cpp
index 6d2277819..951cb1a64 100644
--- a/src/Generating/CompoGenBiomal.cpp
+++ b/src/Generating/CompoGenBiomal.cpp
@@ -27,30 +27,28 @@ class cPattern
public:
struct BlockInfo
{
- BLOCKTYPE m_BlockType;
- NIBBLETYPE m_BlockMeta;
+ BLOCKTYPE m_BlockType = E_BLOCK_STONE;
+ NIBBLETYPE m_BlockMeta = 0;
};
- cPattern(BlockInfo * a_TopBlocks, size_t a_Count)
+ constexpr cPattern(std::initializer_list<BlockInfo> a_TopBlocks)
{
+ ASSERT(a_TopBlocks.size() <= cChunkDef::Height);
// Copy the pattern into the top:
- for (size_t i = 0; i < a_Count; i++)
+ size_t i = 0;
+ for (const auto & Block : a_TopBlocks)
{
- m_Pattern[i] = a_TopBlocks[i];
+ m_Pattern[i] = Block;
+ ++i;
}
- // Fill the rest with stone:
- static BlockInfo Stone = {E_BLOCK_STONE, 0};
- for (int i = static_cast<int>(a_Count); i < cChunkDef::Height; i++)
- {
- m_Pattern[i] = Stone;
- }
+ // The remaining blocks default to stone
}
const BlockInfo * Get(void) const { return m_Pattern; }
protected:
- BlockInfo m_Pattern[cChunkDef::Height];
+ BlockInfo m_Pattern[cChunkDef::Height] = {};
} ;
@@ -58,9 +56,9 @@ protected:
////////////////////////////////////////////////////////////////////////////////
-// The arrays to use for the top block pattern definitions:
+// Land top block patterns:
-static cPattern::BlockInfo tbGrass[] =
+static constexpr cPattern patGrass =
{
{E_BLOCK_GRASS, 0},
{E_BLOCK_DIRT, E_META_DIRT_NORMAL},
@@ -68,7 +66,7 @@ static cPattern::BlockInfo tbGrass[] =
{E_BLOCK_DIRT, E_META_DIRT_NORMAL},
} ;
-static cPattern::BlockInfo tbSand[] =
+static constexpr cPattern patSand =
{
{ E_BLOCK_SAND, 0},
{ E_BLOCK_SAND, 0},
@@ -76,7 +74,7 @@ static cPattern::BlockInfo tbSand[] =
{ E_BLOCK_SANDSTONE, 0},
} ;
-static cPattern::BlockInfo tbDirt[] =
+static constexpr cPattern patDirt =
{
{E_BLOCK_DIRT, E_META_DIRT_NORMAL},
{E_BLOCK_DIRT, E_META_DIRT_NORMAL},
@@ -84,7 +82,7 @@ static cPattern::BlockInfo tbDirt[] =
{E_BLOCK_DIRT, E_META_DIRT_NORMAL},
} ;
-static cPattern::BlockInfo tbPodzol[] =
+static constexpr cPattern patPodzol =
{
{E_BLOCK_DIRT, E_META_DIRT_PODZOL},
{E_BLOCK_DIRT, E_META_DIRT_NORMAL},
@@ -92,7 +90,7 @@ static cPattern::BlockInfo tbPodzol[] =
{E_BLOCK_DIRT, E_META_DIRT_NORMAL},
} ;
-static cPattern::BlockInfo tbGrassLess[] =
+static constexpr cPattern patGrassLess =
{
{E_BLOCK_DIRT, E_META_DIRT_GRASSLESS},
{E_BLOCK_DIRT, E_META_DIRT_NORMAL},
@@ -100,7 +98,7 @@ static cPattern::BlockInfo tbGrassLess[] =
{E_BLOCK_DIRT, E_META_DIRT_NORMAL},
} ;
-static cPattern::BlockInfo tbMycelium[] =
+static constexpr cPattern patMycelium =
{
{E_BLOCK_MYCELIUM, 0},
{E_BLOCK_DIRT, 0},
@@ -108,7 +106,7 @@ static cPattern::BlockInfo tbMycelium[] =
{E_BLOCK_DIRT, 0},
} ;
-static cPattern::BlockInfo tbGravel[] =
+static constexpr cPattern patGravel =
{
{E_BLOCK_GRAVEL, 0},
{E_BLOCK_GRAVEL, 0},
@@ -116,7 +114,7 @@ static cPattern::BlockInfo tbGravel[] =
{E_BLOCK_STONE, 0},
} ;
-static cPattern::BlockInfo tbStone[] =
+static constexpr cPattern patStone =
{
{E_BLOCK_STONE, 0},
{E_BLOCK_STONE, 0},
@@ -127,9 +125,9 @@ static cPattern::BlockInfo tbStone[] =
////////////////////////////////////////////////////////////////////////////////
-// Ocean floor pattern top-block definitions:
+// Ocean floor patterns:
-static cPattern::BlockInfo tbOFSand[] =
+static constexpr cPattern patOFSand =
{
{E_BLOCK_SAND, 0},
{E_BLOCK_SAND, 0},
@@ -137,7 +135,7 @@ static cPattern::BlockInfo tbOFSand[] =
{E_BLOCK_SANDSTONE, 0}
} ;
-static cPattern::BlockInfo tbOFClay[] =
+static constexpr cPattern patOFClay =
{
{ E_BLOCK_CLAY, 0},
{ E_BLOCK_CLAY, 0},
@@ -145,7 +143,7 @@ static cPattern::BlockInfo tbOFClay[] =
{ E_BLOCK_SAND, 0},
} ;
-static cPattern::BlockInfo tbOFOrangeClay[] =
+static constexpr cPattern patOFOrangeClay =
{
{ E_BLOCK_STAINED_CLAY, E_META_STAINED_GLASS_ORANGE},
{ E_BLOCK_STAINED_CLAY, E_META_STAINED_GLASS_ORANGE},
@@ -157,26 +155,6 @@ static cPattern::BlockInfo tbOFOrangeClay[] =
////////////////////////////////////////////////////////////////////////////////
-// Individual patterns to use:
-
-static cPattern patGrass (tbGrass, ARRAYCOUNT(tbGrass));
-static cPattern patSand (tbSand, ARRAYCOUNT(tbSand));
-static cPattern patDirt (tbDirt, ARRAYCOUNT(tbDirt));
-static cPattern patPodzol (tbPodzol, ARRAYCOUNT(tbPodzol));
-static cPattern patGrassLess(tbGrassLess, ARRAYCOUNT(tbGrassLess));
-static cPattern patMycelium (tbMycelium, ARRAYCOUNT(tbMycelium));
-static cPattern patGravel (tbGravel, ARRAYCOUNT(tbGravel));
-static cPattern patStone (tbStone, ARRAYCOUNT(tbStone));
-
-static cPattern patOFSand (tbOFSand, ARRAYCOUNT(tbOFSand));
-static cPattern patOFClay (tbOFClay, ARRAYCOUNT(tbOFClay));
-static cPattern patOFOrangeClay(tbOFOrangeClay, ARRAYCOUNT(tbOFOrangeClay));
-
-
-
-
-
-////////////////////////////////////////////////////////////////////////////////
// cCompoGenBiomal:
class cCompoGenBiomal :