Changeset - r14217:40beee5d2e82
[Not reviewed]
master
0 1 0
michi_cc - 15 years ago 2010-01-11 00:02:14
michi_cc@openttd.org
(svn r18778) -Fix [FS#3483]: [YAPP] Remove a special check for two-sided signals when reserving a path as this causes trains to get stuck in front of them.
1 file changed with 0 insertions and 14 deletions:
0 comments (0 inline, 0 general)
src/train_cmd.cpp
Show inline comments
 
@@ -2830,62 +2830,48 @@ static Track ChooseTrainTrack(Train *v, 
 
 *
 
 * @param v The vehicle
 
 * @param mark_as_stuck Should the train be marked as stuck on a failed reservation?
 
 * @param first_tile_okay True if no path should be reserved if the current tile is a safe position.
 
 * @return True if a path could be reserved.
 
 */
 
bool TryPathReserve(Train *v, bool mark_as_stuck, bool first_tile_okay)
 
{
 
	assert(v->IsFrontEngine());
 

	
 
	/* We have to handle depots specially as the track follower won't look
 
	 * at the depot tile itself but starts from the next tile. If we are still
 
	 * inside the depot, a depot reservation can never be ours. */
 
	if (v->track == TRACK_BIT_DEPOT) {
 
		if (HasDepotReservation(v->tile)) {
 
			if (mark_as_stuck) MarkTrainAsStuck(v);
 
			return false;
 
		} else {
 
			/* Depot not reserved, but the next tile might be. */
 
			TileIndex next_tile = TileAddByDiagDir(v->tile, GetRailDepotDirection(v->tile));
 
			if (HasReservedTracks(next_tile, DiagdirReachesTracks(GetRailDepotDirection(v->tile)))) return false;
 
		}
 
	}
 

	
 
	/* Special check if we are in front of a two-sided conventional signal. */
 
	DiagDirection dir = TrainExitDir(v->direction, v->track);
 
	TileIndex next_tile = TileAddByDiagDir(v->tile, dir);
 
	if (IsTileType(next_tile, MP_RAILWAY) && HasReservedTracks(next_tile, DiagdirReachesTracks(dir))) {
 
		/* Can have only one reserved trackdir. */
 
		Trackdir td = FindFirstTrackdir(TrackBitsToTrackdirBits(GetReservedTrackbits(next_tile)) & DiagdirReachesTrackdirs(dir));
 
		if (HasSignalOnTrackdir(next_tile, td) && HasSignalOnTrackdir(next_tile, ReverseTrackdir(td)) &&
 
				!IsPbsSignal(GetSignalType(next_tile, TrackdirToTrack(td)))) {
 
			/* Signal already reserved, is not ours. */
 
			if (mark_as_stuck) MarkTrainAsStuck(v);
 
			return false;
 
		}
 
	}
 

	
 
	Vehicle *other_train = NULL;
 
	PBSTileInfo origin = FollowTrainReservation(v, &other_train);
 
	/* The path we are driving on is alread blocked by some other train.
 
	 * This can only happen in certain situations when mixing path and
 
	 * block signals or when changing tracks and/or signals.
 
	 * Exit here as doing any further reservations will probably just
 
	 * make matters worse. */
 
	if (other_train != NULL && other_train->index != v->index) {
 
		if (mark_as_stuck) MarkTrainAsStuck(v);
 
		return false;
 
	}
 
	/* If we have a reserved path and the path ends at a safe tile, we are finished already. */
 
	if (origin.okay && (v->tile != origin.tile || first_tile_okay)) {
 
		/* Can't be stuck then. */
 
		if (HasBit(v->flags, VRF_TRAIN_STUCK)) SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
		ClrBit(v->flags, VRF_TRAIN_STUCK);
 
		return true;
 
	}
 

	
 
	/* If we are in a depot, tentativly reserve the depot. */
 
	if (v->track == TRACK_BIT_DEPOT) {
 
		SetDepotReservation(v->tile, true);
 
		if (_settings_client.gui.show_track_reservation) MarkTileDirtyByTile(v->tile);
 
	}
0 comments (0 inline, 0 general)