From 191913568220e659eb4c1c3c6d8fdd210c5594f0 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Fri, 20 Oct 2023 09:23:04 -0400 Subject: [PATCH] Implement remaining functions --- LEGO1/mxregion.cpp | 57 ++++++++++++++++++++++++++++++++++++++-------- LEGO1/mxregion.h | 3 ++- 2 files changed, 49 insertions(+), 11 deletions(-) diff --git a/LEGO1/mxregion.cpp b/LEGO1/mxregion.cpp index e95f7cf3..b15f310e 100644 --- a/LEGO1/mxregion.cpp +++ b/LEGO1/mxregion.cpp @@ -14,23 +14,25 @@ MxRegion::MxRegion() m_rect.SetSize(MxSize32(-1, -1)); } -// OFFSET: LEGO1 0x100c3660 STUB +// OFFSET: LEGO1 0x100c3660 MxBool MxRegion::vtable20() { - // TODO - return FALSE; + return m_list->GetCount() == 0; } -// OFFSET: LEGO1 0x100c3690 STUB +// OFFSET: LEGO1 0x100c3690 MxRegion::~MxRegion() { - // TODO + if (m_list) + delete m_list; } -// OFFSET: LEGO1 0x100c3700 STUB +// OFFSET: LEGO1 0x100c3700 void MxRegion::Reset() { - // TODO + m_list->DeleteAll(); + m_rect.SetPoint(MxPoint32(INT_MAX, INT_MAX)); + m_rect.SetSize(MxSize32(-1, -1)); } // OFFSET: LEGO1 0x100c3750 @@ -100,10 +102,29 @@ void MxRegion::vtable18(MxRect32 &p_rect) m_rect.m_bottom = m_rect.m_bottom <= p_rect.m_bottom ? p_rect.m_bottom : m_rect.m_bottom; } -// OFFSET: LEGO1 0x100c3e20 STUB -void MxRegion::vtable1c() +// OFFSET: LEGO1 0x100c3e20 +MxBool MxRegion::vtable1c(MxRect32 &p_rect) { - // TODO + if (m_rect.m_left < p_rect.m_right && + p_rect.m_left < m_rect.m_right && + (m_rect.m_top < p_rect.m_bottom && + p_rect.m_top < m_rect.m_bottom)) { + MxRegionListCursor cursor(m_list); + MxRegionTopBottom *topBottom; + + do { + do { + if (!cursor.Next(topBottom)) + return FALSE; + if (topBottom->m_top >= p_rect.m_bottom) + return FALSE; + } while (topBottom->m_bottom <= p_rect.m_top); + } while (!topBottom->FUN_100c57b0(p_rect)); + + return TRUE; + } + + return FALSE; } // OFFSET: LEGO1 0x100c4c90 @@ -186,4 +207,20 @@ MxRegionTopBottom *MxRegionTopBottom::Clone() clone->m_leftRightList->Append(leftRight->Clone()); return clone; +} + +// OFFSET: LEGO1 0x100c57b0 +MxBool MxRegionTopBottom::FUN_100c57b0(MxRect32 &p_rect) +{ + MxRegionLeftRightListCursor cursor(m_leftRightList); + MxRegionLeftRight *leftRight; + + do { + if (!cursor.Next(leftRight)) + return FALSE; + if (p_rect.m_right <= leftRight->m_left) + return FALSE; + } while (leftRight->m_right <= p_rect.m_left); + + return TRUE; } \ No newline at end of file diff --git a/LEGO1/mxregion.h b/LEGO1/mxregion.h index 1c7a0716..0b1ef186 100644 --- a/LEGO1/mxregion.h +++ b/LEGO1/mxregion.h @@ -14,6 +14,7 @@ struct MxRegionTopBottom MxRegionTopBottom *Clone(); void FUN_100c5280(MxS32 p_left, MxS32 p_right); + MxBool FUN_100c57b0(MxRect32 &p_rect); MxS32 m_top; MxS32 m_bottom; @@ -48,7 +49,7 @@ public: virtual void Reset(); virtual void vtable18(MxRect32 &p_rect); - virtual void vtable1c(); + virtual MxBool vtable1c(MxRect32 &p_rect); virtual MxBool vtable20(); inline MxRect32 &GetRect() { return this->m_rect; }