Cuberite
A lightweight, fast and extensible game server for Minecraft
|
Makes chunks stay loaded until this object is cleared or destroyed Works by setting internal flags in the cChunk that it should not be unloaded. More...
#include <ChunkStay.h>
Public Member Functions | |
void | Add (int a_ChunkX, int a_ChunkZ) |
Adds a chunk to be locked from unloading. More... | |
cChunkStay (void) | |
void | Clear (void) |
Clears all the chunks that have been added. More... | |
virtual void | Disable (void) |
Disables the ChunkStay, the chunks are released and the ChunkStay object can be edited with Add() and Remove() again. More... | |
void | Enable (cChunkMap &a_ChunkMap) |
Enables the ChunkStay on the specified chunkmap, causing it to load and generate chunks. More... | |
const cChunkCoordsVector & | GetChunks (void) const |
Returns all the chunks that should be kept. More... | |
virtual bool | OnAllChunksAvailable (void)=0 |
Called once all of the contained chunks are available. More... | |
virtual void | OnChunkAvailable (int a_ChunkX, int a_ChunkZ)=0 |
Called when a specific chunk become available. More... | |
virtual void | OnDisabled (void)=0 |
Called by the ChunkMap when the ChunkStay is disabled. More... | |
void | Remove (int a_ChunkX, int a_ChunkZ) |
Releases the chunk so that it's no longer locked from unloading. More... | |
virtual | ~cChunkStay () |
Deletes the object. More... | |
Protected Member Functions | |
bool | ChunkAvailable (int a_ChunkX, int a_ChunkZ) |
Called by cChunkMap when a chunk is available, checks m_NumLoaded and triggers the appropriate callbacks. More... | |
Protected Attributes | |
cChunkMap * | m_ChunkMap |
The chunkmap where the object is enabled. More... | |
cChunkCoordsVector | m_Chunks |
The list of chunks to lock from unloading. More... | |
cChunkCoordsVector | m_OutstandingChunks |
The chunks that still need loading. More... | |
Friends | |
class | cChunkMap |
Makes chunks stay loaded until this object is cleared or destroyed Works by setting internal flags in the cChunk that it should not be unloaded.
To optimize for speed, cChunkStay has an Enabled flag, it will "stay" the chunks only when enabled and it will refuse chunk-list manipulations when enabled. The object itself is not made thread-safe, it's supposed to be used from a single thread only. This class is abstract, the descendants are expected to provide the OnChunkAvailable() and the OnAllChunksAvailable() callback implementations. Note that those are called from the contexts of different threads' - the caller, the Loader or the Generator thread.
Definition at line 35 of file ChunkStay.h.
cChunkStay::cChunkStay | ( | void | ) |
Definition at line 14 of file ChunkStay.cpp.
|
virtual |
Deletes the object.
Note that this calls Clear(), which means that the ChunkStay needs to be disabled.
Definition at line 23 of file ChunkStay.cpp.
void cChunkStay::Add | ( | int | a_ChunkX, |
int | a_ChunkZ | ||
) |
Adds a chunk to be locked from unloading.
To be used only while the ChunkStay object is not enabled.
Definition at line 42 of file ChunkStay.cpp.
|
protected |
Called by cChunkMap when a chunk is available, checks m_NumLoaded and triggers the appropriate callbacks.
May be called for chunks outside this ChunkStay. Returns true if the ChunkStay is to be automatically disabled by the ChunkMap; returns false to keep the ChunkStay.
Definition at line 106 of file ChunkStay.cpp.
void cChunkStay::Clear | ( | void | ) |
Clears all the chunks that have been added.
To be used only while the ChunkStay object is not enabled.
Definition at line 32 of file ChunkStay.cpp.
|
virtual |
Disables the ChunkStay, the chunks are released and the ChunkStay object can be edited with Add() and Remove() again.
Definition at line 93 of file ChunkStay.cpp.
void cChunkStay::Enable | ( | cChunkMap & | a_ChunkMap | ) |
Enables the ChunkStay on the specified chunkmap, causing it to load and generate chunks.
All the contained chunks are queued for loading / generating.
Definition at line 80 of file ChunkStay.cpp.
|
inline |
Returns all the chunks that should be kept.
Definition at line 63 of file ChunkStay.h.
|
pure virtual |
Called once all of the contained chunks are available.
If returns true, the ChunkStay is automatically disabled by the ChunkMap; if it returns false, the ChunkStay is kept.
Implemented in cNetherPortalScanner, cLightingThread::cLightingChunkStay, and cLuaChunkStay.
|
pure virtual |
Called when a specific chunk become available.
Implemented in cLightingThread::cLightingChunkStay, cLuaChunkStay, and cNetherPortalScanner.
|
pure virtual |
Called by the ChunkMap when the ChunkStay is disabled.
The object may choose to delete itself.
Implemented in cNetherPortalScanner, cLightingThread::cLightingChunkStay, and cLuaChunkStay.
void cChunkStay::Remove | ( | int | a_ChunkX, |
int | a_ChunkZ | ||
) |
Releases the chunk so that it's no longer locked from unloading.
To be used only while the ChunkStay object is not enabled.
Definition at line 61 of file ChunkStay.cpp.
|
friend |
Definition at line 77 of file ChunkStay.h.
|
protected |
The chunkmap where the object is enabled.
Valid only after call to Enable() and before Disable().
Definition at line 82 of file ChunkStay.h.
|
protected |
The list of chunks to lock from unloading.
Definition at line 85 of file ChunkStay.h.
|
protected |
The chunks that still need loading.
Definition at line 88 of file ChunkStay.h.