summaryrefslogtreecommitdiffstats
path: root/game/shared
diff options
context:
space:
mode:
authoruntodesu <kirill@untode.su>2025-09-14 19:16:44 +0500
committeruntodesu <kirill@untode.su>2025-09-14 19:16:44 +0500
commit8bcbd2729388edc63c82d77d314b583af1447c49 (patch)
tree460c2b509372077f6adf95d72c4245988a580aed /game/shared
parent7fc7fdb001bea8674fe0dbc1b962f3ec2702debb (diff)
downloadvoxelius-8bcbd2729388edc63c82d77d314b583af1447c49.tar.bz2
voxelius-8bcbd2729388edc63c82d77d314b583af1447c49.zip
Cleanup math with qfengine ports again
Diffstat (limited to 'game/shared')
-rw-r--r--game/shared/entity/collision.cc14
-rw-r--r--game/shared/game.cc11
-rw-r--r--game/shared/splash.cc4
-rw-r--r--game/shared/world/ray_dda.cc6
4 files changed, 19 insertions, 16 deletions
diff --git a/game/shared/entity/collision.cc b/game/shared/entity/collision.cc
index 6b9f063..d2bc0a9 100644
--- a/game/shared/entity/collision.cc
+++ b/game/shared/entity/collision.cc
@@ -29,14 +29,14 @@ static int vgrid_collide(const world::Dimension* dimension, int d, entity::Colli
next_aabb.max[d] += move;
local_pos lpos_min;
- lpos_min.x = math::floor<local_pos::value_type>(next_aabb.min.x);
- lpos_min.y = math::floor<local_pos::value_type>(next_aabb.min.y);
- lpos_min.z = math::floor<local_pos::value_type>(next_aabb.min.z);
+ lpos_min.x = static_cast<local_pos::value_type>(glm::floor(next_aabb.min.x));
+ lpos_min.y = static_cast<local_pos::value_type>(glm::floor(next_aabb.min.y));
+ lpos_min.z = static_cast<local_pos::value_type>(glm::floor(next_aabb.min.z));
local_pos lpos_max;
- lpos_max.x = math::ceil<local_pos::value_type>(next_aabb.max.x);
- lpos_max.y = math::ceil<local_pos::value_type>(next_aabb.max.y);
- lpos_max.z = math::ceil<local_pos::value_type>(next_aabb.max.z);
+ lpos_max.x = static_cast<local_pos::value_type>(glm::ceil(next_aabb.max.x));
+ lpos_max.y = static_cast<local_pos::value_type>(glm::ceil(next_aabb.max.y));
+ lpos_max.z = static_cast<local_pos::value_type>(glm::ceil(next_aabb.max.z));
// Other axes
const int u = (d + 1) % 3;
@@ -110,7 +110,7 @@ static int vgrid_collide(const world::Dimension* dimension, int d, entity::Colli
if(latch_touch != world::VTOUCH_NONE) {
if(latch_touch == world::VTOUCH_BOUNCE) {
- const auto move_distance = math::abs(current_aabb.min[d] - next_aabb.min[d]);
+ const auto move_distance = glm::abs(current_aabb.min[d] - next_aabb.min[d]);
const auto threshold = 2.0f * globals::fixed_frametime;
if(move_distance > threshold) {
diff --git a/game/shared/game.cc b/game/shared/game.cc
index f7b9da4..91bc3bc 100644
--- a/game/shared/game.cc
+++ b/game/shared/game.cc
@@ -3,6 +3,7 @@
#include "shared/game.hh"
#include "core/io/cmdline.hh"
+#include "core/io/physfs.hh"
static std::filesystem::path get_gamepath(void)
{
@@ -77,7 +78,7 @@ void shared_game::init(int argc, char** argv)
logger->flush();
if(!PHYSFS_init(argv[0])) {
- spdlog::critical("physfs: init failed: {}", PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode()));
+ spdlog::critical("physfs: init failed: {}", io::physfs_error());
std::terminate();
}
@@ -92,17 +93,17 @@ void shared_game::init(int argc, char** argv)
std::filesystem::create_directories(userpath, ignore_error);
if(!PHYSFS_mount(gamepath.string().c_str(), nullptr, false)) {
- spdlog::critical("physfs: mount {} failed: {}", gamepath.string(), PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode()));
+ spdlog::critical("physfs: mount {} failed: {}", gamepath.string(), io::physfs_error());
std::terminate();
}
if(!PHYSFS_mount(userpath.string().c_str(), nullptr, false)) {
- spdlog::critical("physfs: mount {} failed: {}", userpath.string(), PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode()));
+ spdlog::critical("physfs: mount {} failed: {}", userpath.string(), io::physfs_error());
std::terminate();
}
if(!PHYSFS_setWriteDir(userpath.string().c_str())) {
- spdlog::critical("physfs: setwritedir {} failed: {}", userpath.string(), PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode()));
+ spdlog::critical("physfs: setwritedir {} failed: {}", userpath.string(), io::physfs_error());
std::terminate();
}
@@ -117,7 +118,7 @@ void shared_game::shutdown(void)
enet_deinitialize();
if(!PHYSFS_deinit()) {
- spdlog::critical("physfs: deinit failed: {}", PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode()));
+ spdlog::critical("physfs: deinit failed: {}", io::physfs_error());
std::terminate();
}
}
diff --git a/game/shared/splash.cc b/game/shared/splash.cc
index 7515358..9d74ba9 100644
--- a/game/shared/splash.cc
+++ b/game/shared/splash.cc
@@ -2,6 +2,8 @@
#include "shared/splash.hh"
+#include "core/io/physfs.hh"
+
constexpr static std::string_view SPLASHES_FILENAME_CLIENT = "misc/splashes_client.txt";
constexpr static std::string_view SPLASHES_FILENAME_SERVER = "misc/splashes_server.txt";
constexpr static std::size_t SPLASH_SERVER_MAX_LENGTH = 32;
@@ -37,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, PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode())));
+ splash_lines.push_back(std::format("{}: {}", filename, io::physfs_error()));
splash_random.seed(std::random_device()());
}
}
diff --git a/game/shared/world/ray_dda.cc b/game/shared/world/ray_dda.cc
index 7bb1068..af1ab3b 100644
--- a/game/shared/world/ray_dda.cc
+++ b/game/shared/world/ray_dda.cc
@@ -26,9 +26,9 @@ void world::RayDDA::reset(const world::Dimension* dimension, const chunk_pos& st
this->start_fpos = start_fpos;
this->direction = direction;
- this->delta_dist.x = direction.x ? math::abs(1.0f / direction.x) : std::numeric_limits<float>::max();
- this->delta_dist.y = direction.y ? math::abs(1.0f / direction.y) : std::numeric_limits<float>::max();
- this->delta_dist.z = direction.z ? math::abs(1.0f / direction.z) : std::numeric_limits<float>::max();
+ this->delta_dist.x = direction.x ? glm::abs(1.0f / direction.x) : std::numeric_limits<float>::max();
+ this->delta_dist.y = direction.y ? glm::abs(1.0f / direction.y) : std::numeric_limits<float>::max();
+ this->delta_dist.z = direction.z ? glm::abs(1.0f / direction.z) : std::numeric_limits<float>::max();
this->distance = 0.0f;
this->vpos = coord::to_voxel(start_chunk, start_fpos);