Skip to content

Commit a6a0628

Browse files
authored
Merge pull request #952 from psiberx/master
Various fixes
2 parents 2987e6c + 13402ac commit a6a0628

9 files changed

+33
-7
lines changed

src/reverse/RTTIExtender.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#include "RTTIExtender.h"
22

3-
#include <RED4ext/SharedMutex.hpp>
43
#include <RED4ext/Scripting/Natives/Generated/Transform.hpp>
54
#include <RED4ext/Scripting/Natives/Generated/WorldTransform.hpp>
65
#include <RED4ext/Scripting/Natives/Generated/ent/Entity.hpp>
@@ -204,9 +203,9 @@ struct TEMP_Spawner
204203
RED4ext::DynArray<RED4ext::Handle<RED4ext::IScriptable>> spawnedEntities;
205204
RED4ext::DynArray<TEMP_PendingEntity> pendingEntities;
206205
RED4ext::DynArray<void*> unk30;
207-
uint8_t unk40 = 0; // most likely a mutex
208-
RED4ext::SharedMutex entitiesMtx; // used in DespawnEntity
209-
RED4ext::SharedMutex pendingEntitiesMtx; // used in SpawnEntity
206+
uint8_t unk40 = 0; // most likely a mutex
207+
RED4ext::SharedSpinLock entitiesMtx; // used in DespawnEntity
208+
RED4ext::SharedSpinLock pendingEntitiesMtx; // used in SpawnEntity
210209
uintptr_t unk48 = 0;
211210
uintptr_t unk50 = 0;
212211
uintptr_t unk58 = 0;

src/reverse/RTTIMapper.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ void RTTIMapper::RegisterSimpleTypes(sol::state& aLuaState, sol::table& aLuaGlob
5656
aLuaGlobal["ToVariant"] = sol::overload(
5757
[](const Type& aInstance, sol::this_state aState) -> sol::object
5858
{
59-
const auto* pType = aInstance.GetType();
59+
auto* pType = aInstance.GetValueType();
6060
auto* pValue = aInstance.GetValuePtr();
6161

6262
if (!pType || !pValue)
@@ -199,6 +199,14 @@ void RTTIMapper::RegisterDirectGlobals(sol::table& aLuaGlobal, RED4ext::CRTTISys
199199
if (!cIsClassFunc && !cIsOperatorFunc)
200200
{
201201
aLuaGlobal[cShortName] = RTTIHelper::Get().ResolveFunction(cShortName);
202+
203+
std::string sanitizedName = cShortName;
204+
SanitizeName(sanitizedName);
205+
206+
if (sanitizedName != cShortName)
207+
{
208+
aLuaGlobal[sanitizedName] = aLuaGlobal[cShortName];
209+
}
202210
}
203211
}
204212
});

src/reverse/StrongReference.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ static RTTILocator s_sIScriptableType{RED4ext::FNV1a64("IScriptable")};
1010
StrongReference::StrongReference(const TiltedPhoques::Lockable<sol::state, std::recursive_mutex>::Ref& aView, RED4ext::Handle<RED4ext::IScriptable> aStrongHandle)
1111
: ClassType(aView, nullptr)
1212
, m_strongHandle(std::move(aStrongHandle))
13+
, m_pHandleType(nullptr)
1314
{
1415
if (m_strongHandle)
1516
{
@@ -21,6 +22,7 @@ StrongReference::StrongReference(
2122
const TiltedPhoques::Lockable<sol::state, std::recursive_mutex>::Ref& aView, RED4ext::Handle<RED4ext::IScriptable> aStrongHandle, RED4ext::CRTTIHandleType* apStrongHandleType)
2223
: ClassType(aView, nullptr)
2324
, m_strongHandle(std::move(aStrongHandle))
25+
, m_pHandleType(apStrongHandleType)
2426
{
2527
if (m_strongHandle)
2628
{
@@ -49,3 +51,8 @@ RED4ext::ScriptInstance StrongReference::GetValuePtr() const
4951
{
5052
return const_cast<RED4ext::Handle<RED4ext::IScriptable>*>(&m_strongHandle);
5153
}
54+
55+
RED4ext::CBaseRTTIType* StrongReference::GetValueType() const
56+
{
57+
return m_pHandleType;
58+
}

src/reverse/StrongReference.h

+2
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ struct StrongReference : ClassType
1313
protected:
1414
RED4ext::ScriptInstance GetHandle() const override;
1515
RED4ext::ScriptInstance GetValuePtr() const override;
16+
RED4ext::CBaseRTTIType* GetValueType() const override;
1617

1718
private:
1819
friend struct Scripting;
1920
friend struct TweakDB;
2021

2122
RED4ext::Handle<RED4ext::IScriptable> m_strongHandle;
23+
RED4ext::CRTTIHandleType* m_pHandleType;
2224
};

src/reverse/TweakDB/ResourcesList.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ bool ResourcesList::IsInitialized() const
100100

101101
const std::string& ResourcesList::Resolve(uint64_t aHash)
102102
{
103-
static std::string defaultName = "ERROR_UNKNOWN_RESOURCE";
103+
static std::string defaultName = "UNRESOLVED_RESOURCE_PATH";
104104

105105
const auto it = m_resourcesByHash.find(aHash);
106106

src/reverse/Type.h

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ struct Type
1717

1818
RED4ext::CBaseRTTIType* GetType() const { return m_pType; }
1919
virtual RED4ext::ScriptInstance GetHandle() const { return nullptr; }
20+
virtual RED4ext::CBaseRTTIType* GetValueType() const { return m_pType; }
2021
virtual RED4ext::ScriptInstance GetValuePtr() const { return nullptr; }
2122

2223
sol::object Index(const std::string& acName, sol::this_environment aThisEnv);

src/reverse/WeakReference.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ static RTTILocator s_sIScriptableType{RED4ext::FNV1a64("IScriptable")};
1010
WeakReference::WeakReference(const TiltedPhoques::Lockable<sol::state, std::recursive_mutex>::Ref& aView, RED4ext::WeakHandle<RED4ext::IScriptable> aWeakHandle)
1111
: ClassType(aView, nullptr)
1212
, m_weakHandle(std::move(aWeakHandle))
13+
, m_pHandleType(nullptr)
1314
{
1415
const auto ref = m_weakHandle.Lock();
1516
if (ref)
@@ -23,6 +24,7 @@ WeakReference::WeakReference(
2324
RED4ext::CRTTIWeakHandleType* apWeakHandleType)
2425
: ClassType(aView, nullptr)
2526
, m_weakHandle(std::move(aWeakHandle))
27+
, m_pHandleType(apWeakHandleType)
2628
{
2729
const auto ref = m_weakHandle.Lock();
2830
if (ref)
@@ -58,3 +60,8 @@ RED4ext::ScriptInstance WeakReference::GetValuePtr() const
5860
{
5961
return const_cast<RED4ext::WeakHandle<RED4ext::IScriptable>*>(&m_weakHandle);
6062
}
63+
64+
RED4ext::CBaseRTTIType* WeakReference::GetValueType() const
65+
{
66+
return m_pHandleType;
67+
}

src/reverse/WeakReference.h

+2
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ struct WeakReference : ClassType
1313
protected:
1414
RED4ext::ScriptInstance GetHandle() const override;
1515
RED4ext::ScriptInstance GetValuePtr() const override;
16+
RED4ext::CBaseRTTIType* GetValueType() const override;
1617

1718
private:
1819
friend struct Scripting;
1920
friend struct TweakDB;
2021

2122
RED4ext::WeakHandle<RED4ext::IScriptable> m_weakHandle;
23+
RED4ext::CRTTIWeakHandleType* m_pHandleType;
2224
};

0 commit comments

Comments
 (0)