2012-05-25 03:18:52 -04:00
|
|
|
|
|
|
|
// BioGen.cpp
|
|
|
|
|
|
|
|
// Implements the various biome generators
|
|
|
|
|
|
|
|
#include "Globals.h"
|
|
|
|
#include "BioGen.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// cBioGenConstant:
|
|
|
|
|
|
|
|
void cBioGenConstant::GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < ARRAYCOUNT(a_BiomeMap); i++)
|
|
|
|
{
|
|
|
|
a_BiomeMap[i] = m_Biome;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// cBioGenDistortedVoronoi:
|
|
|
|
|
|
|
|
void cBioGenDistortedVoronoi::GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap)
|
|
|
|
{
|
|
|
|
// TODO: Replace this placeholder
|
|
|
|
ASSERT(!"Not implemented yet");
|
|
|
|
for (int i = 0; i < ARRAYCOUNT(a_BiomeMap); i++)
|
|
|
|
{
|
|
|
|
a_BiomeMap[i] = (EMCSBiome)(a_ChunkX + a_ChunkZ);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
2012-05-27 07:07:23 -04:00
|
|
|
// cBiomeGenList:
|
2012-05-25 03:18:52 -04:00
|
|
|
|
2012-05-27 07:07:23 -04:00
|
|
|
void cBiomeGenList::InitializeBiomes(const AString & a_Biomes)
|
2012-05-25 03:18:52 -04:00
|
|
|
{
|
2012-05-27 06:51:04 -04:00
|
|
|
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:
|
2012-05-25 03:18:52 -04:00
|
|
|
static EMCSBiome Biomes[] =
|
|
|
|
{
|
|
|
|
biOcean,
|
|
|
|
biPlains,
|
|
|
|
biDesert,
|
|
|
|
biExtremeHills,
|
|
|
|
biForest,
|
|
|
|
biTaiga,
|
|
|
|
biSwampland,
|
|
|
|
biRiver,
|
|
|
|
biFrozenOcean,
|
|
|
|
biFrozenRiver,
|
|
|
|
biIcePlains,
|
|
|
|
biIceMountains,
|
|
|
|
biMushroomIsland,
|
|
|
|
biMushroomShore,
|
|
|
|
biBeach,
|
|
|
|
biDesertHills,
|
|
|
|
biForestHills,
|
|
|
|
biTaigaHills,
|
|
|
|
biExtremeHillsEdge,
|
|
|
|
biJungle,
|
|
|
|
biJungleHills,
|
|
|
|
} ;
|
2012-05-27 06:51:04 -04:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-05-27 07:07:23 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// cBioGenCheckerboard:
|
|
|
|
|
2012-05-27 06:51:04 -04:00
|
|
|
void cBioGenCheckerboard::GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap)
|
|
|
|
{
|
2012-05-25 03:18:52 -04:00
|
|
|
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;
|
2012-05-27 06:51:04 -04:00
|
|
|
a_BiomeMap[x + cChunkDef::Width * z] = m_Biomes[(Base / m_BiomeSize + Add / m_BiomeSize) % m_BiomesCount];
|
2012-05-25 03:18:52 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|