summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2010-03-07 14:00:53 +0000
committeralberth <alberth@openttd.org>2010-03-07 14:00:53 +0000
commit5881a80b6d445ce4d699ada1056e0dd7bf02f51c (patch)
tree04df69c3e441cd85187e1360fcb0650ec4d10bfa /src
parent384e870be2d13bc9465a740ed694bb84d42246de (diff)
downloadopenttd-5881a80b6d445ce4d699ada1056e0dd7bf02f51c.tar.xz
(svn r19363) -Codechange: Remove use of _error_message global from TerraformTile_Track.
Diffstat (limited to 'src')
-rw-r--r--src/rail_cmd.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp
index c989c10fc..439d33b3b 100644
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -2723,10 +2723,10 @@ static VehicleEnterTileStatus VehicleEnter_Track(Vehicle *u, TileIndex tile, int
*/
static CommandCost TestAutoslopeOnRailTile(TileIndex tile, uint flags, uint z_old, Slope tileh_old, uint z_new, Slope tileh_new, TrackBits rail_bits)
{
- if (!_settings_game.construction.build_on_slopes || !AutoslopeEnabled()) return CMD_ERROR;
+ if (!_settings_game.construction.build_on_slopes || !AutoslopeEnabled()) return_cmd_error(STR_ERROR_MUST_REMOVE_RAILROAD_TRACK);
/* Is the slope-rail_bits combination valid in general? I.e. is it safe to call GetRailFoundation() ? */
- if (CheckRailSlope(tileh_new, rail_bits, TRACK_BIT_NONE, tile).Failed()) return CMD_ERROR;
+ if (CheckRailSlope(tileh_new, rail_bits, TRACK_BIT_NONE, tile).Failed()) return_cmd_error(STR_ERROR_MUST_REMOVE_RAILROAD_TRACK);
/* Get the slopes on top of the foundations */
z_old += ApplyFoundationToSlope(GetRailFoundation(tileh_old, rail_bits), &tileh_old);
@@ -2740,13 +2740,15 @@ static CommandCost TestAutoslopeOnRailTile(TileIndex tile, uint flags, uint z_ol
case TRACK_BIT_UPPER: track_corner = CORNER_N; break;
/* Surface slope must not be changed */
- default: return (((z_old != z_new) || (tileh_old != tileh_new)) ? CMD_ERROR : CommandCost(EXPENSES_CONSTRUCTION, _price[PR_BUILD_FOUNDATION]));
+ default:
+ if (z_old != z_new || tileh_old != tileh_new) return_cmd_error(STR_ERROR_MUST_REMOVE_RAILROAD_TRACK);
+ return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_BUILD_FOUNDATION]);
}
/* The height of the track_corner must not be changed. The rest ensures GetRailFoundation() already. */
z_old += GetSlopeZInCorner(RemoveHalftileSlope(tileh_old), track_corner);
z_new += GetSlopeZInCorner(RemoveHalftileSlope(tileh_new), track_corner);
- if (z_old != z_new) return CMD_ERROR;
+ if (z_old != z_new) return_cmd_error(STR_ERROR_MUST_REMOVE_RAILROAD_TRACK);
CommandCost cost = CommandCost(EXPENSES_CONSTRUCTION, _price[PR_BUILD_FOUNDATION]);
/* Make the ground dirty, if surface slope has changed */
@@ -2767,10 +2769,9 @@ static CommandCost TerraformTile_Track(TileIndex tile, DoCommandFlag flags, uint
/* Is there flat water on the lower halftile, that must be cleared expensively? */
bool was_water = (GetRailGroundType(tile) == RAIL_GROUND_WATER && IsSlopeWithOneCornerRaised(tileh_old));
- _error_message = STR_ERROR_MUST_REMOVE_RAILROAD_TRACK;
-
/* First test autoslope. However if it succeeds we still have to test the rest, because non-autoslope terraforming is cheaper. */
CommandCost autoslope_result = TestAutoslopeOnRailTile(tile, flags, z_old, tileh_old, z_new, tileh_new, rail_bits);
+ autoslope_result.SetGlobalErrorMessage();
/* When there is only a single horizontal/vertical track, one corner can be terraformed. */
Corner allowed_corner;