Skip to content

Commit 865646f

Browse files
authored
Fix CVector optional arguments - Follow-up (#3896)
1 parent d9c531e commit 865646f

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

Shared/mods/deathmatch/logic/lua/CLuaFunctionParser.h

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,11 @@ struct CLuaFunctionParserBase
536536
else if constexpr (std::is_same_v<T, CVector2D>)
537537
{
538538
if (lua_isnumber(L, index))
539-
return {PopUnsafe<float>(L, index), PopUnsafe<float>(L, index)};
539+
{
540+
auto x = PopUnsafe<float>(L, index);
541+
auto y = PopUnsafe<float>(L, index);
542+
return CVector2D(x, y);
543+
}
540544

541545
int iType = lua_type(L, index);
542546
bool isLightUserData = iType == LUA_TLIGHTUSERDATA;
@@ -561,7 +565,12 @@ struct CLuaFunctionParserBase
561565
else if constexpr (std::is_same_v<T, CVector>)
562566
{
563567
if (lua_isnumber(L, index))
564-
return CVector(PopUnsafe<float>(L, index), PopUnsafe<float>(L, index), PopUnsafe<float>(L, index));
568+
{
569+
auto x = PopUnsafe<float>(L, index);
570+
auto y = PopUnsafe<float>(L, index);
571+
auto z = PopUnsafe<float>(L, index);
572+
return CVector(x, y, z);
573+
}
565574

566575
int iType = lua_type(L, index);
567576
bool isLightUserData = iType == LUA_TLIGHTUSERDATA;
@@ -584,7 +593,13 @@ struct CLuaFunctionParserBase
584593
else if constexpr (std::is_same_v<T, CVector4D>)
585594
{
586595
if (lua_isnumber(L, index))
587-
return {PopUnsafe<float>(L, index), PopUnsafe<float>(L, index), PopUnsafe<float>(L, index), PopUnsafe<float>(L, index)};
596+
{
597+
auto x = PopUnsafe<float>(L, index);
598+
auto y = PopUnsafe<float>(L, index);
599+
auto z = PopUnsafe<float>(L, index);
600+
auto w = PopUnsafe<float>(L, index);
601+
return CVector4D(x, y, z, w);
602+
}
588603

589604
int iType = lua_type(L, index);
590605
bool isLightUserData = iType == LUA_TLIGHTUSERDATA;
@@ -606,7 +621,13 @@ struct CLuaFunctionParserBase
606621
{
607622
if (lua_isnumber(L, index))
608623
{
609-
const auto ReadVector = [&] { return CVector(PopUnsafe<float>(L, index), PopUnsafe<float>(L, index), PopUnsafe<float>(L, index)); };
624+
const auto ReadVector = [&]
625+
{
626+
auto x = PopUnsafe<float>(L, index);
627+
auto y = PopUnsafe<float>(L, index);
628+
auto z = PopUnsafe<float>(L, index);
629+
return CVector(x, y, z);
630+
};
610631

611632
CMatrix matrix;
612633

0 commit comments

Comments
 (0)