summaryrefslogtreecommitdiffstats
path: root/source/BioGen.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-05-27 12:51:04 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-05-27 12:51:04 +0200
commitba2f0c6229870fd7c1d0b0f530dd1567d43e4e03 (patch)
treefc807d61b7656133a59a1113cbbda65d4bfed53f /source/BioGen.cpp
parentImproved logging on mis-configuration in cPlayer and cWorldStorage (diff)
downloadcuberite-ba2f0c6229870fd7c1d0b0f530dd1567d43e4e03.tar
cuberite-ba2f0c6229870fd7c1d0b0f530dd1567d43e4e03.tar.gz
cuberite-ba2f0c6229870fd7c1d0b0f530dd1567d43e4e03.tar.bz2
cuberite-ba2f0c6229870fd7c1d0b0f530dd1567d43e4e03.tar.lz
cuberite-ba2f0c6229870fd7c1d0b0f530dd1567d43e4e03.tar.xz
cuberite-ba2f0c6229870fd7c1d0b0f530dd1567d43e4e03.tar.zst
cuberite-ba2f0c6229870fd7c1d0b0f530dd1567d43e4e03.zip
Diffstat (limited to '')
-rw-r--r--source/BioGen.cpp38
1 files changed, 34 insertions, 4 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];
}
}
}