1
0
Fork 0

Using suggestions

This commit is contained in:
STRWarrior 2014-07-28 16:53:01 +02:00
parent 579f850506
commit e74984675c
1 changed files with 20 additions and 25 deletions

View File

@ -147,9 +147,12 @@ class cFinishGenSingleTopBlock :
public cFinishGen public cFinishGen
{ {
public: public:
typedef std::vector<BLOCKTYPE> BlockList; typedef std::vector<BLOCKTYPE> BlockList;
bool m_IsAllowedBelow[256];
typedef std::vector<EMCSBiome> BiomeList; typedef std::vector<EMCSBiome> BiomeList;
bool m_IsBiomeAllowed[256];
cFinishGenSingleTopBlock( cFinishGenSingleTopBlock(
int a_Seed, BLOCKTYPE a_BlockType, BiomeList a_Biomes, int a_Amount, int a_Seed, BLOCKTYPE a_BlockType, BiomeList a_Biomes, int a_Amount,
@ -157,46 +160,38 @@ public:
) : ) :
m_Noise(a_Seed), m_Noise(a_Seed),
m_BlockType(a_BlockType), m_BlockType(a_BlockType),
m_Biomes(a_Biomes), m_Amount(a_Amount)
m_Amount(a_Amount),
m_AllowedBelow(a_AllowedBelow)
{ {
// 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: protected:
cNoise m_Noise; cNoise m_Noise;
BLOCKTYPE m_BlockType; BLOCKTYPE m_BlockType;
int m_Amount; ///< Relative amount of blocks to try adding. 1 = one block per 256 biome columns. 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); int GetNumToGen(const cChunkDef::BiomeMap & a_BiomeMap);
// Returns true if the given biome is a biome that is allowed. // 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) return m_IsBiomeAllowed[a_Biome];
{
if (a_Biome == *itr)
{
return true;
}
}
return false;
} }
// Returns true if the given blocktype may be below m_BlockType // 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) return m_IsAllowedBelow[a_BlockBelow];
{
if (*itr == a_BlockBelow)
{
return true;
}
}
return false;
} }