From dba81959c56042721d50b5635954c3065435d9a9 Mon Sep 17 00:00:00 2001 From: Beats Date: Sat, 2 Dec 2023 01:42:45 -0300 Subject: [PATCH] test --- src/lua/functions/lua_functions_loader.hpp | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/lua/functions/lua_functions_loader.hpp b/src/lua/functions/lua_functions_loader.hpp index 17495cd2e63..90f0dc15ce5 100644 --- a/src/lua/functions/lua_functions_loader.hpp +++ b/src/lua/functions/lua_functions_loader.hpp @@ -60,20 +60,13 @@ class LuaFunctionsLoader { template static typename std::enable_if::value, T>::type getNumber(lua_State* L, int32_t arg) { - return static_cast(static_cast(lua_tonumber(L, arg))); + return safe_convert(safe_convert(lua_tonumber(L, arg), __FUNCTION__), __FUNCTION__); } template static typename std::enable_if::value || std::is_floating_point::value, T>::type getNumber(lua_State* L, int32_t arg) { auto number = lua_tonumber(L, arg); - // If there is overflow, we return the value 0 - if constexpr (std::is_integral_v && std::is_unsigned_v) { - if (number < 0) { - g_logger().debug("[{}] overflow, setting to default signed value (0)", __FUNCTION__); - number = T(0); - } - } - return static_cast(number); + return safe_convert(number, __FUNCTION__, 0); } template static T getNumber(lua_State* L, int32_t arg, T defaultValue) {