|
@@ -340,7 +340,7 @@ CommandCost CmdBuildSingleRail(TileIndex
|
|
|
}
|
|
|
|
|
|
ret = CheckRailSlope(tileh, trackbit, GetTrackBits(tile), tile);
|
|
|
if (CmdFailed(ret)) return ret;
|
|
|
if (ret.Failed()) return ret;
|
|
|
cost.AddCost(ret);
|
|
|
|
|
|
/* If the rail types don't match, try to convert only if engines of
|
|
@@ -349,7 +349,7 @@ CommandCost CmdBuildSingleRail(TileIndex
|
|
|
if (GetRailType(tile) != railtype && !HasPowerOnRail(railtype, GetRailType(tile))) {
|
|
|
if (HasPowerOnRail(GetRailType(tile), railtype)) {
|
|
|
ret = DoCommand(tile, tile, railtype, flags, CMD_CONVERT_RAIL);
|
|
|
if (CmdFailed(ret)) return ret;
|
|
|
if (ret.Failed()) return ret;
|
|
|
cost.AddCost(ret);
|
|
|
} else {
|
|
|
return CMD_ERROR;
|
|
@@ -415,11 +415,11 @@ CommandCost CmdBuildSingleRail(TileIndex
|
|
|
bool water_ground = IsTileType(tile, MP_WATER) && IsSlopeWithOneCornerRaised(tileh);
|
|
|
|
|
|
ret = CheckRailSlope(tileh, trackbit, TRACK_BIT_NONE, tile);
|
|
|
if (CmdFailed(ret)) return ret;
|
|
|
if (ret.Failed()) return ret;
|
|
|
cost.AddCost(ret);
|
|
|
|
|
|
ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
|
|
|
if (CmdFailed(ret)) return ret;
|
|
|
if (ret.Failed()) return ret;
|
|
|
cost.AddCost(ret);
|
|
|
|
|
|
if (water_ground) {
|
|
@@ -581,7 +581,7 @@ bool FloodHalftile(TileIndex t)
|
|
|
TrackBits to_remove = lower_track & rail_bits;
|
|
|
if (to_remove != 0) {
|
|
|
_current_company = OWNER_WATER;
|
|
|
if (CmdFailed(DoCommand(t, 0, FIND_FIRST_BIT(to_remove), DC_EXEC, CMD_REMOVE_SINGLE_RAIL))) return flooded; // not yet floodable
|
|
|
if (DoCommand(t, 0, FIND_FIRST_BIT(to_remove), DC_EXEC, CMD_REMOVE_SINGLE_RAIL).Failed()) return flooded; // not yet floodable
|
|
|
flooded = true;
|
|
|
rail_bits = rail_bits & ~to_remove;
|
|
|
if (rail_bits == 0) {
|
|
@@ -693,14 +693,14 @@ static CommandCost CmdRailTrackHelper(Ti
|
|
|
TileIndex end_tile = p1;
|
|
|
Trackdir trackdir = TrackToTrackdir(track);
|
|
|
|
|
|
if (CmdFailed(ValidateAutoDrag(&trackdir, tile, end_tile))) return CMD_ERROR;
|
|
|
if (ValidateAutoDrag(&trackdir, tile, end_tile).Failed()) return CMD_ERROR;
|
|
|
|
|
|
if (flags & DC_EXEC) SndPlayTileFx(SND_20_SPLAT_2, tile);
|
|
|
|
|
|
for (;;) {
|
|
|
ret = DoCommand(tile, railtype, TrackdirToTrack(trackdir), flags, remove ? CMD_REMOVE_SINGLE_RAIL : CMD_BUILD_SINGLE_RAIL);
|
|
|
|
|
|
if (CmdFailed(ret)) {
|
|
|
if (ret.Failed()) {
|
|
|
if (_error_message != STR_ERROR_ALREADY_BUILT && !remove) break;
|
|
|
_error_message = INVALID_STRING_ID;
|
|
|
} else {
|
|
@@ -792,7 +792,7 @@ CommandCost CmdBuildTrainDepot(TileIndex
|
|
|
}
|
|
|
|
|
|
CommandCost cost = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
|
|
|
if (CmdFailed(cost)) return CMD_ERROR;
|
|
|
if (cost.Failed()) return CMD_ERROR;
|
|
|
|
|
|
if (MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST);
|
|
|
|
|
@@ -1082,7 +1082,7 @@ static CommandCost CmdSignalTrackHelper(
|
|
|
* since the original amount will be too dense (shorter tracks) */
|
|
|
signal_density *= 2;
|
|
|
|
|
|
if (CmdFailed(ValidateAutoDrag(&trackdir, tile, end_tile))) return CMD_ERROR;
|
|
|
if (ValidateAutoDrag(&trackdir, tile, end_tile).Failed()) return CMD_ERROR;
|
|
|
|
|
|
track = TrackdirToTrack(trackdir); // trackdir might have changed, keep track in sync
|
|
|
Trackdir start_trackdir = trackdir;
|
|
@@ -1138,7 +1138,7 @@ static CommandCost CmdSignalTrackHelper(
|
|
|
ret = DoCommand(tile, p1, signals, flags, remove ? CMD_REMOVE_SIGNALS : CMD_BUILD_SIGNALS);
|
|
|
|
|
|
/* Be user-friendly and try placing signals as much as possible */
|
|
|
if (CmdSucceeded(ret)) {
|
|
|
if (ret.Succeeded()) {
|
|
|
err = false;
|
|
|
total_cost.AddCost(ret);
|
|
|
}
|
|
@@ -1521,7 +1521,7 @@ static CommandCost ClearTile_Track(TileI
|
|
|
while (tracks != TRACK_BIT_NONE) {
|
|
|
Track track = RemoveFirstTrack(&tracks);
|
|
|
ret = DoCommand(tile, 0, track, flags, CMD_REMOVE_SINGLE_RAIL);
|
|
|
if (CmdFailed(ret)) return CMD_ERROR;
|
|
|
if (ret.Failed()) return CMD_ERROR;
|
|
|
cost.AddCost(ret);
|
|
|
}
|
|
|
|
|
@@ -2454,7 +2454,7 @@ static CommandCost TestAutoslopeOnRailTi
|
|
|
if (!_settings_game.construction.build_on_slopes || !AutoslopeEnabled()) return CMD_ERROR;
|
|
|
|
|
|
/* Is the slope-rail_bits combination valid in general? I.e. is it safe to call GetRailFoundation() ? */
|
|
|
if (CmdFailed(CheckRailSlope(tileh_new, rail_bits, TRACK_BIT_NONE, tile))) return CMD_ERROR;
|
|
|
if (CheckRailSlope(tileh_new, rail_bits, TRACK_BIT_NONE, tile).Failed()) return CMD_ERROR;
|
|
|
|
|
|
/* Get the slopes on top of the foundations */
|
|
|
z_old += ApplyFoundationToSlope(GetRailFoundation(tileh_old, rail_bits), &tileh_old);
|