VOX
A little voxel engine
Loading...
Searching...
No Matches
ServerWorld Class Reference

#include <ServerWorld.hpp>

Inheritance diagram for ServerWorld:
Inheritance graph
Collaboration diagram for ServerWorld:
Collaboration graph

Classes

struct  BlockUpdateData
 
struct  ChunkLoadUnloadData
 
struct  Ticket
 

Public Types

typedef std::unordered_multimap< uint64_t, TicketTicketMultiMap
 

Public Member Functions

 ServerWorld (Server &server)
 
 ~ServerWorld ()
 
 ServerWorld (ServerWorld &other)=delete
 
 ServerWorld (ServerWorld &&other)=delete
 
ServerWorldoperator= (ServerWorld &other)=delete
 
ServerWorldoperator= (ServerWorld &&other)=delete
 
void update ()
 
void addBlockUpdate (const BlockUpdateData &data)
 
void updateBlocks ()
 
void placeBlock (const glm::vec3 &position, BlockInfo::Type block)
 
void setBlock (const glm::vec3 &position, BlockInfo::Type block)
 
void setPlayerTicketLevel (const int &level)
 
int getLoadDistance () const
 
const std::unordered_set< glm::ivec3 > & getBlockUpdateChunks () const
 Get the list of Chunks that need to get a block update tick. More...
 
const std::unordered_set< glm::ivec3 > & getEntityUpdateChunks () const
 Get the list of Chunks that need to get an entity update tick. More...
 
const TicketMultiMapgetTickets () const
 Get the list of Tickets ( May contains duplicates ) More...
 
uint64_t addTicket (const Ticket &ticket)
 Add a ticket to the ticket manager. More...
 
void removeTicket (const uint64_t &ticket_id)
 Remove a ticket from the ticket manager. More...
 
uint64_t changeTicket (const uint64_t &old_ticket_id, const Ticket &new_ticket)
 Shortcut to remove a ticket and add a new one. More...
 
void handlePacket (std::shared_ptr< IPacket > packet)
 
- Public Member Functions inherited from World
 World (bool save=false)
 
 ~World ()
 
 World (World &other)=delete
 
 World (World &&other)=delete
 
Worldoperator= (World &other)=delete
 
Worldoperator= (World &&other)=delete
 
std::shared_ptr< ChunkgetChunk (const glm::ivec3 &position)
 Get the Chunk object. More...
 
void insertChunk (const glm::ivec3 &position, std::shared_ptr< Chunk > chunk)
 
void unloadRegion (const glm::ivec2 region_pos)
 Unloads all chunk inside a region, if save is enabled, will save the region in a region file. More...
 
WorldGeneratorgetWorldGenerator ()
 
SavegetSave ()
 

Additional Inherited Members

- Static Public Member Functions inherited from World
static glm::vec3 getBlockChunkPosition (const glm::vec3 &position)
 will return the block position relative to the chunk More...
 
static glm::vec3 getChunkPosition (const glm::vec3 &position)
 will return the chunk position containing the block More...
 
- Protected Member Functions inherited from World
 TracyLockableN (std::mutex, m_players_mutex, "Players")
 
 TracyLockableN (std::mutex, m_mobs_mutex, "Mobs")
 
 TracyLockableN (std::mutex, m_chunks_mutex, "Chunks")
 
std::shared_ptr< ChunkgetChunkNoLock (const glm::ivec3 &position)
 Get a chunk ptr without locking the chunks mutex. More...
 
void insertChunkNoLock (const glm::ivec3 &position, std::shared_ptr< Chunk > chunk)
 
std::unordered_set< glm::ivec3 > updateSkyLight (const glm::ivec3 &block_position)
 Update the sky light of the chunk containing the block. More...
 
std::unordered_set< glm::ivec3 > updateBlockLight (const glm::ivec3 &block_position)
 Update the block light of the chunk containing the block. More...
 
- Protected Attributes inherited from World
std::unordered_map< uint64_t, std::shared_ptr< Player > > m_players
 
std::unordered_map< uint64_t, std::shared_ptr< Mob > > m_mobs
 
uint64_t m_mob_id = 0
 
std::unordered_map< glm::ivec3, std::shared_ptr< Chunk > > m_chunks
 
ExecutorAccessor m_executor
 
WorldGenerator m_world_generator
 
std::unique_ptr< Savem_save
 

Member Typedef Documentation

◆ TicketMultiMap

typedef std::unordered_multimap<uint64_t, Ticket> ServerWorld::TicketMultiMap

Constructor & Destructor Documentation

◆ ServerWorld() [1/3]

ServerWorld::ServerWorld ( Server server)

◆ ~ServerWorld()

ServerWorld::~ServerWorld ( )

◆ ServerWorld() [2/3]

ServerWorld::ServerWorld ( ServerWorld other)
delete

◆ ServerWorld() [3/3]

ServerWorld::ServerWorld ( ServerWorld &&  other)
delete

Member Function Documentation

◆ addBlockUpdate()

void ServerWorld::addBlockUpdate ( const BlockUpdateData data)

◆ addTicket()

uint64_t ServerWorld::addTicket ( const Ticket ticket)

Add a ticket to the ticket manager.

The new ticket will be active on the next tick

You can keep track of the ticket for further deletion with the ticket id

Parameters
ticket
Returns
uint64_t

◆ changeTicket()

uint64_t ServerWorld::changeTicket ( const uint64_t &  old_ticket_id,
const Ticket new_ticket 
)

Shortcut to remove a ticket and add a new one.

the new ticket will be active on the next tick

you can keep track of the ticket for further deletion with the ticket id

Parameters
old_ticket_id
new_ticket
Returns
uint64_t

◆ getBlockUpdateChunks()

const std::unordered_set< glm::ivec3 > & ServerWorld::getBlockUpdateChunks ( ) const

Get the list of Chunks that need to get a block update tick.

Returns
const std::unordered_set<glm::ivec3>&

◆ getEntityUpdateChunks()

const std::unordered_set< glm::ivec3 > & ServerWorld::getEntityUpdateChunks ( ) const

Get the list of Chunks that need to get an entity update tick.

Returns
const std::unordered_set<glm::ivec3>&

◆ getLoadDistance()

int ServerWorld::getLoadDistance ( ) const

◆ getTickets()

const ServerWorld::TicketMultiMap & ServerWorld::getTickets ( ) const

Get the list of Tickets ( May contains duplicates )

Returns
const TicketMultiMap&

◆ handlePacket()

void ServerWorld::handlePacket ( std::shared_ptr< IPacket packet)

◆ operator=() [1/2]

ServerWorld & ServerWorld::operator= ( ServerWorld &&  other)
delete

◆ operator=() [2/2]

ServerWorld & ServerWorld::operator= ( ServerWorld other)
delete

◆ placeBlock()

void ServerWorld::placeBlock ( const glm::vec3 &  position,
BlockInfo::Type  block 
)

◆ removeTicket()

void ServerWorld::removeTicket ( const uint64_t &  ticket_id)

Remove a ticket from the ticket manager.

Parameters
ticket_id

◆ setBlock()

void ServerWorld::setBlock ( const glm::vec3 &  position,
BlockInfo::Type  block 
)

◆ setPlayerTicketLevel()

void ServerWorld::setPlayerTicketLevel ( const int &  level)

◆ update()

void ServerWorld::update ( )

◆ updateBlocks()

void ServerWorld::updateBlocks ( )

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