Changeset - r3284:d4747e3ae95e
[Not reviewed]
master
0 1 0
peter1138 - 19 years ago 2006-03-21 21:11:41
peter1138@openttd.org
(svn r3998) - Fix: When removing rail track from a while where only X and Y (/ and \) pieces exist, explicitly update signals in both directions.
1 file changed with 12 insertions and 1 deletions:
0 comments (0 inline, 0 general)
rail_cmd.c
Show inline comments
 
@@ -360,12 +360,13 @@ int32 CmdBuildSingleRail(int x, int y, u
 
int32 CmdRemoveSingleRail(int x, int y, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	Track track = (Track)p2;
 
	TrackBits trackbit;
 
	TileIndex tile;
 
	int32 cost = _price.remove_rail;
 
	bool crossing = false;
 

	
 
	if (!ValParamTrackOrientation(p2)) return CMD_ERROR;
 
	trackbit = TrackToTrackBits(track);
 

	
 
	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
 

	
 
@@ -408,12 +409,13 @@ int32 CmdRemoveSingleRail(int x, int y, 
 
					!EnsureNoVehicle(tile)) {
 
				return CMD_ERROR;
 
			}
 

	
 
			present = GetTrackBits(tile);
 
			if ((present & trackbit) == 0) return CMD_ERROR;
 
			if (present == (TRACK_BIT_X | TRACK_BIT_Y)) crossing = true;
 

	
 
			/* Charge extra to remove signals on the track, if they are there */
 
			if (HasSignalOnTrack(tile, track))
 
				cost += DoCommand(x, y, track, 0, flags, CMD_REMOVE_SIGNALS);
 

	
 
			if (flags & DC_EXEC) {
 
@@ -429,13 +431,22 @@ int32 CmdRemoveSingleRail(int x, int y, 
 

	
 
		default: return CMD_ERROR;
 
	}
 

	
 
	if (flags & DC_EXEC) {
 
		MarkTileDirtyByTile(tile);
 
		SetSignalsOnBothDir(tile, track);
 
		if (crossing) {
 
			/* crossing is set when only TRACK_BIT_X and TRACK_BIT_Y are set. As we
 
			 * are removing one of these pieces, we'll need to update signals for
 
			 * both directions explicitly, as after the track is removed it won't
 
			 * 'connect' with the other piece. */
 
			SetSignalsOnBothDir(tile, TRACK_X);
 
			SetSignalsOnBothDir(tile, TRACK_Y);
 
		} else {
 
			SetSignalsOnBothDir(tile, track);
 
		}
 
	}
 

	
 
	return cost;
 
}
 

	
 
static const struct {
0 comments (0 inline, 0 general)