summaryrefslogtreecommitdiffstats
path: root/source/cChunkGenerator.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-06-02 15:45:57 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-06-02 15:45:57 +0200
commit39a59d68061710db886bc00cb571c6feb8cbdc65 (patch)
treee7161107299ed6d9488edc476f865ccc94b88146 /source/cChunkGenerator.cpp
parentAdded a cBioGenCache object for caching generated biomes (diff)
downloadcuberite-39a59d68061710db886bc00cb571c6feb8cbdc65.tar
cuberite-39a59d68061710db886bc00cb571c6feb8cbdc65.tar.gz
cuberite-39a59d68061710db886bc00cb571c6feb8cbdc65.tar.bz2
cuberite-39a59d68061710db886bc00cb571c6feb8cbdc65.tar.lz
cuberite-39a59d68061710db886bc00cb571c6feb8cbdc65.tar.xz
cuberite-39a59d68061710db886bc00cb571c6feb8cbdc65.tar.zst
cuberite-39a59d68061710db886bc00cb571c6feb8cbdc65.zip
Diffstat (limited to 'source/cChunkGenerator.cpp')
-rw-r--r--source/cChunkGenerator.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/source/cChunkGenerator.cpp b/source/cChunkGenerator.cpp
index 1687e0e13..23d6b8422 100644
--- a/source/cChunkGenerator.cpp
+++ b/source/cChunkGenerator.cpp
@@ -177,10 +177,12 @@ void cChunkGenerator::InitHeightGen(cIniFile & a_IniFile)
HeightGenName = "classic";
}
+ bool CacheOffByDefault = false;
if (NoCaseCompare(HeightGenName, "flat") == 0)
{
int Height = a_IniFile.GetValueI("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)
{
@@ -201,6 +203,21 @@ void cChunkGenerator::InitHeightGen(cIniFile & a_IniFile)
}
m_HeightGen = new cHeiGenBiomal(m_Seed, *m_BiomeGen);
}
+
+ // Add a cache, if requested:
+ int CacheSize = a_IniFile.GetValueI("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);
+ m_HeightGen = new cHeiGenCache(m_HeightGen, CacheSize);
+ }
}