Changeset - r15455:028ab2136a1a
[Not reviewed]
master
0 2 0
terkhen - 14 years ago 2010-07-10 20:15:35
terkhen@openttd.org
(svn r20114) -Add: Show an specific error message when trying to remove rail or build/convert/remove signals over nonexistant railways.
2 files changed with 12 insertions and 11 deletions:
0 comments (0 inline, 0 general)
src/lang/english.txt
Show inline comments
 
@@ -3546,12 +3546,13 @@ STR_ERROR_CROSSING_ON_ONEWAY_ROAD       
 
STR_ERROR_CROSSING_DISALLOWED                                   :{WHITE}Level crossings not allowed for this rail type
 
STR_ERROR_CAN_T_BUILD_SIGNALS_HERE                              :{WHITE}Can't build signals here...
 
STR_ERROR_CAN_T_BUILD_RAILROAD_TRACK                            :{WHITE}Can't build railway track here...
 
STR_ERROR_CAN_T_REMOVE_RAILROAD_TRACK                           :{WHITE}Can't remove railway track from here...
 
STR_ERROR_CAN_T_REMOVE_SIGNALS_FROM                             :{WHITE}Can't remove signals from here...
 
STR_ERROR_SIGNAL_CAN_T_CONVERT_SIGNALS_HERE                     :{WHITE}Can't convert signals here...
 
STR_ERROR_THERE_IS_NO_RAILROAD_TRACK                            :{WHITE}...there is no railway track
 

	
 
STR_ERROR_CAN_T_CONVERT_RAIL                                    :{WHITE}Can't convert railtype here...
 

	
 
# Road construction errors
 
STR_ERROR_MUST_REMOVE_ROAD_FIRST                                :{WHITE}Must remove road first
 
STR_ERROR_ONEWAY_ROADS_CAN_T_HAVE_JUNCTION                      :{WHITE}... one way roads can't have junctions
src/rail_cmd.cpp
Show inline comments
 
@@ -514,13 +514,13 @@ CommandCost CmdRemoveSingleRail(TileInde
 
	Owner owner = INVALID_OWNER;
 

	
 
	Train *v = NULL;
 

	
 
	switch (GetTileType(tile)) {
 
		case MP_ROAD: {
 
			if (!IsLevelCrossing(tile) || GetCrossingRailBits(tile) != trackbit) return CMD_ERROR;
 
			if (!IsLevelCrossing(tile) || GetCrossingRailBits(tile) != trackbit) return_cmd_error(STR_ERROR_THERE_IS_NO_RAILROAD_TRACK);
 

	
 
			if (_current_company != OWNER_WATER) {
 
				CommandCost ret = CheckTileOwnership(tile);
 
				if (ret.Failed()) return ret;
 
			}
 

	
 
@@ -542,25 +542,25 @@ CommandCost CmdRemoveSingleRail(TileInde
 
			}
 
			break;
 
		}
 

	
 
		case MP_RAILWAY: {
 
			TrackBits present;
 

	
 
			if (!IsPlainRail(tile)) return CMD_ERROR;
 
			/* There are no rails present at depots. */
 
			if (!IsPlainRail(tile)) return_cmd_error(STR_ERROR_THERE_IS_NO_RAILROAD_TRACK);
 

	
 
			if (_current_company != OWNER_WATER) {
 
				CommandCost ret = CheckTileOwnership(tile);
 
				if (ret.Failed()) return ret;
 
			}
 

	
 
			CommandCost ret = EnsureNoTrainOnTrack(tile, track);
 
			if (ret.Failed()) return ret;
 

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

	
 
			cost.AddCost(RailClearCost(GetRailType(tile)));
 

	
 
			/* Charge extra to remove signals on the track, if they are there */
 
			if (HasSignalOnTrack(tile, track))
 
@@ -587,13 +587,13 @@ CommandCost CmdRemoveSingleRail(TileInde
 
					SetTrackReservation(tile, GetRailReservationTrackBits(tile) & present);
 
				}
 
			}
 
			break;
 
		}
 

	
 
		default: return CMD_ERROR;
 
		default: return_cmd_error(STR_ERROR_THERE_IS_NO_RAILROAD_TRACK);
 
	}
 

	
 
	if (flags & DC_EXEC) {
 
		/* if we got that far, 'owner' variable is set correctly */
 
		assert(Company::IsValidID(owner));
 

	
 
@@ -920,13 +920,13 @@ CommandCost CmdBuildSingleSignal(TileInd
 
	if (sigtype > SIGTYPE_LAST) return CMD_ERROR;
 
	if (cycle_start > cycle_stop || cycle_stop > SIGTYPE_LAST) return CMD_ERROR;
 

	
 
	/* You can only build signals on plain rail tiles, and the selected track must exist */
 
	if (!ValParamTrackOrientation(track) || !IsPlainRailTile(tile) ||
 
			!HasTrack(tile, track)) {
 
		return CMD_ERROR;
 
		return_cmd_error(STR_ERROR_THERE_IS_NO_RAILROAD_TRACK);
 
	}
 
	CommandCost ret = EnsureNoTrainOnTrack(tile, track);
 
	if (ret.Failed()) return ret;
 

	
 
	/* Protect against invalid signal copying */
 
	if (p2 != 0 && (p2 & SignalOnTrack(track)) == 0) return CMD_ERROR;
 
@@ -1146,13 +1146,13 @@ static CommandCost CmdSignalTrackHelper(
 
	byte signal_density = GB(p2, 24, 8);
 

	
 
	if (p1 >= MapSize() || !ValParamTrackOrientation(track)) return CMD_ERROR;
 
	TileIndex end_tile = p1;
 
	if (signal_density == 0 || signal_density > 20) return CMD_ERROR;
 

	
 
	if (!IsPlainRailTile(tile)) return CMD_ERROR;
 
	if (!IsPlainRailTile(tile)) return_cmd_error(STR_ERROR_THERE_IS_NO_RAILROAD_TRACK);
 

	
 
	/* for vertical/horizontal tracks, double the given signals density
 
	 * since the original amount will be too dense (shorter tracks) */
 
	signal_density *= 2;
 

	
 
	Trackdir trackdir = TrackToTrackdir(track);
 
@@ -1281,16 +1281,16 @@ CommandCost CmdBuildSignalTrack(TileInde
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdRemoveSingleSignal(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
{
 
	Track track = Extract<Track, 0, 3>(p1);
 

	
 
	if (!ValParamTrackOrientation(track) ||
 
			!IsPlainRailTile(tile) ||
 
			!HasTrack(tile, track) ||
 
			!HasSignalOnTrack(tile, track)) {
 
	if (!ValParamTrackOrientation(track) || !IsPlainRailTile(tile) || !HasTrack(tile, track)) {
 
		return_cmd_error(STR_ERROR_THERE_IS_NO_RAILROAD_TRACK);
 
	}
 
	if (!HasSignalOnTrack(tile, track)) {
 
		return CMD_ERROR;
 
	}
 
	CommandCost ret = EnsureNoTrainOnTrack(tile, track);
 
	if (ret.Failed()) return ret;
 

	
 
	/* Only water can remove signals from anyone */
0 comments (0 inline, 0 general)