summaryrefslogtreecommitdiffstats
path: root/source/BioGen.h
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-06-02 15:21:59 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-06-02 15:21:59 +0200
commit5e831256ef838e0238a6fd5eaf3b3e39791c6d77 (patch)
treeb525331223279e19a4916a4b0295f3fb618e3b2d /source/BioGen.h
parentAdded the Biomal height generator, made it the default height generator. (diff)
downloadcuberite-5e831256ef838e0238a6fd5eaf3b3e39791c6d77.tar
cuberite-5e831256ef838e0238a6fd5eaf3b3e39791c6d77.tar.gz
cuberite-5e831256ef838e0238a6fd5eaf3b3e39791c6d77.tar.bz2
cuberite-5e831256ef838e0238a6fd5eaf3b3e39791c6d77.tar.lz
cuberite-5e831256ef838e0238a6fd5eaf3b3e39791c6d77.tar.xz
cuberite-5e831256ef838e0238a6fd5eaf3b3e39791c6d77.tar.zst
cuberite-5e831256ef838e0238a6fd5eaf3b3e39791c6d77.zip
Diffstat (limited to '')
-rw-r--r--source/BioGen.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/source/BioGen.h b/source/BioGen.h
index e701b6ec9..9a119ef2e 100644
--- a/source/BioGen.h
+++ b/source/BioGen.h
@@ -39,6 +39,42 @@ protected:
+/// A simple cache that stores N most recently generated chunks' biomes; N being settable upon creation
+class cBioGenCache :
+ public cBiomeGen
+{
+public:
+ cBioGenCache(cBiomeGen * a_BioGenToCache, int a_CacheSize); // Takes ownership of a_BioGenToCache
+ ~cBioGenCache();
+
+protected:
+
+ cBiomeGen * m_BioGenToCache;
+
+ struct sCacheData
+ {
+ int m_ChunkX;
+ int m_ChunkZ;
+ cChunkDef::BiomeMap m_BiomeMap;
+ } ;
+
+ // To avoid moving large amounts of data for the MRU behavior, we MRU-ize indices to an array of the actual data
+ int m_CacheSize;
+ int * m_CacheOrder; // MRU-ized order, indices into m_CacheData array
+ sCacheData * m_CacheData; // m_CacheData[m_CacheOrder[0]] is the most recently used
+
+ // Cache statistics
+ int m_NumHits;
+ int m_NumMisses;
+ int m_TotalChain; // Number of cache items walked to get to a hit (only added for hits)
+
+ virtual void GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap) override;
+} ;
+
+
+
+
+
/// Base class for generators that use a list of available biomes. This class takes care of the list.
class cBiomeGenList :
public cBiomeGen