Skip to content

Commit

Permalink
Merge pull request #952 from psiberx/master
Browse files Browse the repository at this point in the history
Various fixes
  • Loading branch information
WSSDude authored Jul 20, 2024
2 parents 2987e6c + 13402ac commit a6a0628
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 7 deletions.
7 changes: 3 additions & 4 deletions src/reverse/RTTIExtender.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "RTTIExtender.h"

#include <RED4ext/SharedMutex.hpp>
#include <RED4ext/Scripting/Natives/Generated/Transform.hpp>
#include <RED4ext/Scripting/Natives/Generated/WorldTransform.hpp>
#include <RED4ext/Scripting/Natives/Generated/ent/Entity.hpp>
Expand Down Expand Up @@ -204,9 +203,9 @@ struct TEMP_Spawner
RED4ext::DynArray<RED4ext::Handle<RED4ext::IScriptable>> spawnedEntities;
RED4ext::DynArray<TEMP_PendingEntity> pendingEntities;
RED4ext::DynArray<void*> 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;
Expand Down
10 changes: 9 additions & 1 deletion src/reverse/RTTIMapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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];
}
}
}
});
Expand Down
7 changes: 7 additions & 0 deletions src/reverse/StrongReference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ static RTTILocator s_sIScriptableType{RED4ext::FNV1a64("IScriptable")};
StrongReference::StrongReference(const TiltedPhoques::Lockable<sol::state, std::recursive_mutex>::Ref& aView, RED4ext::Handle<RED4ext::IScriptable> aStrongHandle)
: ClassType(aView, nullptr)
, m_strongHandle(std::move(aStrongHandle))
, m_pHandleType(nullptr)
{
if (m_strongHandle)
{
Expand All @@ -21,6 +22,7 @@ StrongReference::StrongReference(
const TiltedPhoques::Lockable<sol::state, std::recursive_mutex>::Ref& aView, RED4ext::Handle<RED4ext::IScriptable> aStrongHandle, RED4ext::CRTTIHandleType* apStrongHandleType)
: ClassType(aView, nullptr)
, m_strongHandle(std::move(aStrongHandle))
, m_pHandleType(apStrongHandleType)
{
if (m_strongHandle)
{
Expand Down Expand Up @@ -49,3 +51,8 @@ RED4ext::ScriptInstance StrongReference::GetValuePtr() const
{
return const_cast<RED4ext::Handle<RED4ext::IScriptable>*>(&m_strongHandle);
}

RED4ext::CBaseRTTIType* StrongReference::GetValueType() const
{
return m_pHandleType;
}
2 changes: 2 additions & 0 deletions src/reverse/StrongReference.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<RED4ext::IScriptable> m_strongHandle;
RED4ext::CRTTIHandleType* m_pHandleType;
};
2 changes: 1 addition & 1 deletion src/reverse/TweakDB/ResourcesList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
1 change: 1 addition & 0 deletions src/reverse/Type.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 7 additions & 0 deletions src/reverse/WeakReference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ static RTTILocator s_sIScriptableType{RED4ext::FNV1a64("IScriptable")};
WeakReference::WeakReference(const TiltedPhoques::Lockable<sol::state, std::recursive_mutex>::Ref& aView, RED4ext::WeakHandle<RED4ext::IScriptable> aWeakHandle)
: ClassType(aView, nullptr)
, m_weakHandle(std::move(aWeakHandle))
, m_pHandleType(nullptr)
{
const auto ref = m_weakHandle.Lock();
if (ref)
Expand All @@ -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)
Expand Down Expand Up @@ -58,3 +60,8 @@ RED4ext::ScriptInstance WeakReference::GetValuePtr() const
{
return const_cast<RED4ext::WeakHandle<RED4ext::IScriptable>*>(&m_weakHandle);
}

RED4ext::CBaseRTTIType* WeakReference::GetValueType() const
{
return m_pHandleType;
}
2 changes: 2 additions & 0 deletions src/reverse/WeakReference.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<RED4ext::IScriptable> m_weakHandle;
RED4ext::CRTTIWeakHandleType* m_pHandleType;
};
2 changes: 1 addition & 1 deletion vendor/RED4ext.SDK
Submodule RED4ext.SDK updated 34 files
+9 −0 include/RED4ext/Buffer-inl.hpp
+6 −4 include/RED4ext/Buffer.hpp
+10 −2 include/RED4ext/CName.hpp
+23 −9 include/RED4ext/DynArray.hpp
+1 −1 include/RED4ext/GameEngine.hpp
+1 −1 include/RED4ext/JobQueue-inl.hpp
+3 −3 include/RED4ext/Memory/Pool.hpp
+54 −54 include/RED4ext/Memory/Utils.hpp
+30 −0 include/RED4ext/Mutex-inl.hpp
+34 −0 include/RED4ext/Mutex.hpp
+12 −3 include/RED4ext/NativeTypes.hpp
+6 −6 include/RED4ext/Package.hpp
+2 −0 include/RED4ext/RED4ext.hpp
+10 −8 include/RED4ext/RTTISystem.hpp
+126 −47 include/RED4ext/RTTITypes.hpp
+4 −4 include/RED4ext/ResourceLoader.hpp
+20 −12 include/RED4ext/ResourcePath.hpp
+4 −2 include/RED4ext/Scripting/Natives/AnimKeyFrames.hpp
+11 −0 include/RED4ext/Scripting/Natives/Generated/ent/AnimationControllerComponent.hpp
+7 −7 include/RED4ext/Scripting/Natives/animAnimationBufferCompressed.hpp
+2 −2 include/RED4ext/Scripting/Natives/animRig.hpp
+106 −0 include/RED4ext/Scripting/Natives/entAnimationControllerComponent.hpp
+1 −1 include/RED4ext/Scripting/Natives/inkHUDLayer.hpp
+1 −1 include/RED4ext/Scripting/Natives/inkMultiChildren.hpp
+4 −4 include/RED4ext/Scripting/Natives/inkWidget.hpp
+2 −2 include/RED4ext/Scripting/Natives/inkWorldLayer.hpp
+1 −40 include/RED4ext/SharedMutex.hpp
+14 −14 include/RED4ext/SharedSpinLock-inl.hpp
+45 −0 include/RED4ext/SharedSpinLock.hpp
+17 −5 include/RED4ext/Span.hpp
+17 −17 include/RED4ext/TweakDB-inl.hpp
+4 −4 include/RED4ext/TweakDB.hpp
+1 −1 src/Mutex.cpp
+5 −0 src/SharedSpinLock.cpp

0 comments on commit a6a0628

Please sign in to comment.