# HG changeset patch # User terkhen # Date 2010-07-10 20:15:35 # Node ID 028ab2136a1a86da41463a183b4bb750d2cbf0f3 # Parent a4eeacd020ee2596c72be244f3557a751266a75f (svn r20114) -Add: Show an specific error message when trying to remove rail or build/convert/remove signals over nonexistant railways. diff --git a/src/lang/english.txt b/src/lang/english.txt --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -3549,6 +3549,7 @@ STR_ERROR_CAN_T_BUILD_RAILROAD_TRACK 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... diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp --- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -517,7 +517,7 @@ CommandCost CmdRemoveSingleRail(TileInde 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); @@ -545,8 +545,8 @@ CommandCost CmdRemoveSingleRail(TileInde 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); @@ -557,7 +557,7 @@ CommandCost CmdRemoveSingleRail(TileInde 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))); @@ -590,7 +590,7 @@ CommandCost CmdRemoveSingleRail(TileInde break; } - default: return CMD_ERROR; + default: return_cmd_error(STR_ERROR_THERE_IS_NO_RAILROAD_TRACK); } if (flags & DC_EXEC) { @@ -923,7 +923,7 @@ CommandCost CmdBuildSingleSignal(TileInd /* 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; @@ -1149,7 +1149,7 @@ static CommandCost CmdSignalTrackHelper( 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) */ @@ -1284,10 +1284,10 @@ CommandCost CmdRemoveSingleSignal(TileIn { Track track = Extract(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);