#ifndef SERVER_CHUNK_DATA_HH_ #define SERVER_CHUNK_DATA_HH_ #include #include #include #include "server/world/chunk.hh" #include "shared/entity/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