Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 3 additions & 18 deletions Core/GameEngine/Source/GameClient/GUI/GameWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,26 +180,11 @@ 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.x > m_region.hi.x )
std::swap( m_region.lo.x, m_region.hi.x );

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;

}

std::swap( m_region.lo.y, m_region.hi.y );
}

// GameWindow::findFirstLeaf ==================================================
Expand Down
49 changes: 5 additions & 44 deletions Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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."));
Expand Down Expand Up @@ -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."));
Expand Down Expand Up @@ -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<m_zoneBlockExtent.x; xBlock++) {
Expand All @@ -3066,18 +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.
if (blockBounds.hi.x > 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;
}
Expand Down Expand Up @@ -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++ )
Expand Down
110 changes: 98 additions & 12 deletions Core/Libraries/Include/Lib/BaseType.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Comment thread
greptile-apps[bot] marked this conversation as resolved.
};

inline Coord2D operator+( const Coord2D &a, const Coord2D &b )
Expand Down Expand Up @@ -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 )
Expand All @@ -478,6 +510,12 @@ struct Region2D
{
Coord2D lo, hi; // bounds of 2D rectangular region

void intersect( const Region2D &other )
Comment thread
xezon marked this conversation as resolved.
{
lo.max(other.lo);
hi.min(other.hi);
}

void zero()
{
lo.zero();
Expand All @@ -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();
Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -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 )
Expand All @@ -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; }
Expand Down Expand Up @@ -750,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]);
}
}

Expand All @@ -783,6 +863,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();
Expand Down
Loading