From 147177c448e10ee7ca14c2f25779bf35fc952278 Mon Sep 17 00:00:00 2001 From: Saty <5752427+SatyPardus@users.noreply.github.com> Date: Thu, 24 Sep 2026 04:23:35 +0200 Subject: [PATCH] Base: CBitArray; Storm: operator delete[] Port CBitArray (Mac 4.0.1 names and field names from asserts) and add the client operator delete[] that 12340 inlines everywhere. Co-Authored-By: Claude Opus 5.5 (1M context) --- Engine/Source/Base/BitArray.cpp | 50 ++++++++++++++++++++++++++++- Engine/Source/Base/BitArray.h | 15 +++++---- Engine/Source/Storm/Source/SMem.cpp | 4 +++ 3 files changed, 62 insertions(+), 7 deletions(-) diff --git a/Engine/Source/Base/BitArray.cpp b/Engine/Source/Base/BitArray.cpp index 55eb698..11542c9 100644 --- a/Engine/Source/Base/BitArray.cpp +++ b/Engine/Source/Base/BitArray.cpp @@ -1 +1,49 @@ -#include "BitArray.h" +#include +#include "Engine/Source/Base/BitArray.h" + +// VERIFY: 08b8f5fb auto +// OFFSET: 0x0095DA10 +CBitArray::CBitArray() { + this->m_array = nullptr; + this->m_size = 0; + this->unk_0008 = false; +} + +// VERIFY: 24197791 auto +// OFFSET: 0x0095DA20 +int32_t CBitArray::Get(uint32_t bitIdx) const { + return (this->m_array[bitIdx >> 3] & (1 << (bitIdx & 7))) != 0; +} + +// VERIFY: 8b0b5341 manual +// OFFSET: 0x0095DA50 +void CBitArray::Set(uint32_t bitIdx, bool value) { + char* byte = &this->m_array[bitIdx >> 3]; + char mask = 1 << (bitIdx & 7); + + if (value) { + *byte |= mask; + } else { + *byte &= ~mask; + } +} + +// VERIFY: 93b36a31 manual +// OFFSET: 0x0095DA80 +CBitArray::~CBitArray() { + if (this->m_array && this->unk_0008) { + delete[] this->m_array; + } +} + +// VERIFY: 0d9be8fd manual +// OFFSET: 0x0095DAA0 +void CBitArray::SetRawData(char* data, uint32_t size, bool owned) { + if (this->m_array && this->unk_0008) { + delete[] this->m_array; + } + + this->m_array = data; + this->m_size = size; + this->unk_0008 = owned; +} diff --git a/Engine/Source/Base/BitArray.h b/Engine/Source/Base/BitArray.h index 8b95d0f..99215c1 100644 --- a/Engine/Source/Base/BitArray.h +++ b/Engine/Source/Base/BitArray.h @@ -1,16 +1,19 @@ #ifndef ENGINE_SOURCE_BASE_BITARRAY_H #define ENGINE_SOURCE_BASE_BITARRAY_H -#include #include class CBitArray { public: - /* 0000 */ uint32_t unk_0000; - /* 0004 */ uint32_t unk_0004; - /* 0008 */ uint8_t unk_0008; - /* 0009 */ uint8_t unk_0009[23]; - /* 0020 */ uint8_t unk_0020; + /* 0000 */ char* m_array; + /* 0004 */ uint32_t m_size; + /* 0008 */ bool unk_0008; + + CBitArray(); + ~CBitArray(); + int32_t Get(uint32_t bitIdx) const; + void Set(uint32_t bitIdx, bool value); + void SetRawData(char* data, uint32_t size, bool owned); }; #endif diff --git a/Engine/Source/Storm/Source/SMem.cpp b/Engine/Source/Storm/Source/SMem.cpp index 44e2746..067e5cc 100644 --- a/Engine/Source/Storm/Source/SMem.cpp +++ b/Engine/Source/Storm/Source/SMem.cpp @@ -108,6 +108,10 @@ void operator delete(void* ptr) noexcept { SMemFree(ptr, "delete", SLOG_FUNCTION, 0); } +void operator delete[](void* ptr) noexcept { + SMemFree(ptr, "delete[]", SLOG_FUNCTION, 0); +} + int32_t STORMAPI SMemDestroy() { return 1; }