summaryrefslogtreecommitdiffstats
path: root/src/Generating
diff options
context:
space:
mode:
authorDayBr3ak <benj.groeneveld@gmail.com>2014-09-03 18:48:47 +0200
committerDayBr3ak <benj.groeneveld@gmail.com>2014-09-03 18:48:47 +0200
commitd2bacc34f6b4e9b0d7a6db9ba81d76c51b1fd60f (patch)
tree5f7b5c176666c80cbc6527928cdec56988138ed5 /src/Generating
parentadapting format (diff)
downloadcuberite-d2bacc34f6b4e9b0d7a6db9ba81d76c51b1fd60f.tar
cuberite-d2bacc34f6b4e9b0d7a6db9ba81d76c51b1fd60f.tar.gz
cuberite-d2bacc34f6b4e9b0d7a6db9ba81d76c51b1fd60f.tar.bz2
cuberite-d2bacc34f6b4e9b0d7a6db9ba81d76c51b1fd60f.tar.lz
cuberite-d2bacc34f6b4e9b0d7a6db9ba81d76c51b1fd60f.tar.xz
cuberite-d2bacc34f6b4e9b0d7a6db9ba81d76c51b1fd60f.tar.zst
cuberite-d2bacc34f6b4e9b0d7a6db9ba81d76c51b1fd60f.zip
Diffstat (limited to 'src/Generating')
-rw-r--r--src/Generating/BioGen.cpp13
-rw-r--r--src/Generating/BioGen.h3
2 files changed, 7 insertions, 9 deletions
diff --git a/src/Generating/BioGen.cpp b/src/Generating/BioGen.cpp
index 46516b327..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 (
@@ -212,11 +212,10 @@ 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_InternalCacheLength(a_CachesLength * a_CacheSize)
+ m_CachesLength(a_CachesLength)
{
- m_Caches.reserve(m_InternalCacheLength);
- for (size_t i = 0; i < m_InternalCacheLength; i++)
+ m_Caches.reserve(a_CachesLength);
+ for (size_t i = 0; i < a_CachesLength; i++)
{
m_Caches.push_back(new cBioGenCache(a_BioGenToCache, a_CacheSize));
}
@@ -240,8 +239,8 @@ cBioGenMulticache::~cBioGenMulticache()
void cBioGenMulticache::GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap)
{
- size_t cacheIdx = ((size_t)a_ChunkX % m_CachesLength) * m_CachesLength
- + ((size_t)a_ChunkZ % m_CachesLength);
+ 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);
}
diff --git a/src/Generating/BioGen.h b/src/Generating/BioGen.h
index 47383633f..a4cf95a72 100644
--- a/src/Generating/BioGen.h
+++ b/src/Generating/BioGen.h
@@ -95,8 +95,7 @@ public:
~cBioGenMulticache();
protected:
- size_t m_CachesLength;
- size_t m_InternalCacheLength; // used internally only
+ size_t m_CachesLength;
std::vector<cBiomeGen*> m_Caches;
virtual void GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap) override;