summaryrefslogtreecommitdiffstats
path: root/src/game/shared
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/shared')
-rw-r--r--src/game/shared/entity/collision.cc32
-rw-r--r--src/game/shared/entity/collision.hh12
-rw-r--r--src/game/shared/entity/factory.cc12
-rw-r--r--src/game/shared/entity/factory.hh9
-rw-r--r--src/game/shared/entity/gravity.cc4
-rw-r--r--src/game/shared/entity/gravity.hh8
-rw-r--r--src/game/shared/entity/grounded.hh5
-rw-r--r--src/game/shared/entity/head.hh7
-rw-r--r--src/game/shared/entity/player.hh3
-rw-r--r--src/game/shared/entity/stasis.cc8
-rw-r--r--src/game/shared/entity/stasis.hh8
-rw-r--r--src/game/shared/entity/transform.cc6
-rw-r--r--src/game/shared/entity/transform.hh14
-rw-r--r--src/game/shared/entity/velocity.cc4
-rw-r--r--src/game/shared/entity/velocity.hh10
-rw-r--r--src/game/shared/game.cc18
-rw-r--r--src/game/shared/game_items.cc54
-rw-r--r--src/game/shared/game_items.hh21
-rw-r--r--src/game/shared/game_voxels.cc112
-rw-r--r--src/game/shared/game_voxels.hh25
-rw-r--r--src/game/shared/protocol.cc26
-rw-r--r--src/game/shared/protocol.hh17
-rw-r--r--src/game/shared/splash.cc2
-rw-r--r--src/game/shared/world/chunk.cc22
-rw-r--r--src/game/shared/world/chunk.hh6
-rw-r--r--src/game/shared/world/chunk_aabb.hh3
-rw-r--r--src/game/shared/world/dimension.cc34
-rw-r--r--src/game/shared/world/dimension.hh20
-rw-r--r--src/game/shared/world/feature.cc6
-rw-r--r--src/game/shared/world/feature.hh6
-rw-r--r--src/game/shared/world/item.cc16
-rw-r--r--src/game/shared/world/item.hh19
-rw-r--r--src/game/shared/world/item_registry.cc16
-rw-r--r--src/game/shared/world/item_registry.hh16
-rw-r--r--src/game/shared/world/ray_dda.cc14
-rw-r--r--src/game/shared/world/ray_dda.hh6
-rw-r--r--src/game/shared/world/voxel.cc44
-rw-r--r--src/game/shared/world/voxel.hh57
-rw-r--r--src/game/shared/world/voxel_registry.cc16
-rw-r--r--src/game/shared/world/voxel_registry.hh16
-rw-r--r--src/game/shared/world/voxel_storage.cc4
-rw-r--r--src/game/shared/world/voxel_storage.hh10
42 files changed, 312 insertions, 436 deletions
diff --git a/src/game/shared/entity/collision.cc b/src/game/shared/entity/collision.cc
index bc9209b..af23047 100644
--- a/src/game/shared/entity/collision.cc
+++ b/src/game/shared/entity/collision.cc
@@ -15,8 +15,8 @@
#include "shared/coord.hh"
#include "shared/globals.hh"
-static int vgrid_collide(const world::Dimension* dimension, int d, entity::Collision& collision, entity::Transform& transform,
- entity::Velocity& velocity, world::VoxelMaterial& touch_surface)
+static int vgrid_collide(const Dimension* dimension, int d, Collision& collision, Transform& transform, Velocity& velocity,
+ VoxelMaterial& touch_surface)
{
const auto move = globals::fixed_frametime * velocity.value[d];
const auto move_sign = math::sign<int>(move);
@@ -57,9 +57,9 @@ static int vgrid_collide(const world::Dimension* dimension, int d, entity::Colli
dmax = lpos_min[d];
}
- world::VoxelTouch latch_touch = world::VTOUCH_NONE;
+ VoxelTouch latch_touch = VTOUCH_NONE;
glm::fvec3 latch_values = glm::fvec3(0.0f, 0.0f, 0.0f);
- world::VoxelMaterial latch_surface = world::VMAT_UNKNOWN;
+ VoxelMaterial latch_surface = VMAT_UNKNOWN;
math::AABBf latch_vbox;
for(auto i = dmin; i != dmax; i += ddir) {
@@ -87,7 +87,7 @@ static int vgrid_collide(const world::Dimension* dimension, int d, entity::Colli
continue;
}
- if(voxel->is_touch_type<world::VTOUCH_SOLID>()) {
+ if(voxel->is_touch_type<VTOUCH_SOLID>()) {
// Solid touch type makes a collision
// response whenever it is encountered
velocity.value[d] = 0.0f;
@@ -98,7 +98,7 @@ static int vgrid_collide(const world::Dimension* dimension, int d, entity::Colli
// In case of other touch types, they
// are latched and the last ever touch
// type is then responded to
- if(voxel->get_touch_type() != world::VTOUCH_NONE) {
+ if(voxel->get_touch_type() != VTOUCH_NONE) {
latch_touch = voxel->get_touch_type();
latch_values = voxel->get_touch_values();
latch_surface = voxel->get_surface_material();
@@ -108,8 +108,8 @@ static int vgrid_collide(const world::Dimension* dimension, int d, entity::Colli
}
}
- if(latch_touch != world::VTOUCH_NONE) {
- if(latch_touch == world::VTOUCH_BOUNCE) {
+ if(latch_touch != VTOUCH_NONE) {
+ if(latch_touch == VTOUCH_BOUNCE) {
const auto move_distance = glm::abs(current_aabb.min[d] - next_aabb.min[d]);
const auto threshold = 2.0f * globals::fixed_frametime;
@@ -125,7 +125,7 @@ static int vgrid_collide(const world::Dimension* dimension, int d, entity::Colli
return move_sign;
}
- if(latch_touch == world::VTOUCH_SINK) {
+ if(latch_touch == VTOUCH_SINK) {
velocity.value[d] *= latch_values[d];
touch_surface = latch_surface;
return move_sign;
@@ -135,7 +135,7 @@ static int vgrid_collide(const world::Dimension* dimension, int d, entity::Colli
return 0;
}
-void entity::Collision::fixed_update(world::Dimension* dimension)
+void Collision::fixed_update(Dimension* dimension)
{
// FIXME: this isn't particularly accurate considering
// some voxels might be passable and some other voxels
@@ -146,25 +146,25 @@ void entity::Collision::fixed_update(world::Dimension* dimension)
// we shouldn't treat all voxels as full cubes if we want
// to support slabs, stairs and non-full liquid voxels in the future
- auto group = dimension->entities.group<entity::Collision>(entt::get<entity::Transform, entity::Velocity>);
+ auto group = dimension->entities.group<Collision>(entt::get<Transform, Velocity>);
for(auto [entity, collision, transform, velocity] : group.each()) {
- auto surface = world::VMAT_UNKNOWN;
+ auto surface = VMAT_UNKNOWN;
auto vertical_move = vgrid_collide(dimension, 1, collision, transform, velocity, surface);
- if(dimension->entities.any_of<entity::Gravity>(entity)) {
+ if(dimension->entities.any_of<Gravity>(entity)) {
if(vertical_move == math::sign<int>(dimension->get_gravity())) {
- dimension->entities.emplace_or_replace<entity::Grounded>(entity, entity::Grounded { surface });
+ dimension->entities.emplace_or_replace<Grounded>(entity, Grounded { surface });
}
else {
- dimension->entities.remove<entity::Grounded>(entity);
+ dimension->entities.remove<Grounded>(entity);
}
}
else {
// The entity cannot be grounded because the component
// setup of said entity should not let it comprehend the
// concept of resting on the ground (it flies around)
- dimension->entities.remove<entity::Grounded>(entity);
+ dimension->entities.remove<Grounded>(entity);
}
vgrid_collide(dimension, 0, collision, transform, velocity, surface);
diff --git a/src/game/shared/entity/collision.hh b/src/game/shared/entity/collision.hh
index b37f409..34a648c 100644
--- a/src/game/shared/entity/collision.hh
+++ b/src/game/shared/entity/collision.hh
@@ -2,20 +2,14 @@
#include "core/math/aabb.hh"
-namespace world
-{
class Dimension;
-} // namespace world
-namespace entity
-{
struct Collision final {
math::AABBf aabb;
public:
- // NOTE: entity::Collision::fixed_update must be called
- // before entity::Transform::fixed_update and entity::Velocity::fixed_update
+ // NOTE: Collision::fixed_update must be called
+ // before Transform::fixed_update and Velocity::fixed_update
// because both transform and velocity may be updated internally
- static void fixed_update(world::Dimension* dimension);
+ static void fixed_update(Dimension* dimension);
};
-} // namespace entity
diff --git a/src/game/shared/entity/factory.cc b/src/game/shared/entity/factory.cc
index 619a418..f2031df 100644
--- a/src/game/shared/entity/factory.cc
+++ b/src/game/shared/entity/factory.cc
@@ -13,25 +13,25 @@
#include "shared/globals.hh"
-void entity::shared::create_player(world::Dimension* dimension, entt::entity entity)
+void shared::create_player(Dimension* dimension, entt::entity entity)
{
spdlog::debug("factory[{}]: assigning player components to {}", dimension->get_name(), static_cast<std::uint64_t>(entity));
- auto& collision = dimension->entities.emplace_or_replace<entity::Collision>(entity);
+ auto& collision = dimension->entities.emplace_or_replace<Collision>(entity);
collision.aabb.min = glm::fvec3(-0.4f, -1.6f, -0.4f);
collision.aabb.max = glm::fvec3(+0.4f, +0.2f, +0.4f);
- auto& head = dimension->entities.emplace_or_replace<entity::Head>(entity);
+ auto& head = dimension->entities.emplace_or_replace<Head>(entity);
head.angles = glm::fvec3(0.0f, 0.0f, 0.0f);
head.offset = glm::fvec3(0.0f, 0.0f, 0.0f);
- dimension->entities.emplace_or_replace<entity::Player>(entity);
+ dimension->entities.emplace_or_replace<Player>(entity);
- auto& transform = dimension->entities.emplace_or_replace<entity::Transform>(entity);
+ auto& transform = dimension->entities.emplace_or_replace<Transform>(entity);
transform.chunk = chunk_pos(0, 2, 0);
transform.local = glm::fvec3(0.0f, 0.0f, 0.0f);
transform.angles = glm::fvec3(0.0f, 0.0f, 0.0f);
- auto& velocity = dimension->entities.emplace_or_replace<entity::Velocity>(entity);
+ auto& velocity = dimension->entities.emplace_or_replace<Velocity>(entity);
velocity.value = glm::fvec3(0.0f, 0.0f, 0.0f);
}
diff --git a/src/game/shared/entity/factory.hh b/src/game/shared/entity/factory.hh
index e709060..7c94136 100644
--- a/src/game/shared/entity/factory.hh
+++ b/src/game/shared/entity/factory.hh
@@ -1,11 +1,8 @@
#pragma once
-namespace world
-{
class Dimension;
-} // namespace world
-namespace entity::shared
+namespace shared
{
-void create_player(world::Dimension* dimension, entt::entity entity);
-} // namespace entity::shared
+void create_player(Dimension* dimension, entt::entity entity);
+} // namespace shared
diff --git a/src/game/shared/entity/gravity.cc b/src/game/shared/entity/gravity.cc
index f1708aa..6a5145f 100644
--- a/src/game/shared/entity/gravity.cc
+++ b/src/game/shared/entity/gravity.cc
@@ -9,10 +9,10 @@
#include "shared/globals.hh"
-void entity::Gravity::fixed_update(world::Dimension* dimension)
+void Gravity::fixed_update(Dimension* dimension)
{
auto fixed_acceleration = globals::fixed_frametime * dimension->get_gravity();
- auto group = dimension->entities.group<entity::Gravity>(entt::get<entity::Velocity>, entt::exclude<entity::Stasis>);
+ auto group = dimension->entities.group<Gravity>(entt::get<Velocity>, entt::exclude<Stasis>);
for(auto [entity, velocity] : group.each()) {
velocity.value.y += fixed_acceleration;
diff --git a/src/game/shared/entity/gravity.hh b/src/game/shared/entity/gravity.hh
index 21f4582..38b3c9b 100644
--- a/src/game/shared/entity/gravity.hh
+++ b/src/game/shared/entity/gravity.hh
@@ -1,14 +1,8 @@
#pragma once
-namespace world
-{
class Dimension;
-} // namespace world
-namespace entity
-{
struct Gravity final {
public:
- static void fixed_update(world::Dimension* dimension);
+ static void fixed_update(Dimension* dimension);
};
-} // namespace entity
diff --git a/src/game/shared/entity/grounded.hh b/src/game/shared/entity/grounded.hh
index 6c33d1d..7307e79 100644
--- a/src/game/shared/entity/grounded.hh
+++ b/src/game/shared/entity/grounded.hh
@@ -2,11 +2,8 @@
#include "shared/world/voxel.hh"
-namespace entity
-{
// Assigned to entities which are grounded
// according to the collision and gravity system
struct Grounded final {
- world::VoxelMaterial surface;
+ VoxelMaterial surface;
};
-} // namespace entity
diff --git a/src/game/shared/entity/head.hh b/src/game/shared/entity/head.hh
index 3f5d6d1..9fa71d9 100644
--- a/src/game/shared/entity/head.hh
+++ b/src/game/shared/entity/head.hh
@@ -1,16 +1,13 @@
#pragma once
-namespace entity
-{
struct Head {
glm::fvec3 angles;
glm::fvec3 offset;
};
-} // namespace entity
-namespace entity::client
+namespace client
{
// Client-side only - interpolated and previous head
struct HeadIntr final : public Head {};
struct HeadPrev final : public Head {};
-} // namespace entity::client
+} // namespace client
diff --git a/src/game/shared/entity/player.hh b/src/game/shared/entity/player.hh
index 4bd0217..d7cd020 100644
--- a/src/game/shared/entity/player.hh
+++ b/src/game/shared/entity/player.hh
@@ -1,6 +1,3 @@
#pragma once
-namespace entity
-{
struct Player final {};
-} // namespace entity
diff --git a/src/game/shared/entity/stasis.cc b/src/game/shared/entity/stasis.cc
index 3b86294..0b8a0c8 100644
--- a/src/game/shared/entity/stasis.cc
+++ b/src/game/shared/entity/stasis.cc
@@ -6,16 +6,16 @@
#include "shared/world/dimension.hh"
-void entity::Stasis::fixed_update(world::Dimension* dimension)
+void Stasis::fixed_update(Dimension* dimension)
{
- auto view = dimension->entities.view<entity::Transform>();
+ auto view = dimension->entities.view<Transform>();
for(auto [entity, transform] : view.each()) {
if(dimension->find_chunk(transform.chunk)) {
- dimension->entities.remove<entity::Stasis>(entity);
+ dimension->entities.remove<Stasis>(entity);
}
else {
- dimension->entities.emplace_or_replace<entity::Stasis>(entity);
+ dimension->entities.emplace_or_replace<Stasis>(entity);
}
}
}
diff --git a/src/game/shared/entity/stasis.hh b/src/game/shared/entity/stasis.hh
index e6cb9e4..5adc592 100644
--- a/src/game/shared/entity/stasis.hh
+++ b/src/game/shared/entity/stasis.hh
@@ -1,16 +1,10 @@
#pragma once
-namespace world
-{
class Dimension;
-} // namespace world
-namespace entity
-{
// Attached to entities with transform values
// out of bounds in a specific dimension
struct Stasis final {
public:
- static void fixed_update(world::Dimension* dimension);
+ static void fixed_update(Dimension* dimension);
};
-} // namespace entity
diff --git a/src/game/shared/entity/transform.cc b/src/game/shared/entity/transform.cc
index 379ddd5..cf09e2f 100644
--- a/src/game/shared/entity/transform.cc
+++ b/src/game/shared/entity/transform.cc
@@ -6,7 +6,7 @@
#include "shared/const.hh"
-constexpr inline static void update_component(unsigned int dim, entity::Transform& component)
+constexpr inline static void update_component(unsigned int dim, Transform& component)
{
if(component.local[dim] >= CHUNK_SIZE) {
component.local[dim] -= CHUNK_SIZE;
@@ -21,9 +21,9 @@ constexpr inline static void update_component(unsigned int dim, entity::Transfor
}
}
-void entity::Transform::fixed_update(world::Dimension* dimension)
+void Transform::fixed_update(Dimension* dimension)
{
- auto view = dimension->entities.view<entity::Transform>();
+ auto view = dimension->entities.view<Transform>();
for(auto [entity, transform] : view.each()) {
update_component(0U, transform);
diff --git a/src/game/shared/entity/transform.hh b/src/game/shared/entity/transform.hh
index 2b357f8..afbe9fa 100644
--- a/src/game/shared/entity/transform.hh
+++ b/src/game/shared/entity/transform.hh
@@ -2,29 +2,23 @@
#include "shared/types.hh"
-namespace world
-{
class Dimension;
-} // namespace world
-namespace entity
-{
struct Transform {
chunk_pos chunk;
glm::fvec3 local;
glm::fvec3 angles;
public:
- // Updates entity::Transform values so that
+ // Updates Transform values so that
// the local translation field is always within
// local coodrinates; [floating-point precision]
- static void fixed_update(world::Dimension* dimension);
+ static void fixed_update(Dimension* dimension);
};
-} // namespace entity
-namespace entity::client
+namespace client
{
// Client-side only - interpolated and previous transform
struct TransformIntr final : public Transform {};
struct TransformPrev final : public Transform {};
-} // namespace entity::client
+} // namespace client
diff --git a/src/game/shared/entity/velocity.cc b/src/game/shared/entity/velocity.cc
index 86df445..6fb8c80 100644
--- a/src/game/shared/entity/velocity.cc
+++ b/src/game/shared/entity/velocity.cc
@@ -9,9 +9,9 @@
#include "shared/globals.hh"
-void entity::Velocity::fixed_update(world::Dimension* dimension)
+void Velocity::fixed_update(Dimension* dimension)
{
- auto group = dimension->entities.group<entity::Velocity>(entt::get<entity::Transform>, entt::exclude<entity::Stasis>);
+ auto group = dimension->entities.group<Velocity>(entt::get<Transform>, entt::exclude<Stasis>);
for(auto [entity, velocity, transform] : group.each()) {
transform.local += velocity.value * globals::fixed_frametime;
diff --git a/src/game/shared/entity/velocity.hh b/src/game/shared/entity/velocity.hh
index c8a1c91..69fce9e 100644
--- a/src/game/shared/entity/velocity.hh
+++ b/src/game/shared/entity/velocity.hh
@@ -1,19 +1,13 @@
#pragma once
-namespace world
-{
class Dimension;
-} // namespace world
-namespace entity
-{
struct Velocity final {
glm::fvec3 value;
public:
- // Updates entities entity::Transform values
+ // Updates entities Transform values
// according to velocities multiplied by fixed_frametime.
// NOTE: This system was previously called inertial
- static void fixed_update(world::Dimension* dimension);
+ static void fixed_update(Dimension* dimension);
};
-} // namespace entity
diff --git a/src/game/shared/game.cc b/src/game/shared/game.cc
index a3a724d..e839e6a 100644
--- a/src/game/shared/game.cc
+++ b/src/game/shared/game.cc
@@ -7,7 +7,7 @@
static std::filesystem::path get_gamepath(void)
{
- if(auto gamepath = io::cmdline::get_cstr("gamepath")) {
+ if(auto gamepath = cmdline::get_cstr("gamepath")) {
// Allow users and third-party launchers to override
// content location. Perhaps this would work to allow
// for a Minecraft-like versioning approach?
@@ -19,7 +19,7 @@ static std::filesystem::path get_gamepath(void)
static std::filesystem::path get_userpath(void)
{
- if(auto userpath = io::cmdline::get_cstr("userpath")) {
+ if(auto userpath = cmdline::get_cstr("userpath")) {
// Allow users and third-party launchers to override
// user data location. Perhaps this would work to allow
// for a Minecraft-like versioning approach?
@@ -67,10 +67,10 @@ void shared_game::init(int argc, char** argv, std::string_view logfile)
constexpr auto default_loglevel = spdlog::level::trace;
#endif
- if(io::cmdline::contains("quiet")) {
+ if(cmdline::contains("quiet")) {
logger->set_level(spdlog::level::warn);
}
- else if(io::cmdline::contains("verbose")) {
+ else if(cmdline::contains("verbose")) {
logger->set_level(spdlog::level::trace);
}
else {
@@ -81,7 +81,7 @@ void shared_game::init(int argc, char** argv, std::string_view logfile)
logger->flush();
if(!PHYSFS_init(argv[0])) {
- spdlog::critical("physfs: init failed: {}", io::physfs_error());
+ spdlog::critical("physfs: init failed: {}", physfs_error());
std::terminate();
}
@@ -96,17 +96,17 @@ void shared_game::init(int argc, char** argv, std::string_view logfile)
std::filesystem::create_directories(userpath, ignore_error);
if(!PHYSFS_mount(gamepath.string().c_str(), nullptr, false)) {
- spdlog::critical("physfs: mount {} failed: {}", gamepath.string(), io::physfs_error());
+ spdlog::critical("physfs: mount {} failed: {}", gamepath.string(), physfs_error());
std::terminate();
}
if(!PHYSFS_mount(userpath.string().c_str(), nullptr, false)) {
- spdlog::critical("physfs: mount {} failed: {}", userpath.string(), io::physfs_error());
+ spdlog::critical("physfs: mount {} failed: {}", userpath.string(), physfs_error());
std::terminate();
}
if(!PHYSFS_setWriteDir(userpath.string().c_str())) {
- spdlog::critical("physfs: setwritedir {} failed: {}", userpath.string(), io::physfs_error());
+ spdlog::critical("physfs: setwritedir {} failed: {}", userpath.string(), physfs_error());
std::terminate();
}
@@ -121,7 +121,7 @@ void shared_game::shutdown(void)
enet_deinitialize();
if(!PHYSFS_deinit()) {
- spdlog::critical("physfs: deinit failed: {}", io::physfs_error());
+ spdlog::critical("physfs: deinit failed: {}", physfs_error());
std::terminate();
}
}
diff --git a/src/game/shared/game_items.cc b/src/game/shared/game_items.cc
index e239063..73f7cef 100644
--- a/src/game/shared/game_items.cc
+++ b/src/game/shared/game_items.cc
@@ -6,60 +6,60 @@
#include "shared/game_voxels.hh"
-const world::Item* game_items::stone = nullptr;
-const world::Item* game_items::cobblestone = nullptr;
-const world::Item* game_items::dirt = nullptr;
-const world::Item* game_items::grass = nullptr;
-const world::Item* game_items::oak_leaves = nullptr;
-const world::Item* game_items::oak_planks = nullptr;
-const world::Item* game_items::oak_log = nullptr;
-const world::Item* game_items::glass = nullptr;
-const world::Item* game_items::slime = nullptr;
+const Item* game_items::stone = nullptr;
+const Item* game_items::cobblestone = nullptr;
+const Item* game_items::dirt = nullptr;
+const Item* game_items::grass = nullptr;
+const Item* game_items::oak_leaves = nullptr;
+const Item* game_items::oak_planks = nullptr;
+const Item* game_items::oak_log = nullptr;
+const Item* game_items::glass = nullptr;
+const Item* game_items::slime = nullptr;
void game_items::populate(void)
{
- auto stone_builder = world::ItemBuilder("stone");
+ auto stone_builder = ItemBuilder("stone");
stone_builder.set_texture("textures/item/stone.png");
stone_builder.set_place_voxel(game_voxels::stone);
- stone = world::item_registry::register_item(stone_builder);
+ stone = item_registry::register_item(stone_builder);
- auto cobblestone_builder = world::ItemBuilder("cobblestone");
+ auto cobblestone_builder = ItemBuilder("cobblestone");
cobblestone_builder.set_texture("textures/item/cobblestone.png");
cobblestone_builder.set_place_voxel(game_voxels::cobblestone);
- cobblestone = world::item_registry::register_item(cobblestone_builder);
+ cobblestone = item_registry::register_item(cobblestone_builder);
- auto dirt_builder = world::ItemBuilder("dirt");
+ auto dirt_builder = ItemBuilder("dirt");
dirt_builder.set_texture("textures/item/dirt.png");
dirt_builder.set_place_voxel(game_voxels::dirt);
- dirt = world::item_registry::register_item(dirt_builder);
+ dirt = item_registry::register_item(dirt_builder);
- auto grass_builder = world::ItemBuilder("grass");
+ auto grass_builder = ItemBuilder("grass");
grass_builder.set_texture("textures/item/grass.png");
grass_builder.set_place_voxel(game_voxels::grass);
- grass = world::item_registry::register_item(grass_builder);
+ grass = item_registry::register_item(grass_builder);
- auto oak_leaves_builder = world::ItemBuilder("oak_leaves");
+ auto oak_leaves_builder = ItemBuilder("oak_leaves");
oak_leaves_builder.set_texture("textures/item/oak_leaves.png");
oak_leaves_builder.set_place_voxel(game_voxels::oak_leaves);
- oak_leaves = world::item_registry::register_item(oak_leaves_builder);
+ oak_leaves = item_registry::register_item(oak_leaves_builder);
- auto oak_planks_builder = world::ItemBuilder("oak_planks");
+ auto oak_planks_builder = ItemBuilder("oak_planks");
oak_planks_builder.set_texture("textures/item/oak_planks.png");
oak_planks_builder.set_place_voxel(game_voxels::oak_planks);
- oak_planks = world::item_registry::register_item(oak_planks_builder);
+ oak_planks = item_registry::register_item(oak_planks_builder);
- auto oak_log_builder = world::ItemBuilder("oak_log");
+ auto oak_log_builder = ItemBuilder("oak_log");
oak_log_builder.set_texture("textures/item/oak_log.png");
oak_log_builder.set_place_voxel(game_voxels::oak_log);
- oak_log = world::item_registry::register_item(oak_log_builder);
+ oak_log = item_registry::register_item(oak_log_builder);
- auto glass_builder = world::ItemBuilder("glass");
+ auto glass_builder = ItemBuilder("glass");
glass_builder.set_texture("textures/item/glass.png");
glass_builder.set_place_voxel(game_voxels::glass);
- glass = world::item_registry::register_item(glass_builder);
+ glass = item_registry::register_item(glass_builder);
- auto slime_builder = world::ItemBuilder("slime");
+ auto slime_builder = ItemBuilder("slime");
slime_builder.set_texture("textures/item/slime.png");
slime_builder.set_place_voxel(game_voxels::slime);
- slime = world::item_registry::register_item(slime_builder);
+ slime = item_registry::register_item(slime_builder);
}
diff --git a/src/game/shared/game_items.hh b/src/game/shared/game_items.hh
index c9b3638..1170543 100644
--- a/src/game/shared/game_items.hh
+++ b/src/game/shared/game_items.hh
@@ -1,21 +1,18 @@
#pragma once
-namespace world
-{
class Item;
-} // namespace world
namespace game_items
{
-extern const world::Item* stone;
-extern const world::Item* cobblestone;
-extern const world::Item* dirt;
-extern const world::Item* grass;
-extern const world::Item* oak_leaves;
-extern const world::Item* oak_planks;
-extern const world::Item* oak_log;
-extern const world::Item* glass;
-extern const world::Item* slime;
+extern const Item* stone;
+extern const Item* cobblestone;
+extern const Item* dirt;
+extern const Item* grass;
+extern const Item* oak_leaves;
+extern const Item* oak_planks;
+extern const Item* oak_log;
+extern const Item* glass;
+extern const Item* slime;
} // namespace game_items
namespace game_items
diff --git a/src/game/shared/game_voxels.cc b/src/game/shared/game_voxels.cc
index c4c4ec3..010053a 100644
--- a/src/game/shared/game_voxels.cc
+++ b/src/game/shared/game_voxels.cc
@@ -7,19 +7,19 @@
#include "shared/const.hh"
-const world::Voxel* game_voxels::cobblestone = nullptr;
-const world::Voxel* game_voxels::dirt = nullptr;
-const world::Voxel* game_voxels::grass = nullptr;
-const world::Voxel* game_voxels::stone = nullptr;
-const world::Voxel* game_voxels::vtest = nullptr;
-const world::Voxel* game_voxels::vtest_ck = nullptr;
-const world::Voxel* game_voxels::oak_leaves = nullptr;
-const world::Voxel* game_voxels::oak_planks = nullptr;
-const world::Voxel* game_voxels::oak_log = nullptr;
-const world::Voxel* game_voxels::glass = nullptr;
-const world::Voxel* game_voxels::slime = nullptr;
-
-static void dirt_tick(world::Dimension* dimension, const voxel_pos& vpos)
+const Voxel* game_voxels::cobblestone = nullptr;
+const Voxel* game_voxels::dirt = nullptr;
+const Voxel* game_voxels::grass = nullptr;
+const Voxel* game_voxels::stone = nullptr;
+const Voxel* game_voxels::vtest = nullptr;
+const Voxel* game_voxels::vtest_ck = nullptr;
+const Voxel* game_voxels::oak_leaves = nullptr;
+const Voxel* game_voxels::oak_planks = nullptr;
+const Voxel* game_voxels::oak_log = nullptr;
+const Voxel* game_voxels::glass = nullptr;
+const Voxel* game_voxels::slime = nullptr;
+
+static void dirt_tick(Dimension* dimension, const voxel_pos& vpos)
{
auto grass_found = false;
auto air_above = false;
@@ -49,7 +49,7 @@ static void dirt_tick(world::Dimension* dimension, const voxel_pos& vpos)
auto above_vpos = vpos + voxel_pos(0, 1, 0);
auto above_voxel = dimension->get_voxel(above_vpos);
- if(above_voxel == nullptr || above_voxel->is_surface_material<world::VMAT_GLASS>()) {
+ if(above_voxel == nullptr || above_voxel->is_surface_material<VMAT_GLASS>()) {
air_above = true;
}
@@ -58,12 +58,12 @@ static void dirt_tick(world::Dimension* dimension, const voxel_pos& vpos)
}
}
-static void grass_tick(world::Dimension* dimension, const voxel_pos& vpos)
+static void grass_tick(Dimension* dimension, const voxel_pos& vpos)
{
auto above_vpos = vpos + voxel_pos(0, 1, 0);
auto above_voxel = dimension->get_voxel(above_vpos);
- if(above_voxel && !above_voxel->is_surface_material<world::VMAT_GLASS>()) {
+ if(above_voxel && !above_voxel->is_surface_material<VMAT_GLASS>()) {
// Decay into dirt if something is blocking airflow
dimension->set_voxel(game_voxels::dirt, vpos);
}
@@ -71,82 +71,82 @@ static void grass_tick(world::Dimension* dimension, const voxel_pos& vpos)
void game_voxels::populate(void)
{
- auto stone_builder = world::VoxelBuilder("stone");
+ auto stone_builder = VoxelBuilder("stone");
stone_builder.add_default_texture("textures/voxel/stone_01.png");
stone_builder.add_default_texture("textures/voxel/stone_02.png");
stone_builder.add_default_texture("textures/voxel/stone_03.png");
stone_builder.add_default_texture("textures/voxel/stone_04.png");
- stone = world::voxel_registry::register_voxel(stone_builder);
+ stone = voxel_registry::register_voxel(stone_builder);
- auto cobblestone_builder = world::VoxelBuilder("cobblestone");
+ auto cobblestone_builder = VoxelBuilder("cobblestone");
cobblestone_builder.add_default_texture("textures/voxel/cobblestone_01.png");
cobblestone_builder.add_default_texture("textures/voxel/cobblestone_02.png");
- cobblestone = world::voxel_registry::register_voxel(cobblestone_builder);
+ cobblestone = voxel_registry::register_voxel(cobblestone_builder);
- auto dirt_builder = world::VoxelBuilder("dirt");
+ auto dirt_builder = VoxelBuilder("dirt");
dirt_builder.add_default_texture("textures/voxel/dirt_01.png");
dirt_builder.add_default_texture("textures/voxel/dirt_02.png");
dirt_builder.add_default_texture("textures/voxel/dirt_03.png");
dirt_builder.add_default_texture("textures/voxel/dirt_04.png");
- dirt_builder.set_surface_material(world::VMAT_DIRT);
+ dirt_builder.set_surface_material(VMAT_DIRT);
dirt_builder.set_on_tick(&dirt_tick);
- dirt = world::voxel_registry::register_voxel(dirt_builder);
+ dirt = voxel_registry::register_voxel(dirt_builder);
- auto grass_builder = world::VoxelBuilder("grass");
+ auto grass_builder = VoxelBuilder("grass");
grass_builder.add_default_texture("textures/voxel/grass_side_01.png");
grass_builder.add_default_texture("textures/voxel/grass_side_02.png");
- grass_builder.add_face_texture(world::VFACE_BOTTOM, "textures/voxel/dirt_01.png");
- grass_builder.add_face_texture(world::VFACE_BOTTOM, "textures/voxel/dirt_02.png");
- grass_builder.add_face_texture(world::VFACE_BOTTOM, "textures/voxel/dirt_03.png");
- grass_builder.add_face_texture(world::VFACE_BOTTOM, "textures/voxel/dirt_04.png");
- grass_builder.add_face_texture(world::VFACE_TOP, "textures/voxel/grass_01.png");
- grass_builder.add_face_texture(world::VFACE_TOP, "textures/voxel/grass_02.png");
- grass_builder.set_surface_material(world::VMAT_GRASS);
+ grass_builder.add_face_texture(VFACE_BOTTOM, "textures/voxel/dirt_01.png");
+ grass_builder.add_face_texture(VFACE_BOTTOM, "textures/voxel/dirt_02.png");
+ grass_builder.add_face_texture(VFACE_BOTTOM, "textures/voxel/dirt_03.png");
+ grass_builder.add_face_texture(VFACE_BOTTOM, "textures/voxel/dirt_04.png");
+ grass_builder.add_face_texture(VFACE_TOP, "textures/voxel/grass_01.png");
+ grass_builder.add_face_texture(VFACE_TOP, "textures/voxel/grass_02.png");
+ grass_builder.set_surface_material(VMAT_GRASS);
grass_builder.set_on_tick(&grass_tick);
- grass = world::voxel_registry::register_voxel(grass_builder);
+ grass = voxel_registry::register_voxel(grass_builder);
- auto vtest_builder = world::VoxelBuilder("vtest");
+ auto vtest_builder = VoxelBuilder("vtest");
vtest_builder.add_default_texture("textures/voxel/vtest_F1.png");
vtest_builder.add_default_texture("textures/voxel/vtest_F2.png");
vtest_builder.add_default_texture("textures/voxel/vtest_F3.png");
vtest_builder.add_default_texture("textures/voxel/vtest_F4.png");
vtest_builder.set_animated(true);
- vtest = world::voxel_registry::register_voxel(vtest_builder);
+ vtest = voxel_registry::register_voxel(vtest_builder);
- auto vtest_ck_builder = world::VoxelBuilder("vtest_ck");
+ auto vtest_ck_builder = VoxelBuilder("vtest_ck");
vtest_ck_builder.add_default_texture("textures/voxel/chromakey.png");
- vtest_ck = world::voxel_registry::register_voxel(vtest_ck_builder);
+ vtest_ck = voxel_registry::register_voxel(vtest_ck_builder);
- auto oak_leaves_builder = world::VoxelBuilder("oak_leaves");
+ auto oak_leaves_builder = VoxelBuilder("oak_leaves");
oak_leaves_builder.add_default_texture("textures/voxel/oak_leaves.png");
- oak_leaves_builder.set_surface_material(world::VMAT_GRASS);
- oak_leaves = world::voxel_registry::register_voxel(oak_leaves_builder);
+ oak_leaves_builder.set_surface_material(VMAT_GRASS);
+ oak_leaves = voxel_registry::register_voxel(oak_leaves_builder);
- auto oak_planks_builder = world::VoxelBuilder("oak_planks");
+ auto oak_planks_builder = VoxelBuilder("oak_planks");
oak_planks_builder.add_default_texture("textures/voxel/oak_planks_01.png");
oak_planks_builder.add_default_texture("textures/voxel/oak_planks_02.png");
- oak_planks_builder.set_surface_material(world::VMAT_WOOD);
- oak_planks = world::voxel_registry::register_voxel(oak_planks_builder);
+ oak_planks_builder.set_surface_material(VMAT_WOOD);
+ oak_planks = voxel_registry::register_voxel(oak_planks_builder);
- auto oak_log_builder = world::VoxelBuilder("oak_log");
+ auto oak_log_builder = VoxelBuilder("oak_log");
oak_log_builder.add_default_texture("textures/voxel/oak_wood_01.png");
oak_log_builder.add_default_texture("textures/voxel/oak_wood_02.png");
- oak_log_builder.add_face_texture(world::VFACE_BOTTOM, "textures/voxel/oak_wood_top.png");
- oak_log_builder.add_face_texture(world::VFACE_TOP, "textures/voxel/oak_wood_top.png");
- oak_log_builder.set_surface_material(world::VMAT_WOOD);
- oak_log = world::voxel_registry::register_voxel(oak_log_builder);
+ oak_log_builder.add_face_texture(VFACE_BOTTOM, "textures/voxel/oak_wood_top.png");
+ oak_log_builder.add_face_texture(VFACE_TOP, "textures/voxel/oak_wood_top.png");
+ oak_log_builder.set_surface_material(VMAT_WOOD);
+ oak_log = voxel_registry::register_voxel(oak_log_builder);
- auto glass_builder = world::VoxelBuilder("glass");
+ auto glass_builder = VoxelBuilder("glass");
glass_builder.add_default_texture("textures/voxel/glass_01.png");
- glass_builder.set_render_mode(world::VRENDER_BLEND);
- glass_builder.set_surface_material(world::VMAT_GLASS);
- glass = world::voxel_registry::register_voxel(glass_builder);
+ glass_builder.set_render_mode(VRENDER_BLEND);
+ glass_builder.set_surface_material(VMAT_GLASS);
+ glass = voxel_registry::register_voxel(glass_builder);
- auto slime_builder = world::VoxelBuilder("slime");
+ auto slime_builder = VoxelBuilder("slime");
slime_builder.add_default_texture("textures/voxel/slime_01.png");
- slime_builder.set_render_mode(world::VRENDER_BLEND);
- slime_builder.set_surface_material(world::VMAT_SLOSH);
- slime_builder.set_touch_type(world::VTOUCH_BOUNCE);
+ slime_builder.set_render_mode(VRENDER_BLEND);
+ slime_builder.set_surface_material(VMAT_SLOSH);
+ slime_builder.set_touch_type(VTOUCH_BOUNCE);
slime_builder.set_touch_values({ 0.00f, 0.60f, 0.00f });
- slime = world::voxel_registry::register_voxel(slime_builder);
+ slime = voxel_registry::register_voxel(slime_builder);
}
diff --git a/src/game/shared/game_voxels.hh b/src/game/shared/game_voxels.hh
index a8d155f..f46385c 100644
--- a/src/game/shared/game_voxels.hh
+++ b/src/game/shared/game_voxels.hh
@@ -1,23 +1,20 @@
#pragma once
-namespace world
-{
class Voxel;
-} // namespace world
namespace game_voxels
{
-extern const world::Voxel* cobblestone;
-extern const world::Voxel* dirt;
-extern const world::Voxel* grass;
-extern const world::Voxel* stone;
-extern const world::Voxel* vtest;
-extern const world::Voxel* vtest_ck;
-extern const world::Voxel* oak_leaves;
-extern const world::Voxel* oak_planks;
-extern const world::Voxel* oak_log;
-extern const world::Voxel* glass;
-extern const world::Voxel* slime;
+extern const Voxel* cobblestone;
+extern const Voxel* dirt;
+extern const Voxel* grass;
+extern const Voxel* stone;
+extern const Voxel* vtest;
+extern const Voxel* vtest_ck;
+extern const Voxel* oak_leaves;
+extern const Voxel* oak_planks;
+extern const Voxel* oak_log;
+extern const Voxel* glass;
+extern const Voxel* slime;
} // namespace game_voxels
namespace game_voxels
diff --git a/src/game/shared/protocol.cc b/src/game/shared/protocol.cc
index 4c0c894..d274955 100644
--- a/src/game/shared/protocol.cc
+++ b/src/game/shared/protocol.cc
@@ -14,8 +14,8 @@
#include "shared/globals.hh"
-static io::ReadBuffer read_buffer;
-static io::WriteBuffer write_buffer;
+static ReadBuffer read_buffer;
+static WriteBuffer write_buffer;
ENetPacket* protocol::encode(const protocol::StatusRequest& packet, enet_uint32 flags)
{
@@ -448,9 +448,9 @@ ENetPacket* protocol::utils::make_chat_message(std::string_view message, enet_ui
return protocol::encode(packet, flags);
}
-ENetPacket* protocol::utils::make_chunk_voxels(world::Dimension* dimension, entt::entity entity, enet_uint32 flags)
+ENetPacket* protocol::utils::make_chunk_voxels(Dimension* dimension, entt::entity entity, enet_uint32 flags)
{
- if(auto component = dimension->chunks.try_get<world::ChunkComponent>(entity)) {
+ if(auto component = dimension->chunks.try_get<ChunkComponent>(entity)) {
protocol::ChunkVoxels packet;
packet.chunk = component->cpos;
packet.voxels = component->chunk->get_voxels();
@@ -460,9 +460,9 @@ ENetPacket* protocol::utils::make_chunk_voxels(world::Dimension* dimension, entt
return nullptr;
}
-ENetPacket* protocol::utils::make_entity_head(world::Dimension* dimension, entt::entity entity, enet_uint32 flags)
+ENetPacket* protocol::utils::make_entity_head(Dimension* dimension, entt::entity entity, enet_uint32 flags)
{
- if(auto component = dimension->entities.try_get<entity::Head>(entity)) {
+ if(auto component = dimension->entities.try_get<Head>(entity)) {
protocol::EntityHead packet;
packet.entity = entity;
packet.angles = component->angles;
@@ -472,9 +472,9 @@ ENetPacket* protocol::utils::make_entity_head(world::Dimension* dimension, entt:
return nullptr;
}
-ENetPacket* protocol::utils::make_entity_transform(world::Dimension* dimension, entt::entity entity, enet_uint32 flags)
+ENetPacket* protocol::utils::make_entity_transform(Dimension* dimension, entt::entity entity, enet_uint32 flags)
{
- if(auto component = dimension->entities.try_get<entity::Transform>(entity)) {
+ if(auto component = dimension->entities.try_get<Transform>(entity)) {
protocol::EntityTransform packet;
packet.entity = entity;
packet.chunk = component->chunk;
@@ -486,9 +486,9 @@ ENetPacket* protocol::utils::make_entity_transform(world::Dimension* dimension,
return nullptr;
}
-ENetPacket* protocol::utils::make_entity_velocity(world::Dimension* dimension, entt::entity entity, enet_uint32 flags)
+ENetPacket* protocol::utils::make_entity_velocity(Dimension* dimension, entt::entity entity, enet_uint32 flags)
{
- if(auto component = dimension->entities.try_get<entity::Velocity>(entity)) {
+ if(auto component = dimension->entities.try_get<Velocity>(entity)) {
protocol::EntityVelocity packet;
packet.entity = entity;
packet.value = component->value;
@@ -498,9 +498,9 @@ ENetPacket* protocol::utils::make_entity_velocity(world::Dimension* dimension, e
return nullptr;
}
-ENetPacket* protocol::utils::make_entity_player(world::Dimension* dimension, entt::entity entity, enet_uint32 flags)
+ENetPacket* protocol::utils::make_entity_player(Dimension* dimension, entt::entity entity, enet_uint32 flags)
{
- if(dimension->entities.any_of<entity::Player>(entity)) {
+ if(dimension->entities.any_of<Player>(entity)) {
protocol::EntityPlayer packet;
packet.entity = entity;
return protocol::encode(packet, flags);
@@ -509,7 +509,7 @@ ENetPacket* protocol::utils::make_entity_player(world::Dimension* dimension, ent
return nullptr;
}
-ENetPacket* protocol::utils::make_dimension_info(const world::Dimension* dimension)
+ENetPacket* protocol::utils::make_dimension_info(const Dimension* dimension)
{
protocol::DimensionInfo packet;
packet.name = dimension->get_name();
diff --git a/src/game/shared/protocol.hh b/src/game/shared/protocol.hh
index b222342..2582406 100644
--- a/src/game/shared/protocol.hh
+++ b/src/game/shared/protocol.hh
@@ -2,10 +2,7 @@
#include "shared/world/chunk.hh"
-namespace world
-{
class Dimension;
-} // namespace world
namespace protocol
{
@@ -93,16 +90,16 @@ ENetPacket* make_chat_message(std::string_view message, enet_uint32 flags = ENET
namespace protocol::utils
{
-ENetPacket* make_chunk_voxels(world::Dimension* dimension, entt::entity entity, enet_uint32 flags = ENET_PACKET_FLAG_RELIABLE);
+ENetPacket* make_chunk_voxels(Dimension* dimension, entt::entity entity, enet_uint32 flags = ENET_PACKET_FLAG_RELIABLE);
} // namespace protocol::utils
namespace protocol::utils
{
-ENetPacket* make_entity_head(world::Dimension* dimension, entt::entity entity, enet_uint32 flags = ENET_PACKET_FLAG_RELIABLE);
-ENetPacket* make_entity_transform(world::Dimension* dimension, entt::entity entity, enet_uint32 flags = ENET_PACKET_FLAG_RELIABLE);
-ENetPacket* make_entity_velocity(world::Dimension* dimension, entt::entity entity, enet_uint32 flags = ENET_PACKET_FLAG_RELIABLE);
-ENetPacket* make_entity_player(world::Dimension* dimension, entt::entity entity, enet_uint32 flags = ENET_PACKET_FLAG_RELIABLE);
-ENetPacket* make_dimension_info(const world::Dimension* dimension);
+ENetPacket* make_entity_head(Dimension* dimension, entt::entity entity, enet_uint32 flags = ENET_PACKET_FLAG_RELIABLE);
+ENetPacket* make_entity_transform(Dimension* dimension, entt::entity entity, enet_uint32 flags = ENET_PACKET_FLAG_RELIABLE);
+ENetPacket* make_entity_velocity(Dimension* dimension, entt::entity entity, enet_uint32 flags = ENET_PACKET_FLAG_RELIABLE);
+ENetPacket* make_entity_player(Dimension* dimension, entt::entity entity, enet_uint32 flags = ENET_PACKET_FLAG_RELIABLE);
+ENetPacket* make_dimension_info(const Dimension* dimension);
} // namespace protocol::utils
struct protocol::StatusRequest final : public protocol::Base<0x0000> {
@@ -140,7 +137,7 @@ struct protocol::Disconnect final : public protocol::Base<0x0004> {
struct protocol::ChunkVoxels final : public protocol::Base<0x0005> {
chunk_pos chunk;
- world::VoxelStorage voxels;
+ VoxelStorage voxels;
};
struct protocol::EntityTransform final : public protocol::Base<0x0006> {
diff --git a/src/game/shared/splash.cc b/src/game/shared/splash.cc
index 4568779..86ed0d0 100644
--- a/src/game/shared/splash.cc
+++ b/src/game/shared/splash.cc
@@ -39,7 +39,7 @@ static void splash_init_filename(std::string_view filename)
splash_random.seed(std::random_device()());
}
else {
- splash_lines.push_back(std::format("{}: {}", filename, io::physfs_error()));
+ splash_lines.push_back(std::format("{}: {}", filename, physfs_error()));
splash_random.seed(std::random_device()());
}
}
diff --git a/src/game/shared/world/chunk.cc b/src/game/shared/world/chunk.cc
index e2d60cb..10da80e 100644
--- a/src/game/shared/world/chunk.cc
+++ b/src/game/shared/world/chunk.cc
@@ -6,7 +6,7 @@
#include "shared/coord.hh"
-world::Chunk::Chunk(entt::entity entity, Dimension* dimension)
+Chunk::Chunk(entt::entity entity, Dimension* dimension)
{
m_entity = entity;
m_dimension = dimension;
@@ -14,12 +14,12 @@ world::Chunk::Chunk(entt::entity entity, Dimension* dimension)
m_biome = BIOME_VOID;
}
-const world::Voxel* world::Chunk::get_voxel(const local_pos& lpos) const
+const Voxel* Chunk::get_voxel(const local_pos& lpos) const
{
return get_voxel(coord::to_index(lpos));
}
-const world::Voxel* world::Chunk::get_voxel(const std::size_t index) const
+const Voxel* Chunk::get_voxel(const std::size_t index) const
{
if(index >= CHUNK_VOLUME) {
return nullptr;
@@ -28,12 +28,12 @@ const world::Voxel* world::Chunk::get_voxel(const std::size_t index) const
return voxel_registry::find(m_voxels[index]);
}
-void world::Chunk::set_voxel(const Voxel* voxel, const local_pos& lpos)
+void Chunk::set_voxel(const Voxel* voxel, const local_pos& lpos)
{
set_voxel(voxel, coord::to_index(lpos));
}
-void world::Chunk::set_voxel(const Voxel* voxel, const std::size_t index)
+void Chunk::set_voxel(const Voxel* voxel, const std::size_t index)
{
if(index < CHUNK_VOLUME) {
m_voxels[index] = voxel ? voxel->get_id() : NULL_VOXEL_ID;
@@ -41,32 +41,32 @@ void world::Chunk::set_voxel(const Voxel* voxel, const std::size_t index)
}
}
-const world::VoxelStorage& world::Chunk::get_voxels(void) const
+const VoxelStorage& Chunk::get_voxels(void) const
{
return m_voxels;
}
-void world::Chunk::set_voxels(const VoxelStorage& voxels)
+void Chunk::set_voxels(const VoxelStorage& voxels)
{
m_voxels = voxels;
}
-unsigned int world::Chunk::get_biome(void) const
+unsigned int Chunk::get_biome(void) const
{
return m_biome;
}
-void world::Chunk::set_biome(unsigned int biome)
+void Chunk::set_biome(unsigned int biome)
{
m_biome = biome;
}
-entt::entity world::Chunk::get_entity(void) const
+entt::entity Chunk::get_entity(void) const
{
return m_entity;
}
-world::Dimension* world::Chunk::get_dimension(void) const
+Dimension* Chunk::get_dimension(void) const
{
return m_dimension;
}
diff --git a/src/game/shared/world/chunk.hh b/src/game/shared/world/chunk.hh
index 7518127..f8e38b4 100644
--- a/src/game/shared/world/chunk.hh
+++ b/src/game/shared/world/chunk.hh
@@ -6,14 +6,9 @@
constexpr static unsigned int BIOME_VOID = 0U;
-namespace world
-{
class Dimension;
class Voxel;
-} // namespace world
-namespace world
-{
class Chunk final {
public:
explicit Chunk(entt::entity entity, Dimension* dimension);
@@ -40,4 +35,3 @@ private:
VoxelStorage m_voxels;
unsigned int m_biome;
};
-} // namespace world
diff --git a/src/game/shared/world/chunk_aabb.hh b/src/game/shared/world/chunk_aabb.hh
index f07d3e1..0f8851c 100644
--- a/src/game/shared/world/chunk_aabb.hh
+++ b/src/game/shared/world/chunk_aabb.hh
@@ -4,7 +4,4 @@
#include "shared/types.hh"
-namespace world
-{
using ChunkAABB = math::AABB<chunk_pos::value_type>;
-} // namespace world
diff --git a/src/game/shared/world/dimension.cc b/src/game/shared/world/dimension.cc
index 0088753..84ca539 100644
--- a/src/game/shared/world/dimension.cc
+++ b/src/game/shared/world/dimension.cc
@@ -8,13 +8,13 @@
#include "shared/coord.hh"
#include "shared/globals.hh"
-world::Dimension::Dimension(std::string_view name, float gravity)
+Dimension::Dimension(std::string_view name, float gravity)
{
m_name = name;
m_gravity = gravity;
}
-world::Dimension::~Dimension(void)
+Dimension::~Dimension(void)
{
for(const auto it : m_chunkmap)
delete it.second;
@@ -22,17 +22,17 @@ world::Dimension::~Dimension(void)
chunks.clear();
}
-std::string_view world::Dimension::get_name(void) const
+std::string_view Dimension::get_name(void) const
{
return m_name;
}
-float world::Dimension::get_gravity(void) const
+float Dimension::get_gravity(void) const
{
return m_gravity;
}
-world::Chunk* world::Dimension::create_chunk(const chunk_pos& cpos)
+Chunk* Dimension::create_chunk(const chunk_pos& cpos)
{
auto it = m_chunkmap.find(cpos);
@@ -58,7 +58,7 @@ world::Chunk* world::Dimension::create_chunk(const chunk_pos& cpos)
return m_chunkmap.insert_or_assign(cpos, std::move(chunk)).first->second;
}
-world::Chunk* world::Dimension::find_chunk(entt::entity entity) const
+Chunk* Dimension::find_chunk(entt::entity entity) const
{
if(chunks.valid(entity)) {
return chunks.get<ChunkComponent>(entity).chunk;
@@ -68,7 +68,7 @@ world::Chunk* world::Dimension::find_chunk(entt::entity entity) const
}
}
-world::Chunk* world::Dimension::find_chunk(const chunk_pos& cpos) const
+Chunk* Dimension::find_chunk(const chunk_pos& cpos) const
{
auto it = m_chunkmap.find(cpos);
@@ -80,7 +80,7 @@ world::Chunk* world::Dimension::find_chunk(const chunk_pos& cpos) const
}
}
-void world::Dimension::remove_chunk(entt::entity entity)
+void Dimension::remove_chunk(entt::entity entity)
{
if(chunks.valid(entity)) {
auto& component = chunks.get<ChunkComponent>(entity);
@@ -89,7 +89,7 @@ void world::Dimension::remove_chunk(entt::entity entity)
}
}
-void world::Dimension::remove_chunk(const chunk_pos& cpos)
+void Dimension::remove_chunk(const chunk_pos& cpos)
{
auto it = m_chunkmap.find(cpos);
@@ -99,7 +99,7 @@ void world::Dimension::remove_chunk(const chunk_pos& cpos)
}
}
-void world::Dimension::remove_chunk(Chunk* chunk)
+void Dimension::remove_chunk(Chunk* chunk)
{
if(chunk) {
const auto& component = chunks.get<ChunkComponent>(chunk->get_entity());
@@ -108,7 +108,7 @@ void world::Dimension::remove_chunk(Chunk* chunk)
}
}
-const world::Voxel* world::Dimension::get_voxel(const voxel_pos& vpos) const
+const Voxel* Dimension::get_voxel(const voxel_pos& vpos) const
{
auto cpos = coord::to_chunk(vpos);
auto lpos = coord::to_local(vpos);
@@ -120,7 +120,7 @@ const world::Voxel* world::Dimension::get_voxel(const voxel_pos& vpos) const
return nullptr;
}
-const world::Voxel* world::Dimension::get_voxel(const chunk_pos& cpos, const local_pos& lpos) const
+const Voxel* Dimension::get_voxel(const chunk_pos& cpos, const local_pos& lpos) const
{
// This allows accessing get_voxel with negative
// local coordinates that usually would result in an
@@ -128,7 +128,7 @@ const world::Voxel* world::Dimension::get_voxel(const chunk_pos& cpos, const loc
return get_voxel(coord::to_voxel(cpos, lpos));
}
-bool world::Dimension::set_voxel(const Voxel* voxel, const voxel_pos& vpos)
+bool Dimension::set_voxel(const Voxel* voxel, const voxel_pos& vpos)
{
auto cpos = coord::to_chunk(vpos);
auto lpos = coord::to_local(vpos);
@@ -165,7 +165,7 @@ bool world::Dimension::set_voxel(const Voxel* voxel, const voxel_pos& vpos)
return false;
}
-bool world::Dimension::set_voxel(const Voxel* voxel, const chunk_pos& cpos, const local_pos& lpos)
+bool Dimension::set_voxel(const Voxel* voxel, const chunk_pos& cpos, const local_pos& lpos)
{
// This allows accessing set_voxel with negative
// local coordinates that usually would result in an
@@ -173,15 +173,15 @@ bool world::Dimension::set_voxel(const Voxel* voxel, const chunk_pos& cpos, cons
return set_voxel(voxel, coord::to_voxel(cpos, lpos));
}
-void world::Dimension::init(io::ConfigMap& config)
+void Dimension::init(ConfigMap& config)
{
}
-void world::Dimension::init_late(std::uint64_t global_seed)
+void Dimension::init_late(std::uint64_t global_seed)
{
}
-bool world::Dimension::generate(const chunk_pos& cpos, VoxelStorage& voxels)
+bool Dimension::generate(const chunk_pos& cpos, VoxelStorage& voxels)
{
return false;
}
diff --git a/src/game/shared/world/dimension.hh b/src/game/shared/world/dimension.hh
index 6549bf6..b57640a 100644
--- a/src/game/shared/world/dimension.hh
+++ b/src/game/shared/world/dimension.hh
@@ -3,26 +3,15 @@
#include "shared/const.hh"
#include "shared/types.hh"
-namespace io
-{
class ConfigMap;
-} // namespace io
-namespace world
-{
class Chunk;
class Voxel;
class VoxelStorage;
-} // namespace world
-namespace world
-{
using dimension_entropy_map = std::array<std::uint64_t, CHUNK_AREA>;
using dimension_height_map = std::array<voxel_pos::value_type, CHUNK_AREA>;
-} // namespace world
-namespace world
-{
class Dimension {
public:
explicit Dimension(std::string_view name, float gravity);
@@ -48,7 +37,7 @@ public:
bool set_voxel(const Voxel* voxel, const chunk_pos& cpos, const local_pos& lpos);
public:
- virtual void init(io::ConfigMap& config);
+ virtual void init(ConfigMap& config);
virtual void init_late(std::uint64_t global_seed);
virtual bool generate(const chunk_pos& cpos, VoxelStorage& voxels);
@@ -61,18 +50,12 @@ private:
emhash8::HashMap<chunk_pos, Chunk*> m_chunkmap;
float m_gravity;
};
-} // namespace world
-namespace world
-{
struct ChunkComponent final {
chunk_pos cpos;
Chunk* chunk;
};
-} // namespace world
-namespace world
-{
struct ChunkCreateEvent final {
Dimension* dimension;
chunk_pos cpos;
@@ -98,4 +81,3 @@ struct VoxelSetEvent final {
local_pos lpos;
Chunk* chunk;
};
-} // namespace world
diff --git a/src/game/shared/world/feature.cc b/src/game/shared/world/feature.cc
index 2468473..3974082 100644
--- a/src/game/shared/world/feature.cc
+++ b/src/game/shared/world/feature.cc
@@ -8,7 +8,7 @@
#include "shared/coord.hh"
-void world::Feature::place(const voxel_pos& vpos, Dimension* dimension) const
+void Feature::place(const voxel_pos& vpos, Dimension* dimension) const
{
for(const auto [rpos, voxel, overwrite] : (*this)) {
auto it_vpos = vpos + rpos;
@@ -30,7 +30,7 @@ void world::Feature::place(const voxel_pos& vpos, Dimension* dimension) const
}
}
-void world::Feature::place(const voxel_pos& vpos, const chunk_pos& cpos, Chunk& chunk) const
+void Feature::place(const voxel_pos& vpos, const chunk_pos& cpos, Chunk& chunk) const
{
for(const auto [rpos, voxel, overwrite] : (*this)) {
auto it_vpos = vpos + rpos;
@@ -52,7 +52,7 @@ void world::Feature::place(const voxel_pos& vpos, const chunk_pos& cpos, Chunk&
}
}
-void world::Feature::place(const voxel_pos& vpos, const chunk_pos& cpos, VoxelStorage& voxels) const
+void Feature::place(const voxel_pos& vpos, const chunk_pos& cpos, VoxelStorage& voxels) const
{
for(const auto [rpos, voxel, overwrite] : (*this)) {
auto it_vpos = vpos + rpos;
diff --git a/src/game/shared/world/feature.hh b/src/game/shared/world/feature.hh
index 0d28b20..b80869d 100644
--- a/src/game/shared/world/feature.hh
+++ b/src/game/shared/world/feature.hh
@@ -2,16 +2,11 @@
#include "shared/types.hh"
-namespace world
-{
class Chunk;
class Dimension;
class Voxel;
class VoxelStorage;
-} // namespace world
-namespace world
-{
class Feature final : public std::vector<std::tuple<voxel_pos, const Voxel*, bool>> {
public:
Feature(void) = default;
@@ -22,4 +17,3 @@ public:
void place(const voxel_pos& vpos, const chunk_pos& cpos, Chunk& chunk) const;
void place(const voxel_pos& vpos, const chunk_pos& cpos, VoxelStorage& voxels) const;
};
-} // namespace world
diff --git a/src/game/shared/world/item.cc b/src/game/shared/world/item.cc
index 5e60609..bc1546a 100644
--- a/src/game/shared/world/item.cc
+++ b/src/game/shared/world/item.cc
@@ -6,17 +6,17 @@
#include "shared/world/voxel.hh"
-world::Item::Item(const Item& source, item_id id) noexcept : Item(source)
+Item::Item(const Item& source, item_id id) noexcept : Item(source)
{
m_id = id;
}
-void world::Item::set_cached_texture(resource_ptr<TextureGUI> texture) const noexcept
+void Item::set_cached_texture(resource_ptr<TextureGUI> texture) const noexcept
{
m_cached_texture = std::move(texture);
}
-std::uint64_t world::Item::get_checksum(std::uint64_t combine) const
+std::uint64_t Item::get_checksum(std::uint64_t combine) const
{
combine = math::crc64(m_name.data(), m_name.size(), combine);
combine = math::crc64(m_texture.data(), m_texture.size(), combine);
@@ -27,29 +27,29 @@ std::uint64_t world::Item::get_checksum(std::uint64_t combine) const
return combine;
}
-world::ItemBuilder::ItemBuilder(std::string_view name)
+ItemBuilder::ItemBuilder(std::string_view name)
{
set_name(name);
}
-void world::ItemBuilder::set_name(std::string_view name)
+void ItemBuilder::set_name(std::string_view name)
{
assert(name.size());
m_name = name;
}
-void world::ItemBuilder::set_texture(std::string_view texture)
+void ItemBuilder::set_texture(std::string_view texture)
{
m_texture = texture;
}
-void world::ItemBuilder::set_place_voxel(const Voxel* place_voxel)
+void ItemBuilder::set_place_voxel(const Voxel* place_voxel)
{
m_place_voxel = place_voxel;
}
-std::unique_ptr<world::Item> world::ItemBuilder::build(item_id id) const
+std::unique_ptr<Item> ItemBuilder::build(item_id id) const
{
return std::make_unique<Item>(*this, id);
}
diff --git a/src/game/shared/world/item.hh b/src/game/shared/world/item.hh
index ffa7f5c..bcec37a 100644
--- a/src/game/shared/world/item.hh
+++ b/src/game/shared/world/item.hh
@@ -9,13 +9,8 @@
// anywhere else in the shared and server code
struct TextureGUI;
-namespace world
-{
class Voxel;
-} // namespace world
-namespace world
-{
class Item {
public:
Item(void) = default;
@@ -41,10 +36,7 @@ protected:
mutable resource_ptr<TextureGUI> m_cached_texture; // Client-side only
};
-} // namespace world
-namespace world
-{
class ItemBuilder final : public Item {
public:
explicit ItemBuilder(std::string_view name);
@@ -56,29 +48,28 @@ public:
std::unique_ptr<Item> build(item_id id) const;
};
-} // namespace world
-constexpr std::string_view world::Item::get_name(void) const noexcept
+constexpr std::string_view Item::get_name(void) const noexcept
{
return m_name;
}
-constexpr item_id world::Item::get_id(void) const noexcept
+constexpr item_id Item::get_id(void) const noexcept
{
return m_id;
}
-constexpr std::string_view world::Item::get_texture(void) const noexcept
+constexpr std::string_view Item::get_texture(void) const noexcept
{
return m_texture;
}
-constexpr const world::Voxel* world::Item::get_place_voxel(void) const noexcept
+constexpr const Voxel* Item::get_place_voxel(void) const noexcept
{
return m_place_voxel;
}
-constexpr resource_ptr<TextureGUI>& world::Item::get_cached_texture(void) const noexcept
+constexpr resource_ptr<TextureGUI>& Item::get_cached_texture(void) const noexcept
{
return m_cached_texture;
}
diff --git a/src/game/shared/world/item_registry.cc b/src/game/shared/world/item_registry.cc
index d89abe9..c7d8d9b 100644
--- a/src/game/shared/world/item_registry.cc
+++ b/src/game/shared/world/item_registry.cc
@@ -7,19 +7,19 @@
#include "shared/world/voxel_registry.hh"
static std::uint64_t registry_checksum = 0U;
-std::unordered_map<std::string, item_id> world::item_registry::names = {};
-std::vector<std::unique_ptr<world::Item>> world::item_registry::items = {};
+std::unordered_map<std::string, item_id> item_registry::names = {};
+std::vector<std::unique_ptr<Item>> item_registry::items = {};
static void recalculate_checksum(void)
{
registry_checksum = 0U;
- for(const auto& item : world::item_registry::items) {
+ for(const auto& item : item_registry::items) {
registry_checksum = item->get_checksum(registry_checksum);
}
}
-world::Item* world::item_registry::register_item(const ItemBuilder& builder)
+Item* item_registry::register_item(const ItemBuilder& builder)
{
assert(builder.get_name().size());
assert(nullptr == find(builder.get_name()));
@@ -35,7 +35,7 @@ world::Item* world::item_registry::register_item(const ItemBuilder& builder)
return items.back().get();
}
-world::Item* world::item_registry::find(std::string_view name)
+Item* item_registry::find(std::string_view name)
{
const auto it = names.find(std::string(name));
@@ -46,7 +46,7 @@ world::Item* world::item_registry::find(std::string_view name)
return items[it->second - 1].get();
}
-world::Item* world::item_registry::find(const item_id item)
+Item* item_registry::find(const item_id item)
{
if(item == NULL_ITEM_ID || item > items.size()) {
return nullptr;
@@ -55,14 +55,14 @@ world::Item* world::item_registry::find(const item_id item)
return items[item - 1].get();
}
-void world::item_registry::purge(void)
+void item_registry::purge(void)
{
registry_checksum = 0U;
items.clear();
names.clear();
}
-std::uint64_t world::item_registry::get_checksum(void)
+std::uint64_t item_registry::get_checksum(void)
{
return registry_checksum;
}
diff --git a/src/game/shared/world/item_registry.hh b/src/game/shared/world/item_registry.hh
index a841a2d..f8fe641 100644
--- a/src/game/shared/world/item_registry.hh
+++ b/src/game/shared/world/item_registry.hh
@@ -2,25 +2,25 @@
#include "shared/world/item.hh"
-namespace world::item_registry
+namespace item_registry
{
extern std::unordered_map<std::string, item_id> names;
extern std::vector<std::unique_ptr<Item>> items;
-} // namespace world::item_registry
+} // namespace item_registry
-namespace world::item_registry
+namespace item_registry
{
Item* register_item(const ItemBuilder& builder);
Item* find(std::string_view name);
Item* find(const item_id item);
-} // namespace world::item_registry
+} // namespace item_registry
-namespace world::item_registry
+namespace item_registry
{
void purge(void);
-} // namespace world::item_registry
+} // namespace item_registry
-namespace world::item_registry
+namespace item_registry
{
std::uint64_t get_checksum(void);
-} // namespace world::item_registry
+} // namespace item_registry
diff --git a/src/game/shared/world/ray_dda.cc b/src/game/shared/world/ray_dda.cc
index d6383b9..5dbf82e 100644
--- a/src/game/shared/world/ray_dda.cc
+++ b/src/game/shared/world/ray_dda.cc
@@ -6,20 +6,17 @@
#include "shared/coord.hh"
-world::RayDDA::RayDDA(const world::Dimension* dimension, const chunk_pos& start_chunk, const glm::fvec3& start_fpos,
- const glm::fvec3& direction)
+RayDDA::RayDDA(const Dimension* dimension, const chunk_pos& start_chunk, const glm::fvec3& start_fpos, const glm::fvec3& direction)
{
reset(dimension, start_chunk, start_fpos, direction);
}
-world::RayDDA::RayDDA(const world::Dimension& dimension, const chunk_pos& start_chunk, const glm::fvec3& start_fpos,
- const glm::fvec3& direction)
+RayDDA::RayDDA(const Dimension& dimension, const chunk_pos& start_chunk, const glm::fvec3& start_fpos, const glm::fvec3& direction)
{
reset(dimension, start_chunk, start_fpos, direction);
}
-void world::RayDDA::reset(const world::Dimension* dimension, const chunk_pos& start_chunk, const glm::fvec3& start_fpos,
- const glm::fvec3& direction)
+void RayDDA::reset(const Dimension* dimension, const chunk_pos& start_chunk, const glm::fvec3& start_fpos, const glm::fvec3& direction)
{
this->dimension = dimension;
this->start_chunk = start_chunk;
@@ -65,13 +62,12 @@ void world::RayDDA::reset(const world::Dimension* dimension, const chunk_pos& st
}
}
-void world::RayDDA::reset(const world::Dimension& dimension, const chunk_pos& start_chunk, const glm::fvec3& start_fpos,
- const glm::fvec3& direction)
+void RayDDA::reset(const Dimension& dimension, const chunk_pos& start_chunk, const glm::fvec3& start_fpos, const glm::fvec3& direction)
{
reset(&dimension, start_chunk, start_fpos, direction);
}
-const world::Voxel* world::RayDDA::step(void)
+const Voxel* RayDDA::step(void)
{
if(side_dist.x < side_dist.z) {
if(side_dist.x < side_dist.y) {
diff --git a/src/game/shared/world/ray_dda.hh b/src/game/shared/world/ray_dda.hh
index 0f548ba..72f746e 100644
--- a/src/game/shared/world/ray_dda.hh
+++ b/src/game/shared/world/ray_dda.hh
@@ -2,14 +2,9 @@
#include "shared/types.hh"
-namespace world
-{
class Dimension;
class Voxel;
-} // namespace world
-namespace world
-{
class RayDDA final {
public:
RayDDA(void) = default;
@@ -35,4 +30,3 @@ public:
voxel_pos vnormal;
voxel_pos vpos;
};
-} // namespace world
diff --git a/src/game/shared/world/voxel.cc b/src/game/shared/world/voxel.cc
index 21fe62c..4f47c2d 100644
--- a/src/game/shared/world/voxel.cc
+++ b/src/game/shared/world/voxel.cc
@@ -6,33 +6,33 @@
#include "shared/world/dimension.hh"
-world::Voxel::Voxel(const Voxel& source, voxel_id id) noexcept : Voxel(source)
+Voxel::Voxel(const Voxel& source, voxel_id id) noexcept : Voxel(source)
{
m_id = id;
}
-void world::Voxel::on_place(Dimension* dimension, const voxel_pos& vpos) const
+void Voxel::on_place(Dimension* dimension, const voxel_pos& vpos) const
{
if(m_on_place) {
m_on_place(dimension, vpos);
}
}
-void world::Voxel::on_remove(Dimension* dimension, const voxel_pos& vpos) const
+void Voxel::on_remove(Dimension* dimension, const voxel_pos& vpos) const
{
if(m_on_remove) {
m_on_remove(dimension, vpos);
}
}
-void world::Voxel::on_tick(Dimension* dimension, const voxel_pos& vpos) const
+void Voxel::on_tick(Dimension* dimension, const voxel_pos& vpos) const
{
if(m_on_tick) {
m_on_tick(dimension, vpos);
}
}
-std::size_t world::Voxel::get_random_texture_index(VoxelFace face, const voxel_pos& vpos) const
+std::size_t Voxel::get_random_texture_index(VoxelFace face, const voxel_pos& vpos) const
{
const auto& textures = get_face_textures(face);
@@ -46,7 +46,7 @@ std::size_t world::Voxel::get_random_texture_index(VoxelFace face, const voxel_p
return static_cast<std::size_t>(hash % textures.size());
}
-void world::Voxel::set_face_cache(VoxelFace face, std::size_t offset, std::size_t plane)
+void Voxel::set_face_cache(VoxelFace face, std::size_t offset, std::size_t plane)
{
assert(face < m_cached_face_offsets.size());
assert(face < m_cached_face_planes.size());
@@ -55,7 +55,7 @@ void world::Voxel::set_face_cache(VoxelFace face, std::size_t offset, std::size_
m_cached_face_planes[face] = plane;
}
-std::uint64_t world::Voxel::get_checksum(std::uint64_t combine) const
+std::uint64_t Voxel::get_checksum(std::uint64_t combine) const
{
combine = math::crc64(m_name.data(), m_name.size(), combine);
combine += static_cast<std::uint64_t>(m_shape);
@@ -63,76 +63,76 @@ std::uint64_t world::Voxel::get_checksum(std::uint64_t combine) const
return combine;
}
-world::VoxelBuilder::VoxelBuilder(std::string_view name)
+VoxelBuilder::VoxelBuilder(std::string_view name)
{
set_name(name);
}
-void world::VoxelBuilder::set_on_place(VoxelOnPlaceFunc func) noexcept
+void VoxelBuilder::set_on_place(VoxelOnPlaceFunc func) noexcept
{
m_on_place = std::move(func);
}
-void world::VoxelBuilder::set_on_remove(VoxelOnRemoveFunc func) noexcept
+void VoxelBuilder::set_on_remove(VoxelOnRemoveFunc func) noexcept
{
m_on_remove = std::move(func);
}
-void world::VoxelBuilder::set_on_tick(VoxelOnTickFunc func) noexcept
+void VoxelBuilder::set_on_tick(VoxelOnTickFunc func) noexcept
{
m_on_tick = std::move(func);
}
-void world::VoxelBuilder::set_name(std::string_view name) noexcept
+void VoxelBuilder::set_name(std::string_view name) noexcept
{
assert(name.size());
m_name = name;
}
-void world::VoxelBuilder::set_render_mode(VoxelRender mode) noexcept
+void VoxelBuilder::set_render_mode(VoxelRender mode) noexcept
{
m_render_mode = mode;
}
-void world::VoxelBuilder::set_shape(VoxelShape shape) noexcept
+void VoxelBuilder::set_shape(VoxelShape shape) noexcept
{
m_shape = shape;
}
-void world::VoxelBuilder::set_animated(bool animated) noexcept
+void VoxelBuilder::set_animated(bool animated) noexcept
{
m_animated = animated;
}
-void world::VoxelBuilder::set_touch_type(VoxelTouch type) noexcept
+void VoxelBuilder::set_touch_type(VoxelTouch type) noexcept
{
m_touch_type = type;
}
-void world::VoxelBuilder::set_touch_values(const glm::fvec3& values) noexcept
+void VoxelBuilder::set_touch_values(const glm::fvec3& values) noexcept
{
m_touch_values = values;
}
-void world::VoxelBuilder::set_surface_material(VoxelMaterial material) noexcept
+void VoxelBuilder::set_surface_material(VoxelMaterial material) noexcept
{
m_surface_material = material;
}
-void world::VoxelBuilder::set_collision(const math::AABBf& box) noexcept
+void VoxelBuilder::set_collision(const math::AABBf& box) noexcept
{
m_collision = box;
}
-void world::VoxelBuilder::add_default_texture(std::string_view path)
+void VoxelBuilder::add_default_texture(std::string_view path)
{
assert(path.size());
m_default_textures.emplace_back(path);
}
-void world::VoxelBuilder::add_face_texture(VoxelFace face, std::string_view path)
+void VoxelBuilder::add_face_texture(VoxelFace face, std::string_view path)
{
assert(face < m_face_textures.size());
assert(path.size());
@@ -140,7 +140,7 @@ void world::VoxelBuilder::add_face_texture(VoxelFace face, std::string_view path
m_face_textures[face].emplace_back(path);
}
-std::unique_ptr<world::Voxel> world::VoxelBuilder::build(voxel_id id) const
+std::unique_ptr<Voxel> VoxelBuilder::build(voxel_id id) const
{
assert(m_name.size());
assert(id);
diff --git a/src/game/shared/world/voxel.hh b/src/game/shared/world/voxel.hh
index 6013962..0a8c4a3 100644
--- a/src/game/shared/world/voxel.hh
+++ b/src/game/shared/world/voxel.hh
@@ -4,13 +4,8 @@
#include "shared/types.hh"
-namespace world
-{
class Dimension;
-} // namespace world
-namespace world
-{
enum VoxelRender : unsigned int {
VRENDER_NONE = 0U, ///< The voxel is not rendered at all
VRENDER_OPAQUE, ///< The voxel is fully opaque
@@ -65,17 +60,11 @@ enum VoxelVisBits : unsigned int {
VVIS_UP = 1U << VFACE_TOP, ///< Positive Y
VVIS_DOWN = 1U << VFACE_BOTTOM, ///< Negative Y
};
-} // namespace world
-namespace world
-{
using VoxelOnPlaceFunc = std::function<void(Dimension*, const voxel_pos&)>;
using VoxelOnRemoveFunc = std::function<void(Dimension*, const voxel_pos&)>;
using VoxelOnTickFunc = std::function<void(Dimension*, const voxel_pos&)>;
-} // namespace world
-namespace world
-{
class Voxel {
public:
Voxel(void) = default;
@@ -154,10 +143,7 @@ protected:
VoxelOnRemoveFunc m_on_remove;
VoxelOnTickFunc m_on_tick;
};
-} // namespace world
-namespace world
-{
class VoxelBuilder final : public Voxel {
public:
VoxelBuilder(void) = default;
@@ -184,59 +170,58 @@ public:
std::unique_ptr<Voxel> build(voxel_id id) const;
};
-} // namespace world
-constexpr std::string_view world::Voxel::get_name(void) const noexcept
+constexpr std::string_view Voxel::get_name(void) const noexcept
{
return m_name;
}
-constexpr voxel_id world::Voxel::get_id(void) const noexcept
+constexpr voxel_id Voxel::get_id(void) const noexcept
{
return m_id;
}
-constexpr world::VoxelRender world::Voxel::get_render_mode(void) const noexcept
+constexpr VoxelRender Voxel::get_render_mode(void) const noexcept
{
return m_render_mode;
}
-constexpr world::VoxelShape world::Voxel::get_shape(void) const noexcept
+constexpr VoxelShape Voxel::get_shape(void) const noexcept
{
return m_shape;
}
-constexpr bool world::Voxel::is_animated(void) const noexcept
+constexpr bool Voxel::is_animated(void) const noexcept
{
return m_animated;
}
-constexpr world::VoxelTouch world::Voxel::get_touch_type(void) const noexcept
+constexpr VoxelTouch Voxel::get_touch_type(void) const noexcept
{
return m_touch_type;
}
-constexpr const glm::fvec3& world::Voxel::get_touch_values(void) const noexcept
+constexpr const glm::fvec3& Voxel::get_touch_values(void) const noexcept
{
return m_touch_values;
}
-constexpr world::VoxelMaterial world::Voxel::get_surface_material(void) const noexcept
+constexpr VoxelMaterial Voxel::get_surface_material(void) const noexcept
{
return m_surface_material;
}
-constexpr const math::AABBf& world::Voxel::get_collision(void) const noexcept
+constexpr const math::AABBf& Voxel::get_collision(void) const noexcept
{
return m_collision;
}
-constexpr const std::vector<std::string>& world::Voxel::get_default_textures(void) const noexcept
+constexpr const std::vector<std::string>& Voxel::get_default_textures(void) const noexcept
{
return m_default_textures;
}
-constexpr const std::vector<std::string>& world::Voxel::get_face_textures(VoxelFace face) const noexcept
+constexpr const std::vector<std::string>& Voxel::get_face_textures(VoxelFace face) const noexcept
{
assert(face <= m_face_textures.size());
@@ -247,40 +232,40 @@ constexpr const std::vector<std::string>& world::Voxel::get_face_textures(VoxelF
return m_face_textures[face];
}
-constexpr std::size_t world::Voxel::get_cached_face_offset(VoxelFace face) const noexcept
+constexpr std::size_t Voxel::get_cached_face_offset(VoxelFace face) const noexcept
{
assert(face <= m_cached_face_offsets.size());
return m_cached_face_offsets[face];
}
-constexpr std::size_t world::Voxel::get_cached_face_plane(VoxelFace face) const noexcept
+constexpr std::size_t Voxel::get_cached_face_plane(VoxelFace face) const noexcept
{
assert(face <= m_cached_face_planes.size());
return m_cached_face_planes[face];
}
-template<world::VoxelRender RenderMode>
-constexpr bool world::Voxel::is_render_mode(void) const noexcept
+template<VoxelRender RenderMode>
+constexpr bool Voxel::is_render_mode(void) const noexcept
{
return m_render_mode == RenderMode;
}
-template<world::VoxelShape Shape>
-constexpr bool world::Voxel::is_shape(void) const noexcept
+template<VoxelShape Shape>
+constexpr bool Voxel::is_shape(void) const noexcept
{
return m_shape == Shape;
}
-template<world::VoxelTouch TouchType>
-constexpr bool world::Voxel::is_touch_type(void) const noexcept
+template<VoxelTouch TouchType>
+constexpr bool Voxel::is_touch_type(void) const noexcept
{
return m_touch_type == TouchType;
}
-template<world::VoxelMaterial Material>
-constexpr bool world::Voxel::is_surface_material(void) const noexcept
+template<VoxelMaterial Material>
+constexpr bool Voxel::is_surface_material(void) const noexcept
{
return m_surface_material == Material;
}
diff --git a/src/game/shared/world/voxel_registry.cc b/src/game/shared/world/voxel_registry.cc
index fae83fa..f950a4d 100644
--- a/src/game/shared/world/voxel_registry.cc
+++ b/src/game/shared/world/voxel_registry.cc
@@ -3,19 +3,19 @@
#include "shared/world/voxel_registry.hh"
static std::uint64_t registry_checksum = 0U;
-emhash8::HashMap<std::string, voxel_id> world::voxel_registry::names;
-std::vector<std::unique_ptr<world::Voxel>> world::voxel_registry::voxels;
+emhash8::HashMap<std::string, voxel_id> voxel_registry::names;
+std::vector<std::unique_ptr<Voxel>> voxel_registry::voxels;
static void recalculate_checksum(void)
{
registry_checksum = 0U;
- for(const auto& voxel : world::voxel_registry::voxels) {
+ for(const auto& voxel : voxel_registry::voxels) {
registry_checksum = voxel->get_checksum(registry_checksum);
}
}
-world::Voxel* world::voxel_registry::register_voxel(const VoxelBuilder& builder)
+Voxel* voxel_registry::register_voxel(const VoxelBuilder& builder)
{
assert(builder.get_name().size());
assert(nullptr == find(builder.get_name()));
@@ -31,7 +31,7 @@ world::Voxel* world::voxel_registry::register_voxel(const VoxelBuilder& builder)
return voxels.back().get();
}
-world::Voxel* world::voxel_registry::find(std::string_view name)
+Voxel* voxel_registry::find(std::string_view name)
{
const auto it = names.find(std::string(name));
@@ -42,7 +42,7 @@ world::Voxel* world::voxel_registry::find(std::string_view name)
return voxels[it->second - 1].get();
}
-world::Voxel* world::voxel_registry::find(voxel_id id)
+Voxel* voxel_registry::find(voxel_id id)
{
if(id == NULL_VOXEL_ID || id > voxels.size()) {
return nullptr;
@@ -51,14 +51,14 @@ world::Voxel* world::voxel_registry::find(voxel_id id)
return voxels[id - 1].get();
}
-void world::voxel_registry::purge(void)
+void voxel_registry::purge(void)
{
registry_checksum = 0U;
voxels.clear();
names.clear();
}
-std::uint64_t world::voxel_registry::get_checksum(void)
+std::uint64_t voxel_registry::get_checksum(void)
{
return registry_checksum;
}
diff --git a/src/game/shared/world/voxel_registry.hh b/src/game/shared/world/voxel_registry.hh
index a1e0eee..5dbaf50 100644
--- a/src/game/shared/world/voxel_registry.hh
+++ b/src/game/shared/world/voxel_registry.hh
@@ -2,25 +2,25 @@
#include "shared/world/voxel.hh"
-namespace world::voxel_registry
+namespace voxel_registry
{
extern emhash8::HashMap<std::string, voxel_id> names;
extern std::vector<std::unique_ptr<Voxel>> voxels;
-} // namespace world::voxel_registry
+} // namespace voxel_registry
-namespace world::voxel_registry
+namespace voxel_registry
{
Voxel* register_voxel(const VoxelBuilder& builder);
Voxel* find(std::string_view name);
Voxel* find(voxel_id id);
-} // namespace world::voxel_registry
+} // namespace voxel_registry
-namespace world::voxel_registry
+namespace voxel_registry
{
void purge(void);
-} // namespace world::voxel_registry
+} // namespace voxel_registry
-namespace world::voxel_registry
+namespace voxel_registry
{
std::uint64_t get_checksum(void);
-} // namespace world::voxel_registry
+} // namespace voxel_registry
diff --git a/src/game/shared/world/voxel_storage.cc b/src/game/shared/world/voxel_storage.cc
index 68e261c..43ca116 100644
--- a/src/game/shared/world/voxel_storage.cc
+++ b/src/game/shared/world/voxel_storage.cc
@@ -4,7 +4,7 @@
#include "core/io/buffer.hh"
-void world::VoxelStorage::serialize(io::WriteBuffer& buffer) const
+void VoxelStorage::serialize(WriteBuffer& buffer) const
{
auto bound = mz_compressBound(sizeof(VoxelStorage));
auto zdata = std::vector<unsigned char>(bound);
@@ -28,7 +28,7 @@ void world::VoxelStorage::serialize(io::WriteBuffer& buffer) const
}
}
-void world::VoxelStorage::deserialize(io::ReadBuffer& buffer)
+void VoxelStorage::deserialize(ReadBuffer& buffer)
{
auto size = static_cast<mz_ulong>(sizeof(VoxelStorage));
auto bound = static_cast<mz_ulong>(buffer.read<std::uint64_t>());
diff --git a/src/game/shared/world/voxel_storage.hh b/src/game/shared/world/voxel_storage.hh
index ac7f03d..ef427b3 100644
--- a/src/game/shared/world/voxel_storage.hh
+++ b/src/game/shared/world/voxel_storage.hh
@@ -3,18 +3,12 @@
#include "shared/const.hh"
#include "shared/types.hh"
-namespace io
-{
class ReadBuffer;
class WriteBuffer;
-} // namespace io
-namespace world
-{
class VoxelStorage final : public std::array<voxel_id, CHUNK_VOLUME> {
public:
using std::array<voxel_id, CHUNK_VOLUME>::array;
- void serialize(io::WriteBuffer& buffer) const;
- void deserialize(io::ReadBuffer& buffer);
+ void serialize(WriteBuffer& buffer) const;
+ void deserialize(ReadBuffer& buffer);
};
-} // namespace world