aboutsummaryrefslogtreecommitdiff
path: root/src/server/world/chunk.hh
diff options
context:
space:
mode:
authorNicolas James <Eele1Ephe7uZahRie@tutanota.com>2025-02-12 21:57:46 +1100
committerNicolas James <Eele1Ephe7uZahRie@tutanota.com>2025-02-12 21:57:46 +1100
commite4483eca01b48b943cd0461e24a74ae1a3139ed4 (patch)
treeed58c3c246e3af1af337697695d780aa31f6ad9a /src/server/world/chunk.hh
parent1cc08c51eb4b0f95c30c0a98ad1fc5ad3459b2df (diff)
Update to most recent version (old initial commit)
Diffstat (limited to 'src/server/world/chunk.hh')
-rw-r--r--src/server/world/chunk.hh46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/server/world/chunk.hh b/src/server/world/chunk.hh
new file mode 100644
index 0000000..b8fc73c
--- /dev/null
+++ b/src/server/world/chunk.hh
@@ -0,0 +1,46 @@
+#ifndef SERVER_WORLD_CHUNK_HH_
+#define SERVER_WORLD_CHUNK_HH_
+
+#include <cstdint>
+
+#include "server/database.hh"
+#include "server/shared.hh"
+#include "shared/entity/player.hh"
+#include "shared/math/math.hh"
+#include "shared/net/net.hh"
+#include "shared/net/proto.hh"
+#include "shared/world/chunk.hh"
+
+namespace server {
+namespace world {
+
+class chunk : public shared::world::chunk {
+private:
+ bool should_write = false;
+ bool should_update = true;
+
+public:
+ proto::packet packet; // Packet ready for sending, updated in update().
+ void arm_should_update() noexcept {
+ this->should_update = this->should_write = true;
+ }
+
+public:
+ template <typename... Args>
+ chunk(Args&&... args) noexcept
+ : shared::world::chunk(std::forward<Args>(args)...) {
+ this->pack(packet.mutable_chunk_packet());
+ }
+ virtual ~chunk() noexcept;
+
+public:
+ // Update the chunk_packet associated with the chunk if necessary.
+ void update() noexcept;
+ // calling .write before the destrutor will not result in a double write
+ void write() noexcept;
+};
+
+} // namespace world
+} // namespace server
+
+#endif