Cuberite
A lightweight, fast and extensible game server for Minecraft
Classes | Public Member Functions | Protected Attributes | List of all members
cHeiGenCache Class Reference

A simple cache that stores N most recently generated chunks' heightmaps; N being settable upon creation. More...

#include <HeiGen.h>

Inheritance diagram for cHeiGenCache:
Inheritance graph
[legend]
Collaboration diagram for cHeiGenCache:
Collaboration graph
[legend]

Classes

struct  sCacheData
 

Public Member Functions

 cHeiGenCache (cTerrainHeightGen &a_HeiGenToCache, size_t a_CacheSize)
 
virtual void GenHeightMap (cChunkCoords a_ChunkCoords, cChunkDef::HeightMap &a_HeightMap) override
 Retrieves the heightmap for the specified chunk. More...
 
virtual HEIGHTTYPE GetHeightAt (int a_BlockX, int a_BlockZ) override
 Returns the height at the specified column. More...
 
bool GetHeightAt (int a_ChunkX, int a_ChunkZ, int a_RelX, int a_RelZ, HEIGHTTYPE &a_Height)
 Retrieves height at the specified point in the cache, returns true if found, false if not found. More...
 
- Public Member Functions inherited from cTerrainHeightGen
virtual void InitializeHeightGen (cIniFile &a_IniFile)
 Initializes the generator, reading its parameters from the INI file. More...
 
virtual ~cTerrainHeightGen ()
 

Protected Attributes

std::vector< sCacheDatam_CacheData
 
std::vector< size_t > m_CacheOrder
 
size_t m_CacheSize
 
cTerrainHeightGenm_HeiGenToCache
 The terrain height generator that is being cached. More...
 
size_t m_NumHits
 
size_t m_NumMisses
 
size_t m_TotalChain
 

Additional Inherited Members

- Static Public Member Functions inherited from cTerrainHeightGen
static std::unique_ptr< cTerrainHeightGenCreateHeightGen (cIniFile &a_IniFile, cBiomeGen &a_BiomeGen, int a_Seed, bool &a_CacheOffByDefault)
 Creates a cTerrainHeightGen descendant based on the INI file settings. More...
 

Detailed Description

A simple cache that stores N most recently generated chunks' heightmaps; N being settable upon creation.

Definition at line 27 of file HeiGen.h.

Constructor & Destructor Documentation

◆ cHeiGenCache()

cHeiGenCache::cHeiGenCache ( cTerrainHeightGen a_HeiGenToCache,
size_t  a_CacheSize 
)

Definition at line 109 of file HeiGen.cpp.

Member Function Documentation

◆ GenHeightMap()

void cHeiGenCache::GenHeightMap ( cChunkCoords  a_ChunkCoords,
cChunkDef::HeightMap a_HeightMap 
)
overridevirtual

Retrieves the heightmap for the specified chunk.

Implements cTerrainHeightGen.

Definition at line 128 of file HeiGen.cpp.

◆ GetHeightAt() [1/2]

HEIGHTTYPE cHeiGenCache::GetHeightAt ( int  a_BlockX,
int  a_BlockZ 
)
overridevirtual

Returns the height at the specified column.

The default implementation calls GenHeightMap(), and then queries the heightmap. Descendants may provide a better-performing method.

Reimplemented from cTerrainHeightGen.

Definition at line 181 of file HeiGen.cpp.

◆ GetHeightAt() [2/2]

bool cHeiGenCache::GetHeightAt ( int  a_ChunkX,
int  a_ChunkZ,
int  a_RelX,
int  a_RelZ,
HEIGHTTYPE a_Height 
)

Retrieves height at the specified point in the cache, returns true if found, false if not found.

Definition at line 202 of file HeiGen.cpp.

Member Data Documentation

◆ m_CacheData

std::vector<sCacheData> cHeiGenCache::m_CacheData
protected

Definition at line 58 of file HeiGen.h.

◆ m_CacheOrder

std::vector<size_t> cHeiGenCache::m_CacheOrder
protected

Definition at line 57 of file HeiGen.h.

◆ m_CacheSize

size_t cHeiGenCache::m_CacheSize
protected

Definition at line 56 of file HeiGen.h.

◆ m_HeiGenToCache

cTerrainHeightGen& cHeiGenCache::m_HeiGenToCache
protected

The terrain height generator that is being cached.

Definition at line 53 of file HeiGen.h.

◆ m_NumHits

size_t cHeiGenCache::m_NumHits
protected

Definition at line 61 of file HeiGen.h.

◆ m_NumMisses

size_t cHeiGenCache::m_NumMisses
protected

Definition at line 62 of file HeiGen.h.

◆ m_TotalChain

size_t cHeiGenCache::m_TotalChain
protected

Definition at line 63 of file HeiGen.h.


The documentation for this class was generated from the following files: