From 53d5a649b9d74e21ad4c87ae8bb1ae2c6344b823 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 6 Nov 2025 19:00:48 +0100 Subject: [PATCH] simplify srb2::floattofixed my tired ass didnt think about just reusing shit kek ty indev <3 --- src/cxxutil.hpp | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/src/cxxutil.hpp b/src/cxxutil.hpp index 91c1a8641..98c9d9e5f 100644 --- a/src/cxxutil.hpp +++ b/src/cxxutil.hpp @@ -189,29 +189,7 @@ static inline int32_t floattofixed(FloatT val) static_assert(std::is_floating_point_v, "Input must be a floating-point type"); // fixed_t is just an int32_t, i dont wanna include doomtype here if it can be avoided - - if (std::fpclassify(val) == FP_NAN) - return 0; // if stuffs not a number we sure screwed up lmao - - // treat inifinity as "int min/max" - if (std::fpclassify(val) == FP_INFINITE) - { - // yes infinity can be signed kek - if (std::signbit(val)) - return std::numeric_limits::min(); // negative infinity, so return min - else - return std::numeric_limits::max(); - } - - const FloatT ret = (val * 65536.0); - - // make sure we fit into our targettype uwu - if (ret > static_cast(std::numeric_limits::max())) - return std::numeric_limits::max(); - else if (ret < static_cast(std::numeric_limits::min())) - return std::numeric_limits::min(); - - return static_cast(ret); + return floattoint(val * 65535.); } } // namespace srb2