From 5b75bf0145708f95cdbec5137aea4f2d9e50aa1f Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Wed, 31 Jan 2024 09:01:31 -0500 Subject: [PATCH] Improve match --- LEGO1/lego/legoomni/src/infocenter/infocenter.cpp | 10 +++++++--- LEGO1/omni/include/mxrect32.h | 5 ----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/LEGO1/lego/legoomni/src/infocenter/infocenter.cpp b/LEGO1/lego/legoomni/src/infocenter/infocenter.cpp index 910fc3e1..37921249 100644 --- a/LEGO1/lego/legoomni/src/infocenter/infocenter.cpp +++ b/LEGO1/lego/legoomni/src/infocenter/infocenter.cpp @@ -741,10 +741,14 @@ MxBool Infocenter::VTable0x5c() void Infocenter::FUN_10070d10(MxS32 p_x, MxS32 p_y) { MxS16 i; - for (i = 0; i < sizeof(m_mapAreas) / sizeof(m_mapAreas[0]); i++) { - if (m_mapAreas[i].m_area.ContainsPoint(p_x, p_y)) { + for (i = 0; i < (MxS32) (sizeof(m_mapAreas) / sizeof(m_mapAreas[0])); i++) { + MxS32 right = m_mapAreas[i].m_area.GetRight(); + MxS32 bottom = m_mapAreas[i].m_area.GetBottom(); + MxS32 left = m_mapAreas[i].m_area.GetLeft(); + MxS32 top = m_mapAreas[i].m_area.GetTop(); + + if (left <= p_x && p_x <= right && top <= p_y && p_y <= bottom) break; - } } if (i == 7) { diff --git a/LEGO1/omni/include/mxrect32.h b/LEGO1/omni/include/mxrect32.h index 3359c303..207d93fa 100644 --- a/LEGO1/omni/include/mxrect32.h +++ b/LEGO1/omni/include/mxrect32.h @@ -71,11 +71,6 @@ class MxRect32 { return m_left < p_rect.m_right && p_rect.m_left < m_right && m_top < p_rect.m_bottom && p_rect.m_top < m_bottom; } - inline MxBool ContainsPoint(MxS32 p_x, MxS32 p_y) - { - return m_left <= p_x && p_x <= m_right && m_top <= p_y && p_y <= m_bottom; - } - inline MxS32 GetWidth() const { return (m_right - m_left) + 1; } inline MxS32 GetHeight() const { return (m_bottom - m_top) + 1; }