diff --git a/src/reverse/RTTIExtender.cpp b/src/reverse/RTTIExtender.cpp index eeb8afa8..3d97d9dc 100644 --- a/src/reverse/RTTIExtender.cpp +++ b/src/reverse/RTTIExtender.cpp @@ -1,6 +1,5 @@ #include "RTTIExtender.h" -#include #include #include #include @@ -204,9 +203,9 @@ struct TEMP_Spawner RED4ext::DynArray> spawnedEntities; RED4ext::DynArray pendingEntities; RED4ext::DynArray unk30; - uint8_t unk40 = 0; // most likely a mutex - RED4ext::SharedMutex entitiesMtx; // used in DespawnEntity - RED4ext::SharedMutex pendingEntitiesMtx; // used in SpawnEntity + uint8_t unk40 = 0; // most likely a mutex + RED4ext::SharedSpinLock entitiesMtx; // used in DespawnEntity + RED4ext::SharedSpinLock pendingEntitiesMtx; // used in SpawnEntity uintptr_t unk48 = 0; uintptr_t unk50 = 0; uintptr_t unk58 = 0; diff --git a/src/reverse/RTTIMapper.cpp b/src/reverse/RTTIMapper.cpp index 4d0b908e..d06c195a 100644 --- a/src/reverse/RTTIMapper.cpp +++ b/src/reverse/RTTIMapper.cpp @@ -56,7 +56,7 @@ void RTTIMapper::RegisterSimpleTypes(sol::state& aLuaState, sol::table& aLuaGlob aLuaGlobal["ToVariant"] = sol::overload( [](const Type& aInstance, sol::this_state aState) -> sol::object { - const auto* pType = aInstance.GetType(); + auto* pType = aInstance.GetValueType(); auto* pValue = aInstance.GetValuePtr(); if (!pType || !pValue) @@ -199,6 +199,14 @@ void RTTIMapper::RegisterDirectGlobals(sol::table& aLuaGlobal, RED4ext::CRTTISys if (!cIsClassFunc && !cIsOperatorFunc) { aLuaGlobal[cShortName] = RTTIHelper::Get().ResolveFunction(cShortName); + + std::string sanitizedName = cShortName; + SanitizeName(sanitizedName); + + if (sanitizedName != cShortName) + { + aLuaGlobal[sanitizedName] = aLuaGlobal[cShortName]; + } } } }); diff --git a/src/reverse/StrongReference.cpp b/src/reverse/StrongReference.cpp index 76f109b9..d6666722 100644 --- a/src/reverse/StrongReference.cpp +++ b/src/reverse/StrongReference.cpp @@ -10,6 +10,7 @@ static RTTILocator s_sIScriptableType{RED4ext::FNV1a64("IScriptable")}; StrongReference::StrongReference(const TiltedPhoques::Lockable::Ref& aView, RED4ext::Handle aStrongHandle) : ClassType(aView, nullptr) , m_strongHandle(std::move(aStrongHandle)) + , m_pHandleType(nullptr) { if (m_strongHandle) { @@ -21,6 +22,7 @@ StrongReference::StrongReference( const TiltedPhoques::Lockable::Ref& aView, RED4ext::Handle aStrongHandle, RED4ext::CRTTIHandleType* apStrongHandleType) : ClassType(aView, nullptr) , m_strongHandle(std::move(aStrongHandle)) + , m_pHandleType(apStrongHandleType) { if (m_strongHandle) { @@ -49,3 +51,8 @@ RED4ext::ScriptInstance StrongReference::GetValuePtr() const { return const_cast*>(&m_strongHandle); } + +RED4ext::CBaseRTTIType* StrongReference::GetValueType() const +{ + return m_pHandleType; +} diff --git a/src/reverse/StrongReference.h b/src/reverse/StrongReference.h index 219011ae..1833ba78 100644 --- a/src/reverse/StrongReference.h +++ b/src/reverse/StrongReference.h @@ -13,10 +13,12 @@ struct StrongReference : ClassType protected: RED4ext::ScriptInstance GetHandle() const override; RED4ext::ScriptInstance GetValuePtr() const override; + RED4ext::CBaseRTTIType* GetValueType() const override; private: friend struct Scripting; friend struct TweakDB; RED4ext::Handle m_strongHandle; + RED4ext::CRTTIHandleType* m_pHandleType; }; diff --git a/src/reverse/TweakDB/ResourcesList.cpp b/src/reverse/TweakDB/ResourcesList.cpp index e23229b6..980cba3f 100644 --- a/src/reverse/TweakDB/ResourcesList.cpp +++ b/src/reverse/TweakDB/ResourcesList.cpp @@ -100,7 +100,7 @@ bool ResourcesList::IsInitialized() const const std::string& ResourcesList::Resolve(uint64_t aHash) { - static std::string defaultName = "ERROR_UNKNOWN_RESOURCE"; + static std::string defaultName = "UNRESOLVED_RESOURCE_PATH"; const auto it = m_resourcesByHash.find(aHash); diff --git a/src/reverse/Type.h b/src/reverse/Type.h index 2d42ee90..bd17c644 100644 --- a/src/reverse/Type.h +++ b/src/reverse/Type.h @@ -17,6 +17,7 @@ struct Type RED4ext::CBaseRTTIType* GetType() const { return m_pType; } virtual RED4ext::ScriptInstance GetHandle() const { return nullptr; } + virtual RED4ext::CBaseRTTIType* GetValueType() const { return m_pType; } virtual RED4ext::ScriptInstance GetValuePtr() const { return nullptr; } sol::object Index(const std::string& acName, sol::this_environment aThisEnv); diff --git a/src/reverse/WeakReference.cpp b/src/reverse/WeakReference.cpp index b4ba8d83..f808c966 100644 --- a/src/reverse/WeakReference.cpp +++ b/src/reverse/WeakReference.cpp @@ -10,6 +10,7 @@ static RTTILocator s_sIScriptableType{RED4ext::FNV1a64("IScriptable")}; WeakReference::WeakReference(const TiltedPhoques::Lockable::Ref& aView, RED4ext::WeakHandle aWeakHandle) : ClassType(aView, nullptr) , m_weakHandle(std::move(aWeakHandle)) + , m_pHandleType(nullptr) { const auto ref = m_weakHandle.Lock(); if (ref) @@ -23,6 +24,7 @@ WeakReference::WeakReference( RED4ext::CRTTIWeakHandleType* apWeakHandleType) : ClassType(aView, nullptr) , m_weakHandle(std::move(aWeakHandle)) + , m_pHandleType(apWeakHandleType) { const auto ref = m_weakHandle.Lock(); if (ref) @@ -58,3 +60,8 @@ RED4ext::ScriptInstance WeakReference::GetValuePtr() const { return const_cast*>(&m_weakHandle); } + +RED4ext::CBaseRTTIType* WeakReference::GetValueType() const +{ + return m_pHandleType; +} diff --git a/src/reverse/WeakReference.h b/src/reverse/WeakReference.h index 71a4e294..c190848b 100644 --- a/src/reverse/WeakReference.h +++ b/src/reverse/WeakReference.h @@ -13,10 +13,12 @@ struct WeakReference : ClassType protected: RED4ext::ScriptInstance GetHandle() const override; RED4ext::ScriptInstance GetValuePtr() const override; + RED4ext::CBaseRTTIType* GetValueType() const override; private: friend struct Scripting; friend struct TweakDB; RED4ext::WeakHandle m_weakHandle; + RED4ext::CRTTIWeakHandleType* m_pHandleType; }; diff --git a/vendor/RED4ext.SDK b/vendor/RED4ext.SDK index 3cc51227..109d7fb0 160000 --- a/vendor/RED4ext.SDK +++ b/vendor/RED4ext.SDK @@ -1 +1 @@ -Subproject commit 3cc51227e860429313b9b36e37d48a3065e16d6f +Subproject commit 109d7fb0044f86b90d6ccc71f2c30c8a5b6ca208