Skip to content

Commit bdcbf9b

Browse files
Synchronize changes from 1.6 master branch [ci skip]
9d776c8 Allow using std::variant with several pointers (Lua parser) (#4224)
2 parents 85d4b5b + 9d776c8 commit bdcbf9b

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,17 @@ struct CLuaFunctionParserBase
320320
// Catch all for class pointer types, assume all classes are valid script entities
321321
// and can be fetched from a userdata
322322
else if constexpr (std::is_pointer_v<T> && std::is_class_v<std::remove_pointer_t<T>>)
323-
return iArgument == LUA_TUSERDATA || iArgument == LUA_TLIGHTUSERDATA;
323+
{
324+
if (iArgument != LUA_TUSERDATA && iArgument != LUA_TLIGHTUSERDATA)
325+
return false;
326+
327+
using class_t = std::remove_pointer_t<T>;
328+
int tempIndex{index};
329+
void* pValue = lua::PopPrimitive<void*>(L, tempIndex);
330+
auto result = iArgument == LUA_TLIGHTUSERDATA ? UserDataCast((class_t*)pValue, L) :
331+
UserDataCast(*reinterpret_cast<class_t**>(pValue), L);
332+
return result != nullptr;
333+
}
324334

325335
// dummy type is used as overload extension if one overload has fewer arguments
326336
// thus it is only allowed if there are no further args on the Lua side

0 commit comments

Comments
 (0)