From 2a0d1f94e1597f9c2f0e22606270bd5d7890fe0d Mon Sep 17 00:00:00 2001 From: pv
Date: Sat, 2 Oct 2021 14:22:36 +0300 Subject: [PATCH 1/2] Mark gamedataTDBIDHelper as static helper --- src/reverse/RTTIHelper.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/reverse/RTTIHelper.cpp b/src/reverse/RTTIHelper.cpp index 97f703de..dfa3758c 100644 --- a/src/reverse/RTTIHelper.cpp +++ b/src/reverse/RTTIHelper.cpp @@ -118,6 +118,7 @@ void RTTIHelper::AddFunctionAlias(const std::string& acAliasClassName, const std bool RTTIHelper::IsFunctionAlias(RED4ext::CBaseFunction* apFunc) { static const auto s_cTweakDBInterfaceHash = RED4ext::FNV1a("gamedataTweakDBInterface"); + static const auto s_cTDBIDHelperHash = RED4ext::FNV1a("gamedataTDBIDHelper"); if (m_extendedFunctions.contains(kGlobalHash)) { @@ -131,9 +132,9 @@ bool RTTIHelper::IsFunctionAlias(RED4ext::CBaseFunction* apFunc) { const auto cClassHash = apFunc->GetParent()->name.hash; - // TweakDBInterface is special. - // All of its methods are non-static, but they can only be used as static ones. - if (cClassHash == s_cTweakDBInterfaceHash) + // TweakDBInterface and TDBID classes are special. + // All of their methods are non-static, but they can only be used as static ones. + if (cClassHash == s_cTweakDBInterfaceHash || cClassHash == s_cTDBIDHelperHash) return true; if (m_extendedFunctions.contains(cClassHash)) From 543fa18aa1bb0785b1d9a310d7d5035ae1ab0998 Mon Sep 17 00:00:00 2001 From: pv
Date: Sat, 2 Oct 2021 14:40:36 +0300
Subject: [PATCH 2/2] Drop second implementation of ToRED
---
src/scripting/Scripting.cpp | 106 ++++--------------------------------
1 file changed, 10 insertions(+), 96 deletions(-)
diff --git a/src/scripting/Scripting.cpp b/src/scripting/Scripting.cpp
index bdcbb6ac..d1181f32 100644
--- a/src/scripting/Scripting.cpp
+++ b/src/scripting/Scripting.cpp
@@ -946,102 +946,16 @@ RED4ext::CStackType Scripting::ToRED(sol::object aObject, RED4ext::CBaseRTTIType
return result;
}
-void Scripting::ToRED(sol::object aObject, RED4ext::CStackType* apType)
+void Scripting::ToRED(sol::object aObject, RED4ext::CStackType* apRet)
{
- const bool hasData = aObject != sol::nil;
+ static thread_local TiltedPhoques::ScratchAllocator s_scratchMemory(1 << 13);
- if (apType->type)
- {
- if (apType->type == s_stringType)
- {
- std::string str;
- if (hasData)
- {
- sol::state_view v(aObject.lua_state());
- str = v["tostring"](aObject);
- }
- RED4ext::CString value(str.c_str());
- *static_cast