@@ -5522,7 +5522,7 @@ Int Pathfinder::examineNeighboringCells(PathfindCell *parentCell, PathfindCell *
55225522 newCell = getCell (parentCell->getLayer (), newCellCoord.x , newCellCoord.y );
55235523
55245524 // check if cell is on the map
5525- if (newCell == NULL )
5525+ if (! newCell)
55265526 continue ;
55275527
55285528 Bool notZonePassable = false ;
@@ -5539,18 +5539,9 @@ Int Pathfinder::examineNeighboringCells(PathfindCell *parentCell, PathfindCell *
55395539
55405540 // check if this neighbor cell is already on the open (waiting to be tried)
55415541 // or closed (already tried) lists
5542- Bool onList = false ;
5543- if (newCell->hasInfo ()) {
5544- if (newCell->getOpen () || newCell->getClosed ())
5545- {
5546- // already on one of the lists
5547- onList = true ;
5548- }
5549- }
5550- if (onList) {
5551- // we have already examined this one, so continue.
5542+ if ( newCell->hasInfo () && (newCell->getOpen () || newCell->getClosed ()) )
55525543 continue ;
5553- }
5544+
55545545 if (i>=firstDiagonal) {
55555546 // make sure one of the adjacent sides is open.
55565547 if (!neighborFlags[adjacent[i-4 ]] && !neighborFlags[adjacent[i-3 ]]) {
@@ -5575,24 +5566,20 @@ Int Pathfinder::examineNeighboringCells(PathfindCell *parentCell, PathfindCell *
55755566 continue ;
55765567 }
55775568
5578- Bool movementValid = true ;
5569+ Bool movementValid = validMovementPosition (isCrusher, locomotorSet. getValidSurfaces (), newCell, parentCell) ;
55795570 Bool dozerHack = false ;
5580- if (validMovementPosition ( isCrusher, locomotorSet.getValidSurfaces (), newCell, parentCell )) {
5581- } else {
5582- movementValid = false ;
5583- if (obj->isKindOf (KINDOF_DOZER)) {
5584- if (newCell->getType ()==PathfindCell::CELL_OBSTACLE) {
5585- Object *obstacle = TheGameLogic->findObjectByID (newCell->getObstacleID ());
5586- if (obstacle && !(obj->getRelationship (obstacle)==ENEMIES)) {
5587- movementValid = true ;
5588- dozerHack = true ;
5589- }
5590- }
5591- }
5592- if (!movementValid && !m_isTunneling) {
5593- continue ;
5571+ if (!movementValid && obj->isKindOf (KINDOF_DOZER) && newCell->getType () == PathfindCell::CELL_OBSTACLE) {
5572+ Object* obstacle = TheGameLogic->findObjectByID (newCell->getObstacleID ());
5573+ if (obstacle && !(obj->getRelationship (obstacle) == ENEMIES)) {
5574+ movementValid = true ;
5575+ dozerHack = true ;
55945576 }
55955577 }
5578+
5579+ if (!movementValid && !m_isTunneling) {
5580+ continue ;
5581+ }
5582+
55965583 if (!dozerHack)
55975584 neighborFlags[i] = true ;
55985585
@@ -5615,10 +5602,12 @@ Int Pathfinder::examineNeighboringCells(PathfindCell *parentCell, PathfindCell *
56155602 }
56165603 movementValid = false ;
56175604 }
5605+
56185606 if (movementValid && !newCell->getPinched ()) {
56195607 // Note to self - only turn off tunneling after check for movement.jba.
56205608 m_isTunneling = false ;
56215609 }
5610+
56225611 if (!newCell->hasInfo ()) {
56235612 if (!newCell->allocateInfo (newCellCoord)) {
56245613 // Out of cells for pathing...
@@ -5631,6 +5620,7 @@ Int Pathfinder::examineNeighboringCells(PathfindCell *parentCell, PathfindCell *
56315620 if (info.allyMoving && dx<10 && dy<10 ) {
56325621 newCostSoFar += 3 *COST_DIAGONAL;
56335622 }
5623+
56345624 if (newCell->getType () == PathfindCell::CELL_CLIFF && !newCell->getPinched () ) {
56355625 Coord3D fromPos;
56365626 fromPos.x = parentCell->getXIndex () * PATHFIND_CELL_SIZE_F ;
@@ -5648,15 +5638,14 @@ Int Pathfinder::examineNeighboringCells(PathfindCell *parentCell, PathfindCell *
56485638 } else if (newCell->getPinched ()) {
56495639 newCostSoFar += COST_ORTHOGONAL;
56505640 }
5641+
56515642 newCell->setBlockedByAlly (false );
5652- if (info.allyFixedCount ) {
5653- if (canPathThroughUnits) {
5654- newCostSoFar += 3 *COST_DIAGONAL*info.allyFixedCount ;
5655- } else {
5643+ if (info.allyFixedCount >0 ) {
5644+ newCostSoFar += 3 *COST_DIAGONAL*info.allyFixedCount ;
5645+ if (!canPathThroughUnits)
56565646 newCell->setBlockedByAlly (true );
5657- newCostSoFar += 3 *COST_DIAGONAL*info.allyFixedCount ;
5658- }
56595647 }
5648+
56605649 Int costRemaining = 0 ;
56615650 if (goalCell) {
56625651 if (attackDistance == 0 ) {
@@ -5666,7 +5655,8 @@ Int Pathfinder::examineNeighboringCells(PathfindCell *parentCell, PathfindCell *
56665655 dy = newCellCoord.y - goalCell->getYIndex ();
56675656 costRemaining = COST_ORTHOGONAL*sqrt (dx*dx + dy*dy);
56685657 costRemaining -= attackDistance/2 ;
5669- if (costRemaining<0 ) costRemaining=0 ;
5658+ if (costRemaining<0 )
5659+ costRemaining=0 ;
56705660 if (info.allyGoal ) {
56715661 if (obj->isKindOf (KINDOF_VEHICLE)) {
56725662 newCostSoFar += 3 *COST_ORTHOGONAL;
@@ -5677,26 +5667,21 @@ Int Pathfinder::examineNeighboringCells(PathfindCell *parentCell, PathfindCell *
56775667 }
56785668 }
56795669 }
5670+
56805671 if (notZonePassable) {
56815672 newCostSoFar += 100 *COST_ORTHOGONAL;
56825673 }
5674+
56835675 if (newCell->getType ()==PathfindCell::CELL_OBSTACLE) {
56845676 newCostSoFar += 100 *COST_ORTHOGONAL;
56855677 }
5686- // check if this neighbor cell is already on the open (waiting to be tried)
5687- // or closed (already tried) lists
5688- if (onList)
5689- {
5690- // already on one of the lists - if existing costSoFar is less,
5691- // the new cell is on a longer path, so skip it
5692- if (newCell->getCostSoFar () <= newCostSoFar)
5693- continue ;
5694- }
5678+
56955679 if (m_isTunneling) {
56965680 if (!validMovementPosition ( isCrusher, locomotorSet.getValidSurfaces (), newCell, parentCell )) {
56975681 newCostSoFar += 10 *COST_ORTHOGONAL;
56985682 }
56995683 }
5684+
57005685 newCell->setCostSoFar (newCostSoFar);
57015686 // keep track of path we're building - point back to cell we moved here from
57025687 newCell->setParentCell (parentCell) ;
0 commit comments