Skip to content

Commit 2a4595a

Browse files
Maullerxezon
authored andcommitted
chore(pathfinder): Change open braces to be K&R style in PathfindZoneManager::calculateZones() (TheSuperHackers#2360)
1 parent f545655 commit 2a4595a

1 file changed

Lines changed: 26 additions & 50 deletions

File tree

GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp

Lines changed: 26 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -2619,11 +2619,9 @@ void PathfindZoneManager::calculateZones( PathfindCell **map, PathfindLayer laye
26192619
collapsedZones[0] = 0;
26202620

26212621
i = 1;
2622-
while ( i < totalZones )
2623-
{
2622+
while ( i < totalZones ) {
26242623
Int zone = zoneEquivalency[ i ];
2625-
if (zone == i)
2626-
{
2624+
if (zone == i) {
26272625
collapsedZones[ i ] = m_maxZone;
26282626
++m_maxZone;
26292627
}
@@ -2635,11 +2633,9 @@ void PathfindZoneManager::calculateZones( PathfindCell **map, PathfindLayer laye
26352633

26362634
// Now map the zones in the map back into the collapsed zones.
26372635
j=globalBounds.lo.y;
2638-
while( j<=globalBounds.hi.y )
2639-
{
2636+
while( j<=globalBounds.hi.y ) {
26402637
i=globalBounds.lo.x;
2641-
while( i<=globalBounds.hi.x )
2642-
{
2638+
while( i<=globalBounds.hi.x ) {
26432639
PathfindCell &cell = map[i][j];
26442640
cell.setZone(collapsedZones[cell.getZone()]);
26452641
++i;
@@ -2648,22 +2644,19 @@ void PathfindZoneManager::calculateZones( PathfindCell **map, PathfindLayer laye
26482644
}
26492645

26502646
i = 0;
2651-
while ( i <= LAYER_LAST )
2652-
{
2647+
while ( i <= LAYER_LAST ) {
26532648
PathfindLayer &r_thisLayer = layers[i];
26542649

26552650
Int zone = collapsedZones[r_thisLayer.getZone()];
2656-
if (zone == 0)
2657-
{
2651+
if (zone == 0) {
26582652
zone = m_maxZone;
26592653
m_maxZone++;
26602654
}
26612655

26622656
r_thisLayer.setZone( zone );
26632657
r_thisLayer.applyZone();
26642658

2665-
if (!r_thisLayer.isUnused() && !r_thisLayer.isDestroyed())
2666-
{
2659+
if (!r_thisLayer.isUnused() && !r_thisLayer.isDestroyed()) {
26672660
ICoord2D ndx;
26682661
r_thisLayer.getStartCellIndex(&ndx);
26692662
setBridge(ndx.x, ndx.y, true);
@@ -2676,10 +2669,8 @@ void PathfindZoneManager::calculateZones( PathfindCell **map, PathfindLayer laye
26762669

26772670
allocateZones();
26782671

2679-
for (xBlock=0; xBlock<xCount; xBlock++)
2680-
{
2681-
for (yBlock=0; yBlock<yCount; yBlock++)
2682-
{
2672+
for (xBlock=0; xBlock<xCount; xBlock++) {
2673+
for (yBlock=0; yBlock<yCount; yBlock++) {
26832674
IRegion2D bounds;
26842675
bounds.lo.x = globalBounds.lo.x + xBlock*ZONE_BLOCK_SIZE;
26852676
bounds.lo.y = globalBounds.lo.y + yBlock*ZONE_BLOCK_SIZE;
@@ -2697,52 +2688,43 @@ void PathfindZoneManager::calculateZones( PathfindCell **map, PathfindLayer laye
26972688
}
26982689

26992690
i = 0;
2700-
while ( i < m_zonesAllocated )
2701-
{
2691+
while ( i < m_zonesAllocated ) {
27022692
m_groundCliffZones[i] = m_groundWaterZones[i] = m_groundRubbleZones[i] = m_terrainZones[i] = m_crusherZones[i] = m_hierarchicalZones[i] = i;
27032693
i++;
27042694
}
27052695

27062696
REGISTER UnsignedInt maxZone = m_maxZone;
27072697
j=globalBounds.lo.y;
2708-
while( j <= globalBounds.hi.y )
2709-
{
2698+
while( j <= globalBounds.hi.y ) {
27102699
i=globalBounds.lo.x;
2711-
while( i <= globalBounds.hi.x )
2712-
{
2700+
while( i <= globalBounds.hi.x ) {
27132701
PathfindCell &r_thisCell = map[i][j];
27142702

27152703
if ( (r_thisCell.getConnectLayer() > LAYER_GROUND) &&
2716-
(r_thisCell.getType() == PathfindCell::CELL_CLEAR) )
2717-
{
2704+
(r_thisCell.getType() == PathfindCell::CELL_CLEAR) ) {
27182705
PathfindLayer *layer = layers + r_thisCell.getConnectLayer();
27192706
resolveZones(r_thisCell.getZone(), layer->getZone(), m_hierarchicalZones, maxZone);
27202707
}
27212708

2722-
if ( i > globalBounds.lo.x && r_thisCell.getZone() != map[i-1][j].getZone() )
2723-
{
2709+
if ( i > globalBounds.lo.x && r_thisCell.getZone() != map[i-1][j].getZone() ) {
27242710
const PathfindCell &r_leftCell = map[i-1][j];
27252711

27262712
if (r_thisCell.getType() == r_leftCell.getType())
27272713
applyZone(r_thisCell, r_leftCell, m_hierarchicalZones, maxZone);//if this is true, skip all the ones below
2728-
else
2729-
{
2714+
else {
27302715
Bool notTerrainOrCrusher = TRUE; // if this is false, skip the if-else-ladder below
27312716

2732-
if (terrain(r_thisCell, r_leftCell))
2733-
{
2717+
if (terrain(r_thisCell, r_leftCell)) {
27342718
applyZone(r_thisCell, r_leftCell, m_terrainZones, maxZone);
27352719
notTerrainOrCrusher = FALSE;
27362720
}
27372721

2738-
if (crusherGround(r_thisCell, r_leftCell))
2739-
{
2722+
if (crusherGround(r_thisCell, r_leftCell)) {
27402723
applyZone(r_thisCell, r_leftCell, m_crusherZones, maxZone);
27412724
notTerrainOrCrusher = FALSE;
27422725
}
27432726

2744-
if ( notTerrainOrCrusher )
2745-
{
2727+
if ( notTerrainOrCrusher ) {
27462728
if (waterGround(r_thisCell, r_leftCell))
27472729
applyZone(r_thisCell, r_leftCell, m_groundWaterZones, maxZone);
27482730
else if (groundRubble(r_thisCell, r_leftCell))
@@ -2755,24 +2737,20 @@ void PathfindZoneManager::calculateZones( PathfindCell **map, PathfindLayer laye
27552737

27562738
}
27572739

2758-
if (j>globalBounds.lo.y && r_thisCell.getZone()!=map[i][j-1].getZone())
2759-
{
2740+
if (j>globalBounds.lo.y && r_thisCell.getZone()!=map[i][j-1].getZone()) {
27602741
const PathfindCell &r_topCell = map[i][j-1];
27612742

27622743
if (r_thisCell.getType() == r_topCell.getType())
27632744
applyZone(r_thisCell, r_topCell, m_hierarchicalZones, maxZone);
2764-
else
2765-
{
2745+
else {
27662746
Bool notTerrainOrCrusher = TRUE; // if this is false, skip the if-else-ladder below
27672747

2768-
if (terrain(r_thisCell, r_topCell))
2769-
{
2748+
if (terrain(r_thisCell, r_topCell)) {
27702749
applyZone(r_thisCell, r_topCell, m_terrainZones, maxZone);
27712750
notTerrainOrCrusher = FALSE;
27722751
}
27732752

2774-
if (crusherGround(r_thisCell, r_topCell))
2775-
{
2753+
if (crusherGround(r_thisCell, r_topCell)) {
27762754
applyZone(r_thisCell, r_topCell, m_crusherZones, maxZone);
27772755
notTerrainOrCrusher = FALSE;
27782756
}
@@ -2798,8 +2776,8 @@ void PathfindZoneManager::calculateZones( PathfindCell **map, PathfindLayer laye
27982776
{
27992777
i = 1;
28002778
REGISTER Int zone;
2801-
while ( i < maxZone )
2802-
{ // Flatten hierarchical zones.
2779+
while ( i < maxZone ) {
2780+
// Flatten hierarchical zones.
28032781
zone = m_hierarchicalZones[i];
28042782
m_hierarchicalZones[i] = m_hierarchicalZones[ zone ];
28052783
++i;
@@ -2818,14 +2796,12 @@ void PathfindZoneManager::calculateZones( PathfindCell **map, PathfindLayer laye
28182796
QueryPerformanceCounter((LARGE_INTEGER *)&endTime64);
28192797
timeToUpdate = ((double)(endTime64-startTime64) / (double)(freq64));
28202798

2821-
if ( updateSamples < 400 )
2822-
{
2799+
if ( updateSamples < 400 ) {
28232800
averageTimeToUpdate = ((averageTimeToUpdate * updateSamples) + timeToUpdate) / (updateSamples + 1.0f);
28242801
updateSamples++;
28252802
DEBUG_LOG(("computing...: %f", averageTimeToUpdate));
28262803
}
2827-
else if ( updateSamples == 400 )
2828-
{
2804+
else if ( updateSamples == 400 ) {
28292805
DEBUG_LOG((" =============DONE============= Average time to calculate zones: %f", averageTimeToUpdate));
28302806
DEBUG_LOG((" Percent of baseline : %f", averageTimeToUpdate/0.003335f));
28312807
updateSamples = 777;

0 commit comments

Comments
 (0)