Changeset - r9830:a397a0f96cdf
[Not reviewed]
master
0 1 0
smatz - 16 years ago 2008-08-03 11:28:35
smatz@openttd.org
(svn r13973) -Codechange [YAPP]: Improve the behavior when changing signals to not cause stale reservations. (michi_cc)
1 file changed with 15 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/rail_cmd.cpp
Show inline comments
 
@@ -877,6 +877,15 @@ CommandCost CmdBuildSingleSignal(TileInd
 
	}
 

	
 
	if (flags & DC_EXEC) {
 
		Vehicle *v = NULL;
 
		/* The new/changed signal could block our path. As this can lead to
 
		 * stale reservations, we clear the path reservation here and try
 
		 * to redo it later on. */
 
		if (HasReservedTracks(tile, TrackToTrackBits(track))) {
 
			v = GetTrainForReservation(tile, track);
 
			if (v != NULL) FreeTrainTrackReservation(v);
 
		}
 

	
 
		if (!HasSignals(tile)) {
 
			/* there are no signals at all on this tile yet */
 
			SetHasSignals(tile, true);
 
@@ -938,6 +947,7 @@ CommandCost CmdBuildSingleSignal(TileInd
 
		MarkTileDirtyByTile(tile);
 
		AddTrackToSignalBuffer(tile, track, _current_player);
 
		YapfNotifyTrackLayoutChange(tile, track);
 
		if (v != NULL) TryPathReserve(v, true);
 
	}
 

	
 
	return cost;
 
@@ -1166,6 +1176,10 @@ CommandCost CmdRemoveSingleSignal(TileIn
 

	
 
	/* Do it? */
 
	if (flags & DC_EXEC) {
 
		Vehicle *v = NULL;
 
		if (HasReservedTracks(tile, TrackToTrackBits(track))) {
 
			v = GetTrainForReservation(tile, track);
 
		}
 
		SetPresentSignals(tile, GetPresentSignals(tile) & ~SignalOnTrack(track));
 

	
 
		/* removed last signal from tile? */
 
@@ -1177,6 +1191,7 @@ CommandCost CmdRemoveSingleSignal(TileIn
 

	
 
		AddTrackToSignalBuffer(tile, track, GetTileOwner(tile));
 
		YapfNotifyTrackLayoutChange(tile, track);
 
		if (v != NULL) TryPathReserve(v, false);
 

	
 
		MarkTileDirtyByTile(tile);
 
	}
0 comments (0 inline, 0 general)