@@ -9967,10 +9967,14 @@ if (g_UT_startTiming) return false;
99679967#endif
99689968 if (!obj->isKindOf (KINDOF_DOZER) && !obj->isKindOf (KINDOF_HARVESTER)) {
99699969 // Harvesters & dozers want a clear path.
9970- if (!path->getBlockedByAlly ()) return FALSE ; // Only move units if it is required.
9970+ if (!path->getBlockedByAlly ()) {
9971+ return FALSE ; // Only move units if it is required.
9972+ }
99719973 }
99729974 LatchRestore<Int> recursiveDepth (m_moveAlliesDepth, m_moveAlliesDepth+1 );
9973- if (m_moveAlliesDepth > 2 ) return false ;
9975+ if (m_moveAlliesDepth > 2 ) {
9976+ return false ;
9977+ }
99749978
99759979 Bool centerInCell;
99769980 Int radius;
@@ -9989,46 +9993,58 @@ if (g_UT_startTiming) return false;
99899993 for (i=curCell.x -radius; i<curCell.x +numCellsAbove; i++) {
99909994 for (j=curCell.y -radius; j<curCell.y +numCellsAbove; j++) {
99919995 PathfindCell *cell = getCell (node->getLayer (), i, j);
9992- if (cell) {
9993- if (cell->getPosUnit ()==INVALID_ID) {
9996+ if (!cell) {
9997+ continue ; // Cell is not on the pathfinding grid
9998+ }
9999+
10000+ ObjectID unitId = cell->getPosUnit ();
10001+ if (unitId==INVALID_ID) {
10002+ continue ;
10003+ }
10004+
10005+ if (unitId==obj->getID ()) {
10006+ continue ; // It's us.
10007+ }
10008+
10009+ if (unitId==ignoreId) {
10010+ continue ; // It's the one we are ignoring.
10011+ }
10012+
10013+ Object *otherObj = TheGameLogic->findObjectByID (unitId);
10014+ if (!otherObj) {
10015+ continue ;
10016+ }
10017+
10018+ if (obj->getRelationship (otherObj)!=ALLIES) {
10019+ continue ; // Only move allies.
10020+ }
10021+
10022+ if (obj->isKindOf (KINDOF_INFANTRY) && otherObj->isKindOf (KINDOF_INFANTRY)) {
10023+ continue ; // infantry can walk through other infantry, so just let them.
10024+ }
10025+ if (obj->isKindOf (KINDOF_INFANTRY) && !otherObj->isKindOf (KINDOF_INFANTRY)) {
10026+ // If this is a general clear operation, don't let infantry push vehicles.
10027+ if (!path->getBlockedByAlly ()) {
999410028 continue ;
999510029 }
9996- if (cell->getPosUnit ()==obj->getID ()) {
9997- continue ; // It's us.
9998- }
9999- if (cell->getPosUnit ()==ignoreId) {
10000- continue ; // It's the one we are ignoring.
10001- }
10002- Object *otherObj = TheGameLogic->findObjectByID (cell->getPosUnit ());
10003- if (obj->getRelationship (otherObj)!=ALLIES) {
10004- continue ; // Only move allies.
10005- }
10006- if (otherObj==NULL ) continue ;
10007- if (obj->isKindOf (KINDOF_INFANTRY) && otherObj->isKindOf (KINDOF_INFANTRY)) {
10008- continue ; // infantry can walk through other infantry, so just let them.
10009- }
10010- if (obj->isKindOf (KINDOF_INFANTRY) && !otherObj->isKindOf (KINDOF_INFANTRY)) {
10011- // If this is a general clear operation, don't let infantry push vehicles.
10012- if (!path->getBlockedByAlly ()) continue ;
10013- }
10014- if ( otherObj && otherObj->getAI () && !otherObj->getAI ()->isMoving () )
10015- {
10016- if ( otherObj->getAI ()->isAttacking () )
10017- {
10018- continue ; // Don't move units that are attacking. [8/14/2003]
10019- }
10030+ }
1002010031
10021- // Kris: Patch 1.01 November 3, 2003
10022- // Black Lotus exploit fix -- moving while hacking.
10023- if ( otherObj->testStatus ( OBJECT_STATUS_IS_USING_ABILITY ) || otherObj->getAI ()->isBusy () )
10024- {
10025- continue ; // Packing or unpacking objects for example
10026- }
10032+ if (!otherObj->getAI () || otherObj->getAI ()->isMoving ()) {
10033+ continue ;
10034+ }
1002710035
10028- // DEBUG_LOG(("Moving ally"));
10029- otherObj->getAI ()->aiMoveAwayFromUnit (obj, CMD_FROM_AI);
10030- }
10036+ if (otherObj->getAI ()->isAttacking ()) {
10037+ continue ; // Don't move units that are attacking. [8/14/2003]
10038+ }
10039+
10040+ // Kris: Patch 1.01 November 3, 2003
10041+ // Black Lotus exploit fix -- moving while hacking.
10042+ if ( otherObj->testStatus ( OBJECT_STATUS_IS_USING_ABILITY ) || otherObj->getAI ()->isBusy () ) {
10043+ continue ; // Packing or unpacking objects for example
1003110044 }
10045+
10046+ // DEBUG_LOG(("Moving ally"));
10047+ otherObj->getAI ()->aiMoveAwayFromUnit (obj, CMD_FROM_AI);
1003210048 }
1003310049 }
1003410050 }
0 commit comments