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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user