diff options
| author | Nicolas James <Eele1Ephe7uZahRie@tutanota.com> | 2025-02-12 21:57:46 +1100 |
|---|---|---|
| committer | Nicolas James <Eele1Ephe7uZahRie@tutanota.com> | 2025-02-12 21:57:46 +1100 |
| commit | e4483eca01b48b943cd0461e24a74ae1a3139ed4 (patch) | |
| tree | ed58c3c246e3af1af337697695d780aa31f6ad9a /src/server/world.hh | |
| parent | 1cc08c51eb4b0f95c30c0a98ad1fc5ad3459b2df (diff) | |
Update to most recent version (old initial commit)
Diffstat (limited to 'src/server/world.hh')
| -rw-r--r-- | src/server/world.hh | 59 |
1 files changed, 0 insertions, 59 deletions
diff --git a/src/server/world.hh b/src/server/world.hh deleted file mode 100644 index 134f63b..0000000 --- a/src/server/world.hh +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef SERVER_WORLD_HH_ -#define SERVER_WORLD_HH_ - -#include <cstdint> - -#include "server/database.hh" -#include "server/shared.hh" -#include "shared/math.hh" -#include "shared/net/net.hh" -#include "shared/net/proto.hh" -#include "shared/player.hh" -#include "shared/world.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; - } - bool get_should_update() noexcept { return this->should_update; } - -private: - proto::packet make_chunk_packet() const noexcept; - -public: - // Attempt to read the file using protobuf, otherwise create a new chunk. - // chunk(const chunk&) = delete; - chunk(const uint64_t& seed, const shared::math::coords& coords) noexcept; - ~chunk() noexcept; - - // Update the chunk_packet associated with the chunk if necessary. - void update() noexcept { - if (!this->should_update) { - return; - } - this->packet = make_chunk_packet(); - this->should_update = false; - } - // calling .write before the destrutor will not result in a double write - void write() noexcept { - if (!this->should_write) { - return; - } - server::database::write_chunk(this->pos, this->packet.chunk_packet()); - this->should_write = false; - } -}; - -} // namespace world -} // namespace server - -#endif |
