Core/Movement: Fix some issues with ConfusedMovementGenerator from recent changes.

- Z position was not set if LOS-check failed, and thereafter causing a crash when trying to move to a uninitialized z-choord.
- Also fixes bad coords in water

Closes #6124
This commit is contained in:
kaelima
2012-04-09 15:00:52 +02:00
parent 4c961ff393
commit 1f1e243bfa
@@ -59,25 +59,25 @@ void ConfusedMovementGenerator<T>::Initialize(T &unit)
if ((is_water && !is_water_ok) || (!is_water && !is_land_ok))
{
//! Ignore bad generated path. Use the current or previous position.
i_waypoints[idx][0] = idx > 0 ? i_waypoints[idx-1][0] : x;
i_waypoints[idx][1] = idx > 0 ? i_waypoints[idx-1][1] : y;
//! Cannot use coordinates outside our InhabitType. Use the current or previous position.
wanderX = idx > 0 ? i_waypoints[idx-1][0] : x;
wanderY = idx > 0 ? i_waypoints[idx-1][1] : y;
}
}
else
{
//! Trying to access path outside line of sight. Skip this by using the current or previous position.
wanderX = idx > 0 ? i_waypoints[idx-1][0] : x;
wanderY = idx > 0 ? i_waypoints[idx-1][1] : y;
}
unit.UpdateAllowedPositionZ(wanderX, wanderY, z);
//! Positions are now fine - apply them to this waypoint
//! Positions are fine - apply them to this waypoint
i_waypoints[idx][0] = wanderX;
i_waypoints[idx][1] = wanderY;
i_waypoints[idx][2] = z;
}
else
{
//! Ignore bad generated path. Use the current or previous position.
i_waypoints[idx][0] = idx > 0 ? i_waypoints[idx-1][0] : x;
i_waypoints[idx][1] = idx > 0 ? i_waypoints[idx-1][1] : y;
}
}
unit.StopMoving();
unit.SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_CONFUSED);