2013-01-25 05:12:29 -05:00
|
|
|
|
|
|
|
// ComposableGenerator.cpp
|
|
|
|
|
|
|
|
// Implements the cComposableGenerator class representing the chunk generator that takes the composition approach to generating chunks
|
|
|
|
|
|
|
|
#include "Globals.h"
|
|
|
|
|
|
|
|
#include "ComposableGenerator.h"
|
|
|
|
#include "../World.h"
|
|
|
|
#include "../../iniFile/iniFile.h"
|
|
|
|
#include "../Root.h"
|
|
|
|
|
|
|
|
// Individual composed algorithms:
|
|
|
|
#include "BioGen.h"
|
|
|
|
#include "HeiGen.h"
|
|
|
|
#include "CompoGen.h"
|
|
|
|
#include "StructGen.h"
|
|
|
|
#include "FinishGen.h"
|
2013-03-29 12:46:58 -04:00
|
|
|
|
2013-01-25 05:12:29 -05:00
|
|
|
#include "Caves.h"
|
2013-05-05 12:27:08 -04:00
|
|
|
#include "DistortedHeightmap.h"
|
2013-03-29 12:46:58 -04:00
|
|
|
#include "MineShafts.h"
|
2013-04-27 15:46:25 -04:00
|
|
|
#include "Noise3DGenerator.h"
|
2013-03-29 12:46:58 -04:00
|
|
|
#include "Ravines.h"
|
2013-01-25 05:12:29 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-03-14 05:52:57 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-01-25 05:12:29 -05:00
|
|
|
cComposableGenerator::cComposableGenerator(cChunkGenerator & a_ChunkGenerator) :
|
|
|
|
super(a_ChunkGenerator),
|
|
|
|
m_BiomeGen(NULL),
|
|
|
|
m_HeightGen(NULL),
|
2013-04-27 15:46:25 -04:00
|
|
|
m_CompositionGen(NULL),
|
2013-05-05 15:56:45 -04:00
|
|
|
m_UnderlyingBiomeGen(NULL),
|
|
|
|
m_UnderlyingHeightGen(NULL),
|
|
|
|
m_UnderlyingCompositionGen(NULL)
|
2013-01-25 05:12:29 -05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cComposableGenerator::~cComposableGenerator()
|
|
|
|
{
|
|
|
|
// Delete the generating composition:
|
|
|
|
for (cFinishGenList::const_iterator itr = m_FinishGens.begin(); itr != m_FinishGens.end(); ++itr)
|
|
|
|
{
|
|
|
|
delete *itr;
|
|
|
|
}
|
|
|
|
m_FinishGens.clear();
|
|
|
|
for (cStructureGenList::const_iterator itr = m_StructureGens.begin(); itr != m_StructureGens.end(); ++itr)
|
|
|
|
{
|
|
|
|
delete *itr;
|
|
|
|
}
|
|
|
|
m_StructureGens.clear();
|
2013-04-27 15:46:25 -04:00
|
|
|
|
2013-05-05 15:56:45 -04:00
|
|
|
delete m_CompositionGen;
|
2013-01-25 05:12:29 -05:00
|
|
|
m_CompositionGen = NULL;
|
|
|
|
delete m_HeightGen;
|
|
|
|
m_HeightGen = NULL;
|
|
|
|
delete m_BiomeGen;
|
|
|
|
m_BiomeGen = NULL;
|
2013-05-05 15:56:45 -04:00
|
|
|
delete m_UnderlyingCompositionGen;
|
|
|
|
m_UnderlyingCompositionGen = NULL;
|
|
|
|
delete m_UnderlyingHeightGen;
|
|
|
|
m_UnderlyingHeightGen = NULL;
|
|
|
|
delete m_UnderlyingBiomeGen;
|
|
|
|
m_UnderlyingBiomeGen = NULL;
|
2013-01-25 05:12:29 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void cComposableGenerator::Initialize(cWorld * a_World, cIniFile & a_IniFile)
|
|
|
|
{
|
|
|
|
super::Initialize(a_World, a_IniFile);
|
|
|
|
|
|
|
|
InitBiomeGen(a_IniFile);
|
|
|
|
InitHeightGen(a_IniFile);
|
|
|
|
InitCompositionGen(a_IniFile);
|
|
|
|
InitStructureGens(a_IniFile);
|
|
|
|
InitFinishGens(a_IniFile);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void cComposableGenerator::GenerateBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap)
|
|
|
|
{
|
|
|
|
if (m_BiomeGen != NULL) // Quick fix for generator deinitializing before the world storage finishes loading
|
|
|
|
{
|
|
|
|
m_BiomeGen->GenBiomes(a_ChunkX, a_ChunkZ, a_BiomeMap);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-02-08 11:01:44 -05:00
|
|
|
void cComposableGenerator::DoGenerate(int a_ChunkX, int a_ChunkZ, cChunkDesc & a_ChunkDesc)
|
2013-01-25 05:12:29 -05:00
|
|
|
{
|
|
|
|
if (a_ChunkDesc.IsUsingDefaultBiomes())
|
|
|
|
{
|
2013-03-19 04:32:02 -04:00
|
|
|
m_BiomeGen->GenBiomes(a_ChunkX, a_ChunkZ, a_ChunkDesc.GetBiomeMap());
|
2013-01-25 05:12:29 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (a_ChunkDesc.IsUsingDefaultHeight())
|
|
|
|
{
|
2013-03-19 04:32:02 -04:00
|
|
|
m_HeightGen->GenHeightMap(a_ChunkX, a_ChunkZ, a_ChunkDesc.GetHeightMap());
|
2013-01-25 05:12:29 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (a_ChunkDesc.IsUsingDefaultComposition())
|
|
|
|
{
|
2013-03-17 13:55:03 -04:00
|
|
|
m_CompositionGen->ComposeTerrain(a_ChunkDesc);
|
2013-01-25 05:12:29 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (a_ChunkDesc.IsUsingDefaultStructures())
|
|
|
|
{
|
|
|
|
for (cStructureGenList::iterator itr = m_StructureGens.begin(); itr != m_StructureGens.end(); ++itr)
|
|
|
|
{
|
2013-03-17 13:55:03 -04:00
|
|
|
(*itr)->GenStructures(a_ChunkDesc);
|
2013-01-25 05:12:29 -05:00
|
|
|
} // for itr - m_StructureGens[]
|
|
|
|
}
|
|
|
|
|
|
|
|
if (a_ChunkDesc.IsUsingDefaultFinish())
|
|
|
|
{
|
|
|
|
for (cFinishGenList::iterator itr = m_FinishGens.begin(); itr != m_FinishGens.end(); ++itr)
|
|
|
|
{
|
2013-03-17 13:55:03 -04:00
|
|
|
(*itr)->GenFinish(a_ChunkDesc);
|
2013-01-25 05:12:29 -05:00
|
|
|
} // for itr - m_FinishGens[]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void cComposableGenerator::InitBiomeGen(cIniFile & a_IniFile)
|
|
|
|
{
|
|
|
|
AString BiomeGenName = a_IniFile.GetValueSet("Generator", "BiomeGen", "");
|
|
|
|
if (BiomeGenName.empty())
|
|
|
|
{
|
2013-03-24 12:08:20 -04:00
|
|
|
LOGWARN("[Generator]::BiomeGen value not found in world.ini, using \"MultiStepMap\".");
|
|
|
|
BiomeGenName = "MultiStepMap";
|
2013-01-25 05:12:29 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int Seed = m_ChunkGenerator.GetSeed();
|
|
|
|
bool CacheOffByDefault = false;
|
|
|
|
if (NoCaseCompare(BiomeGenName, "constant") == 0)
|
|
|
|
{
|
2013-02-02 13:17:46 -05:00
|
|
|
m_BiomeGen = new cBioGenConstant;
|
2013-01-25 05:12:29 -05:00
|
|
|
CacheOffByDefault = true; // we're generating faster than a cache would retrieve data :)
|
|
|
|
}
|
|
|
|
else if (NoCaseCompare(BiomeGenName, "checkerboard") == 0)
|
|
|
|
{
|
2013-02-02 13:17:46 -05:00
|
|
|
m_BiomeGen = new cBioGenCheckerboard;
|
2013-01-25 05:12:29 -05:00
|
|
|
CacheOffByDefault = true; // we're (probably) generating faster than a cache would retrieve data
|
|
|
|
}
|
|
|
|
else if (NoCaseCompare(BiomeGenName, "voronoi") == 0)
|
|
|
|
{
|
2013-02-02 13:17:46 -05:00
|
|
|
m_BiomeGen = new cBioGenVoronoi(Seed);
|
2013-01-25 05:12:29 -05:00
|
|
|
}
|
2013-03-24 12:08:20 -04:00
|
|
|
else if (NoCaseCompare(BiomeGenName, "distortedvoronoi") == 0)
|
2013-01-25 05:12:29 -05:00
|
|
|
{
|
2013-03-24 12:08:20 -04:00
|
|
|
m_BiomeGen = new cBioGenDistortedVoronoi(Seed);
|
2013-01-25 05:12:29 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-03-24 12:08:20 -04:00
|
|
|
if (NoCaseCompare(BiomeGenName, "multistepmap") != 0)
|
2013-01-25 05:12:29 -05:00
|
|
|
{
|
2013-03-24 12:08:20 -04:00
|
|
|
LOGWARNING("Unknown BiomeGen \"%s\", using \"MultiStepMap\" instead.", BiomeGenName.c_str());
|
2013-01-25 05:12:29 -05:00
|
|
|
}
|
2013-03-24 12:08:20 -04:00
|
|
|
m_BiomeGen = new cBioGenMultiStepMap(Seed);
|
2013-04-24 10:34:24 -04:00
|
|
|
|
|
|
|
/*
|
|
|
|
// Performance-testing:
|
|
|
|
LOGINFO("Measuring performance of cBioGenMultiStepMap...");
|
|
|
|
clock_t BeginTick = clock();
|
|
|
|
for (int x = 0; x < 5000; x++)
|
|
|
|
{
|
|
|
|
cChunkDef::BiomeMap Biomes;
|
|
|
|
m_BiomeGen->GenBiomes(x * 5, x * 5, Biomes);
|
|
|
|
}
|
|
|
|
clock_t Duration = clock() - BeginTick;
|
|
|
|
LOGINFO("cBioGenMultiStepMap for 5000 chunks took %d ticks (%.02f sec)", Duration, (double)Duration / CLOCKS_PER_SEC);
|
|
|
|
//*/
|
2013-01-25 05:12:29 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// Add a cache, if requested:
|
|
|
|
int CacheSize = a_IniFile.GetValueSetI("Generator", "BiomeGenCacheSize", CacheOffByDefault ? 0 : 64);
|
|
|
|
if (CacheSize > 0)
|
|
|
|
{
|
|
|
|
if (CacheSize < 4)
|
|
|
|
{
|
|
|
|
LOGWARNING("Biomegen cache size set too low, would hurt performance instead of helping. Increasing from %d to %d",
|
|
|
|
CacheSize, 4
|
|
|
|
);
|
|
|
|
CacheSize = 4;
|
|
|
|
}
|
|
|
|
LOGINFO("Using a cache for biomegen of size %d.", CacheSize);
|
2013-05-05 15:56:45 -04:00
|
|
|
m_UnderlyingBiomeGen = m_BiomeGen;
|
|
|
|
m_BiomeGen = new cBioGenCache(m_UnderlyingBiomeGen, CacheSize);
|
2013-01-25 05:12:29 -05:00
|
|
|
}
|
2013-02-02 13:17:46 -05:00
|
|
|
m_BiomeGen->Initialize(a_IniFile);
|
2013-01-25 05:12:29 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void cComposableGenerator::InitHeightGen(cIniFile & a_IniFile)
|
|
|
|
{
|
|
|
|
AString HeightGenName = a_IniFile.GetValueSet("Generator", "HeightGen", "");
|
|
|
|
if (HeightGenName.empty())
|
|
|
|
{
|
|
|
|
LOGWARN("[Generator]::HeightGen value not found in world.ini, using \"Biomal\".");
|
|
|
|
HeightGenName = "Biomal";
|
|
|
|
}
|
|
|
|
|
|
|
|
int Seed = m_ChunkGenerator.GetSeed();
|
|
|
|
bool CacheOffByDefault = false;
|
|
|
|
if (NoCaseCompare(HeightGenName, "flat") == 0)
|
|
|
|
{
|
|
|
|
int Height = a_IniFile.GetValueSetI("Generator", "FlatHeight", 5);
|
|
|
|
m_HeightGen = new cHeiGenFlat(Height);
|
|
|
|
CacheOffByDefault = true; // We're generating faster than a cache would retrieve data
|
|
|
|
}
|
|
|
|
else if (NoCaseCompare(HeightGenName, "classic") == 0)
|
|
|
|
{
|
|
|
|
// These used to be in terrain.ini, but now they are in world.ini (so that multiple worlds can have different values):
|
|
|
|
float HeightFreq1 = (float)a_IniFile.GetValueSetF("Generator", "ClassicHeightFreq1", 0.1);
|
|
|
|
float HeightFreq2 = (float)a_IniFile.GetValueSetF("Generator", "ClassicHeightFreq2", 1.0);
|
|
|
|
float HeightFreq3 = (float)a_IniFile.GetValueSetF("Generator", "ClassicHeightFreq3", 2.0);
|
|
|
|
float HeightAmp1 = (float)a_IniFile.GetValueSetF("Generator", "ClassicHeightAmp1", 1.0);
|
|
|
|
float HeightAmp2 = (float)a_IniFile.GetValueSetF("Generator", "ClassicHeightAmp2", 0.5);
|
|
|
|
float HeightAmp3 = (float)a_IniFile.GetValueSetF("Generator", "ClassicHeightAmp3", 0.5);
|
|
|
|
m_HeightGen = new cHeiGenClassic(Seed, HeightFreq1, HeightAmp1, HeightFreq2, HeightAmp2, HeightFreq3, HeightAmp3);
|
|
|
|
}
|
2013-05-05 12:27:08 -04:00
|
|
|
else if (NoCaseCompare(HeightGenName, "DistortedHeightmap") == 0)
|
|
|
|
{
|
2013-05-05 15:56:45 -04:00
|
|
|
m_HeightGen = new cDistortedHeightmap(Seed, *m_BiomeGen);
|
|
|
|
((cDistortedHeightmap *)m_HeightGen)->Initialize(a_IniFile);
|
2013-05-05 12:27:08 -04:00
|
|
|
}
|
2013-04-27 15:46:25 -04:00
|
|
|
else if (NoCaseCompare(HeightGenName, "Noise3D") == 0)
|
|
|
|
{
|
2013-05-05 15:56:45 -04:00
|
|
|
m_HeightGen = new cNoise3DComposable(Seed);
|
|
|
|
((cNoise3DComposable *)m_HeightGen)->Initialize(a_IniFile);
|
2013-04-27 15:46:25 -04:00
|
|
|
}
|
2013-01-25 05:12:29 -05:00
|
|
|
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);
|
2013-04-22 14:56:36 -04:00
|
|
|
|
|
|
|
/*
|
|
|
|
// 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);
|
|
|
|
//*/
|
2013-01-25 05:12:29 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// Add a cache, if requested:
|
|
|
|
int CacheSize = a_IniFile.GetValueSetI("Generator", "HeightGenCacheSize", CacheOffByDefault ? 0 : 64);
|
|
|
|
if (CacheSize > 0)
|
|
|
|
{
|
|
|
|
if (CacheSize < 4)
|
|
|
|
{
|
|
|
|
LOGWARNING("Heightgen cache size set too low, would hurt performance instead of helping. Increasing from %d to %d",
|
|
|
|
CacheSize, 4
|
|
|
|
);
|
|
|
|
CacheSize = 4;
|
|
|
|
}
|
|
|
|
LOGINFO("Using a cache for Heightgen of size %d.", CacheSize);
|
2013-05-05 15:56:45 -04:00
|
|
|
m_UnderlyingHeightGen = m_HeightGen;
|
|
|
|
m_HeightGen = new cHeiGenCache(m_UnderlyingHeightGen, CacheSize);
|
2013-01-25 05:12:29 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void cComposableGenerator::InitCompositionGen(cIniFile & a_IniFile)
|
|
|
|
{
|
|
|
|
AString CompoGenName = a_IniFile.GetValueSet("Generator", "CompositionGen", "");
|
|
|
|
if (CompoGenName.empty())
|
|
|
|
{
|
|
|
|
LOGWARN("[Generator]::CompositionGen value not found in world.ini, using \"Biomal\".");
|
|
|
|
CompoGenName = "Biomal";
|
|
|
|
}
|
|
|
|
if (NoCaseCompare(CompoGenName, "sameblock") == 0)
|
|
|
|
{
|
|
|
|
int Block = m_ChunkGenerator.GetIniBlock(a_IniFile, "Generator", "SameBlockType", "stone");
|
|
|
|
bool Bedrocked = (a_IniFile.GetValueSetI("Generator", "SameBlockBedrocked", 1) != 0);
|
|
|
|
m_CompositionGen = new cCompoGenSameBlock((BLOCKTYPE)Block, Bedrocked);
|
|
|
|
}
|
|
|
|
else if (NoCaseCompare(CompoGenName, "debugbiomes") == 0)
|
|
|
|
{
|
|
|
|
m_CompositionGen = new cCompoGenDebugBiomes;
|
|
|
|
}
|
|
|
|
else if (NoCaseCompare(CompoGenName, "classic") == 0)
|
|
|
|
{
|
|
|
|
int SeaLevel = a_IniFile.GetValueSetI("Generator", "ClassicSeaLevel", 60);
|
|
|
|
int BeachHeight = a_IniFile.GetValueSetI("Generator", "ClassicBeachHeight", 2);
|
|
|
|
int BeachDepth = a_IniFile.GetValueSetI("Generator", "ClassicBeachDepth", 4);
|
|
|
|
BLOCKTYPE BlockTop = m_ChunkGenerator.GetIniBlock(a_IniFile, "Generator", "ClassicBlockTop", "grass");
|
|
|
|
BLOCKTYPE BlockMiddle = m_ChunkGenerator.GetIniBlock(a_IniFile, "Generator", "ClassicBlockMiddle", "dirt");
|
|
|
|
BLOCKTYPE BlockBottom = m_ChunkGenerator.GetIniBlock(a_IniFile, "Generator", "ClassicBlockBottom", "stone");
|
|
|
|
BLOCKTYPE BlockBeach = m_ChunkGenerator.GetIniBlock(a_IniFile, "Generator", "ClassicBlockBeach", "sand");
|
|
|
|
BLOCKTYPE BlockBeachBottom = m_ChunkGenerator.GetIniBlock(a_IniFile, "Generator", "ClassicBlockBeachBottom", "sandstone");
|
|
|
|
BLOCKTYPE BlockSea = m_ChunkGenerator.GetIniBlock(a_IniFile, "Generator", "ClassicBlockSea", "stationarywater");
|
|
|
|
m_CompositionGen = new cCompoGenClassic(
|
|
|
|
SeaLevel, BeachHeight, BeachDepth, BlockTop, BlockMiddle, BlockBottom, BlockBeach,
|
|
|
|
BlockBeachBottom, BlockSea
|
|
|
|
);
|
|
|
|
}
|
2013-05-05 12:27:08 -04:00
|
|
|
else if (NoCaseCompare(CompoGenName, "DistortedHeightmap") == 0)
|
|
|
|
{
|
2013-05-05 15:56:45 -04:00
|
|
|
m_CompositionGen = new cDistortedHeightmap(m_ChunkGenerator.GetSeed(), *m_BiomeGen);
|
|
|
|
((cDistortedHeightmap *)m_CompositionGen)->Initialize(a_IniFile);
|
2013-05-05 12:27:08 -04:00
|
|
|
}
|
2013-03-11 13:15:34 -04:00
|
|
|
else if (NoCaseCompare(CompoGenName, "nether") == 0)
|
|
|
|
{
|
|
|
|
m_CompositionGen = new cCompoGenNether(m_ChunkGenerator.GetSeed());
|
|
|
|
}
|
2013-04-27 15:46:25 -04:00
|
|
|
else if (NoCaseCompare(CompoGenName, "Noise3D") == 0)
|
|
|
|
{
|
2013-05-05 15:56:45 -04:00
|
|
|
m_CompositionGen = new cNoise3DComposable(m_ChunkGenerator.GetSeed());
|
|
|
|
((cNoise3DComposable *)m_CompositionGen)->Initialize(a_IniFile);
|
2013-04-27 15:46:25 -04:00
|
|
|
}
|
2013-01-25 05:12:29 -05:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (NoCaseCompare(CompoGenName, "biomal") != 0)
|
|
|
|
{
|
|
|
|
LOGWARN("Unknown CompositionGen \"%s\", using \"biomal\" instead.", CompoGenName.c_str());
|
|
|
|
}
|
|
|
|
int SeaLevel = a_IniFile.GetValueSetI("Generator", "BiomalSeaLevel", 62);
|
|
|
|
int Seed = m_ChunkGenerator.GetSeed();
|
|
|
|
m_CompositionGen = new cCompoGenBiomal(Seed, SeaLevel);
|
2013-04-22 14:56:36 -04:00
|
|
|
|
|
|
|
/*
|
|
|
|
// Performance-testing:
|
|
|
|
LOGINFO("Measuring performance of cCompoGenBiomal...");
|
|
|
|
clock_t BeginTick = clock();
|
|
|
|
for (int x = 0; x < 500; x++)
|
|
|
|
{
|
|
|
|
cChunkDesc Desc(200 + x * 8, 200 + x * 8);
|
|
|
|
m_BiomeGen->GenBiomes(Desc.GetChunkX(), Desc.GetChunkZ(), Desc.GetBiomeMap());
|
|
|
|
m_HeightGen->GenHeightMap(Desc.GetChunkX(), Desc.GetChunkZ(), Desc.GetHeightMap());
|
|
|
|
m_CompositionGen->ComposeTerrain(Desc);
|
|
|
|
}
|
|
|
|
clock_t Duration = clock() - BeginTick;
|
|
|
|
LOGINFO("CompositionGen for 500 chunks took %d ticks (%.02f sec)", Duration, (double)Duration / CLOCKS_PER_SEC);
|
|
|
|
//*/
|
2013-01-25 05:12:29 -05:00
|
|
|
}
|
2013-05-05 15:56:45 -04:00
|
|
|
|
|
|
|
int CompoGenCacheSize = a_IniFile.GetValueSetI("Generator", "CompositionGenCacheSize", 64);
|
|
|
|
if (CompoGenCacheSize > 1)
|
|
|
|
{
|
|
|
|
m_UnderlyingCompositionGen = m_CompositionGen;
|
|
|
|
m_CompositionGen = new cCompoGenCache(m_UnderlyingCompositionGen, 32);
|
|
|
|
}
|
2013-01-25 05:12:29 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void cComposableGenerator::InitStructureGens(cIniFile & a_IniFile)
|
|
|
|
{
|
2013-03-24 12:08:20 -04:00
|
|
|
AString Structures = a_IniFile.GetValueSet("Generator", "Structures", "Ravines, WormNestCaves, WaterLakes, LavaLakes, OreNests, Trees");
|
2013-01-25 05:12:29 -05:00
|
|
|
|
|
|
|
int Seed = m_ChunkGenerator.GetSeed();
|
2013-03-14 05:52:57 -04:00
|
|
|
AStringVector Str = StringSplitAndTrim(Structures, ",");
|
2013-01-25 05:12:29 -05:00
|
|
|
for (AStringVector::const_iterator itr = Str.begin(); itr != Str.end(); ++itr)
|
|
|
|
{
|
2013-03-20 07:00:55 -04:00
|
|
|
if (NoCaseCompare(*itr, "DualRidgeCaves") == 0)
|
2013-01-25 05:12:29 -05:00
|
|
|
{
|
2013-03-20 07:00:55 -04:00
|
|
|
float Threshold = (float)a_IniFile.GetValueSetF("Generator", "DualRidgeCavesThreshold", 0.3);
|
|
|
|
m_StructureGens.push_back(new cStructGenDualRidgeCaves(Seed, Threshold));
|
2013-01-25 05:12:29 -05:00
|
|
|
}
|
2013-04-24 16:30:30 -04:00
|
|
|
else if (NoCaseCompare(*itr, "DirectOverhangs") == 0)
|
|
|
|
{
|
|
|
|
m_StructureGens.push_back(new cStructGenDirectOverhangs(Seed));
|
|
|
|
}
|
2013-04-25 15:29:56 -04:00
|
|
|
else if (NoCaseCompare(*itr, "DistortedMembraneOverhangs") == 0)
|
|
|
|
{
|
|
|
|
m_StructureGens.push_back(new cStructGenDistortedMembraneOverhangs(Seed));
|
|
|
|
}
|
2013-03-20 07:00:55 -04:00
|
|
|
else if (NoCaseCompare(*itr, "LavaLakes") == 0)
|
2013-01-25 05:12:29 -05:00
|
|
|
{
|
2013-03-20 07:00:55 -04:00
|
|
|
int Probability = a_IniFile.GetValueSetI("Generator", "LavaLakesProbability", 10);
|
|
|
|
m_StructureGens.push_back(new cStructGenLakes(Seed * 5 + 16873, E_BLOCK_STATIONARY_LAVA, *m_HeightGen, Probability));
|
2013-01-25 05:12:29 -05:00
|
|
|
}
|
2013-03-20 07:00:55 -04:00
|
|
|
else if (NoCaseCompare(*itr, "MarbleCaves") == 0)
|
2013-01-25 05:12:29 -05:00
|
|
|
{
|
2013-03-20 07:00:55 -04:00
|
|
|
m_StructureGens.push_back(new cStructGenMarbleCaves(Seed));
|
2013-01-25 05:12:29 -05:00
|
|
|
}
|
2013-03-29 12:46:58 -04:00
|
|
|
else if (NoCaseCompare(*itr, "MineShafts") == 0)
|
|
|
|
{
|
2013-04-06 17:53:28 -04:00
|
|
|
int GridSize = a_IniFile.GetValueSetI("Generator", "MineShaftsGridSize", 512);
|
|
|
|
int MaxSystemSize = a_IniFile.GetValueSetI("Generator", "MineShaftsMaxSystemSize", 160);
|
2013-03-31 13:10:17 -04:00
|
|
|
int ChanceCorridor = a_IniFile.GetValueSetI("Generator", "MineShaftsChanceCorridor", 600);
|
|
|
|
int ChanceCrossing = a_IniFile.GetValueSetI("Generator", "MineShaftsChanceCrossing", 200);
|
|
|
|
int ChanceStaircase = a_IniFile.GetValueSetI("Generator", "MineShaftsChanceStaircase", 200);
|
|
|
|
m_StructureGens.push_back(new cStructGenMineShafts(
|
|
|
|
Seed, GridSize, MaxSystemSize,
|
|
|
|
ChanceCorridor, ChanceCrossing, ChanceStaircase
|
|
|
|
));
|
2013-03-29 12:46:58 -04:00
|
|
|
}
|
2013-03-20 07:00:55 -04:00
|
|
|
else if (NoCaseCompare(*itr, "OreNests") == 0)
|
2013-01-25 05:12:29 -05:00
|
|
|
{
|
|
|
|
m_StructureGens.push_back(new cStructGenOreNests(Seed));
|
|
|
|
}
|
2013-03-20 07:00:55 -04:00
|
|
|
else if (NoCaseCompare(*itr, "Ravines") == 0)
|
2013-01-25 05:12:29 -05:00
|
|
|
{
|
|
|
|
m_StructureGens.push_back(new cStructGenRavines(Seed, 128));
|
|
|
|
}
|
2013-03-20 07:00:55 -04:00
|
|
|
else if (NoCaseCompare(*itr, "Trees") == 0)
|
2013-01-25 05:12:29 -05:00
|
|
|
{
|
2013-03-20 07:00:55 -04:00
|
|
|
m_StructureGens.push_back(new cStructGenTrees(Seed, m_BiomeGen, m_HeightGen, m_CompositionGen));
|
2013-01-25 05:12:29 -05:00
|
|
|
}
|
2013-03-20 07:00:55 -04:00
|
|
|
else if (NoCaseCompare(*itr, "WaterLakes") == 0)
|
2013-03-19 04:32:02 -04:00
|
|
|
{
|
2013-03-19 06:14:57 -04:00
|
|
|
int Probability = a_IniFile.GetValueSetI("Generator", "WaterLakesProbability", 25);
|
|
|
|
m_StructureGens.push_back(new cStructGenLakes(Seed * 3 + 652, E_BLOCK_STATIONARY_WATER, *m_HeightGen, Probability));
|
2013-03-19 04:32:02 -04:00
|
|
|
}
|
2013-03-20 07:00:55 -04:00
|
|
|
else if (NoCaseCompare(*itr, "WormNestCaves") == 0)
|
2013-03-19 04:32:02 -04:00
|
|
|
{
|
2013-03-20 07:00:55 -04:00
|
|
|
m_StructureGens.push_back(new cStructGenWormNestCaves(Seed));
|
2013-03-19 04:32:02 -04:00
|
|
|
}
|
2013-01-25 05:12:29 -05:00
|
|
|
else
|
|
|
|
{
|
|
|
|
LOGWARNING("Unknown structure generator: \"%s\". Ignoring.", itr->c_str());
|
|
|
|
}
|
|
|
|
} // for itr - Str[]
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile)
|
|
|
|
{
|
|
|
|
int Seed = m_ChunkGenerator.GetSeed();
|
|
|
|
AString Structures = a_IniFile.GetValueSet("Generator", "Finishers", "SprinkleFoliage,Ice,Snow,Lilypads,BottomLava,DeadBushes,PreSimulator");
|
|
|
|
|
2013-03-14 05:52:57 -04:00
|
|
|
AStringVector Str = StringSplitAndTrim(Structures, ",");
|
2013-01-25 05:12:29 -05:00
|
|
|
for (AStringVector::const_iterator itr = Str.begin(); itr != Str.end(); ++itr)
|
|
|
|
{
|
|
|
|
// Finishers, alpha-sorted:
|
|
|
|
if (NoCaseCompare(*itr, "BottomLava") == 0)
|
|
|
|
{
|
2013-03-14 05:52:57 -04:00
|
|
|
int DefaultBottomLavaLevel = (m_World->GetDimension() == cWorld::dimNether) ? 30 : 10;
|
|
|
|
int BottomLavaLevel = a_IniFile.GetValueSetI("Generator", "BottomLavaLevel", DefaultBottomLavaLevel);
|
2013-01-25 05:12:29 -05:00
|
|
|
m_FinishGens.push_back(new cFinishGenBottomLava(BottomLavaLevel));
|
|
|
|
}
|
|
|
|
else if (NoCaseCompare(*itr, "DeadBushes") == 0)
|
|
|
|
{
|
2013-03-17 13:55:03 -04:00
|
|
|
m_FinishGens.push_back(new cFinishGenSingleBiomeSingleTopBlock(Seed, E_BLOCK_DEAD_BUSH, biDesert, 2, E_BLOCK_SAND, E_BLOCK_SAND));
|
2013-01-25 05:12:29 -05:00
|
|
|
}
|
|
|
|
else if (NoCaseCompare(*itr, "Ice") == 0)
|
|
|
|
{
|
|
|
|
m_FinishGens.push_back(new cFinishGenIce);
|
|
|
|
}
|
2013-03-14 05:52:57 -04:00
|
|
|
else if (NoCaseCompare(*itr, "LavaSprings") == 0)
|
|
|
|
{
|
|
|
|
m_FinishGens.push_back(new cFinishGenFluidSprings(Seed, E_BLOCK_LAVA, a_IniFile, *m_World));
|
|
|
|
}
|
2013-01-25 05:12:29 -05:00
|
|
|
else if (NoCaseCompare(*itr, "Lilypads") == 0)
|
|
|
|
{
|
2013-03-17 13:55:03 -04:00
|
|
|
m_FinishGens.push_back(new cFinishGenSingleBiomeSingleTopBlock(Seed, E_BLOCK_LILY_PAD, biSwampland, 4, E_BLOCK_WATER, E_BLOCK_STATIONARY_WATER));
|
2013-01-25 05:12:29 -05:00
|
|
|
}
|
|
|
|
else if (NoCaseCompare(*itr, "PreSimulator") == 0)
|
|
|
|
{
|
|
|
|
m_FinishGens.push_back(new cFinishGenPreSimulator);
|
|
|
|
}
|
|
|
|
else if (NoCaseCompare(*itr, "Snow") == 0)
|
|
|
|
{
|
|
|
|
m_FinishGens.push_back(new cFinishGenSnow);
|
|
|
|
}
|
|
|
|
else if (NoCaseCompare(*itr, "SprinkleFoliage") == 0)
|
|
|
|
{
|
|
|
|
m_FinishGens.push_back(new cFinishGenSprinkleFoliage(Seed));
|
|
|
|
}
|
2013-03-14 05:52:57 -04:00
|
|
|
else if (NoCaseCompare(*itr, "WaterSprings") == 0)
|
|
|
|
{
|
|
|
|
m_FinishGens.push_back(new cFinishGenFluidSprings(Seed, E_BLOCK_WATER, a_IniFile, *m_World));
|
|
|
|
}
|
2013-01-25 05:12:29 -05:00
|
|
|
} // for itr - Str[]
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|