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

#include <LuaChunkStay.h>

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

Public Member Functions

bool AddChunks (const cLuaState::cStackTable &a_ChunkCoords)
 Adds chunks in the specified Lua table. More...
 
 cLuaChunkStay ()
 
void Enable (cChunkMap &a_ChunkMap, cLuaState::cCallbackPtr a_OnChunkAvailable, cLuaState::cCallbackPtr a_OnAllChunksAvailable)
 Enables the ChunkStay for the specified chunkmap, with the specified Lua callbacks. More...
 
virtual ~cLuaChunkStay () override
 
- Public Member Functions inherited from cChunkStay
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 cChunkCoordsVectorGetChunks (void) const
 Returns all the chunks that should be kept. 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

void AddChunkCoord (cLuaState &a_LuaState, int a_Index)
 Adds a single chunk coord from the table at the top of the Lua stack. More...
 
virtual bool OnAllChunksAvailable (void) override
 Called once all of the contained chunks are available. More...
 
virtual void OnChunkAvailable (int a_ChunkX, int a_ChunkZ) override
 Called when a specific chunk become available. More...
 
virtual void OnDisabled (void) override
 Called by the ChunkMap when the ChunkStay is disabled. More...
 
- Protected Member Functions inherited from cChunkStay
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

cLuaState::cCallbackPtr m_OnAllChunksAvailable
 The Lua function to call in OnAllChunksAvailable. More...
 
cLuaState::cCallbackPtr m_OnChunkAvailable
 The Lua function to call in OnChunkAvailable. More...
 
- Protected Attributes inherited from cChunkStay
cChunkMapm_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...
 

Private Types

using Super = cChunkStay
 

Detailed Description

Definition at line 26 of file LuaChunkStay.h.

Member Typedef Documentation

◆ Super

Definition at line 29 of file LuaChunkStay.h.

Constructor & Destructor Documentation

◆ cLuaChunkStay()

cLuaChunkStay::cLuaChunkStay ( )

Definition at line 14 of file LuaChunkStay.cpp.

◆ ~cLuaChunkStay()

virtual cLuaChunkStay::~cLuaChunkStay ( )
inlineoverridevirtual

Definition at line 34 of file LuaChunkStay.h.

Member Function Documentation

◆ AddChunkCoord()

void cLuaChunkStay::AddChunkCoord ( cLuaState a_LuaState,
int  a_Index 
)
protected

Adds a single chunk coord from the table at the top of the Lua stack.

Expects the top element to be a table, checks that it contains two numbers. Uses those two numbers as chunk coords appended to m_Chunks. If the coords are already present, gives a warning and ignores the pair. The a_Index parameter is only for the error messages.

Definition at line 60 of file LuaChunkStay.cpp.

◆ AddChunks()

bool cLuaChunkStay::AddChunks ( const cLuaState::cStackTable a_ChunkCoords)

Adds chunks in the specified Lua table.

Can be called only once. Returns true if any chunk added, false (plus log warning) if none.

Definition at line 22 of file LuaChunkStay.cpp.

◆ Enable()

void cLuaChunkStay::Enable ( cChunkMap a_ChunkMap,
cLuaState::cCallbackPtr  a_OnChunkAvailable,
cLuaState::cCallbackPtr  a_OnAllChunksAvailable 
)

Enables the ChunkStay for the specified chunkmap, with the specified Lua callbacks.

Definition at line 98 of file LuaChunkStay.cpp.

◆ OnAllChunksAvailable()

bool cLuaChunkStay::OnAllChunksAvailable ( void  )
overrideprotectedvirtual

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.

Implements cChunkStay.

Definition at line 123 of file LuaChunkStay.cpp.

◆ OnChunkAvailable()

void cLuaChunkStay::OnChunkAvailable ( int  a_ChunkX,
int  a_ChunkZ 
)
overrideprotectedvirtual

Called when a specific chunk become available.

Implements cChunkStay.

Definition at line 111 of file LuaChunkStay.cpp.

◆ OnDisabled()

void cLuaChunkStay::OnDisabled ( void  )
overrideprotectedvirtual

Called by the ChunkMap when the ChunkStay is disabled.

The object may choose to delete itself.

Implements cChunkStay.

Definition at line 143 of file LuaChunkStay.cpp.

Member Data Documentation

◆ m_OnAllChunksAvailable

cLuaState::cCallbackPtr cLuaChunkStay::m_OnAllChunksAvailable
protected

The Lua function to call in OnAllChunksAvailable.

Only valid when enabled.

Definition at line 49 of file LuaChunkStay.h.

◆ m_OnChunkAvailable

cLuaState::cCallbackPtr cLuaChunkStay::m_OnChunkAvailable
protected

The Lua function to call in OnChunkAvailable.

Only valid when enabled.

Definition at line 46 of file LuaChunkStay.h.


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