diff options
Diffstat (limited to 'src/server/chunk_data.hh')
| -rw-r--r-- | src/server/chunk_data.hh | 30 |
1 files changed, 30 insertions, 0 deletions
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 <memory> +#include <optional> +#include <unordered_set> + +#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<std::shared_ptr<server::world::chunk>> chunk; + // players associated with the chunk + std::unordered_set<shared::player::index_t> players; + +public: + server::world::chunk& get_chunk() noexcept { return *(*this->chunk); } + bool has_initialised() const noexcept { return chunk.has_value(); } +}; + +} // namespace server + +#endif |
