summaryrefslogtreecommitdiff
path: root/src/aircraft_cmd.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-04-11 08:14:43 +0000
committerrubidium <rubidium@openttd.org>2008-04-11 08:14:43 +0000
commitaa8a5b2c39331fbcbcd6ef2291de8466ac9cdedd (patch)
tree7362e29c0c5e19a26316e830647db11101489af2 /src/aircraft_cmd.cpp
parent23465fa7c49e273352f1e283294a25466585ac4f (diff)
downloadopenttd-aa8a5b2c39331fbcbcd6ef2291de8466ac9cdedd.tar.xz
(svn r12657) -Codechange: add 'FindClosestDepot' to the vehicle class.
Diffstat (limited to 'src/aircraft_cmd.cpp')
-rw-r--r--src/aircraft_cmd.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp
index 83d452b12..0fc9b3a3a 100644
--- a/src/aircraft_cmd.cpp
+++ b/src/aircraft_cmd.cpp
@@ -546,6 +546,25 @@ CommandCost CmdStartStopAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32
return CommandCost();
}
+bool Aircraft::FindClosestDepot(TileIndex *location, DestinationID *destination, bool *reverse)
+{
+ const Station *st = GetStation(this->u.air.targetairport);
+ /* If the station is not a valid airport or if it has no hangars */
+ if (!st->IsValid() || st->airport_tile == 0 || st->Airport()->nof_depots == 0) {
+ /* the aircraft has to search for a hangar on its own */
+ StationID station = FindNearestHangar(this);
+
+ if (station == INVALID_STATION) return false;
+
+ st = GetStation(station);
+ }
+
+ if (location != NULL) *location = st->xy;
+ if (destination != NULL) *destination = st->index;
+
+ return true;
+}
+
/** Send an aircraft to the hangar.
* @param tile unused
* @param flags for command type