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
3 changes: 0 additions & 3 deletions include/RE/O/Object.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ namespace RE
volatile std::int32_t refCountAndHandleLock; // 28
std::uint32_t pad2C; // 2C
Variable variables[0]; // 30 - size == classPtr->GetTotalNumVariables() + 3

private:
void Dtor();
};
static_assert(sizeof(Object) == 0x30);
}
Expand Down
14 changes: 14 additions & 0 deletions include/RE/O/ObjectTypeInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,20 @@ namespace RE
}
}

[[nodiscard]] constexpr bool IsLinkedValid() const noexcept
{
return linkedValid == LinkValidState::kLinkedValid;
}

[[nodiscard]] std::uint32_t GetVariableCount() const noexcept
{
std::uint32_t count = 0;
for (BSTSmartPointer iter{ this }; iter && iter->IsLinkedValid(); iter = iter->parentTypeInfo) {
count += iter->variableCount;
}
return count;
}

UnlinkedNativeFunction* GetUnlinkedFunctionIter();
const UnlinkedNativeFunction* GetUnlinkedFunctionIter() const;

Expand Down
23 changes: 15 additions & 8 deletions src/RE/O/Object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,21 @@ namespace RE
{
Object::~Object()
{
Dtor();
if (IsConstructed()) {
const std::uint32_t size = type ? type->GetVariableCount() : 0;
for (std::uint32_t i = 0; i < size; ++i) {
variables[i].SetNone();
}

constructed = false;
initialized = false;
}

auto lock = reinterpret_cast<std::uintptr_t>(lockStructure) & ~static_cast<std::uintptr_t>(1);
if (lock) {
REX::TAtomicRef l{ lock };
--l;
}
}

VMHandle Object::GetHandle() const
Expand Down Expand Up @@ -109,12 +123,5 @@ namespace RE

return std::addressof(variables[offset + idx]);
}

void Object::Dtor()
{
using func_t = decltype(&Object::Dtor);
static REL::Relocation<func_t> func{ RELOCATION_ID(97462, 104246) };
return func(this);
}
}
}
Loading