From d02df740ef0f8949de8bdf096c0079b702d26288 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Sun, 27 May 2012 11:07:23 +0000 Subject: Restructured biome generators with a list of available biomes to use a common ancestor (preparation for Voronoi and DistortedVoronoi) git-svn-id: http://mc-server.googlecode.com/svn/trunk@508 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/BioGen.cpp | 7 +++++-- source/BioGen.h | 34 +++++++++++++++++++++++++--------- 2 files changed, 30 insertions(+), 11 deletions(-) (limited to 'source') diff --git a/source/BioGen.cpp b/source/BioGen.cpp index 82a937f4f..9073ad721 100644 --- a/source/BioGen.cpp +++ b/source/BioGen.cpp @@ -43,9 +43,9 @@ void cBioGenDistortedVoronoi::GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::B /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// cBioGenCheckerboard: +// cBiomeGenList: -void cBioGenCheckerboard::InitializeBiomes(const AString & a_Biomes) +void cBiomeGenList::InitializeBiomes(const AString & a_Biomes) { AStringVector Split = StringSplit(a_Biomes, ","); @@ -101,6 +101,9 @@ void cBioGenCheckerboard::InitializeBiomes(const AString & a_Biomes) +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// cBioGenCheckerboard: + void cBioGenCheckerboard::GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap) { for (int z = 0; z < cChunkDef::Width; z++) diff --git a/source/BioGen.h b/source/BioGen.h index b44d8fdf4..659470af2 100644 --- a/source/BioGen.h +++ b/source/BioGen.h @@ -56,27 +56,43 @@ protected: -class cBioGenCheckerboard : +/// Base class for generators that use a list of available biomes. This class takes care of the list. +class cBiomeGenList : public cBiomeGen { -public: - cBioGenCheckerboard(int a_BiomeSize, const AString & a_Biomes) : - m_BiomeSize((a_BiomeSize < 8) ? 8 : a_BiomeSize) +protected: + cBiomeGenList(const AString & a_Biomes) { InitializeBiomes(a_Biomes); } -protected: - - int m_BiomeSize; - // List of biomes that the generator is allowed to generate: typedef std::vector EMCSBiomes; EMCSBiomes m_Biomes; - int m_BiomesCount; + int m_BiomesCount; // Pulled out of m_Biomes for faster access void InitializeBiomes(const AString & a_Biomes); +} ; + + + + + +class cBioGenCheckerboard : + public cBiomeGenList +{ +public: + cBioGenCheckerboard(int a_BiomeSize, const AString & a_Biomes) : + cBiomeGenList(a_Biomes), + m_BiomeSize((a_BiomeSize < 8) ? 8 : a_BiomeSize) + { + } + +protected: + + int m_BiomeSize; + // cBiomeGen override: virtual void GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap) override; } ; -- cgit v1.2.3