From 61084a98fc2e31a23a1d97da38853710a9fa6454 Mon Sep 17 00:00:00 2001 From: Mauller <26652186+Mauller@users.noreply.github.com> Date: Fri, 27 Feb 2026 20:42:27 +0000 Subject: [PATCH 1/5] chore(pathfinder): Change leading spaces to leading tabs in PathfindZoneManager:calculateZones() (#2360) --- .../Source/GameLogic/AI/AIPathfind.cpp | 244 +++++++++--------- 1 file changed, 122 insertions(+), 122 deletions(-) diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp index e806d40dc75..cc67ccae8fd 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp @@ -2618,52 +2618,52 @@ void PathfindZoneManager::calculateZones( PathfindCell **map, PathfindLayer laye Int collapsedZones[maxZones]; collapsedZones[0] = 0; - i = 1; - while ( i < totalZones ) - { + i = 1; + while ( i < totalZones ) + { Int zone = zoneEquivalency[ i ]; if (zone == i) - { + { collapsedZones[ i ] = m_maxZone; ++m_maxZone; } - else + else collapsedZones[ i ] = collapsedZones[zone]; - ++i; - } + ++i; + } // Now map the zones in the map back into the collapsed zones. j=globalBounds.lo.y; - while( j<=globalBounds.hi.y ) - { - i=globalBounds.lo.x; + while( j<=globalBounds.hi.y ) + { + i=globalBounds.lo.x; while( i<=globalBounds.hi.x ) - { - PathfindCell &cell = map[i][j]; + { + PathfindCell &cell = map[i][j]; cell.setZone(collapsedZones[cell.getZone()]); - ++i; + ++i; } - ++j; + ++j; } - i = 0; + i = 0; while ( i <= LAYER_LAST ) - { - PathfindLayer &r_thisLayer = layers[i]; + { + PathfindLayer &r_thisLayer = layers[i]; Int zone = collapsedZones[r_thisLayer.getZone()]; if (zone == 0) - { + { zone = m_maxZone; m_maxZone++; } - r_thisLayer.setZone( zone ); - r_thisLayer.applyZone(); + r_thisLayer.setZone( zone ); + r_thisLayer.applyZone(); - if (!r_thisLayer.isUnused() && !r_thisLayer.isDestroyed()) - { + if (!r_thisLayer.isUnused() && !r_thisLayer.isDestroyed()) + { ICoord2D ndx; r_thisLayer.getStartCellIndex(&ndx); setBridge(ndx.x, ndx.y, true); @@ -2671,25 +2671,25 @@ void PathfindZoneManager::calculateZones( PathfindCell **map, PathfindLayer laye setBridge(ndx.x, ndx.y, true); } - ++i; + ++i; } allocateZones(); for (xBlock=0; xBlock globalBounds.hi.x) + if (bounds.hi.x > globalBounds.hi.x) bounds.hi.x = globalBounds.hi.x; - if (bounds.hi.y > globalBounds.hi.y) + if (bounds.hi.y > globalBounds.hi.y) bounds.hi.y = globalBounds.hi.y; m_zoneBlocks[xBlock][yBlock].blockCalculateZones(map, layers, bounds); @@ -2697,116 +2697,116 @@ void PathfindZoneManager::calculateZones( PathfindCell **map, PathfindLayer laye } i = 0; - while ( i < m_zonesAllocated ) + while ( i < m_zonesAllocated ) { - m_groundCliffZones[i] = m_groundWaterZones[i] = m_groundRubbleZones[i] = m_terrainZones[i] = m_crusherZones[i] = m_hierarchicalZones[i] = i; - i++; - } + m_groundCliffZones[i] = m_groundWaterZones[i] = m_groundRubbleZones[i] = m_terrainZones[i] = m_crusherZones[i] = m_hierarchicalZones[i] = i; + i++; + } - REGISTER UnsignedInt maxZone = m_maxZone; + REGISTER UnsignedInt maxZone = m_maxZone; j=globalBounds.lo.y; - while( j <= globalBounds.hi.y ) - { - i=globalBounds.lo.x; + while( j <= globalBounds.hi.y ) + { + i=globalBounds.lo.x; while( i <= globalBounds.hi.x ) - { - PathfindCell &r_thisCell = map[i][j]; + { + PathfindCell &r_thisCell = map[i][j]; if ( (r_thisCell.getConnectLayer() > LAYER_GROUND) && (r_thisCell.getType() == PathfindCell::CELL_CLEAR) ) - { + { PathfindLayer *layer = layers + r_thisCell.getConnectLayer(); resolveZones(r_thisCell.getZone(), layer->getZone(), m_hierarchicalZones, maxZone); } if ( i > globalBounds.lo.x && r_thisCell.getZone() != map[i-1][j].getZone() ) - { - const PathfindCell &r_leftCell = map[i-1][j]; + { + const PathfindCell &r_leftCell = map[i-1][j]; if (r_thisCell.getType() == r_leftCell.getType()) applyZone(r_thisCell, r_leftCell, m_hierarchicalZones, maxZone);//if this is true, skip all the ones below - else - { - Bool notTerrainOrCrusher = TRUE; // if this is false, skip the if-else-ladder below - - if (terrain(r_thisCell, r_leftCell)) - { - applyZone(r_thisCell, r_leftCell, m_terrainZones, maxZone); - notTerrainOrCrusher = FALSE; - } - - if (crusherGround(r_thisCell, r_leftCell)) - { - applyZone(r_thisCell, r_leftCell, m_crusherZones, maxZone); - notTerrainOrCrusher = FALSE; - } - - if ( notTerrainOrCrusher ) - { - if (waterGround(r_thisCell, r_leftCell)) - applyZone(r_thisCell, r_leftCell, m_groundWaterZones, maxZone); - else if (groundRubble(r_thisCell, r_leftCell)) - applyZone(r_thisCell, r_leftCell, m_groundRubbleZones, maxZone); - else if (groundCliff(r_thisCell, r_leftCell)) - applyZone(r_thisCell, r_leftCell, m_groundCliffZones, maxZone); - } - - } - - } + else + { + Bool notTerrainOrCrusher = TRUE; // if this is false, skip the if-else-ladder below + + if (terrain(r_thisCell, r_leftCell)) + { + applyZone(r_thisCell, r_leftCell, m_terrainZones, maxZone); + notTerrainOrCrusher = FALSE; + } + + if (crusherGround(r_thisCell, r_leftCell)) + { + applyZone(r_thisCell, r_leftCell, m_crusherZones, maxZone); + notTerrainOrCrusher = FALSE; + } + + if ( notTerrainOrCrusher ) + { + if (waterGround(r_thisCell, r_leftCell)) + applyZone(r_thisCell, r_leftCell, m_groundWaterZones, maxZone); + else if (groundRubble(r_thisCell, r_leftCell)) + applyZone(r_thisCell, r_leftCell, m_groundRubbleZones, maxZone); + else if (groundCliff(r_thisCell, r_leftCell)) + applyZone(r_thisCell, r_leftCell, m_groundCliffZones, maxZone); + } + + } + + } if (j>globalBounds.lo.y && r_thisCell.getZone()!=map[i][j-1].getZone()) - { - const PathfindCell &r_topCell = map[i][j-1]; + { + const PathfindCell &r_topCell = map[i][j-1]; - if (r_thisCell.getType() == r_topCell.getType()) + if (r_thisCell.getType() == r_topCell.getType()) applyZone(r_thisCell, r_topCell, m_hierarchicalZones, maxZone); - else - { - Bool notTerrainOrCrusher = TRUE; // if this is false, skip the if-else-ladder below + else + { + Bool notTerrainOrCrusher = TRUE; // if this is false, skip the if-else-ladder below - if (terrain(r_thisCell, r_topCell)) - { - applyZone(r_thisCell, r_topCell, m_terrainZones, maxZone); - notTerrainOrCrusher = FALSE; - } + if (terrain(r_thisCell, r_topCell)) + { + applyZone(r_thisCell, r_topCell, m_terrainZones, maxZone); + notTerrainOrCrusher = FALSE; + } - if (crusherGround(r_thisCell, r_topCell)) - { - applyZone(r_thisCell, r_topCell, m_crusherZones, maxZone); - notTerrainOrCrusher = FALSE; - } + if (crusherGround(r_thisCell, r_topCell)) + { + applyZone(r_thisCell, r_topCell, m_crusherZones, maxZone); + notTerrainOrCrusher = FALSE; + } - if (waterGround(r_thisCell,r_topCell)) - applyZone(r_thisCell, r_topCell, m_groundWaterZones, maxZone); - else if (groundRubble(r_thisCell, r_topCell)) - applyZone(r_thisCell, r_topCell, m_groundRubbleZones, maxZone); - else if (groundCliff(r_thisCell,r_topCell)) - applyZone(r_thisCell, r_topCell, m_groundCliffZones, maxZone); + if (waterGround(r_thisCell,r_topCell)) + applyZone(r_thisCell, r_topCell, m_groundWaterZones, maxZone); + else if (groundRubble(r_thisCell, r_topCell)) + applyZone(r_thisCell, r_topCell, m_groundRubbleZones, maxZone); + else if (groundCliff(r_thisCell,r_topCell)) + applyZone(r_thisCell, r_topCell, m_groundCliffZones, maxZone); - } + } - } + } - ++i; + ++i; } - ++j; + ++j; } - //FLATTEN HIERARCHICAL ZONES - { - i = 1; - REGISTER Int zone; - while ( i < maxZone ) - { // Flatten hierarchical zones. - zone = m_hierarchicalZones[i]; - m_hierarchicalZones[i] = m_hierarchicalZones[ zone ]; - ++i; - } - } - - //THIS BLOCK IS 20% + //FLATTEN HIERARCHICAL ZONES + { + i = 1; + REGISTER Int zone; + while ( i < maxZone ) + { // Flatten hierarchical zones. + zone = m_hierarchicalZones[i]; + m_hierarchicalZones[i] = m_hierarchicalZones[ zone ]; + ++i; + } + } + + //THIS BLOCK IS 20% flattenZones(m_groundCliffZones, m_hierarchicalZones, m_maxZone); flattenZones(m_groundWaterZones, m_hierarchicalZones, m_maxZone); flattenZones(m_groundRubbleZones, m_hierarchicalZones, m_maxZone); @@ -2818,21 +2818,21 @@ void PathfindZoneManager::calculateZones( PathfindCell **map, PathfindLayer laye QueryPerformanceCounter((LARGE_INTEGER *)&endTime64); timeToUpdate = ((double)(endTime64-startTime64) / (double)(freq64)); - if ( updateSamples < 400 ) - { - averageTimeToUpdate = ((averageTimeToUpdate * updateSamples) + timeToUpdate) / (updateSamples + 1.0f); - updateSamples++; - DEBUG_LOG(("computing...: %f", averageTimeToUpdate)); - } - else if ( updateSamples == 400 ) - { - DEBUG_LOG((" =============DONE============= Average time to calculate zones: %f", averageTimeToUpdate)); - DEBUG_LOG((" Percent of baseline : %f", averageTimeToUpdate/0.003335f)); - updateSamples = 777; + if ( updateSamples < 400 ) + { + averageTimeToUpdate = ((averageTimeToUpdate * updateSamples) + timeToUpdate) / (updateSamples + 1.0f); + updateSamples++; + DEBUG_LOG(("computing...: %f", averageTimeToUpdate)); + } + else if ( updateSamples == 400 ) + { + DEBUG_LOG((" =============DONE============= Average time to calculate zones: %f", averageTimeToUpdate)); + DEBUG_LOG((" Percent of baseline : %f", averageTimeToUpdate/0.003335f)); + updateSamples = 777; #ifdef forceRefreshCalling - s_stopForceCalling = TRUE; + s_stopForceCalling = TRUE; #endif - } + } #endif #endif @@ -2967,7 +2967,7 @@ void PathfindZoneManager::updateZonesForModify(PathfindCell **map, PathfindLayer } } } - } + } } #ifdef DEBUG_QPF #if defined(DEBUG_LOGGING) From 21afa34e6af6ba72a59d905aff19bda774c71606 Mon Sep 17 00:00:00 2001 From: Mauller <26652186+Mauller@users.noreply.github.com> Date: Fri, 27 Feb 2026 20:48:40 +0000 Subject: [PATCH 2/5] chore(pathfinder): Change open braces to be K&R style in PathfindZoneManager::calculateZones() (#2360) --- .../Source/GameLogic/AI/AIPathfind.cpp | 76 +++++++------------ 1 file changed, 26 insertions(+), 50 deletions(-) diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp index cc67ccae8fd..31587529123 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp @@ -2619,11 +2619,9 @@ void PathfindZoneManager::calculateZones( PathfindCell **map, PathfindLayer laye collapsedZones[0] = 0; i = 1; - while ( i < totalZones ) - { + while ( i < totalZones ) { Int zone = zoneEquivalency[ i ]; - if (zone == i) - { + if (zone == i) { collapsedZones[ i ] = m_maxZone; ++m_maxZone; } @@ -2635,11 +2633,9 @@ void PathfindZoneManager::calculateZones( PathfindCell **map, PathfindLayer laye // Now map the zones in the map back into the collapsed zones. j=globalBounds.lo.y; - while( j<=globalBounds.hi.y ) - { + while( j<=globalBounds.hi.y ) { i=globalBounds.lo.x; - while( i<=globalBounds.hi.x ) - { + while( i<=globalBounds.hi.x ) { PathfindCell &cell = map[i][j]; cell.setZone(collapsedZones[cell.getZone()]); ++i; @@ -2648,13 +2644,11 @@ void PathfindZoneManager::calculateZones( PathfindCell **map, PathfindLayer laye } i = 0; - while ( i <= LAYER_LAST ) - { + while ( i <= LAYER_LAST ) { PathfindLayer &r_thisLayer = layers[i]; Int zone = collapsedZones[r_thisLayer.getZone()]; - if (zone == 0) - { + if (zone == 0) { zone = m_maxZone; m_maxZone++; } @@ -2662,8 +2656,7 @@ void PathfindZoneManager::calculateZones( PathfindCell **map, PathfindLayer laye r_thisLayer.setZone( zone ); r_thisLayer.applyZone(); - if (!r_thisLayer.isUnused() && !r_thisLayer.isDestroyed()) - { + if (!r_thisLayer.isUnused() && !r_thisLayer.isDestroyed()) { ICoord2D ndx; r_thisLayer.getStartCellIndex(&ndx); setBridge(ndx.x, ndx.y, true); @@ -2676,10 +2669,8 @@ void PathfindZoneManager::calculateZones( PathfindCell **map, PathfindLayer laye allocateZones(); - for (xBlock=0; xBlock LAYER_GROUND) && - (r_thisCell.getType() == PathfindCell::CELL_CLEAR) ) - { + (r_thisCell.getType() == PathfindCell::CELL_CLEAR) ) { PathfindLayer *layer = layers + r_thisCell.getConnectLayer(); resolveZones(r_thisCell.getZone(), layer->getZone(), m_hierarchicalZones, maxZone); } - if ( i > globalBounds.lo.x && r_thisCell.getZone() != map[i-1][j].getZone() ) - { + if ( i > globalBounds.lo.x && r_thisCell.getZone() != map[i-1][j].getZone() ) { const PathfindCell &r_leftCell = map[i-1][j]; if (r_thisCell.getType() == r_leftCell.getType()) applyZone(r_thisCell, r_leftCell, m_hierarchicalZones, maxZone);//if this is true, skip all the ones below - else - { + else { Bool notTerrainOrCrusher = TRUE; // if this is false, skip the if-else-ladder below - if (terrain(r_thisCell, r_leftCell)) - { + if (terrain(r_thisCell, r_leftCell)) { applyZone(r_thisCell, r_leftCell, m_terrainZones, maxZone); notTerrainOrCrusher = FALSE; } - if (crusherGround(r_thisCell, r_leftCell)) - { + if (crusherGround(r_thisCell, r_leftCell)) { applyZone(r_thisCell, r_leftCell, m_crusherZones, maxZone); notTerrainOrCrusher = FALSE; } - if ( notTerrainOrCrusher ) - { + if ( notTerrainOrCrusher ) { if (waterGround(r_thisCell, r_leftCell)) applyZone(r_thisCell, r_leftCell, m_groundWaterZones, maxZone); else if (groundRubble(r_thisCell, r_leftCell)) @@ -2755,24 +2737,20 @@ void PathfindZoneManager::calculateZones( PathfindCell **map, PathfindLayer laye } - if (j>globalBounds.lo.y && r_thisCell.getZone()!=map[i][j-1].getZone()) - { + if (j>globalBounds.lo.y && r_thisCell.getZone()!=map[i][j-1].getZone()) { const PathfindCell &r_topCell = map[i][j-1]; if (r_thisCell.getType() == r_topCell.getType()) applyZone(r_thisCell, r_topCell, m_hierarchicalZones, maxZone); - else - { + else { Bool notTerrainOrCrusher = TRUE; // if this is false, skip the if-else-ladder below - if (terrain(r_thisCell, r_topCell)) - { + if (terrain(r_thisCell, r_topCell)) { applyZone(r_thisCell, r_topCell, m_terrainZones, maxZone); notTerrainOrCrusher = FALSE; } - if (crusherGround(r_thisCell, r_topCell)) - { + if (crusherGround(r_thisCell, r_topCell)) { applyZone(r_thisCell, r_topCell, m_crusherZones, maxZone); notTerrainOrCrusher = FALSE; } @@ -2798,8 +2776,8 @@ void PathfindZoneManager::calculateZones( PathfindCell **map, PathfindLayer laye { i = 1; REGISTER Int zone; - while ( i < maxZone ) - { // Flatten hierarchical zones. + while ( i < maxZone ) { + // Flatten hierarchical zones. zone = m_hierarchicalZones[i]; m_hierarchicalZones[i] = m_hierarchicalZones[ zone ]; ++i; @@ -2818,14 +2796,12 @@ void PathfindZoneManager::calculateZones( PathfindCell **map, PathfindLayer laye QueryPerformanceCounter((LARGE_INTEGER *)&endTime64); timeToUpdate = ((double)(endTime64-startTime64) / (double)(freq64)); - if ( updateSamples < 400 ) - { + if ( updateSamples < 400 ) { averageTimeToUpdate = ((averageTimeToUpdate * updateSamples) + timeToUpdate) / (updateSamples + 1.0f); updateSamples++; DEBUG_LOG(("computing...: %f", averageTimeToUpdate)); } - else if ( updateSamples == 400 ) - { + else if ( updateSamples == 400 ) { DEBUG_LOG((" =============DONE============= Average time to calculate zones: %f", averageTimeToUpdate)); DEBUG_LOG((" Percent of baseline : %f", averageTimeToUpdate/0.003335f)); updateSamples = 777; From 5664d4231bf1ce4dfee598b81888025c8442af6e Mon Sep 17 00:00:00 2001 From: Mauller <26652186+Mauller@users.noreply.github.com> Date: Fri, 27 Feb 2026 21:07:52 +0000 Subject: [PATCH 3/5] chore(pathfinder): Change while loops to for loops in PathfindZoneManager::calculateZones() (#2360) --- .../Source/GameLogic/AI/AIPathfind.cpp | 53 +++++++------------ 1 file changed, 18 insertions(+), 35 deletions(-) diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp index 31587529123..bc2f0e3cab5 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp @@ -2618,8 +2618,7 @@ void PathfindZoneManager::calculateZones( PathfindCell **map, PathfindLayer laye Int collapsedZones[maxZones]; collapsedZones[0] = 0; - i = 1; - while ( i < totalZones ) { + for (i=1; i LAYER_GROUND) && @@ -2766,22 +2758,13 @@ void PathfindZoneManager::calculateZones( PathfindCell **map, PathfindLayer laye } - ++i; } - - ++j; } //FLATTEN HIERARCHICAL ZONES - { - i = 1; - REGISTER Int zone; - while ( i < maxZone ) { - // Flatten hierarchical zones. - zone = m_hierarchicalZones[i]; - m_hierarchicalZones[i] = m_hierarchicalZones[ zone ]; - ++i; - } + for (i=1; i Date: Fri, 27 Feb 2026 21:33:27 +0000 Subject: [PATCH 4/5] chore(pathfinder): Remove register variable and use member variable directly in PathfindZoneManager::calculateZones() (#2360) --- .../Source/GameLogic/AI/AIPathfind.cpp | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp index bc2f0e3cab5..e98237d9e63 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp @@ -2687,7 +2687,6 @@ void PathfindZoneManager::calculateZones( PathfindCell **map, PathfindLayer laye m_hierarchicalZones[i] = i; } - REGISTER UnsignedInt maxZone = m_maxZone; for( j=globalBounds.lo.y; j<=globalBounds.hi.y; j++ ) { for( i=globalBounds.lo.x; i<=globalBounds.hi.x; i++ ) { PathfindCell &r_thisCell = map[i][j]; @@ -2695,34 +2694,34 @@ void PathfindZoneManager::calculateZones( PathfindCell **map, PathfindLayer laye if ( (r_thisCell.getConnectLayer() > LAYER_GROUND) && (r_thisCell.getType() == PathfindCell::CELL_CLEAR) ) { PathfindLayer *layer = layers + r_thisCell.getConnectLayer(); - resolveZones(r_thisCell.getZone(), layer->getZone(), m_hierarchicalZones, maxZone); + resolveZones(r_thisCell.getZone(), layer->getZone(), m_hierarchicalZones, m_maxZone); } if ( i > globalBounds.lo.x && r_thisCell.getZone() != map[i-1][j].getZone() ) { const PathfindCell &r_leftCell = map[i-1][j]; if (r_thisCell.getType() == r_leftCell.getType()) - applyZone(r_thisCell, r_leftCell, m_hierarchicalZones, maxZone);//if this is true, skip all the ones below + applyZone(r_thisCell, r_leftCell, m_hierarchicalZones, m_maxZone);//if this is true, skip all the ones below else { Bool notTerrainOrCrusher = TRUE; // if this is false, skip the if-else-ladder below if (terrain(r_thisCell, r_leftCell)) { - applyZone(r_thisCell, r_leftCell, m_terrainZones, maxZone); + applyZone(r_thisCell, r_leftCell, m_terrainZones, m_maxZone); notTerrainOrCrusher = FALSE; } if (crusherGround(r_thisCell, r_leftCell)) { - applyZone(r_thisCell, r_leftCell, m_crusherZones, maxZone); + applyZone(r_thisCell, r_leftCell, m_crusherZones, m_maxZone); notTerrainOrCrusher = FALSE; } if ( notTerrainOrCrusher ) { if (waterGround(r_thisCell, r_leftCell)) - applyZone(r_thisCell, r_leftCell, m_groundWaterZones, maxZone); + applyZone(r_thisCell, r_leftCell, m_groundWaterZones, m_maxZone); else if (groundRubble(r_thisCell, r_leftCell)) - applyZone(r_thisCell, r_leftCell, m_groundRubbleZones, maxZone); + applyZone(r_thisCell, r_leftCell, m_groundRubbleZones, m_maxZone); else if (groundCliff(r_thisCell, r_leftCell)) - applyZone(r_thisCell, r_leftCell, m_groundCliffZones, maxZone); + applyZone(r_thisCell, r_leftCell, m_groundCliffZones, m_maxZone); } } @@ -2733,26 +2732,26 @@ void PathfindZoneManager::calculateZones( PathfindCell **map, PathfindLayer laye const PathfindCell &r_topCell = map[i][j-1]; if (r_thisCell.getType() == r_topCell.getType()) - applyZone(r_thisCell, r_topCell, m_hierarchicalZones, maxZone); + applyZone(r_thisCell, r_topCell, m_hierarchicalZones, m_maxZone); else { Bool notTerrainOrCrusher = TRUE; // if this is false, skip the if-else-ladder below if (terrain(r_thisCell, r_topCell)) { - applyZone(r_thisCell, r_topCell, m_terrainZones, maxZone); + applyZone(r_thisCell, r_topCell, m_terrainZones, m_maxZone); notTerrainOrCrusher = FALSE; } if (crusherGround(r_thisCell, r_topCell)) { - applyZone(r_thisCell, r_topCell, m_crusherZones, maxZone); + applyZone(r_thisCell, r_topCell, m_crusherZones, m_maxZone); notTerrainOrCrusher = FALSE; } if (waterGround(r_thisCell,r_topCell)) - applyZone(r_thisCell, r_topCell, m_groundWaterZones, maxZone); + applyZone(r_thisCell, r_topCell, m_groundWaterZones, m_maxZone); else if (groundRubble(r_thisCell, r_topCell)) - applyZone(r_thisCell, r_topCell, m_groundRubbleZones, maxZone); + applyZone(r_thisCell, r_topCell, m_groundRubbleZones, m_maxZone); else if (groundCliff(r_thisCell,r_topCell)) - applyZone(r_thisCell, r_topCell, m_groundCliffZones, maxZone); + applyZone(r_thisCell, r_topCell, m_groundCliffZones, m_maxZone); } From 2b8e7fdeab3b4dfa6144499a8d3b5e8f06501b5f Mon Sep 17 00:00:00 2001 From: Mauller <26652186+Mauller@users.noreply.github.com> Date: Fri, 27 Feb 2026 21:37:24 +0000 Subject: [PATCH 5/5] fix(pathfinder): Add missing logical block for zone type optimization in PathfindZoneManager::calculateZones() (#2360) --- .../GameEngine/Source/GameLogic/AI/AIPathfind.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp index e98237d9e63..954cf11f495 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp @@ -2746,12 +2746,14 @@ void PathfindZoneManager::calculateZones( PathfindCell **map, PathfindLayer laye notTerrainOrCrusher = FALSE; } - if (waterGround(r_thisCell,r_topCell)) - applyZone(r_thisCell, r_topCell, m_groundWaterZones, m_maxZone); - else if (groundRubble(r_thisCell, r_topCell)) - applyZone(r_thisCell, r_topCell, m_groundRubbleZones, m_maxZone); - else if (groundCliff(r_thisCell,r_topCell)) - applyZone(r_thisCell, r_topCell, m_groundCliffZones, m_maxZone); + if (notTerrainOrCrusher) { + if (waterGround(r_thisCell, r_topCell)) + applyZone(r_thisCell, r_topCell, m_groundWaterZones, m_maxZone); + else if (groundRubble(r_thisCell, r_topCell)) + applyZone(r_thisCell, r_topCell, m_groundRubbleZones, m_maxZone); + else if (groundCliff(r_thisCell, r_topCell)) + applyZone(r_thisCell, r_topCell, m_groundCliffZones, m_maxZone); + } }