From 865646f5155c678f00710ef866f51b14bff9207c Mon Sep 17 00:00:00 2001 From: Tracer <43095317+TracerDS@users.noreply.github.com> Date: Mon, 23 Dec 2024 09:31:51 +0100 Subject: [PATCH] Fix CVector optional arguments - Follow-up (#3896) --- .../deathmatch/logic/lua/CLuaFunctionParser.h | 29 ++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/Shared/mods/deathmatch/logic/lua/CLuaFunctionParser.h b/Shared/mods/deathmatch/logic/lua/CLuaFunctionParser.h index 8f3615f3bd..b31b5cba4a 100644 --- a/Shared/mods/deathmatch/logic/lua/CLuaFunctionParser.h +++ b/Shared/mods/deathmatch/logic/lua/CLuaFunctionParser.h @@ -536,7 +536,11 @@ struct CLuaFunctionParserBase else if constexpr (std::is_same_v) { if (lua_isnumber(L, index)) - return {PopUnsafe(L, index), PopUnsafe(L, index)}; + { + auto x = PopUnsafe(L, index); + auto y = PopUnsafe(L, index); + return CVector2D(x, y); + } int iType = lua_type(L, index); bool isLightUserData = iType == LUA_TLIGHTUSERDATA; @@ -561,7 +565,12 @@ struct CLuaFunctionParserBase else if constexpr (std::is_same_v) { if (lua_isnumber(L, index)) - return CVector(PopUnsafe(L, index), PopUnsafe(L, index), PopUnsafe(L, index)); + { + auto x = PopUnsafe(L, index); + auto y = PopUnsafe(L, index); + auto z = PopUnsafe(L, index); + return CVector(x, y, z); + } int iType = lua_type(L, index); bool isLightUserData = iType == LUA_TLIGHTUSERDATA; @@ -584,7 +593,13 @@ struct CLuaFunctionParserBase else if constexpr (std::is_same_v) { if (lua_isnumber(L, index)) - return {PopUnsafe(L, index), PopUnsafe(L, index), PopUnsafe(L, index), PopUnsafe(L, index)}; + { + auto x = PopUnsafe(L, index); + auto y = PopUnsafe(L, index); + auto z = PopUnsafe(L, index); + auto w = PopUnsafe(L, index); + return CVector4D(x, y, z, w); + } int iType = lua_type(L, index); bool isLightUserData = iType == LUA_TLIGHTUSERDATA; @@ -606,7 +621,13 @@ struct CLuaFunctionParserBase { if (lua_isnumber(L, index)) { - const auto ReadVector = [&] { return CVector(PopUnsafe(L, index), PopUnsafe(L, index), PopUnsafe(L, index)); }; + const auto ReadVector = [&] + { + auto x = PopUnsafe(L, index); + auto y = PopUnsafe(L, index); + auto z = PopUnsafe(L, index); + return CVector(x, y, z); + }; CMatrix matrix;