9#include <unordered_set>
87 return std::hash<int>()(ticket.
level) ^ std::hash<glm::ivec3>()(ticket.
position);
93 return std::hash<int>()(
level) ^ std::hash<glm::ivec3>()(
position);
164 std::unordered_map<uint64_t, uint64_t> m_player_to_connection_id;
165 std::unordered_map<uint64_t, uint64_t> m_connection_to_player_id;
166 TracyLockableN(std::mutex, m_players_info_mutex,
"PlayerInfoMutex");
168 void handleBlockActionPacket(std::shared_ptr<BlockActionPacket> packet);
169 void handleConnectionPacket(std::shared_ptr<ConnectionPacket> packet);
170 void handlePlayerMovePacket(std::shared_ptr<PlayerMovePacket> packet);
171 void handleDisconnectPacket(std::shared_ptr<DisconnectPacket> packet);
172 void handleLoadDistancePacket(std::shared_ptr<LoadDistancePacket> packet);
173 void handlePingPacket(std::shared_ptr<PingPacket> packet);
183 constexpr static int TICKET_LEVEL_ENTITY_UPDATE = 31;
184 constexpr static int TICKET_LEVEL_BLOCK_UPDATE = 32;
185 constexpr static int TICKET_LEVEL_BORDER = 33;
186 constexpr static int TICKET_LEVEL_INACTIVE = 34;
188 constexpr static int SPAWN_TICKET_LEVEL = 34;
189 constexpr static int DEFAULT_PLAYER_TICKET_LEVEL = 31;
190 int m_player_ticket_level = DEFAULT_PLAYER_TICKET_LEVEL;
196 std::unordered_multiset<uint64_t> m_tickets_to_remove;
198 std::unordered_set<glm::ivec3> m_block_update_chunks;
199 std::unordered_set<glm::ivec3> m_entity_update_chunks;
200 std::unordered_set<glm::ivec3> m_border_chunks;
201 std::unordered_set<glm::ivec2> m_regions_to_unload;
203 mutable TracyLockableN(std::mutex, m_tickets_mutex,
"TicketManager");
218 void updateTickets();
228 void floodFill(
const TicketMultiMap & tickets, WorldGenerator::ChunkGenList & chunk_gen_list);
231 void clearChunksLoadLevel();
246 bool applyTicketToChunk(
const Ticket & ticket, WorldGenerator::ChunkGenList & chunk_gen_list);
250 std::queue<BlockUpdateData> m_block_updates;
251 mutable TracyLockableN(std::mutex, m_block_updates_mutex,
"BlockUpdateQueue");
254 void doChunkGens(WorldGenerator::ChunkGenList & chunks_to_gen);
256 void unloadEmptyRegions();
270 std::queue<glm::ivec3> m_block_light_update;
271 TracyLockableN (std::mutex, m_block_light_update_mutex,
"Block light update");
276 ChunkLoadUnloadData updateChunkObservations(uint64_t player_id,
const int & old_load_distance);
277 void removeAllPlayerObservations(std::shared_ptr<Player> player);
278 void removePlayerObservation(uint64_t player_id, std::shared_ptr<Chunk> chunk);
283 std::unordered_map<uint64_t, glm::dvec3> m_last_tick_player_positions;
284 std::unordered_map<uint64_t, glm::dvec3> m_current_tick_player_positions;
288 std::shared_ptr<task::TaskGraph> graph;
289 std::future<void> future;
290 TracyLockableN(std::mutex, m_chunk_gen_data_mutex,
"ChunkFuturesIds");
293 chunkGenData m_chunk_gen_data;
302 void savePlayerPositions();
303 void updatePlayerPositions();
304 void waitForChunkFutures();
308 int player_ticket_level = DEFAULT_PLAYER_TICKET_LEVEL;
309 bool player_ticket_level_changed =
false;
317 void updateTickedValues();
328 return std::hash<int>()(ticket.
level) ^ std::hash<glm::ivec3>()(ticket.
position);
Type
Definition: Block.hpp:33
genLevel
Definition: Chunk.hpp:30
Definition: ServerWorld.hpp:16
void removeTicket(const uint64_t &ticket_id)
Remove a ticket from the ticket manager.
Definition: ServerWorldTickets.cpp:27
int getLoadDistance() const
Definition: ServerWorld.cpp:124
void setBlock(const glm::vec3 &position, BlockInfo::Type block)
Definition: ServerWorldBlocks.cpp:83
const std::unordered_set< glm::ivec3 > & getEntityUpdateChunks() const
Get the list of Chunks that need to get an entity update tick.
Definition: ServerWorldTickets.cpp:8
ServerWorld & operator=(ServerWorld &&other)=delete
ServerWorld(ServerWorld &other)=delete
std::unordered_multimap< uint64_t, Ticket > TicketMultiMap
Definition: ServerWorld.hpp:96
void update()
Definition: ServerWorld.cpp:30
void handlePacket(std::shared_ptr< IPacket > packet)
Definition: ServerWorldNetwork.cpp:3
uint64_t addTicket(const Ticket &ticket)
Add a ticket to the ticket manager.
Definition: ServerWorldTickets.cpp:19
ServerWorld & operator=(ServerWorld &other)=delete
void addBlockUpdate(const BlockUpdateData &data)
Definition: ServerWorldBlocks.cpp:39
void placeBlock(const glm::vec3 &position, BlockInfo::Type block)
Definition: ServerWorldBlocks.cpp:58
const TicketMultiMap & getTickets() const
Get the list of Tickets ( May contains duplicates )
Definition: ServerWorldTickets.cpp:13
void updateBlocks()
Definition: ServerWorldBlocks.cpp:3
~ServerWorld()
Definition: ServerWorld.cpp:26
void setPlayerTicketLevel(const int &level)
Definition: ServerWorldTickets.cpp:41
ServerWorld(ServerWorld &&other)=delete
const std::unordered_set< glm::ivec3 > & getBlockUpdateChunks() const
Get the list of Chunks that need to get a block update tick.
Definition: ServerWorldTickets.cpp:3
uint64_t changeTicket(const uint64_t &old_ticket_id, const Ticket &new_ticket)
Shortcut to remove a ticket and add a new one.
Definition: ServerWorldTickets.cpp:33
The server side interface with the network module.
Definition: Server.hpp:33
Definition: Executor.hpp:21
Definition: ObjLoader.hpp:65
Definition: ServerWorld.hpp:41
glm::ivec3 position
Definition: ServerWorld.hpp:50
Type
Definition: ServerWorld.hpp:43
Type type
Definition: ServerWorld.hpp:49
BlockInfo::Type block
Definition: ServerWorld.hpp:51
Definition: ServerWorld.hpp:27
std::vector< std::shared_ptr< Chunk > > chunks_to_load
Definition: ServerWorld.hpp:28
std::vector< glm::ivec3 > chunks_to_unload
Definition: ServerWorld.hpp:29
Definition: ServerWorld.hpp:84
std::size_t operator()(const ServerWorld::Ticket &ticket) const
Definition: ServerWorld.hpp:85
Definition: ServerWorld.hpp:74
enum ServerWorld::Ticket::Type type
std::size_t hash() const
Definition: ServerWorld.hpp:91
bool operator==(const Ticket &other) const =default
glm::ivec3 position
Definition: ServerWorld.hpp:82
Type
Definition: ServerWorld.hpp:77
int level
Definition: ServerWorld.hpp:81
std::size_t operator()(const ServerWorld::Ticket &ticket) const
Definition: ServerWorld.hpp:326