From bf1aa7993202c2f57de88b068d999d262f1874f6 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Mon, 28 Jul 2014 14:23:29 +0200 Subject: Renamed cFinishGenSingleBiomeSingleTopBlock to cFinishGenSingleTopBlock Now accepts a vector of biomes and a vector of allowed blocks. --- src/Generating/FinishGen.h | 50 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 10 deletions(-) (limited to 'src/Generating/FinishGen.h') diff --git a/src/Generating/FinishGen.h b/src/Generating/FinishGen.h index 810bb4a91..1b885df88 100644 --- a/src/Generating/FinishGen.h +++ b/src/Generating/FinishGen.h @@ -143,32 +143,62 @@ Used for: - Lilypads finisher - DeadBushes finisher */ -class cFinishGenSingleBiomeSingleTopBlock : +class cFinishGenSingleTopBlock : public cFinishGen { public: - cFinishGenSingleBiomeSingleTopBlock( - int a_Seed, BLOCKTYPE a_BlockType, EMCSBiome a_Biome, int a_Amount, - BLOCKTYPE a_AllowedBelow1, BLOCKTYPE a_AllowedBelow2 + + typedef std::vector BlockList; + typedef std::vector BiomeList; + + cFinishGenSingleTopBlock( + int a_Seed, BLOCKTYPE a_BlockType, BiomeList a_Biomes, int a_Amount, + BlockList a_AllowedBelow ) : m_Noise(a_Seed), m_BlockType(a_BlockType), - m_Biome(a_Biome), + m_Biomes(a_Biomes), m_Amount(a_Amount), - m_AllowedBelow1(a_AllowedBelow1), - m_AllowedBelow2(a_AllowedBelow2) + m_AllowedBelow(a_AllowedBelow) { } protected: cNoise m_Noise; BLOCKTYPE m_BlockType; - EMCSBiome m_Biome; int m_Amount; ///< Relative amount of blocks to try adding. 1 = one block per 256 biome columns. - BLOCKTYPE m_AllowedBelow1; ///< First of the two blocktypes that are allowed below m_BlockType - BLOCKTYPE m_AllowedBelow2; ///< Second of the two blocktypes that are allowed below m_BlockType + + BlockList m_AllowedBelow; + BiomeList m_Biomes; int GetNumToGen(const cChunkDef::BiomeMap & a_BiomeMap); + + // Returns true if the given biome is a biome that is allowed. + bool IsAllowedBiome(EMCSBiome a_Biome) + { + for (BiomeList::iterator itr = m_Biomes.begin(); itr != m_Biomes.end(); ++itr) + { + if (a_Biome == *itr) + { + return true; + } + } + return false; + } + + // Returns true if the given blocktype may be below m_BlockType + bool IsAllowedBlockBelow(BLOCKTYPE a_BlockBelow) + { + for (BlockList::iterator itr = m_AllowedBelow.begin(); itr != m_AllowedBelow.end(); ++itr) + { + if (*itr == a_BlockBelow) + { + return true; + } + } + return false; + } + // cFinishGen override: virtual void GenFinish(cChunkDesc & a_ChunkDesc) override; -- cgit v1.2.3 From e74984675cf74f3a74d2694dda10802b158f734c Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Mon, 28 Jul 2014 16:53:01 +0200 Subject: Using suggestions --- src/Generating/FinishGen.h | 45 ++++++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 25 deletions(-) (limited to 'src/Generating/FinishGen.h') diff --git a/src/Generating/FinishGen.h b/src/Generating/FinishGen.h index 1b885df88..a856b2cda 100644 --- a/src/Generating/FinishGen.h +++ b/src/Generating/FinishGen.h @@ -147,9 +147,12 @@ class cFinishGenSingleTopBlock : public cFinishGen { public: - typedef std::vector BlockList; + bool m_IsAllowedBelow[256]; + typedef std::vector BiomeList; + bool m_IsBiomeAllowed[256]; + cFinishGenSingleTopBlock( int a_Seed, BLOCKTYPE a_BlockType, BiomeList a_Biomes, int a_Amount, @@ -157,46 +160,38 @@ public: ) : m_Noise(a_Seed), m_BlockType(a_BlockType), - m_Biomes(a_Biomes), - m_Amount(a_Amount), - m_AllowedBelow(a_AllowedBelow) + m_Amount(a_Amount) { + // Load the allowed blocks into m_IsAllowedBelow + for (BlockList::iterator itr = a_AllowedBelow.begin(); itr != a_AllowedBelow.end(); ++itr) + { + m_IsAllowedBelow[*itr] = true; + } + + // Load the allowed biomes into m_IsBiomeAllowed + for (BiomeList::iterator itr = a_Biomes.begin(); itr != a_Biomes.end(); ++itr) + { + m_IsBiomeAllowed[*itr] = true; + } } protected: cNoise m_Noise; BLOCKTYPE m_BlockType; int m_Amount; ///< Relative amount of blocks to try adding. 1 = one block per 256 biome columns. - - BlockList m_AllowedBelow; - BiomeList m_Biomes; int GetNumToGen(const cChunkDef::BiomeMap & a_BiomeMap); // Returns true if the given biome is a biome that is allowed. - bool IsAllowedBiome(EMCSBiome a_Biome) + inline bool IsAllowedBiome(EMCSBiome a_Biome) { - for (BiomeList::iterator itr = m_Biomes.begin(); itr != m_Biomes.end(); ++itr) - { - if (a_Biome == *itr) - { - return true; - } - } - return false; + return m_IsBiomeAllowed[a_Biome]; } // Returns true if the given blocktype may be below m_BlockType - bool IsAllowedBlockBelow(BLOCKTYPE a_BlockBelow) + inline bool IsAllowedBlockBelow(BLOCKTYPE a_BlockBelow) { - for (BlockList::iterator itr = m_AllowedBelow.begin(); itr != m_AllowedBelow.end(); ++itr) - { - if (*itr == a_BlockBelow) - { - return true; - } - } - return false; + return m_IsAllowedBelow[a_BlockBelow]; } -- cgit v1.2.3 From 57bb03148af3ad2adf2e613cf11ec8bc1852e00e Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Tue, 29 Jul 2014 13:13:23 +0200 Subject: SingleTopBlock: All blocktypes and biometypes get initialized properly --- src/Generating/FinishGen.h | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src/Generating/FinishGen.h') diff --git a/src/Generating/FinishGen.h b/src/Generating/FinishGen.h index a856b2cda..2500ab344 100644 --- a/src/Generating/FinishGen.h +++ b/src/Generating/FinishGen.h @@ -161,13 +161,25 @@ public: m_Noise(a_Seed), m_BlockType(a_BlockType), m_Amount(a_Amount) - { + { + // Initialize all the block types. + for (int idx = 0; idx < ARRAYCOUNT(m_IsAllowedBelow); ++idx) + { + m_IsAllowedBelow[idx] = false; + } + // Load the allowed blocks into m_IsAllowedBelow for (BlockList::iterator itr = a_AllowedBelow.begin(); itr != a_AllowedBelow.end(); ++itr) { m_IsAllowedBelow[*itr] = true; } - + + // Initialize all the biome types. + for (int idx = 0; idx < ARRAYCOUNT(m_IsBiomeAllowed); ++idx) + { + m_IsBiomeAllowed[idx] = false; + } + // Load the allowed biomes into m_IsBiomeAllowed for (BiomeList::iterator itr = a_Biomes.begin(); itr != a_Biomes.end(); ++itr) { -- cgit v1.2.3 From 4ccf14f3b3f7deb19a32afd4253c506d5a224c54 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Tue, 29 Jul 2014 17:01:15 +0200 Subject: Some finishing touches Removed whitespace fixed dead bush comment --- src/Generating/FinishGen.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Generating/FinishGen.h') diff --git a/src/Generating/FinishGen.h b/src/Generating/FinishGen.h index 2500ab344..ed32768b3 100644 --- a/src/Generating/FinishGen.h +++ b/src/Generating/FinishGen.h @@ -161,7 +161,7 @@ public: m_Noise(a_Seed), m_BlockType(a_BlockType), m_Amount(a_Amount) - { + { // Initialize all the block types. for (int idx = 0; idx < ARRAYCOUNT(m_IsAllowedBelow); ++idx) { -- cgit v1.2.3 From 9a4d80fc3b9dbaa09c8e6d9e8021762a486f280f Mon Sep 17 00:00:00 2001 From: Howaner Date: Wed, 30 Jul 2014 00:45:03 +0200 Subject: Fixed compile error with clang. --- src/Generating/FinishGen.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/Generating/FinishGen.h') diff --git a/src/Generating/FinishGen.h b/src/Generating/FinishGen.h index ed32768b3..cf84a0336 100644 --- a/src/Generating/FinishGen.h +++ b/src/Generating/FinishGen.h @@ -163,7 +163,7 @@ public: m_Amount(a_Amount) { // Initialize all the block types. - for (int idx = 0; idx < ARRAYCOUNT(m_IsAllowedBelow); ++idx) + for (size_t idx = 0; idx < (size_t)ARRAYCOUNT(m_IsAllowedBelow); ++idx) { m_IsAllowedBelow[idx] = false; } @@ -175,7 +175,7 @@ public: } // Initialize all the biome types. - for (int idx = 0; idx < ARRAYCOUNT(m_IsBiomeAllowed); ++idx) + for (size_t idx = 0; idx < (size_t)ARRAYCOUNT(m_IsBiomeAllowed); ++idx) { m_IsBiomeAllowed[idx] = false; } -- cgit v1.2.3 From 438e4088d6a38f9904a36f2e1a358965d9fb4a26 Mon Sep 17 00:00:00 2001 From: Howaner Date: Wed, 30 Jul 2014 01:22:51 +0200 Subject: Changed size_t to 'unsigned long' --- src/Generating/FinishGen.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/Generating/FinishGen.h') diff --git a/src/Generating/FinishGen.h b/src/Generating/FinishGen.h index cf84a0336..7171036e2 100644 --- a/src/Generating/FinishGen.h +++ b/src/Generating/FinishGen.h @@ -163,7 +163,7 @@ public: m_Amount(a_Amount) { // Initialize all the block types. - for (size_t idx = 0; idx < (size_t)ARRAYCOUNT(m_IsAllowedBelow); ++idx) + for (unsigned long idx = 0; idx < ARRAYCOUNT(m_IsAllowedBelow); ++idx) { m_IsAllowedBelow[idx] = false; } @@ -175,7 +175,7 @@ public: } // Initialize all the biome types. - for (size_t idx = 0; idx < (size_t)ARRAYCOUNT(m_IsBiomeAllowed); ++idx) + for (unsigned long idx = 0; idx < ARRAYCOUNT(m_IsBiomeAllowed); ++idx) { m_IsBiomeAllowed[idx] = false; } -- cgit v1.2.3 From 7022ae79886a9f90f30ff54387702d406b723837 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 30 Jul 2014 07:08:29 +0200 Subject: Fixed FinishGen.h types. --- src/Generating/FinishGen.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/Generating/FinishGen.h') diff --git a/src/Generating/FinishGen.h b/src/Generating/FinishGen.h index 7171036e2..50a0fd2e7 100644 --- a/src/Generating/FinishGen.h +++ b/src/Generating/FinishGen.h @@ -163,7 +163,7 @@ public: m_Amount(a_Amount) { // Initialize all the block types. - for (unsigned long idx = 0; idx < ARRAYCOUNT(m_IsAllowedBelow); ++idx) + for (size_t idx = 0; idx < ARRAYCOUNT(m_IsAllowedBelow); ++idx) { m_IsAllowedBelow[idx] = false; } @@ -175,7 +175,7 @@ public: } // Initialize all the biome types. - for (unsigned long idx = 0; idx < ARRAYCOUNT(m_IsBiomeAllowed); ++idx) + for (size_t idx = 0; idx < ARRAYCOUNT(m_IsBiomeAllowed); ++idx) { m_IsBiomeAllowed[idx] = false; } -- cgit v1.2.3 From 75b7c3775528ced647eb5d7db3437d2856e01e7e Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Wed, 30 Jul 2014 13:06:48 +0200 Subject: PreSimulator: Added configurations. You can now choose if it should pregenerate something or not --- src/Generating/FinishGen.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/Generating/FinishGen.h') diff --git a/src/Generating/FinishGen.h b/src/Generating/FinishGen.h index 50a0fd2e7..4a08d70c8 100644 --- a/src/Generating/FinishGen.h +++ b/src/Generating/FinishGen.h @@ -240,9 +240,14 @@ class cFinishGenPreSimulator : public cFinishGen { public: - cFinishGenPreSimulator(void); + cFinishGenPreSimulator(bool a_PreSimulateFallingBlocks, bool a_PreSimulateWater, bool a_PreSimulateLava); protected: + + bool m_PreSimulateFallingBlocks; + bool m_PreSimulateWater; + bool m_PreSimulateLava; + // Drops hanging sand and gravel down to the ground, recalculates heightmap void CollapseSandGravel( cChunkDef::BlockTypes & a_BlockTypes, // Block types to read and change -- cgit v1.2.3