aboutsummaryrefslogtreecommitdiff
path: root/src/server/chunk_data.hh
diff options
context:
space:
mode:
authorNicolas James <Eele1Ephe7uZahRie@tutanota.com>2025-02-12 18:05:18 +1100
committerNicolas James <Eele1Ephe7uZahRie@tutanota.com>2025-02-12 18:05:18 +1100
commit1cc08c51eb4b0f95c30c0a98ad1fc5ad3459b2df (patch)
tree222dfcd07a1e40716127a347bbfd7119ce3d0984 /src/server/chunk_data.hh
initial commit
Diffstat (limited to 'src/server/chunk_data.hh')
-rw-r--r--src/server/chunk_data.hh30
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