diff --git a/src/Chain.cpp b/src/Chain.cpp index ed712324..b24d3652 100644 --- a/src/Chain.cpp +++ b/src/Chain.cpp @@ -17,12 +17,7 @@ ChainElem::ChainElem() deletedCallback = NULL; priority = 0; - // MISMATCH: An extra XOR is present for no apparent reason (TODO figure this out) - // xor eax, eax - // mov ax, word ptr [edx + 2] - // and al, 0xfe - // mov ecx, dword ptr [ebp - 4] - flags &= CHAIN_ELEM_FLAG_MASK; + isHeapAllocated = false; } ChainElem::~ChainElem() @@ -49,12 +44,7 @@ ChainElem *Chain::CreateElem(ChainCallback callback) elem->addedCallback = NULL; elem->deletedCallback = NULL; - // MISMATCH: An extra XOR is present for no apparent reason and ecx is used instead of cl (TODO figure this out) - // xor ecx, ecx - // mov cx, word ptr [eax + 2] - // or ecx, 1 - // mov edx, dword ptr [ebp - 0x10] - elem->flags |= CHAIN_ELEM_FLAG_HEAP_ALLOCATED; + elem->isHeapAllocated = true; return elem; } @@ -170,13 +160,7 @@ void Chain::Cut(ChainElem *to_remove) to_remove->prev = NULL; to_remove->next = NULL; - // MISMATCH: An extra XOR is present for no apparent reason and edx is used instead of dx (TODO figure this out) - // xor edx, edx - // mov dx, word ptr [ecx + 2] - // and edx, 1 - // and edx, 0xffff - // test edx, edx - if ((to_remove->flags & CHAIN_ELEM_FLAG_HEAP_ALLOCATED & 0xffff) != 0) + if (to_remove->isHeapAllocated) { delete to_remove; to_remove = NULL; diff --git a/src/Chain.hpp b/src/Chain.hpp index f30001b8..73201213 100644 --- a/src/Chain.hpp +++ b/src/Chain.hpp @@ -2,16 +2,12 @@ #include "ZunResult.hpp" #include "diffbuild.hpp" +#include "inttypes.hpp" #include namespace th06 { -enum ChainElemFlag -{ - CHAIN_ELEM_FLAG_HEAP_ALLOCATED = (unsigned char)1, - CHAIN_ELEM_FLAG_MASK = ~(unsigned char)CHAIN_ELEM_FLAG_HEAP_ALLOCATED, -}; enum ChainCallbackResult { @@ -33,7 +29,7 @@ class ChainElem { public: short priority; - unsigned short flags; + u16 isHeapAllocated : 1; ChainCallback callback; ChainAddedCallback addedCallback; ChainDeletedCallback deletedCallback;