From 0959830d58ac5a507696fad554df6d0164aefee6 Mon Sep 17 00:00:00 2001
From: pv
Date: Wed, 1 Nov 2023 20:37:40 +0300
Subject: [PATCH] Update shared lib
---
lib/Core/Raw.hpp | 2 +-
lib/Red/Specializations.hpp | 9 +++++++++
lib/Red/TypeInfo/Invocation.hpp | 10 ++++++----
lib/Red/TypeInfo/Resolving.hpp | 19 +++++++++++++++++++
vendor/RED4ext.SDK | 2 +-
5 files changed, 36 insertions(+), 6 deletions(-)
diff --git a/lib/Core/Raw.hpp b/lib/Core/Raw.hpp
index 6e88763..7b7c834 100644
--- a/lib/Core/Raw.hpp
+++ b/lib/Core/Raw.hpp
@@ -94,7 +94,7 @@ class RawVFunc : public RawBase
constexpr RawVFunc() = default;
- R operator()(C* aContext, Args&&... aArgs) const
+ R operator()(C* aContext, Args... aArgs) const
{
auto vft = *reinterpret_cast(aContext);
auto callable = *reinterpret_cast(vft + offset);
diff --git a/lib/Red/Specializations.hpp b/lib/Red/Specializations.hpp
index 676fd9c..e7882a2 100644
--- a/lib/Red/Specializations.hpp
+++ b/lib/Red/Specializations.hpp
@@ -29,6 +29,15 @@ struct std::hash
}
};
+template<>
+struct std::hash
+{
+ std::size_t operator()(RED4ext::NodeRef aKey) const
+ {
+ return aKey.hash;
+ }
+};
+
template
requires std::is_class_v && std::is_convertible_v && Red::Detail::HasGeneratedTypeName
struct std::hash
diff --git a/lib/Red/TypeInfo/Invocation.hpp b/lib/Red/TypeInfo/Invocation.hpp
index df37b0f..7dc1d70 100644
--- a/lib/Red/TypeInfo/Invocation.hpp
+++ b/lib/Red/TypeInfo/Invocation.hpp
@@ -139,12 +139,14 @@ inline bool CallFunctionWithArgs(Red::CStackFrame* aFrame, CBaseFunction* aFunc,
const auto& param = aFunc->params[i];
const auto& arg = stack.args[i];
- if (!arg.value && !param->flags.isOptional)
+ if (arg.value)
{
- return false;
+ if (!IsCompatible(param->type, arg.type, arg.value))
+ {
+ return false;
+ }
}
-
- if (!IsCompatible(param->type, arg.type, arg.value))
+ else if (!param->flags.isOptional)
{
return false;
}
diff --git a/lib/Red/TypeInfo/Resolving.hpp b/lib/Red/TypeInfo/Resolving.hpp
index fd3e415..283fa3d 100644
--- a/lib/Red/TypeInfo/Resolving.hpp
+++ b/lib/Red/TypeInfo/Resolving.hpp
@@ -468,6 +468,25 @@ inline void RegisterPendingTypes()
CRTTISystem::Get()->GetType("Int32");
}
+template
+inline const Handle& Cast(const Handle& aObject)
+{
+ static const Handle s_null;
+ return aObject->GetType()->IsA(Red::GetClass()) ? *reinterpret_cast*>(&aObject) : s_null;
+}
+
+template
+inline bool IsInstanceOf(CClass* aType)
+{
+ return aType->IsA(Red::GetClass());
+}
+
+template
+inline bool IsInstanceOf(ISerializable* aObject)
+{
+ return aObject->GetType()->IsA(Red::GetClass());
+}
+
inline bool IsCompatible(CBaseRTTIType* aLhsType, CBaseRTTIType* aRhsType)
{
if (aLhsType != aRhsType)
diff --git a/vendor/RED4ext.SDK b/vendor/RED4ext.SDK
index 6b288b9..d017563 160000
--- a/vendor/RED4ext.SDK
+++ b/vendor/RED4ext.SDK
@@ -1 +1 @@
-Subproject commit 6b288b959c2068af5d779c3ad1d3e7d45f3523b7
+Subproject commit d017563eb4cb5d875a49e47fe21615bfeee00e1d