From 771ab307e4e878dafe320dc6db07495e6f07e1a6 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Fri, 15 Sep 2023 07:01:42 -0400 Subject: [PATCH] Match RemovePresenter/Detach --- LEGO1/mxlist.h | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/LEGO1/mxlist.h b/LEGO1/mxlist.h index 3097dd8d..6b08cf83 100644 --- a/LEGO1/mxlist.h +++ b/LEGO1/mxlist.h @@ -60,9 +60,13 @@ class MxList : protected MxListParent void Append(T*); friend class MxListCursor; + protected: MxListEntry *m_first; // +0x10 MxListEntry *m_last; // +0x14 + +private: + void _DeleteEntry(MxListEntry *match); }; // VTABLE 0x100d6488 @@ -135,6 +139,26 @@ inline void MxList::Append(T *p_newobj) this->m_count++; } +template +inline void MxList::_DeleteEntry(MxListEntry *match) +{ + MxListEntry **pPrev = &match->m_prev; + MxListEntry **pNext = &match->m_next; + + if (match->m_prev) + match->m_prev->m_next = *pNext; + else + m_first = *pNext; + + if (*pNext) + (*pNext)->m_prev = *pPrev; + else + m_last = *pPrev; + + delete match; + m_count--; +} + template inline MxBool MxListCursor::Find(T *p_obj) { @@ -148,21 +172,7 @@ inline MxBool MxListCursor::Find(T *p_obj) template inline void MxListCursor::Detach() { - MxListEntry *m_prev = m_match->m_prev; - MxListEntry *m_next = m_match->m_next; - - if (m_prev) - m_prev->m_next = m_next; - else - m_list->m_first = m_next; - - if (m_next) - m_next->m_prev = m_prev; - else - m_list->m_last = m_prev; - - delete m_match; - m_list->m_count--; + m_list->_DeleteEntry(m_match); m_match = NULL; }