summaryrefslogtreecommitdiffstats
path: root/src/Generating/BioGen.cpp
diff options
context:
space:
mode:
authorMasy98 <masy@antheruscraft.de>2014-09-05 11:27:21 +0200
committerMasy98 <masy@antheruscraft.de>2014-09-05 11:27:21 +0200
commit15bee41a3657498e0072007e24abec50aac2c8df (patch)
tree863ae0ba1fef38d5da79aeb357e955c52d838caa /src/Generating/BioGen.cpp
parentAdded new recipes! (diff)
parentMerge pull request #1375 from mc-server/EntitiesInBox (diff)
downloadcuberite-15bee41a3657498e0072007e24abec50aac2c8df.tar
cuberite-15bee41a3657498e0072007e24abec50aac2c8df.tar.gz
cuberite-15bee41a3657498e0072007e24abec50aac2c8df.tar.bz2
cuberite-15bee41a3657498e0072007e24abec50aac2c8df.tar.lz
cuberite-15bee41a3657498e0072007e24abec50aac2c8df.tar.xz
cuberite-15bee41a3657498e0072007e24abec50aac2c8df.tar.zst
cuberite-15bee41a3657498e0072007e24abec50aac2c8df.zip
Diffstat (limited to 'src/Generating/BioGen.cpp')
-rw-r--r--src/Generating/BioGen.cpp55
1 files changed, 54 insertions, 1 deletions
diff --git a/src/Generating/BioGen.cpp b/src/Generating/BioGen.cpp
index 8fad9f5c9..175e4ef33 100644
--- a/src/Generating/BioGen.cpp
+++ b/src/Generating/BioGen.cpp
@@ -151,7 +151,7 @@ void cBioGenCache::GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a
LOGD("BioGenCache: %d hits, %d misses, saved %.2f %%", m_NumHits, m_NumMisses, 100.0 * m_NumHits / (m_NumHits + m_NumMisses));
LOGD("BioGenCache: Avg cache chain length: %.2f", (float)m_TotalChain / m_NumHits);
}
-
+
for (int i = 0; i < m_CacheSize; i++)
{
if (
@@ -208,6 +208,59 @@ void cBioGenCache::InitializeBiomeGen(cIniFile & a_IniFile)
+////////////////////////////////////////////////////////////////////////////////
+// cBioGenMulticache:
+
+cBioGenMulticache::cBioGenMulticache(cBiomeGen * a_BioGenToCache, size_t a_CacheSize, size_t a_CachesLength) :
+ m_CachesLength(a_CachesLength)
+{
+ m_Caches.reserve(a_CachesLength);
+ for (size_t i = 0; i < a_CachesLength; i++)
+ {
+ m_Caches.push_back(new cBioGenCache(a_BioGenToCache, a_CacheSize));
+ }
+}
+
+
+
+
+
+cBioGenMulticache::~cBioGenMulticache()
+{
+ for (std::vector<cBiomeGen*>::iterator it = m_Caches.begin(); it != m_Caches.end(); it++)
+ {
+ delete *it;
+ }
+}
+
+
+
+
+
+void cBioGenMulticache::GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap)
+{
+ const size_t coefficient = 3;
+ const size_t cacheIdx = ((size_t)a_ChunkX + coefficient * (size_t)a_ChunkZ) % m_CachesLength;
+
+ m_Caches[cacheIdx]->GenBiomes(a_ChunkX, a_ChunkZ, a_BiomeMap);
+}
+
+
+
+
+
+void cBioGenMulticache::InitializeBiomeGen(cIniFile & a_IniFile)
+{
+ for (std::vector<cBiomeGen*>::iterator it = m_Caches.begin(); it != m_Caches.end(); it++)
+ {
+ cBiomeGen * tmp = *it;
+ tmp->InitializeBiomeGen(a_IniFile);
+ }
+}
+
+
+
+
////////////////////////////////////////////////////////////////////////////////
// cBiomeGenList: