From e9076f22fe2a49d1cd8933e54b7b00c5dd943269 Mon Sep 17 00:00:00 2001 From: untodesu Date: Fri, 12 Sep 2025 13:33:52 +0500 Subject: It compiles --- game/server/receive.cc | 5 +++-- game/server/sessions.cc | 4 ++-- game/server/world/overworld.cc | 12 +++++++----- 3 files changed, 12 insertions(+), 9 deletions(-) (limited to 'game/server') diff --git a/game/server/receive.cc b/game/server/receive.cc index 75ac3a6..612674e 100644 --- a/game/server/receive.cc +++ b/game/server/receive.cc @@ -10,6 +10,7 @@ #include "shared/world/chunk_aabb.hh" #include "shared/world/dimension.hh" +#include "shared/world/voxel_registry.hh" #include "shared/coord.hh" #include "shared/protocol.hh" @@ -83,7 +84,7 @@ static void on_entity_head_packet(const protocol::EntityHead& packet) static void on_set_voxel_packet(const protocol::SetVoxel& packet) { if(auto session = sessions::find(packet.peer)) { - if(session->dimension && !session->dimension->set_voxel(packet.voxel, packet.vpos)) { + if(session->dimension && !session->dimension->set_voxel(world::voxel_registry::find(packet.voxel), packet.vpos)) { auto cpos = coord::to_chunk(packet.vpos); auto lpos = coord::to_local(packet.vpos); auto index = coord::to_index(lpos); @@ -102,7 +103,7 @@ static void on_set_voxel_packet(const protocol::SetVoxel& packet) return; } - chunk->set_voxel(packet.voxel, index); + chunk->set_voxel(world::voxel_registry::find(packet.voxel), index); session->dimension->chunks.emplace_or_replace(chunk->get_entity()); diff --git a/game/server/sessions.cc b/game/server/sessions.cc index c06ec3e..32b96a3 100644 --- a/game/server/sessions.cc +++ b/game/server/sessions.cc @@ -65,7 +65,7 @@ static void on_login_request_packet(const protocol::LoginRequest& packet) // FIXME: calculate voxel registry checksum ahead of time // instead of figuring it out every time a new player connects - if(packet.voxel_registry_checksum != world::voxel_registry::calculate_checksum()) { + if(packet.voxel_registry_checksum != world::voxel_registry::get_checksum()) { protocol::Disconnect response; response.reason = "protocol.voxel_registry_checksum"; protocol::send(packet.peer, protocol::encode(response)); @@ -241,7 +241,7 @@ static void on_voxel_set(const world::VoxelSetEvent& event) { protocol::SetVoxel packet; packet.vpos = coord::to_voxel(event.cpos, event.lpos); - packet.voxel = event.voxel; + packet.voxel = event.voxel ? event.voxel->get_id() : NULL_VOXEL_ID; packet.flags = 0U; // UNDONE protocol::broadcast(globals::server_host, protocol::encode(packet)); } diff --git a/game/server/world/overworld.cc b/game/server/world/overworld.cc index eb801de..43059d8 100644 --- a/game/server/world/overworld.cc +++ b/game/server/world/overworld.cc @@ -4,13 +4,15 @@ #include "core/math/vectors.hh" +#include "shared/world/voxel.hh" #include "shared/world/voxel_storage.hh" #include "shared/coord.hh" #include "shared/game_voxels.hh" // FIXME: load these from a file -static void compute_tree_feature(unsigned int height, world::Feature& feature, voxel_id log_voxel, voxel_id leaves_voxel) +static void compute_tree_feature(unsigned int height, world::Feature& feature, const world::Voxel* log_voxel, + const world::Voxel* leaves_voxel) { // Ensure the tree height is too small height = math::max(height, 4U); @@ -251,12 +253,12 @@ void world::Overworld::generate_terrain(const chunk_pos& cpos, VoxelStorage& vox } if(vpos.y < -variation) { - voxels[i] = game_voxels::stone; + voxels[i] = game_voxels::stone->get_id(); continue; } if(is_inside_terrain(vpos)) { - voxels[i] = game_voxels::stone; + voxels[i] = game_voxels::stone->get_id(); continue; } } @@ -308,10 +310,10 @@ void world::Overworld::generate_surface(const chunk_pos& cpos, VoxelStorage& vox if(depth < 5U) { if(depth == 0U) { - voxels[i] = game_voxels::grass; + voxels[i] = game_voxels::grass->get_id(); } else { - voxels[i] = game_voxels::dirt; + voxels[i] = game_voxels::dirt->get_id(); } } } -- cgit