mirror of
https://github.com/isledecomp/isle-portable.git
synced 2025-09-27 22:54:02 -04:00
Match MxRegionTopBottom::FUN_100c5280 (#261)
* Match MxRegionTopBottom::FUN_100c5280 * Resolve OtherAppend/Append * Remove old code
This commit is contained in:
parent
8a528e4146
commit
d5cf23bada
@ -30,7 +30,7 @@ void MxDSSelectAction::CopyFrom(MxDSSelectAction& p_dsSelectAction)
|
|||||||
MxStringListCursor cursor(p_dsSelectAction.m_unk0xac);
|
MxStringListCursor cursor(p_dsSelectAction.m_unk0xac);
|
||||||
MxString string;
|
MxString string;
|
||||||
while (cursor.Next(string))
|
while (cursor.Next(string))
|
||||||
this->m_unk0xac->OtherAppend(string);
|
this->m_unk0xac->Append(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
// OFFSET: LEGO1 0x100cbd50
|
// OFFSET: LEGO1 0x100cbd50
|
||||||
@ -109,7 +109,7 @@ void MxDSSelectAction::Deserialize(char** p_source, MxS16 p_unk24)
|
|||||||
if (!strcmp(string.GetData(), *p_source))
|
if (!strcmp(string.GetData(), *p_source))
|
||||||
index = i;
|
index = i;
|
||||||
|
|
||||||
this->m_unk0xac->OtherAppend(*p_source);
|
this->m_unk0xac->Append(*p_source);
|
||||||
*p_source += strlen(*p_source) + 1;
|
*p_source += strlen(*p_source) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,9 +27,12 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
T GetValue() { return this->m_obj; }
|
T GetValue() { return this->m_obj; }
|
||||||
|
MxListEntry* GetNext() { return m_next; }
|
||||||
|
MxListEntry* GetPrev() { return m_prev; }
|
||||||
|
|
||||||
friend class MxList<T>;
|
void SetValue(T p_obj) { m_obj = p_obj; }
|
||||||
friend class MxListCursor<T>;
|
void SetNext(MxListEntry* p_next) { m_next = p_next; }
|
||||||
|
void SetPrev(MxListEntry* p_prev) { m_prev = p_prev; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
T m_obj;
|
T m_obj;
|
||||||
@ -69,8 +72,7 @@ public:
|
|||||||
|
|
||||||
virtual ~MxList();
|
virtual ~MxList();
|
||||||
|
|
||||||
void Append(T);
|
void Append(T p_obj) { _InsertEntry(p_obj, this->m_last, NULL); };
|
||||||
void OtherAppend(T p_obj) { _InsertEntry(p_obj, this->m_last, NULL); };
|
|
||||||
void DeleteAll();
|
void DeleteAll();
|
||||||
MxU32 GetCount() { return this->m_count; }
|
MxU32 GetCount() { return this->m_count; }
|
||||||
void SetDestroy(void (*p_customDestructor)(T)) { this->m_customDestructor = p_customDestructor; }
|
void SetDestroy(void (*p_customDestructor)(T)) { this->m_customDestructor = p_customDestructor; }
|
||||||
@ -100,7 +102,7 @@ public:
|
|||||||
void Destroy();
|
void Destroy();
|
||||||
MxBool Next(T& p_obj);
|
MxBool Next(T& p_obj);
|
||||||
MxBool Current(T& p_obj);
|
MxBool Current(T& p_obj);
|
||||||
void Advance();
|
MxBool Advance();
|
||||||
MxBool HasMatch() { return m_match != NULL; }
|
MxBool HasMatch() { return m_match != NULL; }
|
||||||
void SetValue(T p_obj);
|
void SetValue(T p_obj);
|
||||||
void Head() { m_match = m_list->m_first; }
|
void Head() { m_match = m_list->m_first; }
|
||||||
@ -139,7 +141,7 @@ inline void MxList<T>::DeleteAll()
|
|||||||
if (!t)
|
if (!t)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
MxListEntry<T>* next = t->m_next;
|
MxListEntry<T>* next = t->GetNext();
|
||||||
this->m_customDestructor(t->GetValue());
|
this->m_customDestructor(t->GetValue());
|
||||||
delete t;
|
delete t;
|
||||||
t = next;
|
t = next;
|
||||||
@ -150,33 +152,18 @@ inline void MxList<T>::DeleteAll()
|
|||||||
m_first = NULL;
|
m_first = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
|
||||||
inline void MxList<T>::Append(T p_newobj)
|
|
||||||
{
|
|
||||||
MxListEntry<T>* currentLast = this->m_last;
|
|
||||||
MxListEntry<T>* newEntry = new MxListEntry<T>(p_newobj, currentLast);
|
|
||||||
|
|
||||||
if (currentLast)
|
|
||||||
currentLast->m_next = newEntry;
|
|
||||||
else
|
|
||||||
this->m_first = newEntry;
|
|
||||||
|
|
||||||
this->m_last = newEntry;
|
|
||||||
this->m_count++;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
inline MxListEntry<T>* MxList<T>::_InsertEntry(T p_newobj, MxListEntry<T>* p_prev, MxListEntry<T>* p_next)
|
inline MxListEntry<T>* MxList<T>::_InsertEntry(T p_newobj, MxListEntry<T>* p_prev, MxListEntry<T>* p_next)
|
||||||
{
|
{
|
||||||
MxListEntry<T>* newEntry = new MxListEntry<T>(p_newobj, p_prev, p_next);
|
MxListEntry<T>* newEntry = new MxListEntry<T>(p_newobj, p_prev, p_next);
|
||||||
|
|
||||||
if (p_prev)
|
if (p_prev)
|
||||||
p_prev->m_next = newEntry;
|
p_prev->SetNext(newEntry);
|
||||||
else
|
else
|
||||||
this->m_first = newEntry;
|
this->m_first = newEntry;
|
||||||
|
|
||||||
if (p_next)
|
if (p_next)
|
||||||
p_next->m_prev = newEntry;
|
p_next->SetPrev(newEntry);
|
||||||
else
|
else
|
||||||
this->m_last = newEntry;
|
this->m_last = newEntry;
|
||||||
|
|
||||||
@ -187,18 +174,15 @@ inline MxListEntry<T>* MxList<T>::_InsertEntry(T p_newobj, MxListEntry<T>* p_pre
|
|||||||
template <class T>
|
template <class T>
|
||||||
inline void MxList<T>::_DeleteEntry(MxListEntry<T>* match)
|
inline void MxList<T>::_DeleteEntry(MxListEntry<T>* match)
|
||||||
{
|
{
|
||||||
MxListEntry<T>** pPrev = &match->m_prev;
|
if (match->GetPrev())
|
||||||
MxListEntry<T>** pNext = &match->m_next;
|
match->GetPrev()->SetNext(match->GetNext());
|
||||||
|
|
||||||
if (match->m_prev)
|
|
||||||
match->m_prev->m_next = *pNext;
|
|
||||||
else
|
else
|
||||||
m_first = *pNext;
|
m_first = match->GetNext();
|
||||||
|
|
||||||
if (*pNext)
|
if (match->GetNext())
|
||||||
(*pNext)->m_prev = *pPrev;
|
match->GetNext()->SetPrev(match->GetPrev());
|
||||||
else
|
else
|
||||||
m_last = *pPrev;
|
m_last = match->GetPrev();
|
||||||
|
|
||||||
delete match;
|
delete match;
|
||||||
this->m_count--;
|
this->m_count--;
|
||||||
@ -207,7 +191,8 @@ inline void MxList<T>::_DeleteEntry(MxListEntry<T>* match)
|
|||||||
template <class T>
|
template <class T>
|
||||||
inline MxBool MxListCursor<T>::Find(T p_obj)
|
inline MxBool MxListCursor<T>::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)
|
for (m_match = m_list->m_first; m_match && m_list->Compare(m_match->GetValue(), p_obj);
|
||||||
|
m_match = m_match->GetNext())
|
||||||
;
|
;
|
||||||
|
|
||||||
return m_match != NULL;
|
return m_match != NULL;
|
||||||
@ -223,7 +208,10 @@ inline void MxListCursor<T>::Detach()
|
|||||||
template <class T>
|
template <class T>
|
||||||
inline void MxListCursor<T>::Destroy()
|
inline void MxListCursor<T>::Destroy()
|
||||||
{
|
{
|
||||||
m_list->m_customDestructor(m_match->GetValue());
|
if (m_match) {
|
||||||
|
m_list->m_customDestructor(m_match->GetValue());
|
||||||
|
Detach();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
@ -232,7 +220,7 @@ inline MxBool MxListCursor<T>::Next(T& p_obj)
|
|||||||
if (!m_match)
|
if (!m_match)
|
||||||
m_match = m_list->m_first;
|
m_match = m_list->m_first;
|
||||||
else
|
else
|
||||||
m_match = m_match->m_next;
|
m_match = m_match->GetNext();
|
||||||
|
|
||||||
if (m_match)
|
if (m_match)
|
||||||
p_obj = m_match->GetValue();
|
p_obj = m_match->GetValue();
|
||||||
@ -250,26 +238,28 @@ inline MxBool MxListCursor<T>::Current(T& p_obj)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
inline void MxListCursor<T>::Advance()
|
inline MxBool MxListCursor<T>::Advance()
|
||||||
{
|
{
|
||||||
if (!m_match)
|
if (!m_match)
|
||||||
m_match = m_list->m_first;
|
m_match = m_list->m_first;
|
||||||
else
|
else
|
||||||
m_match = m_match->m_next;
|
m_match = m_match->GetNext();
|
||||||
|
|
||||||
|
return m_match != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
inline void MxListCursor<T>::SetValue(T p_obj)
|
inline void MxListCursor<T>::SetValue(T p_obj)
|
||||||
{
|
{
|
||||||
if (m_match)
|
if (m_match)
|
||||||
m_match->m_obj = p_obj;
|
m_match->SetValue(p_obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
inline void MxListCursor<T>::Prepend(T p_newobj)
|
inline void MxListCursor<T>::Prepend(T p_newobj)
|
||||||
{
|
{
|
||||||
if (m_match)
|
if (m_match)
|
||||||
m_list->_InsertEntry(p_newobj, m_match->m_prev, m_match);
|
m_list->_InsertEntry(p_newobj, m_match->GetPrev(), m_match);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // MXLIST_H
|
#endif // MXLIST_H
|
||||||
|
@ -87,7 +87,7 @@ void MxRegion::vtable18(MxRect32& p_rect)
|
|||||||
|
|
||||||
if (rectCopy.m_left < rectCopy.m_right && rectCopy.m_top < rectCopy.m_bottom) {
|
if (rectCopy.m_left < rectCopy.m_right && rectCopy.m_top < rectCopy.m_bottom) {
|
||||||
MxRegionTopBottom* newTopBottom = new MxRegionTopBottom(rectCopy);
|
MxRegionTopBottom* newTopBottom = new MxRegionTopBottom(rectCopy);
|
||||||
m_list->OtherAppend(newTopBottom);
|
m_list->Append(newTopBottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_rect.m_left = m_rect.m_left <= p_rect.m_left ? m_rect.m_left : p_rect.m_left;
|
m_rect.m_left = m_rect.m_left <= p_rect.m_left ? m_rect.m_left : p_rect.m_left;
|
||||||
@ -147,7 +147,7 @@ void MxRegionTopBottom::FUN_100c5280(MxS32 p_left, MxS32 p_right)
|
|||||||
|
|
||||||
if (!a.HasMatch()) {
|
if (!a.HasMatch()) {
|
||||||
MxRegionLeftRight* copy = new MxRegionLeftRight(p_left, p_right);
|
MxRegionLeftRight* copy = new MxRegionLeftRight(p_left, p_right);
|
||||||
m_leftRightList->OtherAppend(copy);
|
m_leftRightList->Append(copy);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (p_left > leftRight->m_left)
|
if (p_left > leftRight->m_left)
|
||||||
@ -157,14 +157,9 @@ void MxRegionTopBottom::FUN_100c5280(MxS32 p_left, MxS32 p_right)
|
|||||||
if (p_right < leftRight->m_right)
|
if (p_right < leftRight->m_right)
|
||||||
p_right = leftRight->m_right;
|
p_right = leftRight->m_right;
|
||||||
|
|
||||||
// TODO: Currently inlined, shouldn't be
|
|
||||||
b = a;
|
b = a;
|
||||||
b.Advance();
|
b.Advance();
|
||||||
|
a.Destroy();
|
||||||
if (a.HasMatch()) {
|
|
||||||
a.Destroy();
|
|
||||||
a.Detach();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!b.Current(leftRight))
|
if (!b.Current(leftRight))
|
||||||
break;
|
break;
|
||||||
@ -178,7 +173,7 @@ void MxRegionTopBottom::FUN_100c5280(MxS32 p_left, MxS32 p_right)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
MxRegionLeftRight* copy = new MxRegionLeftRight(p_left, p_right);
|
MxRegionLeftRight* copy = new MxRegionLeftRight(p_left, p_right);
|
||||||
m_leftRightList->OtherAppend(copy);
|
m_leftRightList->Append(copy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ typedef MxListCursorChild<MxString> MxStringListCursor;
|
|||||||
// MxList<MxString>::~MxList<MxString>
|
// MxList<MxString>::~MxList<MxString>
|
||||||
|
|
||||||
// OFFSET: LEGO1 0x100cbb40 TEMPLATE
|
// OFFSET: LEGO1 0x100cbb40 TEMPLATE
|
||||||
// MxList<MxString>::OtherAppend
|
// MxList<MxString>::Append
|
||||||
|
|
||||||
// OFFSET: LEGO1 0x100cc2d0 TEMPLATE
|
// OFFSET: LEGO1 0x100cc2d0 TEMPLATE
|
||||||
// MxList<MxString>::_InsertEntry
|
// MxList<MxString>::_InsertEntry
|
||||||
|
Loading…
x
Reference in New Issue
Block a user