1
0

Added a cHeiGenCache object for caching generated heightmaps. World generation is now about twice as fast as before Rev 535 :)

git-svn-id: http://mc-server.googlecode.com/svn/trunk@538 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
madmaxoft@gmail.com
2012-06-02 13:45:57 +00:00
parent 5e831256ef
commit 39a59d6806
3 changed files with 143 additions and 0 deletions

View File

@@ -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);
}
}