diff options
Diffstat (limited to 'src/server/world/chunk.cc')
| -rw-r--r-- | src/server/world/chunk.cc | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/server/world/chunk.cc b/src/server/world/chunk.cc new file mode 100644 index 0000000..80a3da9 --- /dev/null +++ b/src/server/world/chunk.cc @@ -0,0 +1,26 @@ +#include "server/world/chunk.hh" + +namespace server { +namespace world { + +void chunk::update() noexcept { + if (!this->should_update) { + return; + } + this->packet.clear_chunk_packet(); + this->pack(packet.mutable_chunk_packet()); + this->should_update = false; +} + +void chunk::write() noexcept { + if (!this->should_write) { + return; + } + server::database::write_chunk(this->pos, this->packet.chunk_packet()); + this->should_write = false; +} + +chunk::~chunk() noexcept { this->write(); } + +} // namespace world +} // namespace server |
