Skip to content

Commit

Permalink
* fix #2083 (units ignored ETA failures when <= 200 elmos from goal, …
Browse files Browse the repository at this point in the history
…even if goal unreachable)
  • Loading branch information
kloot committed Sep 5, 2010
1 parent c6606fa commit 351aef6
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions rts/Sim/MoveTypes/GroundMoveType.cpp
Expand Up @@ -374,27 +374,28 @@ void CGroundMoveType::SlowUpdate()
return;
}

if ((progressState == Active) && (pathId != 0) && (etaFailures > (65536 / turnRate))) {
if (owner->pos.SqDistance2D(goalPos) > (200.0f * 200.0f)) {
// too many ETA failures and not within acceptable range of
// our goal, request a new path from our current position
#if (DEBUG_OUTPUT == 1)
logOutput.Print("[CGMT::SU] ETA failure for unit %i", owner->id);
#endif

StopEngine();
StartEngine();
if (progressState == Active) {
if (pathId != 0) {
if (etaFailures > (65536 / turnRate)) {
// we have a path but are not moving (based on the ETA failure count)
#if (DEBUG_OUTPUT == 1)
logOutput.Print("[CGMT::SU] unit %i has path %i but %i ETA failures", owner->id, pathId, etaFailures);
#endif

StopEngine();
StartEngine();
}
} else {
if (gs->frameNum > restartDelay) {
// we want to be moving but don't have a path
#if (DEBUG_OUTPUT == 1)
logOutput.Print("[CGMT::SU] unit %i has no path", owner->id);
#endif
StartEngine();
}
}
}

// If the action is active, but not the engine and the
// re-try-delay has passed, then start the engine.
if (progressState == Active && (pathId == 0) && (gs->frameNum > restartDelay)) {
#if (DEBUG_OUTPUT == 1)
logOutput.Print("[CGMT::SU] restart engine for unit %i", owner->id);
#endif
StartEngine();
}

if (!flying) {
// just kindly move it into the map again instead of deleting
Expand Down

1 comment on commit 351aef6

@slogic
Copy link
Contributor

@slogic slogic commented on 351aef6 Sep 5, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much appreciated. This bug makes AI behave ugly when it builds factory in front of obstacle.

Please sign in to comment.