From 9b7444ae7fe235dad23e4445ca908c990f17c740 Mon Sep 17 00:00:00 2001 From: sbx320 Date: Mon, 25 Aug 2025 12:43:54 +0200 Subject: [PATCH] Fix argument parser not handling noexcept functions --- .../mods/deathmatch/logic/luadefs/CLuaDefs.h | 12 ++++---- Shared/sdk/SharedUtil.Template.h | 30 +++++++++++++++++++ 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/Server/mods/deathmatch/logic/luadefs/CLuaDefs.h b/Server/mods/deathmatch/logic/luadefs/CLuaDefs.h index 412ad98ea7a..9949cccb314 100644 --- a/Server/mods/deathmatch/logic/luadefs/CLuaDefs.h +++ b/Server/mods/deathmatch/logic/luadefs/CLuaDefs.h @@ -96,7 +96,7 @@ class CLuaDefs template static inline int ArgumentParserWarn(lua_State* L) { - return CLuaFunctionParser()(L, m_pScriptDebugging); + return CLuaFunctionParser>()(L, m_pScriptDebugging); } // Special case for overloads @@ -106,8 +106,8 @@ class CLuaDefs { // Pad functions to have the same number of parameters by // filling both up to the larger number of parameters with dummy_type arguments - using PaddedFunctionA = pad_func_with_func; - using PaddedFunctionB = pad_func_with_func; + using PaddedFunctionA = pad_func_with_func, remove_noexcept_fn_v>; + using PaddedFunctionB = pad_func_with_func, remove_noexcept_fn_v>; // Combine functions using Overload = CLuaOverloadParser; @@ -118,7 +118,7 @@ class CLuaDefs template static inline int ArgumentParser(lua_State* L) { - return CLuaFunctionParser()(L, m_pScriptDebugging); + return CLuaFunctionParser>()(L, m_pScriptDebugging); } // Special case for overloads @@ -128,8 +128,8 @@ class CLuaDefs { // Pad functions to have the same number of parameters by // filling both up to the larger number of parameters with dummy_type arguments - using PaddedFunctionA = pad_func_with_func; - using PaddedFunctionB = pad_func_with_func; + using PaddedFunctionA = pad_func_with_func, remove_noexcept_fn_v>; + using PaddedFunctionB = pad_func_with_func, remove_noexcept_fn_v>; // Combine functions using Overload = CLuaOverloadParser; diff --git a/Shared/sdk/SharedUtil.Template.h b/Shared/sdk/SharedUtil.Template.h index e423610cd7f..647372ff515 100644 --- a/Shared/sdk/SharedUtil.Template.h +++ b/Shared/sdk/SharedUtil.Template.h @@ -250,3 +250,33 @@ struct pad_func_with_func std::max(sizeof...(Args), sizeof...(ArgsB)) - sizeof...(Args) == 0>::type> { }; + + +// Removes noexcept(true) from a function type +template +struct remove_noexcept +{ + using type = T; +}; +template +struct remove_noexcept +{ + using type = R(P...); +}; +template +using remove_noexcept_t = typename remove_noexcept::type; + +// Removes noexcept(true) from a function +template +struct remove_noexcept_fn +{ + constexpr static auto func = T; +}; +template +struct remove_noexcept_fn +{ + using func_t = Ret (*)(Args...); + constexpr static func_t func = Func; +}; +template +constexpr auto remove_noexcept_fn_v = remove_noexcept_fn::func;