More implementation

This commit is contained in:
Christian Semmler
2023-10-19 18:10:11 -04:00
parent b77b3b3568
commit 2edc1fd961
2 changed files with 73 additions and 1 deletions

View File

@@ -88,7 +88,11 @@ public:
MxBool Find(T p_obj);
void Detach();
void Destroy();
MxBool Next(T& p_obj);
MxBool Current(T& p_obj);
void Advance();
MxListEntry<T> *GetMatch() { return m_match; }
void SetValue(T p_obj);
void Head() { m_match = m_list->m_first; }
void Reset() { m_match = NULL; }
@@ -209,6 +213,12 @@ inline void MxListCursor<T>::Detach()
m_match = NULL;
}
template <class T>
inline void MxListCursor<T>::Destroy()
{
m_list->m_customDestructor(m_match->GetValue());
}
template <class T>
inline MxBool MxListCursor<T>::Next(T& p_obj)
{
@@ -223,6 +233,24 @@ inline MxBool MxListCursor<T>::Next(T& p_obj)
return m_match != NULL;
}
template <class T>
inline MxBool MxListCursor<T>::Current(T& p_obj)
{
if (m_match)
p_obj = m_match->GetValue();
return m_match != NULL;
}
template <class T>
inline void MxListCursor<T>::Advance()
{
if (!m_match)
m_match = m_list->m_first;
else
m_match = m_match->m_next;
}
template <class T>
inline void MxListCursor<T>::SetValue(T p_obj)
{

View File

@@ -66,6 +66,7 @@ void MxRegion::vtable18(MxRect32 &p_rect)
MxRegionTopBottom *newTopBottom = topBottom->Clone();
newTopBottom->m_bottom = rectCopy.m_top;
topBottom->m_top = rectCopy.m_top;
// TODO: _InsertEntry currently inlined, shouldn't be
cursor.Prepend(newTopBottom);
}
@@ -124,10 +125,53 @@ MxRegionTopBottom::MxRegionTopBottom(MxRect32 &p_rect)
m_leftRightList->Append(leftRight);
}
// OFFSET: LEGO1 0x100c5280 STUB
// OFFSET: LEGO1 0x100c5280
void MxRegionTopBottom::FUN_100c5280(MxS32 p_left, MxS32 p_right)
{
MxRegionLeftRightListCursor a(m_leftRightList);
MxRegionLeftRightListCursor b(m_leftRightList);
MxRegionLeftRight *leftRight;
while (a.Next(leftRight) && leftRight->m_right < p_left);
if (!a.GetMatch()) {
MxRegionLeftRight *copy = new MxRegionLeftRight(p_left, p_right);
m_leftRightList->OtherAppend(copy);
}
else {
if (p_left > leftRight->m_left)
p_left = leftRight->m_left;
if (leftRight->m_left < p_right) {
do {
if (p_right < leftRight->m_right)
p_right = leftRight->m_right;
// TODO: Currently inlined, shouldn't be
b = a;
b.Advance();
if (a.GetMatch()) {
a.Destroy();
a.Detach();
}
if (!b.Current(leftRight))
break;
a = b;
} while (leftRight->m_left < p_right);
}
if (a.GetMatch()) {
MxRegionLeftRight *copy = new MxRegionLeftRight(p_left, p_right);
a.Prepend(copy);
}
else {
MxRegionLeftRight *copy = new MxRegionLeftRight(p_left, p_right);
m_leftRightList->OtherAppend(copy);
}
}
}
// OFFSET: LEGO1 0x100c55d0