Skip to content

Commit

Permalink
Fix CVector optional arguments - Follow-up (#3896)
Browse files Browse the repository at this point in the history
  • Loading branch information
TracerDS authored Dec 23, 2024
1 parent d9c531e commit 865646f
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions Shared/mods/deathmatch/logic/lua/CLuaFunctionParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,11 @@ struct CLuaFunctionParserBase
else if constexpr (std::is_same_v<T, CVector2D>)
{
if (lua_isnumber(L, index))
return {PopUnsafe<float>(L, index), PopUnsafe<float>(L, index)};
{
auto x = PopUnsafe<float>(L, index);
auto y = PopUnsafe<float>(L, index);
return CVector2D(x, y);
}

int iType = lua_type(L, index);
bool isLightUserData = iType == LUA_TLIGHTUSERDATA;
Expand All @@ -561,7 +565,12 @@ struct CLuaFunctionParserBase
else if constexpr (std::is_same_v<T, CVector>)
{
if (lua_isnumber(L, index))
return CVector(PopUnsafe<float>(L, index), PopUnsafe<float>(L, index), PopUnsafe<float>(L, index));
{
auto x = PopUnsafe<float>(L, index);
auto y = PopUnsafe<float>(L, index);
auto z = PopUnsafe<float>(L, index);
return CVector(x, y, z);
}

int iType = lua_type(L, index);
bool isLightUserData = iType == LUA_TLIGHTUSERDATA;
Expand All @@ -584,7 +593,13 @@ struct CLuaFunctionParserBase
else if constexpr (std::is_same_v<T, CVector4D>)
{
if (lua_isnumber(L, index))
return {PopUnsafe<float>(L, index), PopUnsafe<float>(L, index), PopUnsafe<float>(L, index), PopUnsafe<float>(L, index)};
{
auto x = PopUnsafe<float>(L, index);
auto y = PopUnsafe<float>(L, index);
auto z = PopUnsafe<float>(L, index);
auto w = PopUnsafe<float>(L, index);
return CVector4D(x, y, z, w);
}

int iType = lua_type(L, index);
bool isLightUserData = iType == LUA_TLIGHTUSERDATA;
Expand All @@ -606,7 +621,13 @@ struct CLuaFunctionParserBase
{
if (lua_isnumber(L, index))
{
const auto ReadVector = [&] { return CVector(PopUnsafe<float>(L, index), PopUnsafe<float>(L, index), PopUnsafe<float>(L, index)); };
const auto ReadVector = [&]
{
auto x = PopUnsafe<float>(L, index);
auto y = PopUnsafe<float>(L, index);
auto z = PopUnsafe<float>(L, index);
return CVector(x, y, z);
};

CMatrix matrix;

Expand Down

0 comments on commit 865646f

Please sign in to comment.