Changeset - r25092:55e5b7d911fa
[Not reviewed]
master
0 1 0
Charles Pigott - 4 years ago 2021-03-31 08:27:25
charlespigott@googlemail.com
Fix #8803: Only auto-remove signals when rail can be built (#8904)
1 file changed with 4 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/rail_cmd.cpp
Show inline comments
 
@@ -456,12 +456,16 @@ CommandCost CmdBuildSingleRail(TileIndex
 
			if (!IsCompatibleRail(GetRailType(tile), railtype)) return_cmd_error(STR_ERROR_IMPOSSIBLE_TRACK_COMBINATION);
 

	
 
			ret = CheckTrackCombination(tile, trackbit, flags);
 
			if (ret.Succeeded()) ret = EnsureNoTrainOnTrack(tile, track);
 
			if (ret.Failed()) return ret;
 

	
 
			ret = CheckRailSlope(tileh, trackbit, GetTrackBits(tile), tile);
 
			if (ret.Failed()) return ret;
 
			cost.AddCost(ret);
 

	
 
			if (HasSignals(tile) && TracksOverlap(GetTrackBits(tile) | TrackToTrackBits(track))) {
 
				/* If adding the new track causes any overlap, all signals must be removed first */
 
				if (!auto_remove_signals) return_cmd_error(STR_ERROR_MUST_REMOVE_SIGNALS_FIRST);
 

	
 
				for (Track track_it = TRACK_BEGIN; track_it < TRACK_END; track_it++) {
 
					if (HasTrack(tile, track_it) && HasSignalOnTrack(tile, track_it)) {
 
@@ -469,16 +473,12 @@ CommandCost CmdBuildSingleRail(TileIndex
 
						if (ret_remove_signals.Failed()) return ret_remove_signals;
 
						cost.AddCost(ret_remove_signals);
 
					}
 
				}
 
			}
 

	
 
			ret = CheckRailSlope(tileh, trackbit, GetTrackBits(tile), tile);
 
			if (ret.Failed()) return ret;
 
			cost.AddCost(ret);
 

	
 
			/* If the rail types don't match, try to convert only if engines of
 
			 * the new rail type are not powered on the present rail type and engines of
 
			 * the present rail type are powered on the new rail type. */
 
			if (GetRailType(tile) != railtype && !HasPowerOnRail(railtype, GetRailType(tile))) {
 
				if (HasPowerOnRail(GetRailType(tile), railtype)) {
 
					ret = DoCommand(tile, tile, railtype, flags, CMD_CONVERT_RAIL);
0 comments (0 inline, 0 general)