aboutsummaryrefslogtreecommitdiff
path: root/src/server/world/chunk.cc
blob: 80a3da9e3e0076ff50d78671e15b6005a3d0267a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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