From d54ac60e2e9ce2a2d1ab785f6350e7313c6a9812 Mon Sep 17 00:00:00 2001 From: stm <14291421+stephanmeesters@users.noreply.github.com> Date: Tue, 8 Sep 2026 20:56:16 +0200 Subject: [PATCH 01/17] refactor(basetype): Add intersect and min/max to Region and Coord types --- Core/Libraries/Include/Lib/BaseType.h | 96 +++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) diff --git a/Core/Libraries/Include/Lib/BaseType.h b/Core/Libraries/Include/Lib/BaseType.h index 8b5e760aff4..56f77db620a 100644 --- a/Core/Libraries/Include/Lib/BaseType.h +++ b/Core/Libraries/Include/Lib/BaseType.h @@ -331,6 +331,22 @@ struct Coord2D x = ax; y = ay; } + + void min( const Coord2D &other ) + { + if (x > other.x) + x = other.x; + if (y > other.y) + y = other.y; + } + + void max( const Coord2D &other ) + { + if (x < other.x) + x = other.x; + if (y < other.y) + y = other.y; + } }; inline Coord2D operator+( const Coord2D &a, const Coord2D &b ) @@ -458,6 +474,22 @@ struct ICoord2D x = ax; y = ay; } + + void min( const ICoord2D &other ) + { + if (x > other.x) + x = other.x; + if (y > other.y) + y = other.y; + } + + void max( const ICoord2D &other ) + { + if (x < other.x) + x = other.x; + if (y < other.y) + y = other.y; + } }; inline ICoord2D operator+( const ICoord2D &a, const ICoord2D &b ) @@ -478,6 +510,12 @@ struct Region2D { Coord2D lo, hi; // bounds of 2D rectangular region + void intersect( const Region2D &other ) + { + lo.max(other.lo); + hi.min(other.hi); + } + void zero() { lo.zero(); @@ -498,6 +536,12 @@ struct IRegion2D { ICoord2D lo, hi; // bounds of 2D rectangular region + void intersect( const IRegion2D &other ) + { + lo.max(other.lo); + hi.min(other.hi); + } + void zero() { lo.zero(); @@ -611,6 +655,26 @@ struct Coord3D y == r.y && z == r.z); } + + void min( const Coord3D &other ) + { + if (x > other.x) + x = other.x; + if (y > other.y) + y = other.y; + if (z > other.z) + z = other.z; + } + + void max( const Coord3D &other ) + { + if (x < other.x) + x = other.x; + if (y < other.y) + y = other.y; + if (z < other.z) + z = other.z; + } }; inline Coord3D operator+( const Coord3D &a, const Coord3D &b ) @@ -683,6 +747,26 @@ struct ICoord3D y = ay; z = az; } + + void min( const ICoord3D &other ) + { + if (x > other.x) + x = other.x; + if (y > other.y) + y = other.y; + if (z > other.z) + z = other.z; + } + + void max( const ICoord3D &other ) + { + if (x < other.x) + x = other.x; + if (y < other.y) + y = other.y; + if (z < other.z) + z = other.z; + } }; inline ICoord3D operator+( const ICoord3D &a, const ICoord3D &b ) @@ -704,6 +788,12 @@ struct Region3D { Coord3D lo, hi; // axis-aligned bounding box + void intersect( const Region3D &other ) + { + lo.max(other.lo); + hi.min(other.hi); + } + Real width() const { return hi.x - lo.x; } Real height() const { return hi.y - lo.y; } Real depth() const { return hi.z - lo.z; } @@ -783,6 +873,12 @@ struct IRegion3D { ICoord3D lo, hi; // axis-aligned bounding box + void intersect( const IRegion3D &other ) + { + lo.max(other.lo); + hi.min(other.hi); + } + void zero() { lo.zero(); From 906b004c7217c3e70bda052d51ebb05609f6a30f Mon Sep 17 00:00:00 2001 From: stm <14291421+stephanmeesters@users.noreply.github.com> Date: Tue, 8 Sep 2026 21:29:44 +0200 Subject: [PATCH 02/17] Apply new min, max, and intersect functions --- .../Source/GameClient/GUI/GameWindow.cpp | 23 ++------- .../Source/GameLogic/AI/AIPathfind.cpp | 49 ++----------------- Core/Libraries/Include/Lib/BaseType.h | 14 +----- 3 files changed, 10 insertions(+), 76 deletions(-) diff --git a/Core/GameEngine/Source/GameClient/GUI/GameWindow.cpp b/Core/GameEngine/Source/GameClient/GUI/GameWindow.cpp index 84dc88726cc..8bd67813ebf 100644 --- a/Core/GameEngine/Source/GameClient/GUI/GameWindow.cpp +++ b/Core/GameEngine/Source/GameClient/GUI/GameWindow.cpp @@ -180,26 +180,9 @@ void GameWindow::unlinkFromTransitionWindows() //============================================================================= void GameWindow::normalizeWindowRegion() { - Int temp; - - if( m_region.lo.x > m_region.hi.x) - { - - temp = m_region.lo.x; - m_region.lo.x = m_region.hi.x; - m_region.hi.x = temp; - - } - - if( m_region.lo.y > m_region.hi.y ) - { - - temp = m_region.lo.y; - m_region.lo.y = m_region.hi.y; - m_region.hi.y = temp; - - } - + const ICoord2D lo = m_region.lo; + m_region.lo.min(m_region.hi); + m_region.hi.max(lo); } // GameWindow::findFirstLeaf ================================================== diff --git a/Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp b/Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp index ae79ca14249..46550c26294 100644 --- a/Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp +++ b/Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp @@ -2726,12 +2726,7 @@ void PathfindZoneManager::calculateZones( PathfindCell **map, PathfindLayer laye bounds.lo.y = globalBounds.lo.y + yBlock*ZONE_BLOCK_SIZE; bounds.hi.x = bounds.lo.x + ZONE_BLOCK_SIZE - 1; // bounds are inclusive. bounds.hi.y = bounds.lo.y + ZONE_BLOCK_SIZE - 1; // bounds are inclusive. - if (bounds.hi.x > globalBounds.hi.x) { - bounds.hi.x = globalBounds.hi.x; - } - if (bounds.hi.y > globalBounds.hi.y) { - bounds.hi.y = globalBounds.hi.y; - } + bounds.hi.min(globalBounds.hi); #if RTS_GENERALS && RETAIL_COMPATIBLE_PATHFINDING if (bounds.lo.x>bounds.hi.x || bounds.lo.y>bounds.hi.y) { DEBUG_CRASH(("Incorrect bounds calculation. Logic error, fix me. jba.")); @@ -2828,11 +2823,7 @@ void PathfindZoneManager::calculateZones( PathfindCell **map, PathfindLayer laye bounds.hi.x = bounds.lo.x + ZONE_BLOCK_SIZE - 1; // bounds are inclusive. bounds.hi.y = bounds.lo.y + ZONE_BLOCK_SIZE - 1; // bounds are inclusive. - if (bounds.hi.x > globalBounds.hi.x) - bounds.hi.x = globalBounds.hi.x; - - if (bounds.hi.y > globalBounds.hi.y) - bounds.hi.y = globalBounds.hi.y; + bounds.hi.min(globalBounds.hi); #if RTS_GENERALS && RETAIL_COMPATIBLE_PATHFINDING if (bounds.lo.x>bounds.hi.x || bounds.lo.y>bounds.hi.y) { DEBUG_CRASH(("Incorrect bounds calculation. Logic error, fix me. jba.")); @@ -3051,12 +3042,7 @@ void PathfindZoneManager::updateZonesForModify(PathfindCell **map, PathfindLayer IRegion2D bounds = structureBounds; bounds.hi.x++; bounds.hi.y++; - if (bounds.hi.x > globalBounds.hi.x) { - bounds.hi.x = globalBounds.hi.x; - } - if (bounds.hi.y > globalBounds.hi.y) { - bounds.hi.y = globalBounds.hi.y; - } + bounds.hi.min(globalBounds.hi); Int xBlock, yBlock; for (xBlock = 0; xBlock bounds.hi.x) { - blockBounds.hi.x = bounds.hi.x; - } - if (blockBounds.hi.y > bounds.hi.y) { - blockBounds.hi.y = bounds.hi.y; - } - if (blockBounds.lo.x < bounds.lo.x) { - blockBounds.lo.x = bounds.lo.x; - } - if (blockBounds.lo.y < bounds.lo.y) { - blockBounds.lo.y = bounds.lo.y; - } + blockBounds.intersect(bounds); if (blockBounds.lo.x>blockBounds.hi.x || blockBounds.lo.y>blockBounds.hi.y) { continue; } @@ -4607,21 +4582,7 @@ void Pathfinder::internal_classifyObjectFootprint( Object *obj, Bool insert ) Int i, j; - if (cellBounds.lo.x < m_extent.lo.x) { - cellBounds.lo.x = m_extent.lo.x; - } - if (cellBounds.lo.y < m_extent.lo.y) { - cellBounds.lo.y = m_extent.lo.y; - } - if (cellBounds.lo.y < m_extent.lo.y) { - cellBounds.lo.y = m_extent.lo.y; - } - if (cellBounds.hi.x > m_extent.hi.x) { - cellBounds.hi.x = m_extent.hi.x; - } - if (cellBounds.hi.y > m_extent.hi.y) { - cellBounds.hi.y = m_extent.hi.y; - } + cellBounds.intersect(m_extent); if (!insert) { for( j=cellBounds.lo.y; j<=cellBounds.hi.y; j++ ) diff --git a/Core/Libraries/Include/Lib/BaseType.h b/Core/Libraries/Include/Lib/BaseType.h index 56f77db620a..be6b0d0886b 100644 --- a/Core/Libraries/Include/Lib/BaseType.h +++ b/Core/Libraries/Include/Lib/BaseType.h @@ -840,18 +840,8 @@ struct Region3D hi = points[0]; for (Int i = 1; i < count; ++i) { - if (points[i].x < lo.x) - lo.x = points[i].x; - if (points[i].y < lo.y) - lo.y = points[i].y; - if (points[i].z < lo.z) - lo.z = points[i].z; - if (points[i].x > hi.x) - hi.x = points[i].x; - if (points[i].y > hi.y) - hi.y = points[i].y; - if (points[i].z > hi.z) - hi.z = points[i].z; + lo.min(points[i]); + hi.max(points[i]); } } From b89757ee3e8b4ef1a2257ca51123976ba959bc65 Mon Sep 17 00:00:00 2001 From: stm <14291421+stephanmeesters@users.noreply.github.com> Date: Wed, 9 Sep 2026 20:16:54 +0200 Subject: [PATCH 03/17] Update after review --- Core/GameEngine/Source/GameClient/GUI/GameWindow.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Core/GameEngine/Source/GameClient/GUI/GameWindow.cpp b/Core/GameEngine/Source/GameClient/GUI/GameWindow.cpp index 8bd67813ebf..526f8bb52cf 100644 --- a/Core/GameEngine/Source/GameClient/GUI/GameWindow.cpp +++ b/Core/GameEngine/Source/GameClient/GUI/GameWindow.cpp @@ -180,9 +180,11 @@ void GameWindow::unlinkFromTransitionWindows() //============================================================================= void GameWindow::normalizeWindowRegion() { - const ICoord2D lo = m_region.lo; - m_region.lo.min(m_region.hi); - m_region.hi.max(lo); + if( m_region.lo.x > m_region.hi.x ) + std::swap( m_region.lo.x, m_region.hi.x ); + + if( m_region.lo.y > m_region.hi.y ) + std::swap( m_region.lo.y, m_region.hi.y ); } // GameWindow::findFirstLeaf ================================================== From 7babd44d821bea33547b28385ad76d7b436a6474 Mon Sep 17 00:00:00 2001 From: stm <14291421+stephanmeesters@users.noreply.github.com> Date: Thu, 10 Sep 2026 12:53:01 +0200 Subject: [PATCH 04/17] Add comments --- Core/Libraries/Include/Lib/BaseType.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Core/Libraries/Include/Lib/BaseType.h b/Core/Libraries/Include/Lib/BaseType.h index be6b0d0886b..97b329387e8 100644 --- a/Core/Libraries/Include/Lib/BaseType.h +++ b/Core/Libraries/Include/Lib/BaseType.h @@ -510,6 +510,7 @@ struct Region2D { Coord2D lo, hi; // bounds of 2D rectangular region + // Keep only the overlapping portion of both regions. void intersect( const Region2D &other ) { lo.max(other.lo); @@ -536,6 +537,7 @@ struct IRegion2D { ICoord2D lo, hi; // bounds of 2D rectangular region + // Keep only the overlapping portion of both regions. void intersect( const IRegion2D &other ) { lo.max(other.lo); @@ -788,6 +790,7 @@ struct Region3D { Coord3D lo, hi; // axis-aligned bounding box + // Keep only the overlapping portion of both regions. void intersect( const Region3D &other ) { lo.max(other.lo); @@ -863,6 +866,7 @@ struct IRegion3D { ICoord3D lo, hi; // axis-aligned bounding box + // Keep only the overlapping portion of both regions. void intersect( const IRegion3D &other ) { lo.max(other.lo); From 07217e6ad385a05ba29ef92e75bd35752640b457 Mon Sep 17 00:00:00 2001 From: stm <14291421+stephanmeesters@users.noreply.github.com> Date: Thu, 10 Sep 2026 13:33:24 +0200 Subject: [PATCH 05/17] One more regular replacement --- Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp b/Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp index 46550c26294..7828384ae2b 100644 --- a/Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp +++ b/Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp @@ -3591,10 +3591,8 @@ void PathfindLayer::allocateCellsForWallLayer(const IRegion2D *extent, ObjectID bridgeBounds = objBounds; first = false; } else { - if (bridgeBounds.lo.x>objBounds.lo.x) bridgeBounds.lo.x = objBounds.lo.x; - if (bridgeBounds.lo.y>objBounds.lo.y) bridgeBounds.lo.y = objBounds.lo.y; - if (bridgeBounds.hi.x Date: Thu, 10 Sep 2026 14:00:17 +0200 Subject: [PATCH 06/17] Add xy accessors and use them in bounds min/max calls --- Core/Libraries/Include/Lib/BaseType.h | 12 +++++++ .../Source/GameLogic/AI/AIPlayer.cpp | 12 +++---- .../Source/GameLogic/Map/PolygonTrigger.cpp | 6 ++-- .../Source/GameLogic/Map/TerrainLogic.cpp | 36 +++++++------------ .../Object/Behavior/PrisonBehavior.cpp | 10 ++---- .../Source/GameLogic/AI/AIPlayer.cpp | 12 +++---- .../Source/GameLogic/Map/PolygonTrigger.cpp | 6 ++-- .../Source/GameLogic/Map/TerrainLogic.cpp | 36 +++++++------------ .../Object/Behavior/PrisonBehavior.cpp | 10 ++---- 9 files changed, 52 insertions(+), 88 deletions(-) diff --git a/Core/Libraries/Include/Lib/BaseType.h b/Core/Libraries/Include/Lib/BaseType.h index 97b329387e8..ca54715db73 100644 --- a/Core/Libraries/Include/Lib/BaseType.h +++ b/Core/Libraries/Include/Lib/BaseType.h @@ -565,6 +565,12 @@ struct Coord3D { Real x, y, z; + Coord2D xy() const + { + const Coord2D xy = { x, y }; + return xy; + } + Real length() const { return (Real)sqrt( x*x + y*y + z*z ); } Real lengthSqr() const { return ( x*x + y*y + z*z ); } @@ -697,6 +703,12 @@ struct ICoord3D { Int x, y, z; + ICoord2D xy() const + { + const ICoord2D xy = { x, y }; + return xy; + } + Int length() const { return (Int)sqrt( (double)(x*x + y*y + z*z) ); } Int lengthSqr() const { return x*x + y*y + z*z; } diff --git a/Generals/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp b/Generals/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp index 2472c2ffefc..443e2fd0dc1 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp @@ -3496,20 +3496,16 @@ void AIPlayer::getPlayerStructureBounds(Region2D *bounds, Int playerNdx ) objBounds.lo.y = objBounds.hi.y = pos.y; firstObject = false; } else { - if (objBounds.lo.x>pos.x) objBounds.lo.x = pos.x; - if (objBounds.lo.y>pos.y) objBounds.lo.y = pos.y; - if (objBounds.hi.xlo.x = bounds->hi.x = pos.x; bounds->lo.y = bounds->hi.y = pos.y; firstStructure = false; } else { - if (bounds->lo.x>pos.x) bounds->lo.x = pos.x; - if (bounds->lo.y>pos.y) bounds->lo.y = pos.y; - if (bounds->hi.xhi.x = pos.x; - if (bounds->hi.yhi.y = pos.y; + bounds->lo.min(pos.xy()); + bounds->hi.max(pos.xy()); } } } diff --git a/Generals/Code/GameEngine/Source/GameLogic/Map/PolygonTrigger.cpp b/Generals/Code/GameEngine/Source/GameLogic/Map/PolygonTrigger.cpp index 6cea7c6227a..4d570f779ac 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Map/PolygonTrigger.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Map/PolygonTrigger.cpp @@ -261,10 +261,8 @@ void PolygonTrigger::updateBounds() const m_bounds.hi.x = m_bounds.hi.y = -BIG_INT; Int i; for (i=0; i m_bounds.hi.x) m_bounds.hi.x = m_points[i].x; - if (m_points[i].y > m_bounds.hi.y) m_bounds.hi.y = m_points[i].y; + m_bounds.lo.min(m_points[i].xy()); + m_bounds.hi.max(m_points[i].xy()); } m_boundsNeedsUpdate = 0; Real halfWidth = (m_bounds.hi.x - m_bounds.lo.x) / 2.0f; diff --git a/Generals/Code/GameEngine/Source/GameLogic/Map/TerrainLogic.cpp b/Generals/Code/GameEngine/Source/GameLogic/Map/TerrainLogic.cpp index 00386047267..e39dbbe3eaf 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Map/TerrainLogic.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Map/TerrainLogic.cpp @@ -224,18 +224,12 @@ m_bridgeInfo(theInfo) m_bounds.lo.x = m_bridgeInfo.fromLeft.x; m_bounds.lo.y = m_bridgeInfo.fromLeft.y; m_bounds.hi = m_bounds.lo; - if (m_bounds.lo.x > m_bridgeInfo.fromRight.x) m_bounds.lo.x = m_bridgeInfo.fromRight.x; - if (m_bounds.lo.y > m_bridgeInfo.fromRight.y) m_bounds.lo.y = m_bridgeInfo.fromRight.y; - if (m_bounds.hi.x < m_bridgeInfo.fromRight.x) m_bounds.hi.x = m_bridgeInfo.fromRight.x; - if (m_bounds.hi.y < m_bridgeInfo.fromRight.y) m_bounds.hi.y = m_bridgeInfo.fromRight.y; - if (m_bounds.lo.x > m_bridgeInfo.toLeft.x) m_bounds.lo.x = m_bridgeInfo.toLeft.x; - if (m_bounds.lo.y > m_bridgeInfo.toLeft.y) m_bounds.lo.y = m_bridgeInfo.toLeft.y; - if (m_bounds.hi.x < m_bridgeInfo.toLeft.x) m_bounds.hi.x = m_bridgeInfo.toLeft.x; - if (m_bounds.hi.y < m_bridgeInfo.toLeft.y) m_bounds.hi.y = m_bridgeInfo.toLeft.y; - if (m_bounds.lo.x > m_bridgeInfo.toRight.x) m_bounds.lo.x = m_bridgeInfo.toRight.x; - if (m_bounds.lo.y > m_bridgeInfo.toRight.y) m_bounds.lo.y = m_bridgeInfo.toRight.y; - if (m_bounds.hi.x < m_bridgeInfo.toRight.x) m_bounds.hi.x = m_bridgeInfo.toRight.x; - if (m_bounds.hi.y < m_bridgeInfo.toRight.y) m_bounds.hi.y = m_bridgeInfo.toRight.y; + m_bounds.lo.min(m_bridgeInfo.fromRight.xy()); + m_bounds.hi.max(m_bridgeInfo.fromRight.xy()); + m_bounds.lo.min(m_bridgeInfo.toLeft.xy()); + m_bounds.hi.max(m_bridgeInfo.toLeft.xy()); + m_bounds.lo.min(m_bridgeInfo.toRight.xy()); + m_bounds.hi.max(m_bridgeInfo.toRight.xy()); m_bridgeInfo.curDamageState = BODY_PRISTINE; @@ -360,18 +354,12 @@ Bridge::Bridge(Object *bridgeObj) m_bounds.lo.x = m_bridgeInfo.fromLeft.x; m_bounds.lo.y = m_bridgeInfo.fromLeft.y; m_bounds.hi = m_bounds.lo; - if (m_bounds.lo.x > m_bridgeInfo.fromRight.x) m_bounds.lo.x = m_bridgeInfo.fromRight.x; - if (m_bounds.lo.y > m_bridgeInfo.fromRight.y) m_bounds.lo.y = m_bridgeInfo.fromRight.y; - if (m_bounds.hi.x < m_bridgeInfo.fromRight.x) m_bounds.hi.x = m_bridgeInfo.fromRight.x; - if (m_bounds.hi.y < m_bridgeInfo.fromRight.y) m_bounds.hi.y = m_bridgeInfo.fromRight.y; - if (m_bounds.lo.x > m_bridgeInfo.toLeft.x) m_bounds.lo.x = m_bridgeInfo.toLeft.x; - if (m_bounds.lo.y > m_bridgeInfo.toLeft.y) m_bounds.lo.y = m_bridgeInfo.toLeft.y; - if (m_bounds.hi.x < m_bridgeInfo.toLeft.x) m_bounds.hi.x = m_bridgeInfo.toLeft.x; - if (m_bounds.hi.y < m_bridgeInfo.toLeft.y) m_bounds.hi.y = m_bridgeInfo.toLeft.y; - if (m_bounds.lo.x > m_bridgeInfo.toRight.x) m_bounds.lo.x = m_bridgeInfo.toRight.x; - if (m_bounds.lo.y > m_bridgeInfo.toRight.y) m_bounds.lo.y = m_bridgeInfo.toRight.y; - if (m_bounds.hi.x < m_bridgeInfo.toRight.x) m_bounds.hi.x = m_bridgeInfo.toRight.x; - if (m_bounds.hi.y < m_bridgeInfo.toRight.y) m_bounds.hi.y = m_bridgeInfo.toRight.y; + m_bounds.lo.min(m_bridgeInfo.fromRight.xy()); + m_bounds.hi.max(m_bridgeInfo.fromRight.xy()); + m_bounds.lo.min(m_bridgeInfo.toLeft.xy()); + m_bounds.hi.max(m_bridgeInfo.toLeft.xy()); + m_bounds.lo.min(m_bridgeInfo.toRight.xy()); + m_bounds.hi.max(m_bridgeInfo.toRight.xy()); m_bridgeInfo.curDamageState = BODY_PRISTINE; diff --git a/Generals/Code/GameEngine/Source/GameLogic/Object/Behavior/PrisonBehavior.cpp b/Generals/Code/GameEngine/Source/GameLogic/Object/Behavior/PrisonBehavior.cpp index 92ce422a6b0..f2bbb7ab5fd 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Object/Behavior/PrisonBehavior.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Object/Behavior/PrisonBehavior.cpp @@ -244,14 +244,8 @@ void PrisonBehavior::pickVisualLocation( Coord3D *pos ) for( i = 1; i < yardBones; i++ ) { - if( yardPositions[ i ].x < yardRegion.lo.x ) - yardRegion.lo.x = yardPositions[ i ].x; - if( yardPositions[ i ].y < yardRegion.lo.y ) - yardRegion.lo.y = yardPositions[ i ].y; - if( yardPositions[ i ].x > yardRegion.hi.x ) - yardRegion.hi.x = yardPositions[ i ].x; - if( yardPositions[ i ].y > yardRegion.hi.y ) - yardRegion.hi.y = yardPositions[ i ].y; + yardRegion.lo.min(yardPositions[ i ].xy()); + yardRegion.hi.max(yardPositions[ i ].xy()); } diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp index 330969a65ed..33e88c56545 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp @@ -3848,10 +3848,8 @@ void AIPlayer::getPlayerStructureBounds( Region2D *bounds, Int playerNdx, Bool c } else { - if (objBounds.lo.x>pos.x) objBounds.lo.x = pos.x; - if (objBounds.lo.y>pos.y) objBounds.lo.y = pos.y; - if (objBounds.hi.xlo.x>pos.x) bounds->lo.x = pos.x; - if (bounds->lo.y>pos.y) bounds->lo.y = pos.y; - if (bounds->hi.xhi.x = pos.x; - if (bounds->hi.yhi.y = pos.y; + bounds->lo.min(pos.xy()); + bounds->hi.max(pos.xy()); } } } diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/PolygonTrigger.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/PolygonTrigger.cpp index 4f19ee9cfc2..84abe5478bd 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/PolygonTrigger.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/PolygonTrigger.cpp @@ -277,10 +277,8 @@ void PolygonTrigger::updateBounds() const m_bounds.hi.x = m_bounds.hi.y = -BIG_INT; Int i; for (i=0; i m_bounds.hi.x) m_bounds.hi.x = m_points[i].x; - if (m_points[i].y > m_bounds.hi.y) m_bounds.hi.y = m_points[i].y; + m_bounds.lo.min(m_points[i].xy()); + m_bounds.hi.max(m_points[i].xy()); } m_boundsNeedsUpdate = 0; Real halfWidth = (m_bounds.hi.x - m_bounds.lo.x) / 2.0f; diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/TerrainLogic.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/TerrainLogic.cpp index 5a3d16f86ae..102c8576dc4 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/TerrainLogic.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/TerrainLogic.cpp @@ -224,18 +224,12 @@ m_bridgeInfo(theInfo) m_bounds.lo.x = m_bridgeInfo.fromLeft.x; m_bounds.lo.y = m_bridgeInfo.fromLeft.y; m_bounds.hi = m_bounds.lo; - if (m_bounds.lo.x > m_bridgeInfo.fromRight.x) m_bounds.lo.x = m_bridgeInfo.fromRight.x; - if (m_bounds.lo.y > m_bridgeInfo.fromRight.y) m_bounds.lo.y = m_bridgeInfo.fromRight.y; - if (m_bounds.hi.x < m_bridgeInfo.fromRight.x) m_bounds.hi.x = m_bridgeInfo.fromRight.x; - if (m_bounds.hi.y < m_bridgeInfo.fromRight.y) m_bounds.hi.y = m_bridgeInfo.fromRight.y; - if (m_bounds.lo.x > m_bridgeInfo.toLeft.x) m_bounds.lo.x = m_bridgeInfo.toLeft.x; - if (m_bounds.lo.y > m_bridgeInfo.toLeft.y) m_bounds.lo.y = m_bridgeInfo.toLeft.y; - if (m_bounds.hi.x < m_bridgeInfo.toLeft.x) m_bounds.hi.x = m_bridgeInfo.toLeft.x; - if (m_bounds.hi.y < m_bridgeInfo.toLeft.y) m_bounds.hi.y = m_bridgeInfo.toLeft.y; - if (m_bounds.lo.x > m_bridgeInfo.toRight.x) m_bounds.lo.x = m_bridgeInfo.toRight.x; - if (m_bounds.lo.y > m_bridgeInfo.toRight.y) m_bounds.lo.y = m_bridgeInfo.toRight.y; - if (m_bounds.hi.x < m_bridgeInfo.toRight.x) m_bounds.hi.x = m_bridgeInfo.toRight.x; - if (m_bounds.hi.y < m_bridgeInfo.toRight.y) m_bounds.hi.y = m_bridgeInfo.toRight.y; + m_bounds.lo.min(m_bridgeInfo.fromRight.xy()); + m_bounds.hi.max(m_bridgeInfo.fromRight.xy()); + m_bounds.lo.min(m_bridgeInfo.toLeft.xy()); + m_bounds.hi.max(m_bridgeInfo.toLeft.xy()); + m_bounds.lo.min(m_bridgeInfo.toRight.xy()); + m_bounds.hi.max(m_bridgeInfo.toRight.xy()); m_bridgeInfo.curDamageState = BODY_PRISTINE; @@ -360,18 +354,12 @@ Bridge::Bridge(Object *bridgeObj) m_bounds.lo.x = m_bridgeInfo.fromLeft.x; m_bounds.lo.y = m_bridgeInfo.fromLeft.y; m_bounds.hi = m_bounds.lo; - if (m_bounds.lo.x > m_bridgeInfo.fromRight.x) m_bounds.lo.x = m_bridgeInfo.fromRight.x; - if (m_bounds.lo.y > m_bridgeInfo.fromRight.y) m_bounds.lo.y = m_bridgeInfo.fromRight.y; - if (m_bounds.hi.x < m_bridgeInfo.fromRight.x) m_bounds.hi.x = m_bridgeInfo.fromRight.x; - if (m_bounds.hi.y < m_bridgeInfo.fromRight.y) m_bounds.hi.y = m_bridgeInfo.fromRight.y; - if (m_bounds.lo.x > m_bridgeInfo.toLeft.x) m_bounds.lo.x = m_bridgeInfo.toLeft.x; - if (m_bounds.lo.y > m_bridgeInfo.toLeft.y) m_bounds.lo.y = m_bridgeInfo.toLeft.y; - if (m_bounds.hi.x < m_bridgeInfo.toLeft.x) m_bounds.hi.x = m_bridgeInfo.toLeft.x; - if (m_bounds.hi.y < m_bridgeInfo.toLeft.y) m_bounds.hi.y = m_bridgeInfo.toLeft.y; - if (m_bounds.lo.x > m_bridgeInfo.toRight.x) m_bounds.lo.x = m_bridgeInfo.toRight.x; - if (m_bounds.lo.y > m_bridgeInfo.toRight.y) m_bounds.lo.y = m_bridgeInfo.toRight.y; - if (m_bounds.hi.x < m_bridgeInfo.toRight.x) m_bounds.hi.x = m_bridgeInfo.toRight.x; - if (m_bounds.hi.y < m_bridgeInfo.toRight.y) m_bounds.hi.y = m_bridgeInfo.toRight.y; + m_bounds.lo.min(m_bridgeInfo.fromRight.xy()); + m_bounds.hi.max(m_bridgeInfo.fromRight.xy()); + m_bounds.lo.min(m_bridgeInfo.toLeft.xy()); + m_bounds.hi.max(m_bridgeInfo.toLeft.xy()); + m_bounds.lo.min(m_bridgeInfo.toRight.xy()); + m_bounds.hi.max(m_bridgeInfo.toRight.xy()); m_bridgeInfo.curDamageState = BODY_PRISTINE; diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/PrisonBehavior.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/PrisonBehavior.cpp index ccffe16691f..776f24ddb87 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/PrisonBehavior.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/PrisonBehavior.cpp @@ -244,14 +244,8 @@ void PrisonBehavior::pickVisualLocation( Coord3D *pos ) for( i = 1; i < yardBones; i++ ) { - if( yardPositions[ i ].x < yardRegion.lo.x ) - yardRegion.lo.x = yardPositions[ i ].x; - if( yardPositions[ i ].y < yardRegion.lo.y ) - yardRegion.lo.y = yardPositions[ i ].y; - if( yardPositions[ i ].x > yardRegion.hi.x ) - yardRegion.hi.x = yardPositions[ i ].x; - if( yardPositions[ i ].y > yardRegion.hi.y ) - yardRegion.hi.y = yardPositions[ i ].y; + yardRegion.lo.min(yardPositions[ i ].xy()); + yardRegion.hi.max(yardPositions[ i ].xy()); } From 9bdddc3d9ccca28d3705ab6693a0a62e502d8937 Mon Sep 17 00:00:00 2001 From: stm <14291421+stephanmeesters@users.noreply.github.com> Date: Thu, 10 Sep 2026 14:00:30 +0200 Subject: [PATCH 07/17] Replace manual coordinate projections with XY accessors --- Core/GameEngine/Include/GameClient/View.h | 2 +- Core/GameEngine/Source/GameClient/Line2D.cpp | 26 +++----- .../Source/GameLogic/AI/AIPathfind.cpp | 18 ++---- .../Source/W3DDevice/GameClient/W3DView.cpp | 3 +- .../Source/GameLogic/Map/TerrainLogic.cpp | 60 +++++++------------ .../Object/Behavior/PrisonBehavior.cpp | 6 +- .../Code/Tools/WorldBuilder/src/RampTool.cpp | 6 +- .../Code/Tools/WorldBuilder/src/RoadTool.cpp | 9 +-- .../Source/GameLogic/Map/TerrainLogic.cpp | 60 +++++++------------ .../Object/Behavior/PrisonBehavior.cpp | 6 +- .../Code/Tools/WorldBuilder/src/RampTool.cpp | 6 +- .../Code/Tools/WorldBuilder/src/RoadTool.cpp | 9 +-- 12 files changed, 73 insertions(+), 138 deletions(-) diff --git a/Core/GameEngine/Include/GameClient/View.h b/Core/GameEngine/Include/GameClient/View.h index d60010da63c..583bbbd1008 100644 --- a/Core/GameEngine/Include/GameClient/View.h +++ b/Core/GameEngine/Include/GameClient/View.h @@ -197,7 +197,7 @@ class View : public Snapshot void setPosition( const Coord3D &pos ) { m_pos = pos; } void setPosition2D( const Coord2D &pos ) { m_pos.x = pos.x; m_pos.y = pos.y; } const Coord3D &getPosition() const { return m_pos; } ///< Returns position camera is looking at - Coord2D getPosition2D() const { Coord2D c = { m_pos.x, m_pos.y }; return c; } ///< Returns position camera is looking at + Coord2D getPosition2D() const { return m_pos.xy(); } ///< Returns position camera is looking at virtual Coord3D get3DCameraPosition() const { Coord3D c={0,0,0}; return c; } ///< Returns the actual camera position virtual Coord3D get3DCameraDirection() const { Coord3D c={0,0,0}; return c; } ///< Returns the actual camera view direction diff --git a/Core/GameEngine/Source/GameClient/Line2D.cpp b/Core/GameEngine/Source/GameClient/Line2D.cpp index 19267f6204a..6e6836bb01f 100644 --- a/Core/GameEngine/Source/GameClient/Line2D.cpp +++ b/Core/GameEngine/Source/GameClient/Line2D.cpp @@ -289,17 +289,12 @@ Bool PointInsideRect3D(const Coord3D *bl, const Coord3D *tl, const Coord3D *br, const Coord3D *inputPoint) { Coord2D bl2d, tl2d, br2d, tr2d, pt; - bl2d.x = bl->x; - bl2d.y = bl->y; - tl2d.x = tl->x; - tl2d.y = tl->y; - br2d.x = br->x; - br2d.y = br->y; - tr2d.x = tr->x; - tr2d.y = tr->y; - - pt.x = inputPoint->x; - pt.y = inputPoint->y; + bl2d = bl->xy(); + tl2d = tl->xy(); + br2d = br->xy(); + tr2d = tr->xy(); + + pt = inputPoint->xy(); return PointInsideRect2D(&bl2d, &br2d, &tl2d, &tr2d, &pt); } @@ -322,14 +317,11 @@ Bool PointInsideArea2D( const Coord3D *ptToTest, const Coord3D *area, Int numPoi { int numIntersections = 0; Coord2D pt2D, area2D1, area2D2; - pt2D.x = ptToTest->x; - pt2D.y = ptToTest->y; + pt2D = ptToTest->xy(); for (int i = 0; i < numPointsInArea; ++i) { - area2D1.x = area[i].x; - area2D1.y = area[i].y; - area2D2.x = area[(i + 1) % numPointsInArea].x; - area2D2.y = area[(i + 1) % numPointsInArea].y; + area2D1 = area[i].xy(); + area2D2 = area[(i + 1) % numPointsInArea].xy(); if (IntersectLine2D(&pt2D, &reallyFarPoint, &area2D1, &area2D2)) { ++numIntersections; } diff --git a/Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp b/Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp index 7828384ae2b..49bf0803e17 100644 --- a/Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp +++ b/Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp @@ -3882,10 +3882,8 @@ void PathfindLayer::classifyLayerMapCell( Int i, Int j , PathfindCell *cell, Bri // check against the end lines. Region2D cellBounds; - cellBounds.lo.x = topLeftCorner.x; - cellBounds.lo.y = topLeftCorner.y; - cellBounds.hi.x = bottomRightCorner.x; - cellBounds.hi.y = bottomRightCorner.y; + cellBounds.lo = topLeftCorner.xy(); + cellBounds.hi = bottomRightCorner.xy(); #if RTS_GENERALS && RETAIL_COMPATIBLE_PATHFINDING if (m_bridge->isCellOnEnd(&cellBounds)) { @@ -10443,10 +10441,8 @@ Path *Pathfinder::getMoveAwayFromPath(Object* obj, Object *otherObj, for( node = pathToAvoid->getFirstNode(); node && node->getNextOptimized(); node = node->getNextOptimized() ) { Coord2D start, end; - start.x = node->getPosition()->x; - start.y = node->getPosition()->y; - end.x = node->getNextOptimized()->getPosition()->x; - end.y = node->getNextOptimized()->getPosition()->y; + start = node->getPosition()->xy(); + end = node->getNextOptimized()->getPosition()->xy(); if (LineInRegion(&start, &end, &bounds)) { overlap = true; break; @@ -10456,10 +10452,8 @@ Path *Pathfinder::getMoveAwayFromPath(Object* obj, Object *otherObj, if (!overlap && pathToAvoid2) { for( node = pathToAvoid2->getFirstNode(); node && node->getNextOptimized(); node = node->getNextOptimized() ) { Coord2D start, end; - start.x = node->getPosition()->x; - start.y = node->getPosition()->y; - end.x = node->getNextOptimized()->getPosition()->x; - end.y = node->getNextOptimized()->getPosition()->y; + start = node->getPosition()->xy(); + end = node->getNextOptimized()->getPosition()->xy(); if (LineInRegion(&start, &end, &bounds)) { overlap = true; break; diff --git a/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp index b2d54ac0b7e..f2ae76a05ee 100644 --- a/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp @@ -2625,8 +2625,7 @@ void W3DView::lookAt( const Coord3D *o ) } } - Coord2D pos2D = { pos.x, pos.y }; - setPosition2D(pos2D); + setPosition2D(pos.xy()); resetPivotToGround(); diff --git a/Generals/Code/GameEngine/Source/GameLogic/Map/TerrainLogic.cpp b/Generals/Code/GameEngine/Source/GameLogic/Map/TerrainLogic.cpp index e39dbbe3eaf..a2ac5fb31b9 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Map/TerrainLogic.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Map/TerrainLogic.cpp @@ -221,8 +221,7 @@ m_bridgeInfo(theInfo) m_templateName = bridgeTemplateName; //Coord3D fromLeft, fromRight, toLeft, toRight; /// The 4 corners of the rectangle that the bridge covers. - m_bounds.lo.x = m_bridgeInfo.fromLeft.x; - m_bounds.lo.y = m_bridgeInfo.fromLeft.y; + m_bounds.lo = m_bridgeInfo.fromLeft.xy(); m_bounds.hi = m_bounds.lo; m_bounds.lo.min(m_bridgeInfo.fromRight.xy()); m_bounds.hi.max(m_bridgeInfo.fromRight.xy()); @@ -351,8 +350,7 @@ Bridge::Bridge(Object *bridgeObj) m_bridgeInfo.to.z = (m_bridgeInfo.toLeft.z + m_bridgeInfo.toRight.z)/2.0f; //Coord3D fromLeft, fromRight, toLeft, toRight; /// The 4 corners of the rectangle that the bridge covers. - m_bounds.lo.x = m_bridgeInfo.fromLeft.x; - m_bounds.lo.y = m_bridgeInfo.fromLeft.y; + m_bounds.lo = m_bridgeInfo.fromLeft.xy(); m_bounds.hi = m_bounds.lo; m_bounds.lo.min(m_bridgeInfo.fromRight.xy()); m_bounds.hi.max(m_bridgeInfo.fromRight.xy()); @@ -661,17 +659,13 @@ Bool Bridge::isCellOnEnd(const Region2D *cell) if (PointInRegion2D(&toLeft, cell)) return false; if (PointInRegion2D(&toRight, cell)) return false; */ Coord2D line1, line2; - line1.x = fromLeft.x; - line1.y = fromLeft.y; - line2.x = fromRight.x; - line2.y = fromRight.y; + line1 = fromLeft.xy(); + line2 = fromRight.xy(); if (LineInRegion(&line1, &line2, cell)) { return true; } - line1.x = toLeft.x; - line1.y = toLeft.y; - line2.x = toRight.x; - line2.y = toRight.y; + line1 = toLeft.xy(); + line2 = toRight.xy(); if (LineInRegion(&line1, &line2, cell)) { return true; } @@ -709,17 +703,13 @@ Bool Bridge::isCellOnSide(const Region2D *cell) toRight.y += endVector.y; Coord2D line1, line2; - line1.x = fromLeft.x; - line1.y = fromLeft.y; - line2.x = toLeft.x; - line2.y = toLeft.y; + line1 = fromLeft.xy(); + line2 = toLeft.xy(); if (LineInRegion(&line1, &line2, cell)) { return true; } - line1.x = fromRight.x; - line1.y = fromRight.y; - line2.x = toRight.x; - line2.y = toRight.y; + line1 = fromRight.xy(); + line2 = toRight.xy(); if (LineInRegion(&line1, &line2, cell)) { return true; } @@ -735,17 +725,13 @@ Bool Bridge::isCellOnSide(const Region2D *cell) toRight.x += endVector.x; toRight.y += endVector.y; - line1.x = fromLeft.x; - line1.y = fromLeft.y; - line2.x = toLeft.x; - line2.y = toLeft.y; + line1 = fromLeft.xy(); + line2 = toLeft.xy(); if (LineInRegion(&line1, &line2, cell)) { return true; } - line1.x = fromRight.x; - line1.y = fromRight.y; - line2.x = toRight.x; - line2.y = toRight.y; + line1 = fromRight.xy(); + line2 = toRight.xy(); if (LineInRegion(&line1, &line2, cell)) { return true; } @@ -804,17 +790,13 @@ Bool Bridge::isCellEntryPoint(const Region2D *cell) if (PointInRegion2D(&toRight, cell)) return false; */ Coord2D line1, line2; - line1.x = fromLeft.x; - line1.y = fromLeft.y; - line2.x = fromRight.x; - line2.y = fromRight.y; + line1 = fromLeft.xy(); + line2 = fromRight.xy(); if (LineInRegion(&line1, &line2, cell)) { return true; } - line1.x = toLeft.x; - line1.y = toLeft.y; - line2.x = toRight.x; - line2.y = toRight.y; + line1 = toLeft.xy(); + line2 = toRight.xy(); if (LineInRegion(&line1, &line2, cell)) { return true; } @@ -1769,8 +1751,7 @@ Bool TerrainLogic::objectInteractsWithBridgeLayer(Object *obj, Int layer, Bool c Real radius = obj->getGeometryInfo().getMinorRadius(); radius += PATHFIND_CELL_SIZE_F/2.0f; Region2D bounds; - bounds.lo.x = obj->getPosition()->x; - bounds.lo.y = obj->getPosition()->y; + bounds.lo = obj->getPosition()->xy(); bounds.hi = bounds.lo; bounds.lo.x -= radius; bounds.lo.y -= radius; @@ -1818,8 +1799,7 @@ Bool TerrainLogic::objectInteractsWithBridgeEnd(Object *obj, Int layer) const Real radius = obj->getGeometryInfo().getMinorRadius(); radius += PATHFIND_CELL_SIZE_F/2.0f; Region2D bounds; - bounds.lo.x = obj->getPosition()->x; - bounds.lo.y = obj->getPosition()->y; + bounds.lo = obj->getPosition()->xy(); bounds.hi = bounds.lo; bounds.lo.x -= radius; bounds.lo.y -= radius; diff --git a/Generals/Code/GameEngine/Source/GameLogic/Object/Behavior/PrisonBehavior.cpp b/Generals/Code/GameEngine/Source/GameLogic/Object/Behavior/PrisonBehavior.cpp index f2bbb7ab5fd..9e14e326a8f 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Object/Behavior/PrisonBehavior.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Object/Behavior/PrisonBehavior.cpp @@ -237,10 +237,8 @@ void PrisonBehavior::pickVisualLocation( Coord3D *pos ) // find the bounding region of the yard area Region2D yardRegion; - yardRegion.lo.x = yardPositions[ 0 ].x; - yardRegion.lo.y = yardPositions[ 0 ].y; - yardRegion.hi.x = yardPositions[ 0 ].x; - yardRegion.hi.y = yardPositions[ 0 ].y; + yardRegion.lo = yardPositions[ 0 ].xy(); + yardRegion.hi = yardPositions[ 0 ].xy(); for( i = 1; i < yardBones; i++ ) { diff --git a/Generals/Code/Tools/WorldBuilder/src/RampTool.cpp b/Generals/Code/Tools/WorldBuilder/src/RampTool.cpp index 572684b34c6..bfda07a97f4 100644 --- a/Generals/Code/Tools/WorldBuilder/src/RampTool.cpp +++ b/Generals/Code/Tools/WorldBuilder/src/RampTool.cpp @@ -159,9 +159,9 @@ void RampTool::applyRamp(CWorldBuilderDoc* pDoc) pDoc->getCoordFromCellIndex(indices[i], &pt); Real uVal; - Coord2D start = { mStartPoint.x, mStartPoint.y }; - Coord2D end = { mEndPoint.x, mEndPoint.y }; - Coord2D pt2D = { pt.x, pt.y }; + Coord2D start = mStartPoint.xy(); + Coord2D end = mEndPoint.xy(); + Coord2D pt2D = pt.xy(); ShortestDistancePointToSegment2D(&start, &end, &pt2D, nullptr, nullptr, &uVal); Real height = mStartPoint.z + uVal * (mEndPoint.z - mStartPoint.z); diff --git a/Generals/Code/Tools/WorldBuilder/src/RoadTool.cpp b/Generals/Code/Tools/WorldBuilder/src/RoadTool.cpp index e5d9d1dfc69..fe86c04c614 100644 --- a/Generals/Code/Tools/WorldBuilder/src/RoadTool.cpp +++ b/Generals/Code/Tools/WorldBuilder/src/RoadTool.cpp @@ -67,12 +67,9 @@ MapObject* RoadTool::findSegment(const Coord3D *pLoc, Coord3D *outLoc) if (!pMapObj2->getFlag(FLAG_ROAD_POINT2)) continue; Coord2D start, end, loc, snapLoc; - start.x = pMapObj->getLocation()->x; - start.y = pMapObj->getLocation()->y; - end.x = pMapObj2->getLocation()->x; - end.y = pMapObj2->getLocation()->y; - loc.x = pLoc->x; - loc.y = pLoc->y; + start = pMapObj->getLocation()->xy(); + end = pMapObj2->getLocation()->xy(); + loc = pLoc->xy(); Real dist; Real u; diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/TerrainLogic.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/TerrainLogic.cpp index 102c8576dc4..b3ad6da148e 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/TerrainLogic.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/TerrainLogic.cpp @@ -221,8 +221,7 @@ m_bridgeInfo(theInfo) m_templateName = bridgeTemplateName; //Coord3D fromLeft, fromRight, toLeft, toRight; /// The 4 corners of the rectangle that the bridge covers. - m_bounds.lo.x = m_bridgeInfo.fromLeft.x; - m_bounds.lo.y = m_bridgeInfo.fromLeft.y; + m_bounds.lo = m_bridgeInfo.fromLeft.xy(); m_bounds.hi = m_bounds.lo; m_bounds.lo.min(m_bridgeInfo.fromRight.xy()); m_bounds.hi.max(m_bridgeInfo.fromRight.xy()); @@ -351,8 +350,7 @@ Bridge::Bridge(Object *bridgeObj) m_bridgeInfo.to.z = (m_bridgeInfo.toLeft.z + m_bridgeInfo.toRight.z)/2.0f; //Coord3D fromLeft, fromRight, toLeft, toRight; /// The 4 corners of the rectangle that the bridge covers. - m_bounds.lo.x = m_bridgeInfo.fromLeft.x; - m_bounds.lo.y = m_bridgeInfo.fromLeft.y; + m_bounds.lo = m_bridgeInfo.fromLeft.xy(); m_bounds.hi = m_bounds.lo; m_bounds.lo.min(m_bridgeInfo.fromRight.xy()); m_bounds.hi.max(m_bridgeInfo.fromRight.xy()); @@ -661,17 +659,13 @@ Bool Bridge::isCellOnEnd(const Region2D *cell) if (PointInRegion2D(&toLeft, cell)) return false; if (PointInRegion2D(&toRight, cell)) return false; */ Coord2D line1, line2; - line1.x = fromLeft.x; - line1.y = fromLeft.y; - line2.x = fromRight.x; - line2.y = fromRight.y; + line1 = fromLeft.xy(); + line2 = fromRight.xy(); if (LineInRegion(&line1, &line2, cell)) { return true; } - line1.x = toLeft.x; - line1.y = toLeft.y; - line2.x = toRight.x; - line2.y = toRight.y; + line1 = toLeft.xy(); + line2 = toRight.xy(); if (LineInRegion(&line1, &line2, cell)) { return true; } @@ -709,17 +703,13 @@ Bool Bridge::isCellOnSide(const Region2D *cell) toRight.y += endVector.y; Coord2D line1, line2; - line1.x = fromLeft.x; - line1.y = fromLeft.y; - line2.x = toLeft.x; - line2.y = toLeft.y; + line1 = fromLeft.xy(); + line2 = toLeft.xy(); if (LineInRegion(&line1, &line2, cell)) { return true; } - line1.x = fromRight.x; - line1.y = fromRight.y; - line2.x = toRight.x; - line2.y = toRight.y; + line1 = fromRight.xy(); + line2 = toRight.xy(); if (LineInRegion(&line1, &line2, cell)) { return true; } @@ -735,17 +725,13 @@ Bool Bridge::isCellOnSide(const Region2D *cell) toRight.x += endVector.x; toRight.y += endVector.y; - line1.x = fromLeft.x; - line1.y = fromLeft.y; - line2.x = toLeft.x; - line2.y = toLeft.y; + line1 = fromLeft.xy(); + line2 = toLeft.xy(); if (LineInRegion(&line1, &line2, cell)) { return true; } - line1.x = fromRight.x; - line1.y = fromRight.y; - line2.x = toRight.x; - line2.y = toRight.y; + line1 = fromRight.xy(); + line2 = toRight.xy(); if (LineInRegion(&line1, &line2, cell)) { return true; } @@ -804,17 +790,13 @@ Bool Bridge::isCellEntryPoint(const Region2D *cell) if (PointInRegion2D(&toRight, cell)) return false; */ Coord2D line1, line2; - line1.x = fromLeft.x; - line1.y = fromLeft.y; - line2.x = fromRight.x; - line2.y = fromRight.y; + line1 = fromLeft.xy(); + line2 = fromRight.xy(); if (LineInRegion(&line1, &line2, cell)) { return true; } - line1.x = toLeft.x; - line1.y = toLeft.y; - line2.x = toRight.x; - line2.y = toRight.y; + line1 = toLeft.xy(); + line2 = toRight.xy(); if (LineInRegion(&line1, &line2, cell)) { return true; } @@ -1769,8 +1751,7 @@ Bool TerrainLogic::objectInteractsWithBridgeLayer(Object *obj, Int layer, Bool c Real radius = obj->getGeometryInfo().getMinorRadius(); radius += PATHFIND_CELL_SIZE_F/2.0f; Region2D bounds; - bounds.lo.x = obj->getPosition()->x; - bounds.lo.y = obj->getPosition()->y; + bounds.lo = obj->getPosition()->xy(); bounds.hi = bounds.lo; bounds.lo.x -= radius; bounds.lo.y -= radius; @@ -1818,8 +1799,7 @@ Bool TerrainLogic::objectInteractsWithBridgeEnd(Object *obj, Int layer) const Real radius = obj->getGeometryInfo().getMinorRadius(); radius += PATHFIND_CELL_SIZE_F/2.0f; Region2D bounds; - bounds.lo.x = obj->getPosition()->x; - bounds.lo.y = obj->getPosition()->y; + bounds.lo = obj->getPosition()->xy(); bounds.hi = bounds.lo; bounds.lo.x -= radius; bounds.lo.y -= radius; diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/PrisonBehavior.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/PrisonBehavior.cpp index 776f24ddb87..317c57052f1 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/PrisonBehavior.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/PrisonBehavior.cpp @@ -237,10 +237,8 @@ void PrisonBehavior::pickVisualLocation( Coord3D *pos ) // find the bounding region of the yard area Region2D yardRegion; - yardRegion.lo.x = yardPositions[ 0 ].x; - yardRegion.lo.y = yardPositions[ 0 ].y; - yardRegion.hi.x = yardPositions[ 0 ].x; - yardRegion.hi.y = yardPositions[ 0 ].y; + yardRegion.lo = yardPositions[ 0 ].xy(); + yardRegion.hi = yardPositions[ 0 ].xy(); for( i = 1; i < yardBones; i++ ) { diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/RampTool.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/RampTool.cpp index 4e2cf875af8..a1186d001f7 100644 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/RampTool.cpp +++ b/GeneralsMD/Code/Tools/WorldBuilder/src/RampTool.cpp @@ -161,9 +161,9 @@ void RampTool::applyRamp(CWorldBuilderDoc* pDoc) pDoc->getCoordFromCellIndex(indices[i], &pt); Real uVal; - Coord2D start = { mStartPoint.x, mStartPoint.y }; - Coord2D end = { mEndPoint.x, mEndPoint.y }; - Coord2D pt2D = { pt.x, pt.y }; + Coord2D start = mStartPoint.xy(); + Coord2D end = mEndPoint.xy(); + Coord2D pt2D = pt.xy(); ShortestDistancePointToSegment2D(&start, &end, &pt2D, nullptr, nullptr, &uVal); Real height = mStartPoint.z + uVal * (mEndPoint.z - mStartPoint.z); diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/RoadTool.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/RoadTool.cpp index 39ea5558efd..cc7662f20ef 100644 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/RoadTool.cpp +++ b/GeneralsMD/Code/Tools/WorldBuilder/src/RoadTool.cpp @@ -67,12 +67,9 @@ MapObject* RoadTool::findSegment(const Coord3D *pLoc, Coord3D *outLoc) if (!pMapObj2->getFlag(FLAG_ROAD_POINT2)) continue; Coord2D start, end, loc, snapLoc; - start.x = pMapObj->getLocation()->x; - start.y = pMapObj->getLocation()->y; - end.x = pMapObj2->getLocation()->x; - end.y = pMapObj2->getLocation()->y; - loc.x = pLoc->x; - loc.y = pLoc->y; + start = pMapObj->getLocation()->xy(); + end = pMapObj2->getLocation()->xy(); + loc = pLoc->xy(); Real dist; Real u; From f56c24b1066a5cd96da866cbd4e9cdb6a3b1921e Mon Sep 17 00:00:00 2001 From: stm <14291421+stephanmeesters@users.noreply.github.com> Date: Thu, 10 Sep 2026 17:07:57 +0200 Subject: [PATCH 08/17] Rename xy() to getXY() --- Core/GameEngine/Include/GameClient/View.h | 2 +- Core/GameEngine/Source/GameClient/Line2D.cpp | 16 ++--- .../Source/GameLogic/AI/AIPathfind.cpp | 12 ++-- .../Source/W3DDevice/GameClient/W3DView.cpp | 2 +- Core/Libraries/Include/Lib/BaseType.h | 4 +- .../Source/GameLogic/AI/AIPlayer.cpp | 8 +-- .../Source/GameLogic/Map/PolygonTrigger.cpp | 4 +- .../Source/GameLogic/Map/TerrainLogic.cpp | 64 +++++++++---------- .../Object/Behavior/PrisonBehavior.cpp | 8 +-- .../Code/Tools/WorldBuilder/src/RampTool.cpp | 6 +- .../Code/Tools/WorldBuilder/src/RoadTool.cpp | 6 +- .../Source/GameLogic/AI/AIPlayer.cpp | 8 +-- .../Source/GameLogic/Map/PolygonTrigger.cpp | 4 +- .../Source/GameLogic/Map/TerrainLogic.cpp | 64 +++++++++---------- .../Object/Behavior/PrisonBehavior.cpp | 8 +-- .../Code/Tools/WorldBuilder/src/RampTool.cpp | 6 +- .../Code/Tools/WorldBuilder/src/RoadTool.cpp | 6 +- 17 files changed, 114 insertions(+), 114 deletions(-) diff --git a/Core/GameEngine/Include/GameClient/View.h b/Core/GameEngine/Include/GameClient/View.h index 583bbbd1008..41894709be3 100644 --- a/Core/GameEngine/Include/GameClient/View.h +++ b/Core/GameEngine/Include/GameClient/View.h @@ -197,7 +197,7 @@ class View : public Snapshot void setPosition( const Coord3D &pos ) { m_pos = pos; } void setPosition2D( const Coord2D &pos ) { m_pos.x = pos.x; m_pos.y = pos.y; } const Coord3D &getPosition() const { return m_pos; } ///< Returns position camera is looking at - Coord2D getPosition2D() const { return m_pos.xy(); } ///< Returns position camera is looking at + Coord2D getPosition2D() const { return m_pos.getXY(); } ///< Returns position camera is looking at virtual Coord3D get3DCameraPosition() const { Coord3D c={0,0,0}; return c; } ///< Returns the actual camera position virtual Coord3D get3DCameraDirection() const { Coord3D c={0,0,0}; return c; } ///< Returns the actual camera view direction diff --git a/Core/GameEngine/Source/GameClient/Line2D.cpp b/Core/GameEngine/Source/GameClient/Line2D.cpp index 6e6836bb01f..d6a5084d0ce 100644 --- a/Core/GameEngine/Source/GameClient/Line2D.cpp +++ b/Core/GameEngine/Source/GameClient/Line2D.cpp @@ -289,12 +289,12 @@ Bool PointInsideRect3D(const Coord3D *bl, const Coord3D *tl, const Coord3D *br, const Coord3D *inputPoint) { Coord2D bl2d, tl2d, br2d, tr2d, pt; - bl2d = bl->xy(); - tl2d = tl->xy(); - br2d = br->xy(); - tr2d = tr->xy(); + bl2d = bl->getXY(); + tl2d = tl->getXY(); + br2d = br->getXY(); + tr2d = tr->getXY(); - pt = inputPoint->xy(); + pt = inputPoint->getXY(); return PointInsideRect2D(&bl2d, &br2d, &tl2d, &tr2d, &pt); } @@ -317,11 +317,11 @@ Bool PointInsideArea2D( const Coord3D *ptToTest, const Coord3D *area, Int numPoi { int numIntersections = 0; Coord2D pt2D, area2D1, area2D2; - pt2D = ptToTest->xy(); + pt2D = ptToTest->getXY(); for (int i = 0; i < numPointsInArea; ++i) { - area2D1 = area[i].xy(); - area2D2 = area[(i + 1) % numPointsInArea].xy(); + area2D1 = area[i].getXY(); + area2D2 = area[(i + 1) % numPointsInArea].getXY(); if (IntersectLine2D(&pt2D, &reallyFarPoint, &area2D1, &area2D2)) { ++numIntersections; } diff --git a/Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp b/Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp index 49bf0803e17..a073fe9c5f6 100644 --- a/Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp +++ b/Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp @@ -3882,8 +3882,8 @@ void PathfindLayer::classifyLayerMapCell( Int i, Int j , PathfindCell *cell, Bri // check against the end lines. Region2D cellBounds; - cellBounds.lo = topLeftCorner.xy(); - cellBounds.hi = bottomRightCorner.xy(); + cellBounds.lo = topLeftCorner.getXY(); + cellBounds.hi = bottomRightCorner.getXY(); #if RTS_GENERALS && RETAIL_COMPATIBLE_PATHFINDING if (m_bridge->isCellOnEnd(&cellBounds)) { @@ -10441,8 +10441,8 @@ Path *Pathfinder::getMoveAwayFromPath(Object* obj, Object *otherObj, for( node = pathToAvoid->getFirstNode(); node && node->getNextOptimized(); node = node->getNextOptimized() ) { Coord2D start, end; - start = node->getPosition()->xy(); - end = node->getNextOptimized()->getPosition()->xy(); + start = node->getPosition()->getXY(); + end = node->getNextOptimized()->getPosition()->getXY(); if (LineInRegion(&start, &end, &bounds)) { overlap = true; break; @@ -10452,8 +10452,8 @@ Path *Pathfinder::getMoveAwayFromPath(Object* obj, Object *otherObj, if (!overlap && pathToAvoid2) { for( node = pathToAvoid2->getFirstNode(); node && node->getNextOptimized(); node = node->getNextOptimized() ) { Coord2D start, end; - start = node->getPosition()->xy(); - end = node->getNextOptimized()->getPosition()->xy(); + start = node->getPosition()->getXY(); + end = node->getNextOptimized()->getPosition()->getXY(); if (LineInRegion(&start, &end, &bounds)) { overlap = true; break; diff --git a/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp index f2ae76a05ee..a20a8c05fb9 100644 --- a/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp @@ -2625,7 +2625,7 @@ void W3DView::lookAt( const Coord3D *o ) } } - setPosition2D(pos.xy()); + setPosition2D(pos.getXY()); resetPivotToGround(); diff --git a/Core/Libraries/Include/Lib/BaseType.h b/Core/Libraries/Include/Lib/BaseType.h index ca54715db73..1228da5924b 100644 --- a/Core/Libraries/Include/Lib/BaseType.h +++ b/Core/Libraries/Include/Lib/BaseType.h @@ -565,7 +565,7 @@ struct Coord3D { Real x, y, z; - Coord2D xy() const + Coord2D getXY() const { const Coord2D xy = { x, y }; return xy; @@ -703,7 +703,7 @@ struct ICoord3D { Int x, y, z; - ICoord2D xy() const + ICoord2D getXY() const { const ICoord2D xy = { x, y }; return xy; diff --git a/Generals/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp b/Generals/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp index 443e2fd0dc1..e34bb771cd5 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp @@ -3496,16 +3496,16 @@ void AIPlayer::getPlayerStructureBounds(Region2D *bounds, Int playerNdx ) objBounds.lo.y = objBounds.hi.y = pos.y; firstObject = false; } else { - objBounds.lo.min(pos.xy()); - objBounds.hi.max(pos.xy()); + objBounds.lo.min(pos.getXY()); + objBounds.hi.max(pos.getXY()); } if (firstStructure) { bounds->lo.x = bounds->hi.x = pos.x; bounds->lo.y = bounds->hi.y = pos.y; firstStructure = false; } else { - bounds->lo.min(pos.xy()); - bounds->hi.max(pos.xy()); + bounds->lo.min(pos.getXY()); + bounds->hi.max(pos.getXY()); } } } diff --git a/Generals/Code/GameEngine/Source/GameLogic/Map/PolygonTrigger.cpp b/Generals/Code/GameEngine/Source/GameLogic/Map/PolygonTrigger.cpp index 4d570f779ac..f94fc491309 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Map/PolygonTrigger.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Map/PolygonTrigger.cpp @@ -261,8 +261,8 @@ void PolygonTrigger::updateBounds() const m_bounds.hi.x = m_bounds.hi.y = -BIG_INT; Int i; for (i=0; igetGeometryInfo().getMinorRadius(); radius += PATHFIND_CELL_SIZE_F/2.0f; Region2D bounds; - bounds.lo = obj->getPosition()->xy(); + bounds.lo = obj->getPosition()->getXY(); bounds.hi = bounds.lo; bounds.lo.x -= radius; bounds.lo.y -= radius; @@ -1799,7 +1799,7 @@ Bool TerrainLogic::objectInteractsWithBridgeEnd(Object *obj, Int layer) const Real radius = obj->getGeometryInfo().getMinorRadius(); radius += PATHFIND_CELL_SIZE_F/2.0f; Region2D bounds; - bounds.lo = obj->getPosition()->xy(); + bounds.lo = obj->getPosition()->getXY(); bounds.hi = bounds.lo; bounds.lo.x -= radius; bounds.lo.y -= radius; diff --git a/Generals/Code/GameEngine/Source/GameLogic/Object/Behavior/PrisonBehavior.cpp b/Generals/Code/GameEngine/Source/GameLogic/Object/Behavior/PrisonBehavior.cpp index 9e14e326a8f..bb3a8c2a324 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Object/Behavior/PrisonBehavior.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Object/Behavior/PrisonBehavior.cpp @@ -237,13 +237,13 @@ void PrisonBehavior::pickVisualLocation( Coord3D *pos ) // find the bounding region of the yard area Region2D yardRegion; - yardRegion.lo = yardPositions[ 0 ].xy(); - yardRegion.hi = yardPositions[ 0 ].xy(); + yardRegion.lo = yardPositions[ 0 ].getXY(); + yardRegion.hi = yardPositions[ 0 ].getXY(); for( i = 1; i < yardBones; i++ ) { - yardRegion.lo.min(yardPositions[ i ].xy()); - yardRegion.hi.max(yardPositions[ i ].xy()); + yardRegion.lo.min(yardPositions[ i ].getXY()); + yardRegion.hi.max(yardPositions[ i ].getXY()); } diff --git a/Generals/Code/Tools/WorldBuilder/src/RampTool.cpp b/Generals/Code/Tools/WorldBuilder/src/RampTool.cpp index bfda07a97f4..55a7ba7fc2d 100644 --- a/Generals/Code/Tools/WorldBuilder/src/RampTool.cpp +++ b/Generals/Code/Tools/WorldBuilder/src/RampTool.cpp @@ -159,9 +159,9 @@ void RampTool::applyRamp(CWorldBuilderDoc* pDoc) pDoc->getCoordFromCellIndex(indices[i], &pt); Real uVal; - Coord2D start = mStartPoint.xy(); - Coord2D end = mEndPoint.xy(); - Coord2D pt2D = pt.xy(); + Coord2D start = mStartPoint.getXY(); + Coord2D end = mEndPoint.getXY(); + Coord2D pt2D = pt.getXY(); ShortestDistancePointToSegment2D(&start, &end, &pt2D, nullptr, nullptr, &uVal); Real height = mStartPoint.z + uVal * (mEndPoint.z - mStartPoint.z); diff --git a/Generals/Code/Tools/WorldBuilder/src/RoadTool.cpp b/Generals/Code/Tools/WorldBuilder/src/RoadTool.cpp index fe86c04c614..ce3770dff83 100644 --- a/Generals/Code/Tools/WorldBuilder/src/RoadTool.cpp +++ b/Generals/Code/Tools/WorldBuilder/src/RoadTool.cpp @@ -67,9 +67,9 @@ MapObject* RoadTool::findSegment(const Coord3D *pLoc, Coord3D *outLoc) if (!pMapObj2->getFlag(FLAG_ROAD_POINT2)) continue; Coord2D start, end, loc, snapLoc; - start = pMapObj->getLocation()->xy(); - end = pMapObj2->getLocation()->xy(); - loc = pLoc->xy(); + start = pMapObj->getLocation()->getXY(); + end = pMapObj2->getLocation()->getXY(); + loc = pLoc->getXY(); Real dist; Real u; diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp index 33e88c56545..6d56286cfff 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp @@ -3848,8 +3848,8 @@ void AIPlayer::getPlayerStructureBounds( Region2D *bounds, Int playerNdx, Bool c } else { - objBounds.lo.min(pos.xy()); - objBounds.hi.max(pos.xy()); + objBounds.lo.min(pos.getXY()); + objBounds.hi.max(pos.getXY()); } if (firstStructure) { @@ -3859,8 +3859,8 @@ void AIPlayer::getPlayerStructureBounds( Region2D *bounds, Int playerNdx, Bool c } else { - bounds->lo.min(pos.xy()); - bounds->hi.max(pos.xy()); + bounds->lo.min(pos.getXY()); + bounds->hi.max(pos.getXY()); } } } diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/PolygonTrigger.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/PolygonTrigger.cpp index 84abe5478bd..5ab5b09aa90 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/PolygonTrigger.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/PolygonTrigger.cpp @@ -277,8 +277,8 @@ void PolygonTrigger::updateBounds() const m_bounds.hi.x = m_bounds.hi.y = -BIG_INT; Int i; for (i=0; igetGeometryInfo().getMinorRadius(); radius += PATHFIND_CELL_SIZE_F/2.0f; Region2D bounds; - bounds.lo = obj->getPosition()->xy(); + bounds.lo = obj->getPosition()->getXY(); bounds.hi = bounds.lo; bounds.lo.x -= radius; bounds.lo.y -= radius; @@ -1799,7 +1799,7 @@ Bool TerrainLogic::objectInteractsWithBridgeEnd(Object *obj, Int layer) const Real radius = obj->getGeometryInfo().getMinorRadius(); radius += PATHFIND_CELL_SIZE_F/2.0f; Region2D bounds; - bounds.lo = obj->getPosition()->xy(); + bounds.lo = obj->getPosition()->getXY(); bounds.hi = bounds.lo; bounds.lo.x -= radius; bounds.lo.y -= radius; diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/PrisonBehavior.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/PrisonBehavior.cpp index 317c57052f1..5023e179a60 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/PrisonBehavior.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/PrisonBehavior.cpp @@ -237,13 +237,13 @@ void PrisonBehavior::pickVisualLocation( Coord3D *pos ) // find the bounding region of the yard area Region2D yardRegion; - yardRegion.lo = yardPositions[ 0 ].xy(); - yardRegion.hi = yardPositions[ 0 ].xy(); + yardRegion.lo = yardPositions[ 0 ].getXY(); + yardRegion.hi = yardPositions[ 0 ].getXY(); for( i = 1; i < yardBones; i++ ) { - yardRegion.lo.min(yardPositions[ i ].xy()); - yardRegion.hi.max(yardPositions[ i ].xy()); + yardRegion.lo.min(yardPositions[ i ].getXY()); + yardRegion.hi.max(yardPositions[ i ].getXY()); } diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/RampTool.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/RampTool.cpp index a1186d001f7..27c6bec375d 100644 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/RampTool.cpp +++ b/GeneralsMD/Code/Tools/WorldBuilder/src/RampTool.cpp @@ -161,9 +161,9 @@ void RampTool::applyRamp(CWorldBuilderDoc* pDoc) pDoc->getCoordFromCellIndex(indices[i], &pt); Real uVal; - Coord2D start = mStartPoint.xy(); - Coord2D end = mEndPoint.xy(); - Coord2D pt2D = pt.xy(); + Coord2D start = mStartPoint.getXY(); + Coord2D end = mEndPoint.getXY(); + Coord2D pt2D = pt.getXY(); ShortestDistancePointToSegment2D(&start, &end, &pt2D, nullptr, nullptr, &uVal); Real height = mStartPoint.z + uVal * (mEndPoint.z - mStartPoint.z); diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/RoadTool.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/RoadTool.cpp index cc7662f20ef..71202cf28e4 100644 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/RoadTool.cpp +++ b/GeneralsMD/Code/Tools/WorldBuilder/src/RoadTool.cpp @@ -67,9 +67,9 @@ MapObject* RoadTool::findSegment(const Coord3D *pLoc, Coord3D *outLoc) if (!pMapObj2->getFlag(FLAG_ROAD_POINT2)) continue; Coord2D start, end, loc, snapLoc; - start = pMapObj->getLocation()->xy(); - end = pMapObj2->getLocation()->xy(); - loc = pLoc->xy(); + start = pMapObj->getLocation()->getXY(); + end = pMapObj2->getLocation()->getXY(); + loc = pLoc->getXY(); Real dist; Real u; From c5637d2d0a1dc57b83216ac678b9ae9322ebfc7b Mon Sep 17 00:00:00 2001 From: stm <14291421+stephanmeesters@users.noreply.github.com> Date: Thu, 10 Sep 2026 17:12:03 +0200 Subject: [PATCH 09/17] Introduce unite functions --- .../Source/GameLogic/AI/AIPathfind.cpp | 3 +- Core/Libraries/Include/Lib/BaseType.h | 59 ++++++++++++++++++- .../Source/GameLogic/AI/AIPlayer.cpp | 6 +- .../Source/GameLogic/Map/PolygonTrigger.cpp | 3 +- .../Source/GameLogic/Map/TerrainLogic.cpp | 18 ++---- .../Object/Behavior/PrisonBehavior.cpp | 3 +- .../Source/GameLogic/AI/AIPlayer.cpp | 6 +- .../Source/GameLogic/Map/PolygonTrigger.cpp | 3 +- .../Source/GameLogic/Map/TerrainLogic.cpp | 18 ++---- .../Object/Behavior/PrisonBehavior.cpp | 3 +- 10 files changed, 78 insertions(+), 44 deletions(-) diff --git a/Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp b/Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp index a073fe9c5f6..da61e9e282e 100644 --- a/Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp +++ b/Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp @@ -3591,8 +3591,7 @@ void PathfindLayer::allocateCellsForWallLayer(const IRegion2D *extent, ObjectID bridgeBounds = objBounds; first = false; } else { - bridgeBounds.lo.min(objBounds.lo); - bridgeBounds.hi.max(objBounds.hi); + bridgeBounds.unite(objBounds); } } diff --git a/Core/Libraries/Include/Lib/BaseType.h b/Core/Libraries/Include/Lib/BaseType.h index 1228da5924b..21336aa390e 100644 --- a/Core/Libraries/Include/Lib/BaseType.h +++ b/Core/Libraries/Include/Lib/BaseType.h @@ -517,6 +517,20 @@ struct Region2D hi.min(other.hi); } + // Expand to include both regions. + void unite( const Region2D &other ) + { + lo.min(other.lo); + hi.max(other.hi); + } + + // Expand to include the point. + void unite( const Coord2D &point ) + { + lo.min(point); + hi.max(point); + } + void zero() { lo.zero(); @@ -544,6 +558,20 @@ struct IRegion2D hi.min(other.hi); } + // Expand to include both regions. + void unite( const IRegion2D &other ) + { + lo.min(other.lo); + hi.max(other.hi); + } + + // Expand to include the point. + void unite( const ICoord2D &point ) + { + lo.min(point); + hi.max(point); + } + void zero() { lo.zero(); @@ -809,6 +837,20 @@ struct Region3D hi.min(other.hi); } + // Expand to include both regions. + void unite( const Region3D &other ) + { + lo.min(other.lo); + hi.max(other.hi); + } + + // Expand to include the point. + void unite( const Coord3D &point ) + { + lo.min(point); + hi.max(point); + } + Real width() const { return hi.x - lo.x; } Real height() const { return hi.y - lo.y; } Real depth() const { return hi.z - lo.z; } @@ -855,8 +897,7 @@ struct Region3D hi = points[0]; for (Int i = 1; i < count; ++i) { - lo.min(points[i]); - hi.max(points[i]); + unite(points[i]); } } @@ -885,6 +926,20 @@ struct IRegion3D hi.min(other.hi); } + // Expand to include both regions. + void unite( const IRegion3D &other ) + { + lo.min(other.lo); + hi.max(other.hi); + } + + // Expand to include the point. + void unite( const ICoord3D &point ) + { + lo.min(point); + hi.max(point); + } + void zero() { lo.zero(); diff --git a/Generals/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp b/Generals/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp index e34bb771cd5..96bc6d4935a 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp @@ -3496,16 +3496,14 @@ void AIPlayer::getPlayerStructureBounds(Region2D *bounds, Int playerNdx ) objBounds.lo.y = objBounds.hi.y = pos.y; firstObject = false; } else { - objBounds.lo.min(pos.getXY()); - objBounds.hi.max(pos.getXY()); + objBounds.unite(pos.getXY()); } if (firstStructure) { bounds->lo.x = bounds->hi.x = pos.x; bounds->lo.y = bounds->hi.y = pos.y; firstStructure = false; } else { - bounds->lo.min(pos.getXY()); - bounds->hi.max(pos.getXY()); + bounds->unite(pos.getXY()); } } } diff --git a/Generals/Code/GameEngine/Source/GameLogic/Map/PolygonTrigger.cpp b/Generals/Code/GameEngine/Source/GameLogic/Map/PolygonTrigger.cpp index f94fc491309..5223c9c6860 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Map/PolygonTrigger.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Map/PolygonTrigger.cpp @@ -261,8 +261,7 @@ void PolygonTrigger::updateBounds() const m_bounds.hi.x = m_bounds.hi.y = -BIG_INT; Int i; for (i=0; ilo.min(pos.getXY()); - bounds->hi.max(pos.getXY()); + bounds->unite(pos.getXY()); } } } diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/PolygonTrigger.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/PolygonTrigger.cpp index 5ab5b09aa90..b9f2a913a06 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/PolygonTrigger.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/PolygonTrigger.cpp @@ -277,8 +277,7 @@ void PolygonTrigger::updateBounds() const m_bounds.hi.x = m_bounds.hi.y = -BIG_INT; Int i; for (i=0; i Date: Fri, 11 Sep 2026 12:05:28 +0200 Subject: [PATCH 10/17] Rename getXY to asCoord2D --- Core/GameEngine/Include/GameClient/View.h | 2 +- Core/GameEngine/Source/GameClient/Line2D.cpp | 16 +++--- .../Source/GameLogic/AI/AIPathfind.cpp | 12 ++--- .../Source/W3DDevice/GameClient/W3DView.cpp | 2 +- Core/Libraries/Include/Lib/BaseType.h | 2 +- .../Source/GameLogic/AI/AIPlayer.cpp | 4 +- .../Source/GameLogic/Map/TerrainLogic.cpp | 52 +++++++++---------- .../Object/Behavior/PrisonBehavior.cpp | 6 +-- .../Code/Tools/WorldBuilder/src/RampTool.cpp | 6 +-- .../Code/Tools/WorldBuilder/src/RoadTool.cpp | 6 +-- .../Source/GameLogic/AI/AIPlayer.cpp | 4 +- .../Source/GameLogic/Map/TerrainLogic.cpp | 52 +++++++++---------- .../Object/Behavior/PrisonBehavior.cpp | 6 +-- .../Code/Tools/WorldBuilder/src/RampTool.cpp | 6 +-- .../Code/Tools/WorldBuilder/src/RoadTool.cpp | 6 +-- 15 files changed, 91 insertions(+), 91 deletions(-) diff --git a/Core/GameEngine/Include/GameClient/View.h b/Core/GameEngine/Include/GameClient/View.h index 41894709be3..22ddec7f3c5 100644 --- a/Core/GameEngine/Include/GameClient/View.h +++ b/Core/GameEngine/Include/GameClient/View.h @@ -197,7 +197,7 @@ class View : public Snapshot void setPosition( const Coord3D &pos ) { m_pos = pos; } void setPosition2D( const Coord2D &pos ) { m_pos.x = pos.x; m_pos.y = pos.y; } const Coord3D &getPosition() const { return m_pos; } ///< Returns position camera is looking at - Coord2D getPosition2D() const { return m_pos.getXY(); } ///< Returns position camera is looking at + Coord2D getPosition2D() const { return m_pos.asCoord2D(); } ///< Returns position camera is looking at virtual Coord3D get3DCameraPosition() const { Coord3D c={0,0,0}; return c; } ///< Returns the actual camera position virtual Coord3D get3DCameraDirection() const { Coord3D c={0,0,0}; return c; } ///< Returns the actual camera view direction diff --git a/Core/GameEngine/Source/GameClient/Line2D.cpp b/Core/GameEngine/Source/GameClient/Line2D.cpp index d6a5084d0ce..00b2cf5fdc7 100644 --- a/Core/GameEngine/Source/GameClient/Line2D.cpp +++ b/Core/GameEngine/Source/GameClient/Line2D.cpp @@ -289,12 +289,12 @@ Bool PointInsideRect3D(const Coord3D *bl, const Coord3D *tl, const Coord3D *br, const Coord3D *inputPoint) { Coord2D bl2d, tl2d, br2d, tr2d, pt; - bl2d = bl->getXY(); - tl2d = tl->getXY(); - br2d = br->getXY(); - tr2d = tr->getXY(); + bl2d = bl->asCoord2D(); + tl2d = tl->asCoord2D(); + br2d = br->asCoord2D(); + tr2d = tr->asCoord2D(); - pt = inputPoint->getXY(); + pt = inputPoint->asCoord2D(); return PointInsideRect2D(&bl2d, &br2d, &tl2d, &tr2d, &pt); } @@ -317,11 +317,11 @@ Bool PointInsideArea2D( const Coord3D *ptToTest, const Coord3D *area, Int numPoi { int numIntersections = 0; Coord2D pt2D, area2D1, area2D2; - pt2D = ptToTest->getXY(); + pt2D = ptToTest->asCoord2D(); for (int i = 0; i < numPointsInArea; ++i) { - area2D1 = area[i].getXY(); - area2D2 = area[(i + 1) % numPointsInArea].getXY(); + area2D1 = area[i].asCoord2D(); + area2D2 = area[(i + 1) % numPointsInArea].asCoord2D(); if (IntersectLine2D(&pt2D, &reallyFarPoint, &area2D1, &area2D2)) { ++numIntersections; } diff --git a/Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp b/Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp index da61e9e282e..c91f782bf22 100644 --- a/Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp +++ b/Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp @@ -3881,8 +3881,8 @@ void PathfindLayer::classifyLayerMapCell( Int i, Int j , PathfindCell *cell, Bri // check against the end lines. Region2D cellBounds; - cellBounds.lo = topLeftCorner.getXY(); - cellBounds.hi = bottomRightCorner.getXY(); + cellBounds.lo = topLeftCorner.asCoord2D(); + cellBounds.hi = bottomRightCorner.asCoord2D(); #if RTS_GENERALS && RETAIL_COMPATIBLE_PATHFINDING if (m_bridge->isCellOnEnd(&cellBounds)) { @@ -10440,8 +10440,8 @@ Path *Pathfinder::getMoveAwayFromPath(Object* obj, Object *otherObj, for( node = pathToAvoid->getFirstNode(); node && node->getNextOptimized(); node = node->getNextOptimized() ) { Coord2D start, end; - start = node->getPosition()->getXY(); - end = node->getNextOptimized()->getPosition()->getXY(); + start = node->getPosition()->asCoord2D(); + end = node->getNextOptimized()->getPosition()->asCoord2D(); if (LineInRegion(&start, &end, &bounds)) { overlap = true; break; @@ -10451,8 +10451,8 @@ Path *Pathfinder::getMoveAwayFromPath(Object* obj, Object *otherObj, if (!overlap && pathToAvoid2) { for( node = pathToAvoid2->getFirstNode(); node && node->getNextOptimized(); node = node->getNextOptimized() ) { Coord2D start, end; - start = node->getPosition()->getXY(); - end = node->getNextOptimized()->getPosition()->getXY(); + start = node->getPosition()->asCoord2D(); + end = node->getNextOptimized()->getPosition()->asCoord2D(); if (LineInRegion(&start, &end, &bounds)) { overlap = true; break; diff --git a/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp index a20a8c05fb9..91ad7d39152 100644 --- a/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp @@ -2625,7 +2625,7 @@ void W3DView::lookAt( const Coord3D *o ) } } - setPosition2D(pos.getXY()); + setPosition2D(pos.asCoord2D()); resetPivotToGround(); diff --git a/Core/Libraries/Include/Lib/BaseType.h b/Core/Libraries/Include/Lib/BaseType.h index 21336aa390e..176b9d9c1e4 100644 --- a/Core/Libraries/Include/Lib/BaseType.h +++ b/Core/Libraries/Include/Lib/BaseType.h @@ -593,7 +593,7 @@ struct Coord3D { Real x, y, z; - Coord2D getXY() const + Coord2D asCoord2D() const { const Coord2D xy = { x, y }; return xy; diff --git a/Generals/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp b/Generals/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp index 96bc6d4935a..1ef3df2015d 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp @@ -3496,14 +3496,14 @@ void AIPlayer::getPlayerStructureBounds(Region2D *bounds, Int playerNdx ) objBounds.lo.y = objBounds.hi.y = pos.y; firstObject = false; } else { - objBounds.unite(pos.getXY()); + objBounds.unite(pos.asCoord2D()); } if (firstStructure) { bounds->lo.x = bounds->hi.x = pos.x; bounds->lo.y = bounds->hi.y = pos.y; firstStructure = false; } else { - bounds->unite(pos.getXY()); + bounds->unite(pos.asCoord2D()); } } } diff --git a/Generals/Code/GameEngine/Source/GameLogic/Map/TerrainLogic.cpp b/Generals/Code/GameEngine/Source/GameLogic/Map/TerrainLogic.cpp index e2fefc5ec46..ebd2e0a9fc6 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Map/TerrainLogic.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Map/TerrainLogic.cpp @@ -221,11 +221,11 @@ m_bridgeInfo(theInfo) m_templateName = bridgeTemplateName; //Coord3D fromLeft, fromRight, toLeft, toRight; /// The 4 corners of the rectangle that the bridge covers. - m_bounds.lo = m_bridgeInfo.fromLeft.getXY(); + m_bounds.lo = m_bridgeInfo.fromLeft.asCoord2D(); m_bounds.hi = m_bounds.lo; - m_bounds.unite(m_bridgeInfo.fromRight.getXY()); - m_bounds.unite(m_bridgeInfo.toLeft.getXY()); - m_bounds.unite(m_bridgeInfo.toRight.getXY()); + m_bounds.unite(m_bridgeInfo.fromRight.asCoord2D()); + m_bounds.unite(m_bridgeInfo.toLeft.asCoord2D()); + m_bounds.unite(m_bridgeInfo.toRight.asCoord2D()); m_bridgeInfo.curDamageState = BODY_PRISTINE; @@ -347,11 +347,11 @@ Bridge::Bridge(Object *bridgeObj) m_bridgeInfo.to.z = (m_bridgeInfo.toLeft.z + m_bridgeInfo.toRight.z)/2.0f; //Coord3D fromLeft, fromRight, toLeft, toRight; /// The 4 corners of the rectangle that the bridge covers. - m_bounds.lo = m_bridgeInfo.fromLeft.getXY(); + m_bounds.lo = m_bridgeInfo.fromLeft.asCoord2D(); m_bounds.hi = m_bounds.lo; - m_bounds.unite(m_bridgeInfo.fromRight.getXY()); - m_bounds.unite(m_bridgeInfo.toLeft.getXY()); - m_bounds.unite(m_bridgeInfo.toRight.getXY()); + m_bounds.unite(m_bridgeInfo.fromRight.asCoord2D()); + m_bounds.unite(m_bridgeInfo.toLeft.asCoord2D()); + m_bounds.unite(m_bridgeInfo.toRight.asCoord2D()); m_bridgeInfo.curDamageState = BODY_PRISTINE; @@ -653,13 +653,13 @@ Bool Bridge::isCellOnEnd(const Region2D *cell) if (PointInRegion2D(&toLeft, cell)) return false; if (PointInRegion2D(&toRight, cell)) return false; */ Coord2D line1, line2; - line1 = fromLeft.getXY(); - line2 = fromRight.getXY(); + line1 = fromLeft.asCoord2D(); + line2 = fromRight.asCoord2D(); if (LineInRegion(&line1, &line2, cell)) { return true; } - line1 = toLeft.getXY(); - line2 = toRight.getXY(); + line1 = toLeft.asCoord2D(); + line2 = toRight.asCoord2D(); if (LineInRegion(&line1, &line2, cell)) { return true; } @@ -697,13 +697,13 @@ Bool Bridge::isCellOnSide(const Region2D *cell) toRight.y += endVector.y; Coord2D line1, line2; - line1 = fromLeft.getXY(); - line2 = toLeft.getXY(); + line1 = fromLeft.asCoord2D(); + line2 = toLeft.asCoord2D(); if (LineInRegion(&line1, &line2, cell)) { return true; } - line1 = fromRight.getXY(); - line2 = toRight.getXY(); + line1 = fromRight.asCoord2D(); + line2 = toRight.asCoord2D(); if (LineInRegion(&line1, &line2, cell)) { return true; } @@ -719,13 +719,13 @@ Bool Bridge::isCellOnSide(const Region2D *cell) toRight.x += endVector.x; toRight.y += endVector.y; - line1 = fromLeft.getXY(); - line2 = toLeft.getXY(); + line1 = fromLeft.asCoord2D(); + line2 = toLeft.asCoord2D(); if (LineInRegion(&line1, &line2, cell)) { return true; } - line1 = fromRight.getXY(); - line2 = toRight.getXY(); + line1 = fromRight.asCoord2D(); + line2 = toRight.asCoord2D(); if (LineInRegion(&line1, &line2, cell)) { return true; } @@ -784,13 +784,13 @@ Bool Bridge::isCellEntryPoint(const Region2D *cell) if (PointInRegion2D(&toRight, cell)) return false; */ Coord2D line1, line2; - line1 = fromLeft.getXY(); - line2 = fromRight.getXY(); + line1 = fromLeft.asCoord2D(); + line2 = fromRight.asCoord2D(); if (LineInRegion(&line1, &line2, cell)) { return true; } - line1 = toLeft.getXY(); - line2 = toRight.getXY(); + line1 = toLeft.asCoord2D(); + line2 = toRight.asCoord2D(); if (LineInRegion(&line1, &line2, cell)) { return true; } @@ -1745,7 +1745,7 @@ Bool TerrainLogic::objectInteractsWithBridgeLayer(Object *obj, Int layer, Bool c Real radius = obj->getGeometryInfo().getMinorRadius(); radius += PATHFIND_CELL_SIZE_F/2.0f; Region2D bounds; - bounds.lo = obj->getPosition()->getXY(); + bounds.lo = obj->getPosition()->asCoord2D(); bounds.hi = bounds.lo; bounds.lo.x -= radius; bounds.lo.y -= radius; @@ -1793,7 +1793,7 @@ Bool TerrainLogic::objectInteractsWithBridgeEnd(Object *obj, Int layer) const Real radius = obj->getGeometryInfo().getMinorRadius(); radius += PATHFIND_CELL_SIZE_F/2.0f; Region2D bounds; - bounds.lo = obj->getPosition()->getXY(); + bounds.lo = obj->getPosition()->asCoord2D(); bounds.hi = bounds.lo; bounds.lo.x -= radius; bounds.lo.y -= radius; diff --git a/Generals/Code/GameEngine/Source/GameLogic/Object/Behavior/PrisonBehavior.cpp b/Generals/Code/GameEngine/Source/GameLogic/Object/Behavior/PrisonBehavior.cpp index 125c3ba93a4..041a92b9eb6 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Object/Behavior/PrisonBehavior.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Object/Behavior/PrisonBehavior.cpp @@ -237,12 +237,12 @@ void PrisonBehavior::pickVisualLocation( Coord3D *pos ) // find the bounding region of the yard area Region2D yardRegion; - yardRegion.lo = yardPositions[ 0 ].getXY(); - yardRegion.hi = yardPositions[ 0 ].getXY(); + yardRegion.lo = yardPositions[ 0 ].asCoord2D(); + yardRegion.hi = yardPositions[ 0 ].asCoord2D(); for( i = 1; i < yardBones; i++ ) { - yardRegion.unite(yardPositions[ i ].getXY()); + yardRegion.unite(yardPositions[ i ].asCoord2D()); } diff --git a/Generals/Code/Tools/WorldBuilder/src/RampTool.cpp b/Generals/Code/Tools/WorldBuilder/src/RampTool.cpp index 55a7ba7fc2d..71fc30840dd 100644 --- a/Generals/Code/Tools/WorldBuilder/src/RampTool.cpp +++ b/Generals/Code/Tools/WorldBuilder/src/RampTool.cpp @@ -159,9 +159,9 @@ void RampTool::applyRamp(CWorldBuilderDoc* pDoc) pDoc->getCoordFromCellIndex(indices[i], &pt); Real uVal; - Coord2D start = mStartPoint.getXY(); - Coord2D end = mEndPoint.getXY(); - Coord2D pt2D = pt.getXY(); + Coord2D start = mStartPoint.asCoord2D(); + Coord2D end = mEndPoint.asCoord2D(); + Coord2D pt2D = pt.asCoord2D(); ShortestDistancePointToSegment2D(&start, &end, &pt2D, nullptr, nullptr, &uVal); Real height = mStartPoint.z + uVal * (mEndPoint.z - mStartPoint.z); diff --git a/Generals/Code/Tools/WorldBuilder/src/RoadTool.cpp b/Generals/Code/Tools/WorldBuilder/src/RoadTool.cpp index ce3770dff83..c2dbc0e32e3 100644 --- a/Generals/Code/Tools/WorldBuilder/src/RoadTool.cpp +++ b/Generals/Code/Tools/WorldBuilder/src/RoadTool.cpp @@ -67,9 +67,9 @@ MapObject* RoadTool::findSegment(const Coord3D *pLoc, Coord3D *outLoc) if (!pMapObj2->getFlag(FLAG_ROAD_POINT2)) continue; Coord2D start, end, loc, snapLoc; - start = pMapObj->getLocation()->getXY(); - end = pMapObj2->getLocation()->getXY(); - loc = pLoc->getXY(); + start = pMapObj->getLocation()->asCoord2D(); + end = pMapObj2->getLocation()->asCoord2D(); + loc = pLoc->asCoord2D(); Real dist; Real u; diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp index aad0d0c0e8c..82e0e9ae685 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp @@ -3848,7 +3848,7 @@ void AIPlayer::getPlayerStructureBounds( Region2D *bounds, Int playerNdx, Bool c } else { - objBounds.unite(pos.getXY()); + objBounds.unite(pos.asCoord2D()); } if (firstStructure) { @@ -3858,7 +3858,7 @@ void AIPlayer::getPlayerStructureBounds( Region2D *bounds, Int playerNdx, Bool c } else { - bounds->unite(pos.getXY()); + bounds->unite(pos.asCoord2D()); } } } diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/TerrainLogic.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/TerrainLogic.cpp index dd7698127c1..6f7934edef5 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/TerrainLogic.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/TerrainLogic.cpp @@ -221,11 +221,11 @@ m_bridgeInfo(theInfo) m_templateName = bridgeTemplateName; //Coord3D fromLeft, fromRight, toLeft, toRight; /// The 4 corners of the rectangle that the bridge covers. - m_bounds.lo = m_bridgeInfo.fromLeft.getXY(); + m_bounds.lo = m_bridgeInfo.fromLeft.asCoord2D(); m_bounds.hi = m_bounds.lo; - m_bounds.unite(m_bridgeInfo.fromRight.getXY()); - m_bounds.unite(m_bridgeInfo.toLeft.getXY()); - m_bounds.unite(m_bridgeInfo.toRight.getXY()); + m_bounds.unite(m_bridgeInfo.fromRight.asCoord2D()); + m_bounds.unite(m_bridgeInfo.toLeft.asCoord2D()); + m_bounds.unite(m_bridgeInfo.toRight.asCoord2D()); m_bridgeInfo.curDamageState = BODY_PRISTINE; @@ -347,11 +347,11 @@ Bridge::Bridge(Object *bridgeObj) m_bridgeInfo.to.z = (m_bridgeInfo.toLeft.z + m_bridgeInfo.toRight.z)/2.0f; //Coord3D fromLeft, fromRight, toLeft, toRight; /// The 4 corners of the rectangle that the bridge covers. - m_bounds.lo = m_bridgeInfo.fromLeft.getXY(); + m_bounds.lo = m_bridgeInfo.fromLeft.asCoord2D(); m_bounds.hi = m_bounds.lo; - m_bounds.unite(m_bridgeInfo.fromRight.getXY()); - m_bounds.unite(m_bridgeInfo.toLeft.getXY()); - m_bounds.unite(m_bridgeInfo.toRight.getXY()); + m_bounds.unite(m_bridgeInfo.fromRight.asCoord2D()); + m_bounds.unite(m_bridgeInfo.toLeft.asCoord2D()); + m_bounds.unite(m_bridgeInfo.toRight.asCoord2D()); m_bridgeInfo.curDamageState = BODY_PRISTINE; @@ -653,13 +653,13 @@ Bool Bridge::isCellOnEnd(const Region2D *cell) if (PointInRegion2D(&toLeft, cell)) return false; if (PointInRegion2D(&toRight, cell)) return false; */ Coord2D line1, line2; - line1 = fromLeft.getXY(); - line2 = fromRight.getXY(); + line1 = fromLeft.asCoord2D(); + line2 = fromRight.asCoord2D(); if (LineInRegion(&line1, &line2, cell)) { return true; } - line1 = toLeft.getXY(); - line2 = toRight.getXY(); + line1 = toLeft.asCoord2D(); + line2 = toRight.asCoord2D(); if (LineInRegion(&line1, &line2, cell)) { return true; } @@ -697,13 +697,13 @@ Bool Bridge::isCellOnSide(const Region2D *cell) toRight.y += endVector.y; Coord2D line1, line2; - line1 = fromLeft.getXY(); - line2 = toLeft.getXY(); + line1 = fromLeft.asCoord2D(); + line2 = toLeft.asCoord2D(); if (LineInRegion(&line1, &line2, cell)) { return true; } - line1 = fromRight.getXY(); - line2 = toRight.getXY(); + line1 = fromRight.asCoord2D(); + line2 = toRight.asCoord2D(); if (LineInRegion(&line1, &line2, cell)) { return true; } @@ -719,13 +719,13 @@ Bool Bridge::isCellOnSide(const Region2D *cell) toRight.x += endVector.x; toRight.y += endVector.y; - line1 = fromLeft.getXY(); - line2 = toLeft.getXY(); + line1 = fromLeft.asCoord2D(); + line2 = toLeft.asCoord2D(); if (LineInRegion(&line1, &line2, cell)) { return true; } - line1 = fromRight.getXY(); - line2 = toRight.getXY(); + line1 = fromRight.asCoord2D(); + line2 = toRight.asCoord2D(); if (LineInRegion(&line1, &line2, cell)) { return true; } @@ -784,13 +784,13 @@ Bool Bridge::isCellEntryPoint(const Region2D *cell) if (PointInRegion2D(&toRight, cell)) return false; */ Coord2D line1, line2; - line1 = fromLeft.getXY(); - line2 = fromRight.getXY(); + line1 = fromLeft.asCoord2D(); + line2 = fromRight.asCoord2D(); if (LineInRegion(&line1, &line2, cell)) { return true; } - line1 = toLeft.getXY(); - line2 = toRight.getXY(); + line1 = toLeft.asCoord2D(); + line2 = toRight.asCoord2D(); if (LineInRegion(&line1, &line2, cell)) { return true; } @@ -1745,7 +1745,7 @@ Bool TerrainLogic::objectInteractsWithBridgeLayer(Object *obj, Int layer, Bool c Real radius = obj->getGeometryInfo().getMinorRadius(); radius += PATHFIND_CELL_SIZE_F/2.0f; Region2D bounds; - bounds.lo = obj->getPosition()->getXY(); + bounds.lo = obj->getPosition()->asCoord2D(); bounds.hi = bounds.lo; bounds.lo.x -= radius; bounds.lo.y -= radius; @@ -1793,7 +1793,7 @@ Bool TerrainLogic::objectInteractsWithBridgeEnd(Object *obj, Int layer) const Real radius = obj->getGeometryInfo().getMinorRadius(); radius += PATHFIND_CELL_SIZE_F/2.0f; Region2D bounds; - bounds.lo = obj->getPosition()->getXY(); + bounds.lo = obj->getPosition()->asCoord2D(); bounds.hi = bounds.lo; bounds.lo.x -= radius; bounds.lo.y -= radius; diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/PrisonBehavior.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/PrisonBehavior.cpp index 8401b41c60e..4428bc8c82f 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/PrisonBehavior.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/PrisonBehavior.cpp @@ -237,12 +237,12 @@ void PrisonBehavior::pickVisualLocation( Coord3D *pos ) // find the bounding region of the yard area Region2D yardRegion; - yardRegion.lo = yardPositions[ 0 ].getXY(); - yardRegion.hi = yardPositions[ 0 ].getXY(); + yardRegion.lo = yardPositions[ 0 ].asCoord2D(); + yardRegion.hi = yardPositions[ 0 ].asCoord2D(); for( i = 1; i < yardBones; i++ ) { - yardRegion.unite(yardPositions[ i ].getXY()); + yardRegion.unite(yardPositions[ i ].asCoord2D()); } diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/RampTool.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/RampTool.cpp index 27c6bec375d..e1fbf328a6f 100644 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/RampTool.cpp +++ b/GeneralsMD/Code/Tools/WorldBuilder/src/RampTool.cpp @@ -161,9 +161,9 @@ void RampTool::applyRamp(CWorldBuilderDoc* pDoc) pDoc->getCoordFromCellIndex(indices[i], &pt); Real uVal; - Coord2D start = mStartPoint.getXY(); - Coord2D end = mEndPoint.getXY(); - Coord2D pt2D = pt.getXY(); + Coord2D start = mStartPoint.asCoord2D(); + Coord2D end = mEndPoint.asCoord2D(); + Coord2D pt2D = pt.asCoord2D(); ShortestDistancePointToSegment2D(&start, &end, &pt2D, nullptr, nullptr, &uVal); Real height = mStartPoint.z + uVal * (mEndPoint.z - mStartPoint.z); diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/RoadTool.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/RoadTool.cpp index 71202cf28e4..dc367be288c 100644 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/RoadTool.cpp +++ b/GeneralsMD/Code/Tools/WorldBuilder/src/RoadTool.cpp @@ -67,9 +67,9 @@ MapObject* RoadTool::findSegment(const Coord3D *pLoc, Coord3D *outLoc) if (!pMapObj2->getFlag(FLAG_ROAD_POINT2)) continue; Coord2D start, end, loc, snapLoc; - start = pMapObj->getLocation()->getXY(); - end = pMapObj2->getLocation()->getXY(); - loc = pLoc->getXY(); + start = pMapObj->getLocation()->asCoord2D(); + end = pMapObj2->getLocation()->asCoord2D(); + loc = pLoc->asCoord2D(); Real dist; Real u; From 3ed6e149252c4366150e310ceb7207d8ec680515 Mon Sep 17 00:00:00 2001 From: stm <14291421+stephanmeesters@users.noreply.github.com> Date: Fri, 11 Sep 2026 12:06:43 +0200 Subject: [PATCH 11/17] Update comments --- Core/Libraries/Include/Lib/BaseType.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Core/Libraries/Include/Lib/BaseType.h b/Core/Libraries/Include/Lib/BaseType.h index 176b9d9c1e4..532b74d1776 100644 --- a/Core/Libraries/Include/Lib/BaseType.h +++ b/Core/Libraries/Include/Lib/BaseType.h @@ -517,7 +517,7 @@ struct Region2D hi.min(other.hi); } - // Expand to include both regions. + // Expand to include the other region. void unite( const Region2D &other ) { lo.min(other.lo); @@ -558,7 +558,7 @@ struct IRegion2D hi.min(other.hi); } - // Expand to include both regions. + // Expand to include the other region. void unite( const IRegion2D &other ) { lo.min(other.lo); @@ -837,7 +837,7 @@ struct Region3D hi.min(other.hi); } - // Expand to include both regions. + // Expand to include the other region. void unite( const Region3D &other ) { lo.min(other.lo); @@ -926,7 +926,7 @@ struct IRegion3D hi.min(other.hi); } - // Expand to include both regions. + // Expand to include the other region. void unite( const IRegion3D &other ) { lo.min(other.lo); From a6f0bfaf09462367da8b1b485b67b798fba1516f Mon Sep 17 00:00:00 2001 From: stm <14291421+stephanmeesters@users.noreply.github.com> Date: Fri, 11 Sep 2026 12:13:02 +0200 Subject: [PATCH 12/17] Rename min and max to minimize and maximize --- .../Source/GameLogic/AI/AIPathfind.cpp | 6 +- Core/Libraries/Include/Lib/BaseType.h | 64 +++++++++---------- 2 files changed, 35 insertions(+), 35 deletions(-) diff --git a/Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp b/Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp index c91f782bf22..662f6669b93 100644 --- a/Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp +++ b/Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp @@ -2726,7 +2726,7 @@ void PathfindZoneManager::calculateZones( PathfindCell **map, PathfindLayer laye bounds.lo.y = globalBounds.lo.y + yBlock*ZONE_BLOCK_SIZE; bounds.hi.x = bounds.lo.x + ZONE_BLOCK_SIZE - 1; // bounds are inclusive. bounds.hi.y = bounds.lo.y + ZONE_BLOCK_SIZE - 1; // bounds are inclusive. - bounds.hi.min(globalBounds.hi); + bounds.hi.minimize(globalBounds.hi); #if RTS_GENERALS && RETAIL_COMPATIBLE_PATHFINDING if (bounds.lo.x>bounds.hi.x || bounds.lo.y>bounds.hi.y) { DEBUG_CRASH(("Incorrect bounds calculation. Logic error, fix me. jba.")); @@ -2823,7 +2823,7 @@ void PathfindZoneManager::calculateZones( PathfindCell **map, PathfindLayer laye bounds.hi.x = bounds.lo.x + ZONE_BLOCK_SIZE - 1; // bounds are inclusive. bounds.hi.y = bounds.lo.y + ZONE_BLOCK_SIZE - 1; // bounds are inclusive. - bounds.hi.min(globalBounds.hi); + bounds.hi.minimize(globalBounds.hi); #if RTS_GENERALS && RETAIL_COMPATIBLE_PATHFINDING if (bounds.lo.x>bounds.hi.x || bounds.lo.y>bounds.hi.y) { DEBUG_CRASH(("Incorrect bounds calculation. Logic error, fix me. jba.")); @@ -3042,7 +3042,7 @@ void PathfindZoneManager::updateZonesForModify(PathfindCell **map, PathfindLayer IRegion2D bounds = structureBounds; bounds.hi.x++; bounds.hi.y++; - bounds.hi.min(globalBounds.hi); + bounds.hi.minimize(globalBounds.hi); Int xBlock, yBlock; for (xBlock = 0; xBlock other.x) x = other.x; @@ -340,7 +340,7 @@ struct Coord2D y = other.y; } - void max( const Coord2D &other ) + void maximize( const Coord2D &other ) { if (x < other.x) x = other.x; @@ -475,7 +475,7 @@ struct ICoord2D y = ay; } - void min( const ICoord2D &other ) + void minimize( const ICoord2D &other ) { if (x > other.x) x = other.x; @@ -483,7 +483,7 @@ struct ICoord2D y = other.y; } - void max( const ICoord2D &other ) + void maximize( const ICoord2D &other ) { if (x < other.x) x = other.x; @@ -513,22 +513,22 @@ struct Region2D // Keep only the overlapping portion of both regions. void intersect( const Region2D &other ) { - lo.max(other.lo); - hi.min(other.hi); + lo.maximize(other.lo); + hi.minimize(other.hi); } // Expand to include the other region. void unite( const Region2D &other ) { - lo.min(other.lo); - hi.max(other.hi); + lo.minimize(other.lo); + hi.maximize(other.hi); } // Expand to include the point. void unite( const Coord2D &point ) { - lo.min(point); - hi.max(point); + lo.minimize(point); + hi.maximize(point); } void zero() @@ -554,22 +554,22 @@ struct IRegion2D // Keep only the overlapping portion of both regions. void intersect( const IRegion2D &other ) { - lo.max(other.lo); - hi.min(other.hi); + lo.maximize(other.lo); + hi.minimize(other.hi); } // Expand to include the other region. void unite( const IRegion2D &other ) { - lo.min(other.lo); - hi.max(other.hi); + lo.minimize(other.lo); + hi.maximize(other.hi); } // Expand to include the point. void unite( const ICoord2D &point ) { - lo.min(point); - hi.max(point); + lo.minimize(point); + hi.maximize(point); } void zero() @@ -692,7 +692,7 @@ struct Coord3D z == r.z); } - void min( const Coord3D &other ) + void minimize( const Coord3D &other ) { if (x > other.x) x = other.x; @@ -702,7 +702,7 @@ struct Coord3D z = other.z; } - void max( const Coord3D &other ) + void maximize( const Coord3D &other ) { if (x < other.x) x = other.x; @@ -790,7 +790,7 @@ struct ICoord3D z = az; } - void min( const ICoord3D &other ) + void minimize( const ICoord3D &other ) { if (x > other.x) x = other.x; @@ -800,7 +800,7 @@ struct ICoord3D z = other.z; } - void max( const ICoord3D &other ) + void maximize( const ICoord3D &other ) { if (x < other.x) x = other.x; @@ -833,22 +833,22 @@ struct Region3D // Keep only the overlapping portion of both regions. void intersect( const Region3D &other ) { - lo.max(other.lo); - hi.min(other.hi); + lo.maximize(other.lo); + hi.minimize(other.hi); } // Expand to include the other region. void unite( const Region3D &other ) { - lo.min(other.lo); - hi.max(other.hi); + lo.minimize(other.lo); + hi.maximize(other.hi); } // Expand to include the point. void unite( const Coord3D &point ) { - lo.min(point); - hi.max(point); + lo.minimize(point); + hi.maximize(point); } Real width() const { return hi.x - lo.x; } @@ -922,22 +922,22 @@ struct IRegion3D // Keep only the overlapping portion of both regions. void intersect( const IRegion3D &other ) { - lo.max(other.lo); - hi.min(other.hi); + lo.maximize(other.lo); + hi.minimize(other.hi); } // Expand to include the other region. void unite( const IRegion3D &other ) { - lo.min(other.lo); - hi.max(other.hi); + lo.minimize(other.lo); + hi.maximize(other.hi); } // Expand to include the point. void unite( const ICoord3D &point ) { - lo.min(point); - hi.max(point); + lo.minimize(point); + hi.maximize(point); } void zero() From 84de135b21fb543195bb6a5f0f9fa546d6b4d11b Mon Sep 17 00:00:00 2001 From: stm <14291421+stephanmeesters@users.noreply.github.com> Date: Fri, 11 Sep 2026 12:15:36 +0200 Subject: [PATCH 13/17] Rename unite to expandWith and intersect to clipTo --- .../Source/GameLogic/AI/AIPathfind.cpp | 6 ++--- Core/Libraries/Include/Lib/BaseType.h | 26 +++++++++---------- .../Source/GameLogic/AI/AIPlayer.cpp | 4 +-- .../Source/GameLogic/Map/PolygonTrigger.cpp | 2 +- .../Source/GameLogic/Map/TerrainLogic.cpp | 12 ++++----- .../Object/Behavior/PrisonBehavior.cpp | 2 +- .../Source/GameLogic/AI/AIPlayer.cpp | 4 +-- .../Source/GameLogic/Map/PolygonTrigger.cpp | 2 +- .../Source/GameLogic/Map/TerrainLogic.cpp | 12 ++++----- .../Object/Behavior/PrisonBehavior.cpp | 2 +- 10 files changed, 36 insertions(+), 36 deletions(-) diff --git a/Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp b/Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp index 662f6669b93..ca9d3f07a8a 100644 --- a/Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp +++ b/Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp @@ -3052,7 +3052,7 @@ void PathfindZoneManager::updateZonesForModify(PathfindCell **map, PathfindLayer blockBounds.lo.y = globalBounds.lo.y + yBlock*ZONE_BLOCK_SIZE; blockBounds.hi.x = blockBounds.lo.x + ZONE_BLOCK_SIZE - 1; // blockBounds are inclusive. blockBounds.hi.y = blockBounds.lo.y + ZONE_BLOCK_SIZE - 1; // blockBounds are inclusive. - blockBounds.intersect(bounds); + blockBounds.clipTo(bounds); if (blockBounds.lo.x>blockBounds.hi.x || blockBounds.lo.y>blockBounds.hi.y) { continue; } @@ -3591,7 +3591,7 @@ void PathfindLayer::allocateCellsForWallLayer(const IRegion2D *extent, ObjectID bridgeBounds = objBounds; first = false; } else { - bridgeBounds.unite(objBounds); + bridgeBounds.expandWith(objBounds); } } @@ -4577,7 +4577,7 @@ void Pathfinder::internal_classifyObjectFootprint( Object *obj, Bool insert ) Int i, j; - cellBounds.intersect(m_extent); + cellBounds.clipTo(m_extent); if (!insert) { for( j=cellBounds.lo.y; j<=cellBounds.hi.y; j++ ) diff --git a/Core/Libraries/Include/Lib/BaseType.h b/Core/Libraries/Include/Lib/BaseType.h index 7ebe043273d..1ef89dd439e 100644 --- a/Core/Libraries/Include/Lib/BaseType.h +++ b/Core/Libraries/Include/Lib/BaseType.h @@ -511,21 +511,21 @@ struct Region2D Coord2D lo, hi; // bounds of 2D rectangular region // Keep only the overlapping portion of both regions. - void intersect( const Region2D &other ) + void clipTo( const Region2D &other ) { lo.maximize(other.lo); hi.minimize(other.hi); } // Expand to include the other region. - void unite( const Region2D &other ) + void expandWith( const Region2D &other ) { lo.minimize(other.lo); hi.maximize(other.hi); } // Expand to include the point. - void unite( const Coord2D &point ) + void expandWith( const Coord2D &point ) { lo.minimize(point); hi.maximize(point); @@ -552,21 +552,21 @@ struct IRegion2D ICoord2D lo, hi; // bounds of 2D rectangular region // Keep only the overlapping portion of both regions. - void intersect( const IRegion2D &other ) + void clipTo( const IRegion2D &other ) { lo.maximize(other.lo); hi.minimize(other.hi); } // Expand to include the other region. - void unite( const IRegion2D &other ) + void expandWith( const IRegion2D &other ) { lo.minimize(other.lo); hi.maximize(other.hi); } // Expand to include the point. - void unite( const ICoord2D &point ) + void expandWith( const ICoord2D &point ) { lo.minimize(point); hi.maximize(point); @@ -831,21 +831,21 @@ struct Region3D Coord3D lo, hi; // axis-aligned bounding box // Keep only the overlapping portion of both regions. - void intersect( const Region3D &other ) + void clipTo( const Region3D &other ) { lo.maximize(other.lo); hi.minimize(other.hi); } // Expand to include the other region. - void unite( const Region3D &other ) + void expandWith( const Region3D &other ) { lo.minimize(other.lo); hi.maximize(other.hi); } // Expand to include the point. - void unite( const Coord3D &point ) + void expandWith( const Coord3D &point ) { lo.minimize(point); hi.maximize(point); @@ -897,7 +897,7 @@ struct Region3D hi = points[0]; for (Int i = 1; i < count; ++i) { - unite(points[i]); + expandWith(points[i]); } } @@ -920,21 +920,21 @@ struct IRegion3D ICoord3D lo, hi; // axis-aligned bounding box // Keep only the overlapping portion of both regions. - void intersect( const IRegion3D &other ) + void clipTo( const IRegion3D &other ) { lo.maximize(other.lo); hi.minimize(other.hi); } // Expand to include the other region. - void unite( const IRegion3D &other ) + void expandWith( const IRegion3D &other ) { lo.minimize(other.lo); hi.maximize(other.hi); } // Expand to include the point. - void unite( const ICoord3D &point ) + void expandWith( const ICoord3D &point ) { lo.minimize(point); hi.maximize(point); diff --git a/Generals/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp b/Generals/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp index 1ef3df2015d..a6f563c2cc9 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp @@ -3496,14 +3496,14 @@ void AIPlayer::getPlayerStructureBounds(Region2D *bounds, Int playerNdx ) objBounds.lo.y = objBounds.hi.y = pos.y; firstObject = false; } else { - objBounds.unite(pos.asCoord2D()); + objBounds.expandWith(pos.asCoord2D()); } if (firstStructure) { bounds->lo.x = bounds->hi.x = pos.x; bounds->lo.y = bounds->hi.y = pos.y; firstStructure = false; } else { - bounds->unite(pos.asCoord2D()); + bounds->expandWith(pos.asCoord2D()); } } } diff --git a/Generals/Code/GameEngine/Source/GameLogic/Map/PolygonTrigger.cpp b/Generals/Code/GameEngine/Source/GameLogic/Map/PolygonTrigger.cpp index 5223c9c6860..656a19c9179 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Map/PolygonTrigger.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Map/PolygonTrigger.cpp @@ -261,7 +261,7 @@ void PolygonTrigger::updateBounds() const m_bounds.hi.x = m_bounds.hi.y = -BIG_INT; Int i; for (i=0; iunite(pos.asCoord2D()); + bounds->expandWith(pos.asCoord2D()); } } } diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/PolygonTrigger.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/PolygonTrigger.cpp index b9f2a913a06..e01b819356d 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/PolygonTrigger.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/PolygonTrigger.cpp @@ -277,7 +277,7 @@ void PolygonTrigger::updateBounds() const m_bounds.hi.x = m_bounds.hi.y = -BIG_INT; Int i; for (i=0; i Date: Fri, 11 Sep 2026 12:17:36 +0200 Subject: [PATCH 14/17] Add spaces in minimize and maximize --- Core/Libraries/Include/Lib/BaseType.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Core/Libraries/Include/Lib/BaseType.h b/Core/Libraries/Include/Lib/BaseType.h index 1ef89dd439e..8c0a8500baf 100644 --- a/Core/Libraries/Include/Lib/BaseType.h +++ b/Core/Libraries/Include/Lib/BaseType.h @@ -336,6 +336,7 @@ struct Coord2D { if (x > other.x) x = other.x; + if (y > other.y) y = other.y; } @@ -344,6 +345,7 @@ struct Coord2D { if (x < other.x) x = other.x; + if (y < other.y) y = other.y; } @@ -479,6 +481,7 @@ struct ICoord2D { if (x > other.x) x = other.x; + if (y > other.y) y = other.y; } @@ -487,6 +490,7 @@ struct ICoord2D { if (x < other.x) x = other.x; + if (y < other.y) y = other.y; } @@ -696,8 +700,10 @@ struct Coord3D { if (x > other.x) x = other.x; + if (y > other.y) y = other.y; + if (z > other.z) z = other.z; } @@ -706,8 +712,10 @@ struct Coord3D { if (x < other.x) x = other.x; + if (y < other.y) y = other.y; + if (z < other.z) z = other.z; } @@ -794,8 +802,10 @@ struct ICoord3D { if (x > other.x) x = other.x; + if (y > other.y) y = other.y; + if (z > other.z) z = other.z; } @@ -804,8 +814,10 @@ struct ICoord3D { if (x < other.x) x = other.x; + if (y < other.y) y = other.y; + if (z < other.z) z = other.z; } From e6ebf1a4a7e38326a33645e99ad55129b20b7c14 Mon Sep 17 00:00:00 2001 From: stm <14291421+stephanmeesters@users.noreply.github.com> Date: Sat, 12 Sep 2026 12:29:50 +0200 Subject: [PATCH 15/17] Rename minimize and maximize to updateMin and updateMax --- .../Source/GameLogic/AI/AIPathfind.cpp | 6 +- Core/Libraries/Include/Lib/BaseType.h | 64 +++++++++---------- 2 files changed, 35 insertions(+), 35 deletions(-) diff --git a/Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp b/Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp index ca9d3f07a8a..1cff36fb057 100644 --- a/Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp +++ b/Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp @@ -2726,7 +2726,7 @@ void PathfindZoneManager::calculateZones( PathfindCell **map, PathfindLayer laye bounds.lo.y = globalBounds.lo.y + yBlock*ZONE_BLOCK_SIZE; bounds.hi.x = bounds.lo.x + ZONE_BLOCK_SIZE - 1; // bounds are inclusive. bounds.hi.y = bounds.lo.y + ZONE_BLOCK_SIZE - 1; // bounds are inclusive. - bounds.hi.minimize(globalBounds.hi); + bounds.hi.updateMin(globalBounds.hi); #if RTS_GENERALS && RETAIL_COMPATIBLE_PATHFINDING if (bounds.lo.x>bounds.hi.x || bounds.lo.y>bounds.hi.y) { DEBUG_CRASH(("Incorrect bounds calculation. Logic error, fix me. jba.")); @@ -2823,7 +2823,7 @@ void PathfindZoneManager::calculateZones( PathfindCell **map, PathfindLayer laye bounds.hi.x = bounds.lo.x + ZONE_BLOCK_SIZE - 1; // bounds are inclusive. bounds.hi.y = bounds.lo.y + ZONE_BLOCK_SIZE - 1; // bounds are inclusive. - bounds.hi.minimize(globalBounds.hi); + bounds.hi.updateMin(globalBounds.hi); #if RTS_GENERALS && RETAIL_COMPATIBLE_PATHFINDING if (bounds.lo.x>bounds.hi.x || bounds.lo.y>bounds.hi.y) { DEBUG_CRASH(("Incorrect bounds calculation. Logic error, fix me. jba.")); @@ -3042,7 +3042,7 @@ void PathfindZoneManager::updateZonesForModify(PathfindCell **map, PathfindLayer IRegion2D bounds = structureBounds; bounds.hi.x++; bounds.hi.y++; - bounds.hi.minimize(globalBounds.hi); + bounds.hi.updateMin(globalBounds.hi); Int xBlock, yBlock; for (xBlock = 0; xBlock other.x) x = other.x; @@ -341,7 +341,7 @@ struct Coord2D y = other.y; } - void maximize( const Coord2D &other ) + void updateMax( const Coord2D &other ) { if (x < other.x) x = other.x; @@ -477,7 +477,7 @@ struct ICoord2D y = ay; } - void minimize( const ICoord2D &other ) + void updateMin( const ICoord2D &other ) { if (x > other.x) x = other.x; @@ -486,7 +486,7 @@ struct ICoord2D y = other.y; } - void maximize( const ICoord2D &other ) + void updateMax( const ICoord2D &other ) { if (x < other.x) x = other.x; @@ -517,22 +517,22 @@ struct Region2D // Keep only the overlapping portion of both regions. void clipTo( const Region2D &other ) { - lo.maximize(other.lo); - hi.minimize(other.hi); + lo.updateMax(other.lo); + hi.updateMin(other.hi); } // Expand to include the other region. void expandWith( const Region2D &other ) { - lo.minimize(other.lo); - hi.maximize(other.hi); + lo.updateMin(other.lo); + hi.updateMax(other.hi); } // Expand to include the point. void expandWith( const Coord2D &point ) { - lo.minimize(point); - hi.maximize(point); + lo.updateMin(point); + hi.updateMax(point); } void zero() @@ -558,22 +558,22 @@ struct IRegion2D // Keep only the overlapping portion of both regions. void clipTo( const IRegion2D &other ) { - lo.maximize(other.lo); - hi.minimize(other.hi); + lo.updateMax(other.lo); + hi.updateMin(other.hi); } // Expand to include the other region. void expandWith( const IRegion2D &other ) { - lo.minimize(other.lo); - hi.maximize(other.hi); + lo.updateMin(other.lo); + hi.updateMax(other.hi); } // Expand to include the point. void expandWith( const ICoord2D &point ) { - lo.minimize(point); - hi.maximize(point); + lo.updateMin(point); + hi.updateMax(point); } void zero() @@ -696,7 +696,7 @@ struct Coord3D z == r.z); } - void minimize( const Coord3D &other ) + void updateMin( const Coord3D &other ) { if (x > other.x) x = other.x; @@ -708,7 +708,7 @@ struct Coord3D z = other.z; } - void maximize( const Coord3D &other ) + void updateMax( const Coord3D &other ) { if (x < other.x) x = other.x; @@ -798,7 +798,7 @@ struct ICoord3D z = az; } - void minimize( const ICoord3D &other ) + void updateMin( const ICoord3D &other ) { if (x > other.x) x = other.x; @@ -810,7 +810,7 @@ struct ICoord3D z = other.z; } - void maximize( const ICoord3D &other ) + void updateMax( const ICoord3D &other ) { if (x < other.x) x = other.x; @@ -845,22 +845,22 @@ struct Region3D // Keep only the overlapping portion of both regions. void clipTo( const Region3D &other ) { - lo.maximize(other.lo); - hi.minimize(other.hi); + lo.updateMax(other.lo); + hi.updateMin(other.hi); } // Expand to include the other region. void expandWith( const Region3D &other ) { - lo.minimize(other.lo); - hi.maximize(other.hi); + lo.updateMin(other.lo); + hi.updateMax(other.hi); } // Expand to include the point. void expandWith( const Coord3D &point ) { - lo.minimize(point); - hi.maximize(point); + lo.updateMin(point); + hi.updateMax(point); } Real width() const { return hi.x - lo.x; } @@ -934,22 +934,22 @@ struct IRegion3D // Keep only the overlapping portion of both regions. void clipTo( const IRegion3D &other ) { - lo.maximize(other.lo); - hi.minimize(other.hi); + lo.updateMax(other.lo); + hi.updateMin(other.hi); } // Expand to include the other region. void expandWith( const IRegion3D &other ) { - lo.minimize(other.lo); - hi.maximize(other.hi); + lo.updateMin(other.lo); + hi.updateMax(other.hi); } // Expand to include the point. void expandWith( const ICoord3D &point ) { - lo.minimize(point); - hi.maximize(point); + lo.updateMin(point); + hi.updateMax(point); } void zero() From a1045ff42fbcd5421d6402c91b20ccc5d4d9ac66 Mon Sep 17 00:00:00 2001 From: stm <14291421+stephanmeesters@users.noreply.github.com> Date: Sat, 12 Sep 2026 12:32:51 +0200 Subject: [PATCH 16/17] Rename clipTo to intersectWith, expandWith to uniteWith --- .../Source/GameLogic/AI/AIPathfind.cpp | 6 ++--- Core/Libraries/Include/Lib/BaseType.h | 26 +++++++++---------- .../Source/GameLogic/AI/AIPlayer.cpp | 4 +-- .../Source/GameLogic/Map/PolygonTrigger.cpp | 2 +- .../Source/GameLogic/Map/TerrainLogic.cpp | 12 ++++----- .../Object/Behavior/PrisonBehavior.cpp | 2 +- .../Source/GameLogic/AI/AIPlayer.cpp | 4 +-- .../Source/GameLogic/Map/PolygonTrigger.cpp | 2 +- .../Source/GameLogic/Map/TerrainLogic.cpp | 12 ++++----- .../Object/Behavior/PrisonBehavior.cpp | 2 +- 10 files changed, 36 insertions(+), 36 deletions(-) diff --git a/Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp b/Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp index 1cff36fb057..60d1add770b 100644 --- a/Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp +++ b/Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp @@ -3052,7 +3052,7 @@ void PathfindZoneManager::updateZonesForModify(PathfindCell **map, PathfindLayer blockBounds.lo.y = globalBounds.lo.y + yBlock*ZONE_BLOCK_SIZE; blockBounds.hi.x = blockBounds.lo.x + ZONE_BLOCK_SIZE - 1; // blockBounds are inclusive. blockBounds.hi.y = blockBounds.lo.y + ZONE_BLOCK_SIZE - 1; // blockBounds are inclusive. - blockBounds.clipTo(bounds); + blockBounds.intersectWith(bounds); if (blockBounds.lo.x>blockBounds.hi.x || blockBounds.lo.y>blockBounds.hi.y) { continue; } @@ -3591,7 +3591,7 @@ void PathfindLayer::allocateCellsForWallLayer(const IRegion2D *extent, ObjectID bridgeBounds = objBounds; first = false; } else { - bridgeBounds.expandWith(objBounds); + bridgeBounds.uniteWith(objBounds); } } @@ -4577,7 +4577,7 @@ void Pathfinder::internal_classifyObjectFootprint( Object *obj, Bool insert ) Int i, j; - cellBounds.clipTo(m_extent); + cellBounds.intersectWith(m_extent); if (!insert) { for( j=cellBounds.lo.y; j<=cellBounds.hi.y; j++ ) diff --git a/Core/Libraries/Include/Lib/BaseType.h b/Core/Libraries/Include/Lib/BaseType.h index 73e0cff6119..0a926fd8954 100644 --- a/Core/Libraries/Include/Lib/BaseType.h +++ b/Core/Libraries/Include/Lib/BaseType.h @@ -515,21 +515,21 @@ struct Region2D Coord2D lo, hi; // bounds of 2D rectangular region // Keep only the overlapping portion of both regions. - void clipTo( const Region2D &other ) + void intersectWith( const Region2D &other ) { lo.updateMax(other.lo); hi.updateMin(other.hi); } // Expand to include the other region. - void expandWith( const Region2D &other ) + void uniteWith( const Region2D &other ) { lo.updateMin(other.lo); hi.updateMax(other.hi); } // Expand to include the point. - void expandWith( const Coord2D &point ) + void uniteWith( const Coord2D &point ) { lo.updateMin(point); hi.updateMax(point); @@ -556,21 +556,21 @@ struct IRegion2D ICoord2D lo, hi; // bounds of 2D rectangular region // Keep only the overlapping portion of both regions. - void clipTo( const IRegion2D &other ) + void intersectWith( const IRegion2D &other ) { lo.updateMax(other.lo); hi.updateMin(other.hi); } // Expand to include the other region. - void expandWith( const IRegion2D &other ) + void uniteWith( const IRegion2D &other ) { lo.updateMin(other.lo); hi.updateMax(other.hi); } // Expand to include the point. - void expandWith( const ICoord2D &point ) + void uniteWith( const ICoord2D &point ) { lo.updateMin(point); hi.updateMax(point); @@ -843,21 +843,21 @@ struct Region3D Coord3D lo, hi; // axis-aligned bounding box // Keep only the overlapping portion of both regions. - void clipTo( const Region3D &other ) + void intersectWith( const Region3D &other ) { lo.updateMax(other.lo); hi.updateMin(other.hi); } // Expand to include the other region. - void expandWith( const Region3D &other ) + void uniteWith( const Region3D &other ) { lo.updateMin(other.lo); hi.updateMax(other.hi); } // Expand to include the point. - void expandWith( const Coord3D &point ) + void uniteWith( const Coord3D &point ) { lo.updateMin(point); hi.updateMax(point); @@ -909,7 +909,7 @@ struct Region3D hi = points[0]; for (Int i = 1; i < count; ++i) { - expandWith(points[i]); + uniteWith(points[i]); } } @@ -932,21 +932,21 @@ struct IRegion3D ICoord3D lo, hi; // axis-aligned bounding box // Keep only the overlapping portion of both regions. - void clipTo( const IRegion3D &other ) + void intersectWith( const IRegion3D &other ) { lo.updateMax(other.lo); hi.updateMin(other.hi); } // Expand to include the other region. - void expandWith( const IRegion3D &other ) + void uniteWith( const IRegion3D &other ) { lo.updateMin(other.lo); hi.updateMax(other.hi); } // Expand to include the point. - void expandWith( const ICoord3D &point ) + void uniteWith( const ICoord3D &point ) { lo.updateMin(point); hi.updateMax(point); diff --git a/Generals/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp b/Generals/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp index a6f563c2cc9..fc9385a7b68 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp @@ -3496,14 +3496,14 @@ void AIPlayer::getPlayerStructureBounds(Region2D *bounds, Int playerNdx ) objBounds.lo.y = objBounds.hi.y = pos.y; firstObject = false; } else { - objBounds.expandWith(pos.asCoord2D()); + objBounds.uniteWith(pos.asCoord2D()); } if (firstStructure) { bounds->lo.x = bounds->hi.x = pos.x; bounds->lo.y = bounds->hi.y = pos.y; firstStructure = false; } else { - bounds->expandWith(pos.asCoord2D()); + bounds->uniteWith(pos.asCoord2D()); } } } diff --git a/Generals/Code/GameEngine/Source/GameLogic/Map/PolygonTrigger.cpp b/Generals/Code/GameEngine/Source/GameLogic/Map/PolygonTrigger.cpp index 656a19c9179..c5b269e61e1 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Map/PolygonTrigger.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Map/PolygonTrigger.cpp @@ -261,7 +261,7 @@ void PolygonTrigger::updateBounds() const m_bounds.hi.x = m_bounds.hi.y = -BIG_INT; Int i; for (i=0; iexpandWith(pos.asCoord2D()); + bounds->uniteWith(pos.asCoord2D()); } } } diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/PolygonTrigger.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/PolygonTrigger.cpp index e01b819356d..4e50c5281fe 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/PolygonTrigger.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/PolygonTrigger.cpp @@ -277,7 +277,7 @@ void PolygonTrigger::updateBounds() const m_bounds.hi.x = m_bounds.hi.y = -BIG_INT; Int i; for (i=0; i Date: Sat, 12 Sep 2026 12:57:50 +0200 Subject: [PATCH 17/17] Rename getXY() in ICoord2D to asICoord2D() --- Core/Libraries/Include/Lib/BaseType.h | 2 +- .../Code/GameEngine/Source/GameLogic/Map/PolygonTrigger.cpp | 2 +- .../Code/GameEngine/Source/GameLogic/Map/PolygonTrigger.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Core/Libraries/Include/Lib/BaseType.h b/Core/Libraries/Include/Lib/BaseType.h index 0a926fd8954..91a50112aee 100644 --- a/Core/Libraries/Include/Lib/BaseType.h +++ b/Core/Libraries/Include/Lib/BaseType.h @@ -739,7 +739,7 @@ struct ICoord3D { Int x, y, z; - ICoord2D getXY() const + ICoord2D asICoord2D() const { const ICoord2D xy = { x, y }; return xy; diff --git a/Generals/Code/GameEngine/Source/GameLogic/Map/PolygonTrigger.cpp b/Generals/Code/GameEngine/Source/GameLogic/Map/PolygonTrigger.cpp index c5b269e61e1..53547241570 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Map/PolygonTrigger.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Map/PolygonTrigger.cpp @@ -261,7 +261,7 @@ void PolygonTrigger::updateBounds() const m_bounds.hi.x = m_bounds.hi.y = -BIG_INT; Int i; for (i=0; i