aboutsummaryrefslogtreecommitdiff
path: root/src/server/world.cc
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.cc
parent1cc08c51eb4b0f95c30c0a98ad1fc5ad3459b2df (diff)
Update to most recent version (old initial commit)
Diffstat (limited to 'src/server/world.cc')
-rw-r--r--src/server/world.cc53
1 files changed, 0 insertions, 53 deletions
diff --git a/src/server/world.cc b/src/server/world.cc
deleted file mode 100644
index 6527d6c..0000000
--- a/src/server/world.cc
+++ /dev/null
@@ -1,53 +0,0 @@
-#include "server/world.hh"
-
-namespace server {
-namespace world {
-
-proto::packet chunk::make_chunk_packet() const noexcept {
-
- proto::packet ret_packet;
-
- auto chunk_packet = ret_packet.mutable_chunk_packet();
-
- auto chunk_pos = chunk_packet->mutable_chunk_pos();
- const shared::math::coords this_chunk_pos = this->get_pos();
- chunk_pos->set_x(this_chunk_pos.x);
- chunk_pos->set_z(this_chunk_pos.z);
-
- // Since protobuf can store at minimum uint32, we mash four of our
- // uint_8 chunk blocks into a single uint32.
- static_assert(shared::world::chunk::VOLUME % 4 == 0);
- for (unsigned i = 0u; i < shared::world::chunk::VOLUME / 4u; ++i) {
- std::uint32_t packed_blocks = 0u;
-
- for (unsigned j = 0; j < 4; ++j) {
- const auto block =
- static_cast<std::uint8_t>(this->blocks[i * 4 + j].type);
- packed_blocks |= static_cast<unsigned>(block << j * 8);
- }
-
- chunk_packet->add_blocks(packed_blocks);
- }
-
- return ret_packet;
-}
-
-static std::optional<shared::world::chunk::block_array>
-maybe_get_blocks(const shared::math::coords& coords) {
- const auto chunk = database::maybe_read_chunk(coords);
- if (!chunk.has_value()) {
- return std::nullopt;
- }
- return shared::world::chunk::make_blocks_from_chunk(chunk.value());
-}
-
-chunk::chunk(const std::uint64_t& seed,
- const shared::math::coords& coords) noexcept
- : shared::world::chunk(seed, coords, maybe_get_blocks(coords)) {
- this->update();
-}
-
-chunk::~chunk() noexcept { this->write(); }
-
-} // namespace world
-} // namespace server