Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions include/RED4ext/NativeTypes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ struct Variant
Variant(CName aTypeName);
Variant(CName aTypeName, const void* aData);
template<typename T>
requires !std::derived_from<std::remove_pointer_t<std::decay_t<T>>, rtti::IType>
Variant(const T& acValue)
requires(!std::derived_from<std::remove_pointer_t<std::decay_t<T>>, rtti::IType>)
Variant(const T& acValue)
: Variant(GetTypeName<T>(), std::addressof(acValue))
{
}
Expand Down Expand Up @@ -290,7 +290,7 @@ struct Variant
{
// TODO: support all game types and user types using RedLib solution:
// https://github.com/psiberx/cp2077-red-lib/blob/master/include/Red/TypeInfo/Resolving.hpp
static_assert(false, "Type is currently unsupported.");
static_assert(!std::is_same_v<T, T>, "Type is currently unsupported.");
return "";
}
}
Expand Down
17 changes: 10 additions & 7 deletions include/RED4ext/TweakDB-inl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,17 +324,20 @@ RED4EXT_INLINE int32_t RED4ext::TweakDB::CreateFlatValue(const CStackType& aStac

UpsizeFlatDataBuffer(MaxFlatDataBufferSize);

uintptr_t flatAlignment = (std::max)(aStackType.type->GetAlignment(), 8u);
uintptr_t flatValueSize = RED4ext::AlignUp(8ull /* vftable */ + aStackType.type->GetSize(), flatAlignment);
uintptr_t flatDataBufferEnd_Aligned = RED4ext::AlignUp(flatDataBufferEnd, flatAlignment);
const uintptr_t flatAlignment = (std::max)(aStackType.type->GetAlignment(), 8u);
const uintptr_t flatValueSize = RED4ext::AlignUp(8ull /* vftable */ + aStackType.type->GetSize(), flatAlignment);
const uintptr_t flatAddressAligned = RED4ext::AlignUp(flatDataBufferEnd, flatAlignment);
const uintptr_t newFlatDataBufferEnd = flatAddressAligned + flatValueSize;

if (AllocateFlatValue(reinterpret_cast<void*>(flatDataBufferEnd_Aligned), aStackType))
if (newFlatDataBufferEnd > (flatDataBuffer + flatDataBufferCapacity) ||
!AllocateFlatValue(reinterpret_cast<void*>(flatAddressAligned), aStackType))
{
flatDataBufferEnd = flatDataBufferEnd_Aligned + flatValueSize;
return reinterpret_cast<FlatValue*>(flatDataBufferEnd_Aligned)->ToTDBOffset();
return -1;
}

return -1;
flatDataBufferEnd = newFlatDataBufferEnd;

return reinterpret_cast<FlatValue*>(flatAddressAligned)->ToTDBOffset();
}

RED4EXT_INLINE bool RED4ext::TweakDB::AllocateFlatValue(void* aBuffer, const CStackType& aStackType)
Expand Down
Loading