diff options
author | rubidium <rubidium@openttd.org> | 2008-04-11 08:14:43 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2008-04-11 08:14:43 +0000 |
commit | 62bdc381e7dffac0e4898ba733bbfc434fdd00b4 (patch) | |
tree | 7362e29c0c5e19a26316e830647db11101489af2 /src/train_cmd.cpp | |
parent | 3a0cb23548e3836f2481869c5a0d386af161956d (diff) | |
download | openttd-62bdc381e7dffac0e4898ba733bbfc434fdd00b4.tar.xz |
(svn r12657) -Codechange: add 'FindClosestDepot' to the vehicle class.
Diffstat (limited to 'src/train_cmd.cpp')
-rw-r--r-- | src/train_cmd.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 72a0e1784..3813178d5 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -2084,6 +2084,18 @@ static TrainFindDepotData FindClosestTrainDepot(Vehicle *v, int max_distance) return tfdd; } +bool Train::FindClosestDepot(TileIndex *location, DestinationID *destination, bool *reverse) +{ + TrainFindDepotData tfdd = FindClosestTrainDepot(this, 0); + if (tfdd.best_length == (uint)-1) return false; + + if (location != NULL) *location = tfdd.tile; + if (destination != NULL) *destination = GetDepotByTile(tfdd.tile)->index; + if (reverse != NULL) *reverse = tfdd.reverse; + + return true; +} + /** Send a train to a depot * @param tile unused * @param flags type of operation |