From 1cc08c51eb4b0f95c30c0a98ad1fc5ad3459b2df Mon Sep 17 00:00:00 2001 From: Nicolas James Date: Wed, 12 Feb 2025 18:05:18 +1100 Subject: initial commit --- src/server/chunk_data.hh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/server/chunk_data.hh (limited to 'src/server/chunk_data.hh') diff --git a/src/server/chunk_data.hh b/src/server/chunk_data.hh new file mode 100644 index 0000000..eea5cef --- /dev/null +++ b/src/server/chunk_data.hh @@ -0,0 +1,30 @@ +#ifndef SERVER_CHUNK_DATA_HH_ +#define SERVER_CHUNK_DATA_HH_ + +#include +#include +#include + +#include "server/world.hh" +#include "shared/player.hh" + +namespace server { + +struct chunk_data { +public: + // nullopt = constructing/destructing via future operations in thread pool + // we use shared_ptr here to avoid complex moves in boost::asio::post. + // There is no good reason to use shared_ptr over unique_ptr, other than + // boost::asio::post requiring copy_constructable args in std::bind. + std::optional> chunk; + // players associated with the chunk + std::unordered_set players; + +public: + server::world::chunk& get_chunk() noexcept { return *(*this->chunk); } + bool has_initialised() const noexcept { return chunk.has_value(); } +}; + +} // namespace server + +#endif -- cgit v1.2.3