summaryrefslogtreecommitdiff
path: root/src/rail_cmd.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/rail_cmd.cpp')
-rw-r--r--src/rail_cmd.cpp20
1 files changed, 3 insertions, 17 deletions
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp
index 439d33b3b..19c044e31 100644
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -144,32 +144,18 @@ static const byte _track_sloped_sprites[14] = {
* 11uuuudd => rail depot
*/
-
-Vehicle *EnsureNoTrainOnTrackProc(Vehicle *v, void *data)
-{
- TrackBits rail_bits = *(TrackBits *)data;
-
- if (v->type != VEH_TRAIN) return NULL;
-
- Train *t = Train::From(v);
- if ((t->track != rail_bits) && !TracksOverlap(t->track | rail_bits)) return NULL;
-
- _error_message = STR_ERROR_TRAIN_IN_THE_WAY + v->type;
- return v;
-}
-
/**
* Tests if a vehicle interacts with the specified track.
- * All track bits interact except parallel TRACK_BIT_HORZ or TRACK_BIT_VERT.
+ * All track bits interact except parallel #TRACK_BIT_HORZ or #TRACK_BIT_VERT.
*
* @param tile The tile.
* @param track The track.
+ * @return \c true if no train that interacts, is found. \c false if a train is found.
*/
static bool EnsureNoTrainOnTrack(TileIndex tile, Track track)
{
TrackBits rail_bits = TrackToTrackBits(track);
-
- return !HasVehicleOnPos(tile, &rail_bits, &EnsureNoTrainOnTrackProc);
+ return EnsureNoTrainOnTrackBits(tile, rail_bits);
}
/** Check that the new track bits may be built.