Codechange: refactor FindClosestDepot to not use pointers, but return a struct
This commit is contained in:
@@ -2106,23 +2106,12 @@ static FindDepotData FindClosestTrainDepot(Train *v, int max_distance)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Locate the closest depot for this consist, and return the information to the caller.
|
||||
* @param[out] location If not \c nullptr and a depot is found, store its location in the given address.
|
||||
* @param[out] destination If not \c nullptr and a depot is found, store its index in the given address.
|
||||
* @param[out] reverse If not \c nullptr and a depot is found, store reversal information in the given address.
|
||||
* @return A depot has been found.
|
||||
*/
|
||||
bool Train::FindClosestDepot(TileIndex *location, DestinationID *destination, bool *reverse)
|
||||
ClosestDepot Train::FindClosestDepot()
|
||||
{
|
||||
FindDepotData tfdd = FindClosestTrainDepot(this, 0);
|
||||
if (tfdd.best_length == UINT_MAX) return false;
|
||||
if (tfdd.best_length == UINT_MAX) return ClosestDepot();
|
||||
|
||||
if (location != nullptr) *location = tfdd.tile;
|
||||
if (destination != nullptr) *destination = GetDepotIndex(tfdd.tile);
|
||||
if (reverse != nullptr) *reverse = tfdd.reverse;
|
||||
|
||||
return true;
|
||||
return ClosestDepot(tfdd.tile, GetDepotIndex(tfdd.tile), tfdd.reverse);
|
||||
}
|
||||
|
||||
/** Play a sound for a train leaving the station. */
|
||||
|
Reference in New Issue
Block a user