From 39a59d68061710db886bc00cb571c6feb8cbdc65 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Sat, 2 Jun 2012 13:45:57 +0000 Subject: 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 --- source/cChunkGenerator.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'source/cChunkGenerator.cpp') 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); + } } -- cgit v1.2.3