summaryrefslogtreecommitdiff
path: root/src/rail_cmd.cpp
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2010-03-07 15:54:58 +0000
committeralberth <alberth@openttd.org>2010-03-07 15:54:58 +0000
commit29b79e03e80f0e57f9af5ec4eeedc6de205f201b (patch)
tree5b37b2a70727b65ca2d7dd5be9c87c7aa57f01ef /src/rail_cmd.cpp
parent58012c6e6bde1dc6d480d928de24773f75957938 (diff)
downloadopenttd-29b79e03e80f0e57f9af5ec4eeedc6de205f201b.tar.xz
(svn r19365) -Codechange: Move EnsureNoTrainOnTrackProc() to src/vehicle.cpp.
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.