@@ -4724,7 +4724,6 @@ Bool Pathfinder::checkForMovement(const Object *obj, TCheckMovementInfo &info)
47244724 }
47254725
47264726 PathfindCell::CellFlags flags = cell->getFlags ();
4727- ObjectID posUnit = cell->getPosUnit ();
47284727 if ((flags == PathfindCell::UNIT_GOAL) || (flags == PathfindCell::UNIT_GOAL_OTHER_MOVING)) {
47294728 info.allyGoal = true ;
47304729 }
@@ -4733,6 +4732,7 @@ Bool Pathfinder::checkForMovement(const Object *obj, TCheckMovementInfo &info)
47334732 continue ; // Nobody is here, so it's ok.
47344733 }
47354734
4735+ ObjectID posUnit = cell->getPosUnit ();
47364736 if (posUnit == obj->getID ()) {
47374737 continue ; // we got it.
47384738 }
@@ -9969,10 +9969,14 @@ if (g_UT_startTiming) return false;
99699969#endif
99709970 if (!obj->isKindOf (KINDOF_DOZER) && !obj->isKindOf (KINDOF_HARVESTER)) {
99719971 // Harvesters & dozers want a clear path.
9972- if (!path->getBlockedByAlly ()) return FALSE ; // Only move units if it is required.
9972+ if (!path->getBlockedByAlly ()) {
9973+ return FALSE ; // Only move units if it is required.
9974+ }
99739975 }
99749976 LatchRestore<Int> recursiveDepth (m_moveAlliesDepth, m_moveAlliesDepth+1 );
9975- if (m_moveAlliesDepth > 2 ) return false ;
9977+ if (m_moveAlliesDepth > 2 ) {
9978+ return false ;
9979+ }
99769980
99779981 Bool centerInCell;
99789982 Int radius;
@@ -9991,46 +9995,58 @@ if (g_UT_startTiming) return false;
99919995 for (i=curCell.x -radius; i<curCell.x +numCellsAbove; i++) {
99929996 for (j=curCell.y -radius; j<curCell.y +numCellsAbove; j++) {
99939997 PathfindCell *cell = getCell (node->getLayer (), i, j);
9994- if (cell) {
9995- if (cell->getPosUnit ()==INVALID_ID) {
9998+ if (!cell) {
9999+ continue ; // Cell is not on the pathfinding grid
10000+ }
10001+
10002+ ObjectID unitId = cell->getPosUnit ();
10003+ if (unitId==INVALID_ID) {
10004+ continue ;
10005+ }
10006+
10007+ if (unitId==obj->getID ()) {
10008+ continue ; // It's us.
10009+ }
10010+
10011+ if (unitId==ignoreId) {
10012+ continue ; // It's the one we are ignoring.
10013+ }
10014+
10015+ Object *otherObj = TheGameLogic->findObjectByID (unitId);
10016+ if (!otherObj) {
10017+ continue ;
10018+ }
10019+
10020+ if (obj->getRelationship (otherObj)!=ALLIES) {
10021+ continue ; // Only move allies.
10022+ }
10023+
10024+ if (obj->isKindOf (KINDOF_INFANTRY) && otherObj->isKindOf (KINDOF_INFANTRY)) {
10025+ continue ; // infantry can walk through other infantry, so just let them.
10026+ }
10027+ if (obj->isKindOf (KINDOF_INFANTRY) && !otherObj->isKindOf (KINDOF_INFANTRY)) {
10028+ // If this is a general clear operation, don't let infantry push vehicles.
10029+ if (!path->getBlockedByAlly ()) {
999610030 continue ;
999710031 }
9998- if (cell->getPosUnit ()==obj->getID ()) {
9999- continue ; // It's us.
10000- }
10001- if (cell->getPosUnit ()==ignoreId) {
10002- continue ; // It's the one we are ignoring.
10003- }
10004- Object *otherObj = TheGameLogic->findObjectByID (cell->getPosUnit ());
10005- if (obj->getRelationship (otherObj)!=ALLIES) {
10006- continue ; // Only move allies.
10007- }
10008- if (otherObj==NULL ) continue ;
10009- if (obj->isKindOf (KINDOF_INFANTRY) && otherObj->isKindOf (KINDOF_INFANTRY)) {
10010- continue ; // infantry can walk through other infantry, so just let them.
10011- }
10012- if (obj->isKindOf (KINDOF_INFANTRY) && !otherObj->isKindOf (KINDOF_INFANTRY)) {
10013- // If this is a general clear operation, don't let infantry push vehicles.
10014- if (!path->getBlockedByAlly ()) continue ;
10015- }
10016- if ( otherObj && otherObj->getAI () && !otherObj->getAI ()->isMoving () )
10017- {
10018- if ( otherObj->getAI ()->isAttacking () )
10019- {
10020- continue ; // Don't move units that are attacking. [8/14/2003]
10021- }
10032+ }
1002210033
10023- // Kris: Patch 1.01 November 3, 2003
10024- // Black Lotus exploit fix -- moving while hacking.
10025- if ( otherObj->testStatus ( OBJECT_STATUS_IS_USING_ABILITY ) || otherObj->getAI ()->isBusy () )
10026- {
10027- continue ; // Packing or unpacking objects for example
10028- }
10034+ if (!otherObj->getAI () || otherObj->getAI ()->isMoving ()) {
10035+ continue ;
10036+ }
1002910037
10030- // DEBUG_LOG(("Moving ally"));
10031- otherObj->getAI ()->aiMoveAwayFromUnit (obj, CMD_FROM_AI);
10032- }
10038+ if (otherObj->getAI ()->isAttacking ()) {
10039+ continue ; // Don't move units that are attacking. [8/14/2003]
10040+ }
10041+
10042+ // Kris: Patch 1.01 November 3, 2003
10043+ // Black Lotus exploit fix -- moving while hacking.
10044+ if ( otherObj->testStatus ( OBJECT_STATUS_IS_USING_ABILITY ) || otherObj->getAI ()->isBusy () ) {
10045+ continue ; // Packing or unpacking objects for example
1003310046 }
10047+
10048+ // DEBUG_LOG(("Moving ally"));
10049+ otherObj->getAI ()->aiMoveAwayFromUnit (obj, CMD_FROM_AI);
1003410050 }
1003510051 }
1003610052 }
0 commit comments