(svn r19365) -Codechange: Move EnsureNoTrainOnTrackProc() to src/vehicle.cpp.

This commit is contained in:
alberth
2010-03-07 15:54:58 +00:00
parent 58012c6e6b
commit 29b79e03e8
5 changed files with 31 additions and 19 deletions

View File

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