1
0
mirror of https://github.com/OpenTTD/OpenTTD.git synced 2025-08-21 05:29:11 +00:00

(svn r12657) -Codechange: add 'FindClosestDepot' to the vehicle class.

This commit is contained in:
rubidium
2008-04-11 08:14:43 +00:00
parent 3a0cb23548
commit 62bdc381e7
9 changed files with 73 additions and 4 deletions

View File

@@ -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