diff --git a/LEGO1/mxlist.h b/LEGO1/mxlist.h index d8e2155d..aac365d1 100644 --- a/LEGO1/mxlist.h +++ b/LEGO1/mxlist.h @@ -58,11 +58,72 @@ class MxList : protected MxListParent virtual ~MxList(); void Append(T*); + + friend class MxListCursor; protected: MxListEntry *m_first; // +0x10 MxListEntry *m_last; // +0x14 }; +// VTABLE 0x100d6488 +template +class MxListCursor : public MxCore +{ +public: + MxListCursor(MxList *p_list) { + m_list = p_list; + m_match = NULL; + } + + MxBool Find(T *p_obj) { + for (m_match = m_list->m_first; + m_match && m_list->Compare(m_match->m_obj, p_obj); + m_match = m_match->m_next); + + return m_match != NULL; + } + + void 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_match = NULL; + } +private: + MxList *m_list; + MxListEntry *m_match; +}; + +// Unclear purpose +// VTABLE 0x100d6530 +template +class MxListCursorChild : public MxListCursor +{ +public: + MxListCursorChild(MxList *p_list) : MxListCursor(p_list) {} +}; + +// Unclear purpose +// VTABLE 0x100d6470 +template +class MxListCursorChildChild : public MxListCursorChild +{ +public: + MxListCursorChildChild(MxList *p_list) : MxListCursorChild(p_list) {} +}; + template // OFFSET: LEGO1 0x1001ce20 MxList::~MxList() diff --git a/LEGO1/mxmediamanager.cpp b/LEGO1/mxmediamanager.cpp index 2be3531f..c1b59dab 100644 --- a/LEGO1/mxmediamanager.cpp +++ b/LEGO1/mxmediamanager.cpp @@ -4,6 +4,8 @@ DECOMP_SIZE_ASSERT(MxMediaManager, 0x2c); +typedef MxListCursorChildChild MxPresenterListCursor; + // OFFSET: LEGO1 0x100b84c0 MxMediaManager::MxMediaManager() { @@ -64,12 +66,14 @@ void MxMediaManager::AddPresenter(MxPresenter &p_presenter) this->m_presenters->Append(&p_presenter); } -// OFFSET: LEGO1 0x100b8980 STUB +// OFFSET: LEGO1 0x100b8980 void MxMediaManager::RemovePresenter(MxPresenter &p_presenter) { MxAutoLocker lock(&this->m_criticalSection); + MxPresenterListCursor cursor(this->m_presenters); - // Remove element from m_presenters + if (cursor.Find(&p_presenter)) + cursor.Detach(); } // OFFSET: LEGO1 0x100b8ac0 STUB