Height generator creating moved info HeiGen.cpp.
The generator also explicitly sets the default back into the INI file.
This commit is contained in:
parent
4a1b78787f
commit
1ef20e858f
@ -173,60 +173,8 @@ void cComposableGenerator::InitBiomeGen(cIniFile & a_IniFile)
|
|||||||
|
|
||||||
void cComposableGenerator::InitHeightGen(cIniFile & a_IniFile)
|
void cComposableGenerator::InitHeightGen(cIniFile & a_IniFile)
|
||||||
{
|
{
|
||||||
AString HeightGenName = a_IniFile.GetValueSet("Generator", "HeightGen", "");
|
|
||||||
if (HeightGenName.empty())
|
|
||||||
{
|
|
||||||
LOGWARN("[Generator] HeightGen value not set in world.ini, using \"Biomal\".");
|
|
||||||
HeightGenName = "Biomal";
|
|
||||||
}
|
|
||||||
|
|
||||||
int Seed = m_ChunkGenerator.GetSeed();
|
|
||||||
bool CacheOffByDefault = false;
|
bool CacheOffByDefault = false;
|
||||||
if (NoCaseCompare(HeightGenName, "flat") == 0)
|
m_HeightGen = cTerrainHeightGen::CreateHeightGen(a_IniFile, *m_BiomeGen, m_ChunkGenerator.GetSeed(), CacheOffByDefault);
|
||||||
{
|
|
||||||
m_HeightGen = new cHeiGenFlat;
|
|
||||||
CacheOffByDefault = true; // We're generating faster than a cache would retrieve data
|
|
||||||
}
|
|
||||||
else if (NoCaseCompare(HeightGenName, "classic") == 0)
|
|
||||||
{
|
|
||||||
m_HeightGen = new cHeiGenClassic(Seed);
|
|
||||||
}
|
|
||||||
else if (NoCaseCompare(HeightGenName, "DistortedHeightmap") == 0)
|
|
||||||
{
|
|
||||||
m_HeightGen = new cDistortedHeightmap(Seed, *m_BiomeGen);
|
|
||||||
}
|
|
||||||
else if (NoCaseCompare(HeightGenName, "End") == 0)
|
|
||||||
{
|
|
||||||
m_HeightGen = new cEndGen(Seed);
|
|
||||||
}
|
|
||||||
else if (NoCaseCompare(HeightGenName, "Noise3D") == 0)
|
|
||||||
{
|
|
||||||
m_HeightGen = new cNoise3DComposable(Seed);
|
|
||||||
}
|
|
||||||
else // "biomal" or <not found>
|
|
||||||
{
|
|
||||||
if (NoCaseCompare(HeightGenName, "biomal") != 0)
|
|
||||||
{
|
|
||||||
LOGWARN("Unknown HeightGen \"%s\", using \"Biomal\" instead.", HeightGenName.c_str());
|
|
||||||
}
|
|
||||||
m_HeightGen = new cHeiGenBiomal(Seed, *m_BiomeGen);
|
|
||||||
|
|
||||||
/*
|
|
||||||
// Performance-testing:
|
|
||||||
LOGINFO("Measuring performance of cHeiGenBiomal...");
|
|
||||||
clock_t BeginTick = clock();
|
|
||||||
for (int x = 0; x < 500; x++)
|
|
||||||
{
|
|
||||||
cChunkDef::HeightMap Heights;
|
|
||||||
m_HeightGen->GenHeightMap(x * 5, x * 5, Heights);
|
|
||||||
}
|
|
||||||
clock_t Duration = clock() - BeginTick;
|
|
||||||
LOGINFO("HeightGen for 500 chunks took %d ticks (%.02f sec)", Duration, (double)Duration / CLOCKS_PER_SEC);
|
|
||||||
//*/
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read the settings:
|
|
||||||
m_HeightGen->InitializeHeightGen(a_IniFile);
|
|
||||||
|
|
||||||
// Add a cache, if requested:
|
// Add a cache, if requested:
|
||||||
int CacheSize = a_IniFile.GetValueSetI("Generator", "HeightGenCacheSize", CacheOffByDefault ? 0 : 64);
|
int CacheSize = a_IniFile.GetValueSetI("Generator", "HeightGenCacheSize", CacheOffByDefault ? 0 : 64);
|
||||||
|
@ -50,7 +50,7 @@ public:
|
|||||||
virtual void InitializeBiomeGen(cIniFile & a_IniFile) {}
|
virtual void InitializeBiomeGen(cIniFile & a_IniFile) {}
|
||||||
|
|
||||||
/// Creates the correct BiomeGen descendant based on the ini file settings and the seed provided.
|
/// Creates the correct BiomeGen descendant based on the ini file settings and the seed provided.
|
||||||
/// a_CacheOffByDefault gets set to whether the cache should be enabled by default
|
/// a_CacheOffByDefault gets set to whether the cache should be disabled by default
|
||||||
/// Used in BiomeVisualiser, too.
|
/// Used in BiomeVisualiser, too.
|
||||||
/// Implemented in BioGen.cpp!
|
/// Implemented in BioGen.cpp!
|
||||||
static cBiomeGen * CreateBiomeGen(cIniFile & a_IniFile, int a_Seed, bool & a_CacheOffByDefault);
|
static cBiomeGen * CreateBiomeGen(cIniFile & a_IniFile, int a_Seed, bool & a_CacheOffByDefault);
|
||||||
@ -77,6 +77,13 @@ public:
|
|||||||
|
|
||||||
/// Reads parameters from the ini file, prepares generator for use.
|
/// Reads parameters from the ini file, prepares generator for use.
|
||||||
virtual void InitializeHeightGen(cIniFile & a_IniFile) {}
|
virtual void InitializeHeightGen(cIniFile & a_IniFile) {}
|
||||||
|
|
||||||
|
/** Creates the correct TerrainHeightGen descendant based on the ini file settings and the seed provided.
|
||||||
|
a_BiomeGen is the underlying biome generator, some height generators may depend on it to generate more biomes
|
||||||
|
a_CacheOffByDefault gets set to whether the cache should be disabled by default
|
||||||
|
Implemented in HeiGen.cpp!
|
||||||
|
*/
|
||||||
|
static cTerrainHeightGen * CreateHeightGen(cIniFile & a_IniFile, cBiomeGen & a_BiomeGen, int a_Seed, bool & a_CacheOffByDefault);
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,12 +7,85 @@
|
|||||||
#include "HeiGen.h"
|
#include "HeiGen.h"
|
||||||
#include "../LinearUpscale.h"
|
#include "../LinearUpscale.h"
|
||||||
#include "inifile/iniFile.h"
|
#include "inifile/iniFile.h"
|
||||||
|
#include "DistortedHeightmap.h"
|
||||||
|
#include "EndGen.h"
|
||||||
|
#include "Noise3DGenerator.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// cTerrainHeightGen:
|
||||||
|
|
||||||
|
cTerrainHeightGen * cTerrainHeightGen::CreateHeightGen(cIniFile &a_IniFile, cBiomeGen & a_BiomeGen, int a_Seed, bool & a_CacheOffByDefault)
|
||||||
|
{
|
||||||
|
AString HeightGenName = a_IniFile.GetValueSet("Generator", "HeightGen", "");
|
||||||
|
if (HeightGenName.empty())
|
||||||
|
{
|
||||||
|
LOGWARN("[Generator] HeightGen value not set in world.ini, using \"Biomal\".");
|
||||||
|
HeightGenName = "Biomal";
|
||||||
|
}
|
||||||
|
|
||||||
|
a_CacheOffByDefault = false;
|
||||||
|
cTerrainHeightGen * res = NULL;
|
||||||
|
if (NoCaseCompare(HeightGenName, "flat") == 0)
|
||||||
|
{
|
||||||
|
res = new cHeiGenFlat;
|
||||||
|
a_CacheOffByDefault = true; // We're generating faster than a cache would retrieve data
|
||||||
|
}
|
||||||
|
else if (NoCaseCompare(HeightGenName, "classic") == 0)
|
||||||
|
{
|
||||||
|
res = new cHeiGenClassic(a_Seed);
|
||||||
|
}
|
||||||
|
else if (NoCaseCompare(HeightGenName, "DistortedHeightmap") == 0)
|
||||||
|
{
|
||||||
|
res = new cDistortedHeightmap(a_Seed, a_BiomeGen);
|
||||||
|
}
|
||||||
|
else if (NoCaseCompare(HeightGenName, "End") == 0)
|
||||||
|
{
|
||||||
|
res = new cEndGen(a_Seed);
|
||||||
|
}
|
||||||
|
else if (NoCaseCompare(HeightGenName, "Noise3D") == 0)
|
||||||
|
{
|
||||||
|
res = new cNoise3DComposable(a_Seed);
|
||||||
|
}
|
||||||
|
else if (NoCaseCompare(HeightGenName, "biomal") == 0)
|
||||||
|
{
|
||||||
|
res = new cHeiGenBiomal(a_Seed, a_BiomeGen);
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Performance-testing:
|
||||||
|
LOGINFO("Measuring performance of cHeiGenBiomal...");
|
||||||
|
clock_t BeginTick = clock();
|
||||||
|
for (int x = 0; x < 500; x++)
|
||||||
|
{
|
||||||
|
cChunkDef::HeightMap Heights;
|
||||||
|
res->GenHeightMap(x * 5, x * 5, Heights);
|
||||||
|
}
|
||||||
|
clock_t Duration = clock() - BeginTick;
|
||||||
|
LOGINFO("HeightGen for 500 chunks took %d ticks (%.02f sec)", Duration, (double)Duration / CLOCKS_PER_SEC);
|
||||||
|
//*/
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// No match found, force-set the default and retry
|
||||||
|
LOGWARN("Unknown HeightGen \"%s\", using \"Biomal\" instead.", HeightGenName.c_str());
|
||||||
|
a_IniFile.SetValue("Generator", "HeightGen", "Biomal");
|
||||||
|
return CreateHeightGen(a_IniFile, a_BiomeGen, a_Seed, a_CacheOffByDefault);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read the settings:
|
||||||
|
res->InitializeHeightGen(a_IniFile);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// cHeiGenFlat:
|
// cHeiGenFlat:
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user