diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp index e806d40dc75..954cf11f495 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp @@ -2618,195 +2618,157 @@ void PathfindZoneManager::calculateZones( PathfindCell **map, PathfindLayer laye Int collapsedZones[maxZones]; collapsedZones[0] = 0; - i = 1; - while ( i < totalZones ) - { + for (i=1; i 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); } } - i = 0; - while ( i < m_zonesAllocated ) - { - m_groundCliffZones[i] = m_groundWaterZones[i] = m_groundRubbleZones[i] = m_terrainZones[i] = m_crusherZones[i] = m_hierarchicalZones[i] = i; - i++; - } + // Determine water/ground equivalent zones, and ground/cliff equivalent zones. + for (i=0; i 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); + 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 ( 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 - { - Bool notTerrainOrCrusher = TRUE; // if this is false, skip the if-else-ladder 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); - notTerrainOrCrusher = FALSE; - } + if (terrain(r_thisCell, r_leftCell)) { + 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); - notTerrainOrCrusher = FALSE; - } + if (crusherGround(r_thisCell, r_leftCell)) { + 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); - 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 ( notTerrainOrCrusher ) { + if (waterGround(r_thisCell, r_leftCell)) + applyZone(r_thisCell, r_leftCell, m_groundWaterZones, m_maxZone); + else if (groundRubble(r_thisCell, r_leftCell)) + applyZone(r_thisCell, r_leftCell, m_groundRubbleZones, m_maxZone); + else if (groundCliff(r_thisCell, r_leftCell)) + applyZone(r_thisCell, r_leftCell, m_groundCliffZones, m_maxZone); + } - } + } - } + } - if (j>globalBounds.lo.y && r_thisCell.getZone()!=map[i][j-1].getZone()) - { - const PathfindCell &r_topCell = map[i][j-1]; + 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 - { - Bool notTerrainOrCrusher = TRUE; // if this is false, skip the if-else-ladder below + if (r_thisCell.getType() == r_topCell.getType()) + 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); - notTerrainOrCrusher = FALSE; - } + if (terrain(r_thisCell, r_topCell)) { + 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); - notTerrainOrCrusher = FALSE; - } + if (crusherGround(r_thisCell, r_topCell)) { + 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); - 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 (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); + } - } + } - } + } - ++i; } + } - ++j; + //FLATTEN HIERARCHICAL ZONES + for (i=1; i