From 69a3a82e6792581c97debb37156288d4e2732ff4 Mon Sep 17 00:00:00 2001 From: yamashi Date: Sat, 13 Feb 2021 22:43:10 +0100 Subject: [PATCH] Functions are not cached anymore --- src/reverse/Type.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/reverse/Type.cpp b/src/reverse/Type.cpp index b0725b72..d988798e 100644 --- a/src/reverse/Type.cpp +++ b/src/reverse/Type.cpp @@ -395,8 +395,23 @@ sol::object ClassType::Index_Impl(const std::string& acName, sol::this_environme } } - auto obj = make_object(m_lua, [pFunc, name = acName](Type* apType, sol::variadic_args aArgs, sol::this_environment aThisEnv, sol::this_state L) + auto obj = make_object(m_lua, [pType, name = acName](Type* apType, sol::variadic_args aArgs, + sol::this_environment aThisEnv, sol::this_state L) { + // We need to retrieve the function everytime as they can change with this + auto* pFunc = pType->GetFunction(RED4ext::FNV1a(name.c_str())); + if (!pFunc) + { + for (uint32_t i = 0; i < pType->funcs.size; ++i) + { + if (pType->funcs.entries[i]->fullName.hash == RED4ext::FNV1a(name.c_str())) + { + pFunc = static_cast(pType->funcs.entries[i]); + break; + } + } + } + std::string result; auto funcRet = apType->Execute(pFunc, name, aArgs, aThisEnv, L, result); if (!result.empty())