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

#include <ChunkSender.h>

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

Classes

struct  sChunkQueue
 
struct  sSendChunk
 Used for sending chunks to specific clients. More...
 

Public Types

enum class  Priority { Low , Medium , High , Critical }
 Tag indicating urgency of chunk to be sent. More...
 

Public Member Functions

 cChunkSender (cWorld &a_World)
 
void QueueSendChunkTo (int a_ChunkX, int a_ChunkZ, Priority a_Priority, cClientHandle *a_Client)
 Queues a chunk to be sent to a specific client. More...
 
void QueueSendChunkTo (int a_ChunkX, int a_ChunkZ, Priority a_Priority, const std::vector< cClientHandle * > &a_Clients)
 
void Stop (void)
 
virtual ~cChunkSender () override
 
- Public Member Functions inherited from cIsThread
 cIsThread (AString &&a_ThreadName)
 
bool IsCurrentThread (void) const
 Returns true if the thread calling this function is the thread contained within this object. More...
 
void Start (void)
 Starts the thread; returns without waiting for the actual start. More...
 
void Stop (void)
 Signals the thread to terminate and waits until it's finished. More...
 
virtual ~cIsThread ()
 

Protected Types

using WeakClients = std::set< std::weak_ptr< cClientHandle >, std::owner_less< std::weak_ptr< cClientHandle > >>
 

Protected Member Functions

virtual void BiomeMap (const cChunkDef::BiomeMap &a_BiomeMap) override
 
virtual void BlockEntity (cBlockEntity *a_Entity) override
 
virtual void Entity (cEntity *a_Entity) override
 
virtual void Execute (void) override
 This function, overloaded by the descendants, is called in the new thread. More...
 
void SendChunk (int a_ChunkX, int a_ChunkZ, const WeakClients &a_Clients)
 Sends the specified chunk to all the specified clients. More...
 

Protected Attributes

unsigned char m_BiomeMap [cChunkDef::Width *cChunkDef::Width]
 
std::vector< Vector3im_BlockEntities
 
std::unordered_map< cChunkCoords, sSendChunk, cChunkCoordsHashm_ChunkInfo
 
cCriticalSection m_CS
 
std::vector< UInt32m_EntityIDs
 
cEvent m_evtQueue
 
std::priority_queue< sChunkQueuem_SendChunks
 
cChunkDataSerializer m_Serializer
 An instance of a chunk serializer, held to maintain its internal cache. More...
 
cWorldm_World
 
- Protected Attributes inherited from cIsThread
std::atomic< bool > m_ShouldTerminate
 The overriden Execute() method should check this value periodically and terminate if this is true. More...
 

Private Types

using Super = cIsThread
 

Additional Inherited Members

- Public Attributes inherited from cChunkDataCopyCollector
ChunkBlockData m_BlockData
 
ChunkLightData m_LightData
 

Detailed Description

Definition at line 50 of file ChunkSender.h.

Member Typedef Documentation

◆ Super

using cChunkSender::Super = cIsThread
private

Definition at line 54 of file ChunkSender.h.

◆ WeakClients

using cChunkSender::WeakClients = std::set<std::weak_ptr<cClientHandle>, std::owner_less<std::weak_ptr<cClientHandle> >>
protected

Definition at line 79 of file ChunkSender.h.

Member Enumeration Documentation

◆ Priority

Tag indicating urgency of chunk to be sent.

Order MUST be from least to most urgent.

Enumerator
Low 
Medium 
High 
Critical 

Definition at line 63 of file ChunkSender.h.

Constructor & Destructor Documentation

◆ cChunkSender()

cChunkSender::cChunkSender ( cWorld a_World)

Definition at line 61 of file ChunkSender.cpp.

◆ ~cChunkSender()

cChunkSender::~cChunkSender ( )
overridevirtual

Definition at line 72 of file ChunkSender.cpp.

Member Function Documentation

◆ BiomeMap()

void cChunkSender::BiomeMap ( const cChunkDef::BiomeMap &  a_BiomeMap)
overrideprotectedvirtual

Definition at line 306 of file ChunkSender.cpp.

◆ BlockEntity()

void cChunkSender::BlockEntity ( cBlockEntity a_Entity)
overrideprotectedvirtual

Definition at line 288 of file ChunkSender.cpp.

◆ Entity()

void cChunkSender::Entity ( cEntity a_Entity)
overrideprotectedvirtual

Definition at line 297 of file ChunkSender.cpp.

◆ Execute()

void cChunkSender::Execute ( void  )
overrideprotectedvirtual

This function, overloaded by the descendants, is called in the new thread.

Implements cIsThread.

Definition at line 161 of file ChunkSender.cpp.

◆ QueueSendChunkTo() [1/2]

void cChunkSender::QueueSendChunkTo ( int  a_ChunkX,
int  a_ChunkZ,
Priority  a_Priority,
cClientHandle a_Client 
)

Queues a chunk to be sent to a specific client.

Definition at line 92 of file ChunkSender.cpp.

◆ QueueSendChunkTo() [2/2]

void cChunkSender::QueueSendChunkTo ( int  a_ChunkX,
int  a_ChunkZ,
Priority  a_Priority,
const std::vector< cClientHandle * > &  a_Clients 
)

Definition at line 124 of file ChunkSender.cpp.

◆ SendChunk()

void cChunkSender::SendChunk ( int  a_ChunkX,
int  a_ChunkZ,
const WeakClients a_Clients 
)
protected

Sends the specified chunk to all the specified clients.

Definition at line 194 of file ChunkSender.cpp.

◆ Stop()

void cChunkSender::Stop ( void  )

Definition at line 81 of file ChunkSender.cpp.

Member Data Documentation

◆ m_BiomeMap

unsigned char cChunkSender::m_BiomeMap[cChunkDef::Width *cChunkDef::Width]
protected

Definition at line 119 of file ChunkSender.h.

◆ m_BlockEntities

std::vector<Vector3i> cChunkSender::m_BlockEntities
protected

Definition at line 120 of file ChunkSender.h.

◆ m_ChunkInfo

std::unordered_map<cChunkCoords, sSendChunk, cChunkCoordsHash> cChunkSender::m_ChunkInfo
protected

Definition at line 114 of file ChunkSender.h.

◆ m_CS

cCriticalSection cChunkSender::m_CS
protected

Definition at line 112 of file ChunkSender.h.

◆ m_EntityIDs

std::vector<UInt32> cChunkSender::m_EntityIDs
protected

Definition at line 121 of file ChunkSender.h.

◆ m_evtQueue

cEvent cChunkSender::m_evtQueue
protected

Definition at line 115 of file ChunkSender.h.

◆ m_SendChunks

std::priority_queue<sChunkQueue> cChunkSender::m_SendChunks
protected

Definition at line 113 of file ChunkSender.h.

◆ m_Serializer

cChunkDataSerializer cChunkSender::m_Serializer
protected

An instance of a chunk serializer, held to maintain its internal cache.

Definition at line 110 of file ChunkSender.h.

◆ m_World

cWorld& cChunkSender::m_World
protected

Definition at line 107 of file ChunkSender.h.


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