summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--source/BioGen.cpp38
-rw-r--r--source/BioGen.h13
-rw-r--r--source/BlockID.cpp56
-rw-r--r--source/BlockID.h5
-rw-r--r--source/cChunkGenerator.cpp5
5 files changed, 109 insertions, 8 deletions
diff --git a/source/BioGen.cpp b/source/BioGen.cpp
index c87a6ec1b..82a937f4f 100644
--- a/source/BioGen.cpp
+++ b/source/BioGen.cpp
@@ -45,9 +45,26 @@ void cBioGenDistortedVoronoi::GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::B
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// cBioGenCheckerboard:
-void cBioGenCheckerboard::GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap)
+void cBioGenCheckerboard::InitializeBiomes(const AString & a_Biomes)
{
- // The list of biomes we will generate in the checkerboard:
+ AStringVector Split = StringSplit(a_Biomes, ",");
+
+ // Convert each string in the list into biome:
+ for (AStringVector::const_iterator itr = Split.begin(); itr != Split.end(); ++itr)
+ {
+ EMCSBiome Biome = StringToBiome(*itr);
+ if (Biome != -1)
+ {
+ m_Biomes.push_back(Biome);
+ }
+ } // for itr - Split[]
+ if (!m_Biomes.empty())
+ {
+ m_BiomesCount = (int)m_Biomes.size();
+ return;
+ }
+
+ // There were no biomes, add default biomes:
static EMCSBiome Biomes[] =
{
biOcean,
@@ -72,14 +89,27 @@ void cBioGenCheckerboard::GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::Biome
biJungle,
biJungleHills,
} ;
-
+ m_Biomes.reserve(ARRAYCOUNT(Biomes));
+ for (int i = 0; i < ARRAYCOUNT(Biomes); i++)
+ {
+ m_Biomes.push_back(Biomes[i]);
+ }
+ m_BiomesCount = (int)m_Biomes.size();
+}
+
+
+
+
+
+void cBioGenCheckerboard::GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap)
+{
for (int z = 0; z < cChunkDef::Width; z++)
{
int Base = cChunkDef::Width * a_ChunkZ + z;
for (int x = 0; x < cChunkDef::Width; x++)
{
int Add = cChunkDef::Width * a_ChunkX + x;
- a_BiomeMap[x + cChunkDef::Width * z] = Biomes[(Base / m_BiomeSize + Add / m_BiomeSize) % ARRAYCOUNT(Biomes)];
+ a_BiomeMap[x + cChunkDef::Width * z] = m_Biomes[(Base / m_BiomeSize + Add / m_BiomeSize) % m_BiomesCount];
}
}
}
diff --git a/source/BioGen.h b/source/BioGen.h
index 316399436..b44d8fdf4 100644
--- a/source/BioGen.h
+++ b/source/BioGen.h
@@ -60,12 +60,23 @@ class cBioGenCheckerboard :
public cBiomeGen
{
public:
- cBioGenCheckerboard(int a_BiomeSize) : m_BiomeSize((a_BiomeSize < 8) ? 8 : a_BiomeSize) {}
+ cBioGenCheckerboard(int a_BiomeSize, const AString & a_Biomes) :
+ m_BiomeSize((a_BiomeSize < 8) ? 8 : a_BiomeSize)
+ {
+ InitializeBiomes(a_Biomes);
+ }
protected:
int m_BiomeSize;
+ // List of biomes that the generator is allowed to generate:
+ typedef std::vector<EMCSBiome> EMCSBiomes;
+ EMCSBiomes m_Biomes;
+ int m_BiomesCount;
+
+ void InitializeBiomes(const AString & a_Biomes);
+
// cBiomeGen override:
virtual void GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap) override;
} ;
diff --git a/source/BlockID.cpp b/source/BlockID.cpp
index 2e2484f21..32f9bb96e 100644
--- a/source/BlockID.cpp
+++ b/source/BlockID.cpp
@@ -63,6 +63,62 @@ int BlockStringToType(const AString & a_BlockTypeString)
+EMCSBiome StringToBiome(const AString & a_BiomeString)
+{
+ // If it is a number, return it:
+ int res = atoi(a_BiomeString.c_str());
+ if ((res != 0) || (a_BiomeString.compare("0") == 0))
+ {
+ // It was a valid number
+ return (EMCSBiome)res;
+ }
+
+ // Convert using the built-in map:
+ static struct {
+ EMCSBiome m_Biome;
+ const char * m_String;
+ } BiomeMap[] =
+ {
+ {biOcean, "Ocean"} ,
+ {biPlains, "Plains"},
+ {biDesert, "Desert"},
+ {biExtremeHills, "ExtremeHills"},
+ {biForest, "Forest"},
+ {biTaiga, "Taiga"},
+ {biSwampland, "Swampland"},
+ {biRiver, "River"},
+ {biHell, "Hell"},
+ {biHell, "Nether"},
+ {biSky, "Sky"},
+ {biFrozenOcean, "FrozenOcean"},
+ {biFrozenRiver, "FrozenRiver"},
+ {biIcePlains, "IcePlains"},
+ {biIceMountains, "IceMountains"},
+ {biMushroomIsland, "MushroomIsland"},
+ {biMushroomShore, "MushroomShore"},
+ {biBeach, "Beach"},
+ {biDesertHills, "DesertHills"},
+ {biForestHills, "ForestHills"},
+ {biTaigaHills, "TaigaHills"},
+ {biExtremeHillsEdge, "ExtremeHillsEdge "},
+ {biJungle, "Jungle"},
+ {biJungleHills, "JungleHills"},
+ } ;
+
+ for (int i = 0; i < ARRAYCOUNT(BiomeMap); i++)
+ {
+ if (NoCaseCompare(BiomeMap[i].m_String, a_BiomeString) == 0)
+ {
+ return BiomeMap[i].m_Biome;
+ }
+ } // for i - BiomeMap[]
+ return (EMCSBiome)-1;
+}
+
+
+
+
+
// This is actually just some code that needs to run at program startup, so it is wrapped into a global var's constructor:
class cBlockPropertiesInitializer
{
diff --git a/source/BlockID.h b/source/BlockID.h
index 323319fcb..ec7bb70ac 100644
--- a/source/BlockID.h
+++ b/source/BlockID.h
@@ -440,9 +440,12 @@ enum
-// Translates a blocktype string into blocktype. Takes either a number or an items.ini alias as input. Returns -1 on failure.
+/// Translates a blocktype string into blocktype. Takes either a number or an items.ini alias as input. Returns -1 on failure.
extern int BlockStringToType(const AString & a_BlockTypeString);
+/// Translates a biome string to biome enum. Takes either a number or a biome alias (built-in). Returns -1 on failure.
+extern EMCSBiome StringToBiome(const AString & a_BiomeString);
+
diff --git a/source/cChunkGenerator.cpp b/source/cChunkGenerator.cpp
index 321246298..e8565f6ac 100644
--- a/source/cChunkGenerator.cpp
+++ b/source/cChunkGenerator.cpp
@@ -119,7 +119,8 @@ void cChunkGenerator::InitBiomeGen(cIniFile & a_IniFile)
else if (NoCaseCompare(BiomeGenName, "checkerboard") == 0)
{
int BiomeSize = a_IniFile.GetValueI("Generator", "CheckerboardBiomeSize", 64);
- m_BiomeGen = new cBioGenCheckerboard(BiomeSize);
+ AString Biomes = a_IniFile.GetValue("Generator", "CheckerBoardBiomes", "");
+ m_BiomeGen = new cBioGenCheckerboard(BiomeSize, Biomes);
}
else
{
@@ -218,7 +219,7 @@ void cChunkGenerator::InitCompositionGen(cIniFile & a_IniFile)
void cChunkGenerator::InitStructureGens(cIniFile & a_IniFile)
{
- AString Structures = a_IniFile.GetValue("Generator", "Structures", "Trees,MarbleCaves");
+ AString Structures = a_IniFile.GetValue("Generator", "Structures", "Trees,MarbleCaves,OreNests");
AStringVector Str = StringSplit(Structures, ",");
for (AStringVector::const_iterator itr = Str.begin(); itr != Str.end(); ++itr)