summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormichi_cc <michi_cc@openttd.org>2012-12-26 12:45:19 +0000
committermichi_cc <michi_cc@openttd.org>2012-12-26 12:45:19 +0000
commit799a74509918f06ef69f8d900d33b0392c1d1aa3 (patch)
tree7c07893e5e8f847f637b2968a1ced5a03905d981 /src
parent1e30884201debc1b6dc1af0859e5b99c39592df2 (diff)
downloadopenttd-799a74509918f06ef69f8d900d33b0392c1d1aa3.tar.xz
(svn r24855) -Fix [FS#5405]: Don't send aircraft to depots that are out of range of the next destination.
Diffstat (limited to 'src')
-rw-r--r--src/aircraft_cmd.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp
index 36110654a..d273b8f36 100644
--- a/src/aircraft_cmd.cpp
+++ b/src/aircraft_cmd.cpp
@@ -136,6 +136,11 @@ static StationID FindNearestHangar(const Aircraft *v)
/* v->tile can't be used here, when aircraft is flying v->tile is set to 0 */
uint distance = DistanceSquare(vtile, st->airport.tile);
+ if (v->acache.cached_max_range_sqr != 0) {
+ /* Check if our current destination can be reached from the depot airport. */
+ const Station *cur_dest = GetTargetAirportIfValid(v);
+ if (cur_dest != NULL && DistanceSquare(st->airport.tile, cur_dest->airport.tile) > v->acache.cached_max_range_sqr) continue;
+ }
if (distance < best || index == INVALID_STATION) {
best = distance;
index = st->index;