summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2010-03-20 17:58:24 +0000
committeralberth <alberth@openttd.org>2010-03-20 17:58:24 +0000
commit05d705e077cb247ee31e0a61bc410fe2b9183c6a (patch)
tree7c96d4ce3b519c3edc7def2e1769c2ae4d82a334
parenta901ab53925857a3f6ae70a045a9f0ec6362107e (diff)
downloadopenttd-05d705e077cb247ee31e0a61bc410fe2b9183c6a.tar.xz
(svn r19494) -Codechange: Remove _error_message.
-rw-r--r--src/ai/api/ai_object.cpp1
-rw-r--r--src/aircraft_cmd.cpp2
-rw-r--r--src/autoreplace_cmd.cpp1
-rw-r--r--src/command.cpp8
-rw-r--r--src/command_func.h1
-rw-r--r--src/command_type.h17
-rw-r--r--src/industry_cmd.cpp7
-rw-r--r--src/order_cmd.cpp15
-rw-r--r--src/rail_cmd.cpp20
-rw-r--r--src/road_cmd.cpp14
-rw-r--r--src/roadveh_cmd.cpp3
-rw-r--r--src/ship_cmd.cpp2
-rw-r--r--src/station_cmd.cpp37
-rw-r--r--src/timetable_cmd.cpp4
-rw-r--r--src/train_cmd.cpp6
-rw-r--r--src/tunnelbridge_cmd.cpp18
-rw-r--r--src/unmovable_cmd.cpp3
-rw-r--r--src/vehicle.cpp1
-rw-r--r--src/vehicle_cmd.cpp4
-rw-r--r--src/water_cmd.cpp7
-rw-r--r--src/waypoint_cmd.cpp10
21 files changed, 8 insertions, 173 deletions
diff --git a/src/ai/api/ai_object.cpp b/src/ai/api/ai_object.cpp
index e137faf1e..ed36719c6 100644
--- a/src/ai/api/ai_object.cpp
+++ b/src/ai/api/ai_object.cpp
@@ -214,7 +214,6 @@ bool AIObject::DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint cmd, const c
/* We failed; set the error and bail out */
if (res.Failed()) {
- res.SetGlobalErrorMessage();
SetLastError(AIError::StringToError(res.GetErrorMessage()));
return false;
}
diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp
index 3ff480c55..3b6712239 100644
--- a/src/aircraft_cmd.cpp
+++ b/src/aircraft_cmd.cpp
@@ -394,7 +394,6 @@ CommandCost CmdSellAircraft(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
if (v == NULL) return CMD_ERROR;
CommandCost ret = CheckOwnership(v->owner);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
if (!v->IsStoppedInDepot()) return_cmd_error(STR_ERROR_AIRCRAFT_MUST_BE_STOPPED);
@@ -473,7 +472,6 @@ CommandCost CmdRefitAircraft(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
if (v == NULL) return CMD_ERROR;
CommandCost ret = CheckOwnership(v->owner);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
if (!v->IsStoppedInDepot()) return_cmd_error(STR_ERROR_AIRCRAFT_MUST_BE_STOPPED);
diff --git a/src/autoreplace_cmd.cpp b/src/autoreplace_cmd.cpp
index e4caba619..aeee94ff2 100644
--- a/src/autoreplace_cmd.cpp
+++ b/src/autoreplace_cmd.cpp
@@ -620,7 +620,6 @@ CommandCost CmdAutoreplaceVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1
if (v == NULL) return CMD_ERROR;
CommandCost ret = CheckOwnership(v->owner);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
if (!v->IsInDepot()) return CMD_ERROR;
diff --git a/src/command.cpp b/src/command.cpp
index 73d8901c5..aad1bba76 100644
--- a/src/command.cpp
+++ b/src/command.cpp
@@ -29,8 +29,6 @@
#include "table/strings.h"
-StringID _error_message; ///< Global error message. @see CommandCost::SetGlobalErrorMessage()
-
CommandProc CmdBuildRailroadTrack;
CommandProc CmdRemoveRailroadTrack;
CommandProc CmdBuildSingleRail;
@@ -400,8 +398,6 @@ CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, DoCommandFlag flags,
/* Chop of any CMD_MSG or other flags; we don't need those here */
CommandProc *proc = _command_proc_table[cmd & CMD_ID_MASK].proc;
- if (_docommand_recursive == 0) _error_message = INVALID_STRING_ID;
-
_docommand_recursive++;
/* only execute the test call if it's toplevel, or we're not execing. */
@@ -431,7 +427,6 @@ CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, DoCommandFlag flags,
res = proc(tile, flags, p1, p2, text);
if (res.Failed()) {
error:
- res.SetGlobalErrorMessage();
_docommand_recursive--;
return res;
}
@@ -506,8 +501,6 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallbac
CommandCost res = DoCommandPInternal(tile, p1, p2, cmd, callback, text, my_cmd, estimate_only);
if (res.Failed()) {
- res.SetGlobalErrorMessage();
-
/* Only show the error when it's for us. */
StringID error_part1 = GB(cmd, 16, 16);
if (estimate_only || (IsLocalCompany() && error_part1 != 0 && my_cmd)) {
@@ -559,7 +552,6 @@ CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd,
_docommand_recursive = 1;
/* Reset the state. */
- _error_message = INVALID_STRING_ID;
_additional_cash_required = 0;
/* Get pointer to command handler */
diff --git a/src/command_func.h b/src/command_func.h
index 15c2611a8..8bda62693 100644
--- a/src/command_func.h
+++ b/src/command_func.h
@@ -57,7 +57,6 @@ void NetworkSend_Command(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, Comma
#endif /* ENABLE_NETWORK */
extern Money _additional_cash_required;
-extern StringID _error_message;
/**
* Checks if a integer value belongs to a command.
diff --git a/src/command_type.h b/src/command_type.h
index 37b52a94c..a9827f68d 100644
--- a/src/command_type.h
+++ b/src/command_type.h
@@ -90,16 +90,6 @@ public:
}
/**
- * Sets the global error message *if* this class has one.
- * @see _error_message
- */
- FORCEINLINE void SetGlobalErrorMessage() const
- {
- extern StringID _error_message;
- if (this->message != INVALID_STRING_ID) _error_message = this->message;
- }
-
- /**
* Makes this #CommandCost behave like an error command.
* @param message The error message.
*/
@@ -112,15 +102,12 @@ public:
/**
* Returns the error message of a command
- * @return the error message, if succeeded INVALID_STRING_ID
+ * @return the error message, if succeeded #INVALID_STRING_ID
*/
StringID GetErrorMessage() const
{
- extern StringID _error_message;
-
if (this->success) return INVALID_STRING_ID;
- if (this->message != INVALID_STRING_ID) return this->message;
- return _error_message;
+ return this->message;
}
/**
diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp
index 999194762..27ba3f364 100644
--- a/src/industry_cmd.cpp
+++ b/src/industry_cmd.cpp
@@ -1339,7 +1339,6 @@ static CommandCost CheckIfIndustryTilesAreFree(TileIndex tile, const IndustryTil
}
} else {
CommandCost ret = EnsureNoVehicleOnGround(cur_tile);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
if (MayHaveBridgeAbove(cur_tile) && IsBridgeAbove(cur_tile)) return_cmd_error(STR_ERROR_SITE_UNSUITABLE);
@@ -1353,7 +1352,6 @@ static CommandCost CheckIfIndustryTilesAreFree(TileIndex tile, const IndustryTil
if (HasBit(its->callback_mask, CBM_INDT_SHAPE_CHECK)) {
custom_shape = true;
CommandCost ret = PerformIndustryTileSlopeCheck(tile, cur_tile, its, type, gfx, itspec_index);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
} else {
Slope tileh = GetTileSlope(cur_tile, NULL);
@@ -1798,7 +1796,6 @@ CommandCost CmdBuildIndustry(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
*/
tile = RandomTile();
CommandCost ret = CreateNewIndustryHelper(tile, it, flags, indspec, RandomRange(indspec->num_table), p2, founder, &ind);
- ret.SetGlobalErrorMessage();
if (ret.Succeeded()) break;
}
}
@@ -1811,16 +1808,13 @@ CommandCost CmdBuildIndustry(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
if (num >= count) return CMD_ERROR;
CommandCost ret = CommandCost(STR_ERROR_SITE_UNSUITABLE);
- ret.SetGlobalErrorMessage();
do {
if (--count < 0) return ret;
if (--num < 0) num = indspec->num_table - 1;
ret = CheckIfIndustryTilesAreFree(tile, itt[num], num, it);
- ret.SetGlobalErrorMessage();
} while (ret.Failed());
ret = CreateNewIndustryHelper(tile, it, flags, indspec, num, p2, _current_company, &ind);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
}
@@ -1849,7 +1843,6 @@ static Industry *CreateNewIndustry(TileIndex tile, IndustryType type)
Industry *i = NULL;
CommandCost ret = CreateNewIndustryHelper(tile, type, DC_EXEC, indspec, RandomRange(indspec->num_table), seed, OWNER_NONE, &i);
assert(i != NULL || ret.Failed());
- ret.SetGlobalErrorMessage();
return i;
}
diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp
index 8735fec6c..7bbcbb86b 100644
--- a/src/order_cmd.cpp
+++ b/src/order_cmd.cpp
@@ -471,7 +471,6 @@ CommandCost CmdInsertOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
if (v == NULL) return CMD_ERROR;
CommandCost ret = CheckOwnership(v->owner);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
/* Check if the inserted order is to the correct destination (owner, type),
@@ -483,7 +482,6 @@ CommandCost CmdInsertOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
if (st->owner != OWNER_NONE) {
CommandCost ret = CheckOwnership(st->owner);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
}
@@ -532,7 +530,6 @@ CommandCost CmdInsertOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
if (st == NULL) return CMD_ERROR;
CommandCost ret = CheckOwnership(st->owner);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
if (!CanVehicleUseStation(v, st) || !st->airport.HasHangar()) {
@@ -544,7 +541,6 @@ CommandCost CmdInsertOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
if (dp == NULL) return CMD_ERROR;
CommandCost ret = CheckOwnership(GetTileOwner(dp->xy));
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
switch (v->type) {
@@ -585,7 +581,6 @@ CommandCost CmdInsertOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
if (!(wp->facilities & FACIL_TRAIN)) return_cmd_error(STR_ERROR_CAN_T_ADD_ORDER);
CommandCost ret = CheckOwnership(wp->owner);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
break;
}
@@ -594,7 +589,6 @@ CommandCost CmdInsertOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
if (!(wp->facilities & FACIL_DOCK)) return_cmd_error(STR_ERROR_CAN_T_ADD_ORDER);
if (wp->owner != OWNER_NONE) {
CommandCost ret = CheckOwnership(wp->owner);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
}
break;
@@ -756,7 +750,6 @@ CommandCost CmdDeleteOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
if (v == NULL) return CMD_ERROR;
CommandCost ret = CheckOwnership(v->owner);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
/* If we did not select an order, we maybe want to de-clone the orders */
@@ -826,7 +819,6 @@ CommandCost CmdSkipToOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
if (v == NULL || sel_ord == v->cur_order_index || sel_ord >= v->GetNumOrders() || v->GetNumOrders() < 2) return CMD_ERROR;
CommandCost ret = CheckOwnership(v->owner);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
if (flags & DC_EXEC) {
@@ -867,7 +859,6 @@ CommandCost CmdMoveOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
if (v == NULL) return CMD_ERROR;
CommandCost ret = CheckOwnership(v->owner);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
/* Don't make senseless movements */
@@ -951,7 +942,6 @@ CommandCost CmdModifyOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
if (v == NULL) return CMD_ERROR;
CommandCost ret = CheckOwnership(v->owner);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
/* Is it a valid order? */
@@ -1178,7 +1168,6 @@ CommandCost CmdCloneOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
if (dst == NULL) return CMD_ERROR;
CommandCost ret = CheckOwnership(dst->owner);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
switch (p2) {
@@ -1189,7 +1178,6 @@ CommandCost CmdCloneOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
if (src == NULL || dst->type != src->type || dst == src) return CMD_ERROR;
CommandCost ret = CheckOwnership(src->owner);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
/* Trucks can't share orders with busses (and visa versa) */
@@ -1232,7 +1220,6 @@ CommandCost CmdCloneOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
if (src == NULL || dst->type != src->type || dst == src) return CMD_ERROR;
CommandCost ret = CheckOwnership(src->owner);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
/* Trucks can't copy all the orders from busses (and visa versa),
@@ -1310,7 +1297,6 @@ CommandCost CmdOrderRefit(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
if (v == NULL) return CMD_ERROR;
CommandCost ret = CheckOwnership(v->owner);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
Order *order = v->GetOrder(order_number);
@@ -1466,7 +1452,6 @@ CommandCost CmdRestoreOrderIndex(TileIndex tile, DoCommandFlag flags, uint32 p1,
if (v == NULL) return CMD_ERROR;
CommandCost ret = CheckOwnership(v->owner);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
if (serv_int != GetServiceIntervalClamped(serv_int, v->owner) || cur_ord >= v->GetNumOrders()) return CMD_ERROR;
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp
index 61b004a10..ce48c9e37 100644
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -370,7 +370,6 @@ CommandCost CmdBuildSingleRail(TileIndex tile, DoCommandFlag flags, uint32 p1, u
switch (GetTileType(tile)) {
case MP_RAILWAY: {
CommandCost ret = CheckTileOwnership(tile);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
if (!IsPlainRail(tile)) return CMD_ERROR;
@@ -379,7 +378,6 @@ CommandCost CmdBuildSingleRail(TileIndex tile, DoCommandFlag flags, uint32 p1, u
ret = CheckTrackCombination(tile, trackbit, flags);
if (ret.Succeeded()) ret = EnsureNoTrainOnTrack(tile, track);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
ret = CheckRailSlope(tileh, trackbit, GetTrackBits(tile), tile);
@@ -415,7 +413,6 @@ CommandCost CmdBuildSingleRail(TileIndex tile, DoCommandFlag flags, uint32 p1, u
#undef M
CommandCost ret = EnsureNoVehicleOnGround(tile);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
if (IsNormalRoad(tile)) {
@@ -523,13 +520,11 @@ CommandCost CmdRemoveSingleRail(TileIndex tile, DoCommandFlag flags, uint32 p1,
if (_current_company != OWNER_WATER) {
CommandCost ret = CheckTileOwnership(tile);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
}
if (!(flags & DC_BANKRUPT)) {
CommandCost ret = EnsureNoVehicleOnGround(tile);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
}
@@ -553,12 +548,10 @@ CommandCost CmdRemoveSingleRail(TileIndex tile, DoCommandFlag flags, uint32 p1,
if (_current_company != OWNER_WATER) {
CommandCost ret = CheckTileOwnership(tile);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
}
CommandCost ret = EnsureNoTrainOnTrack(tile, track);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
present = GetTrackBits(tile);
@@ -758,7 +751,6 @@ static CommandCost CmdRailTrackHelper(TileIndex tile, DoCommandFlag flags, uint3
Trackdir trackdir = TrackToTrackdir(track);
CommandCost ret = ValidateAutoDrag(&trackdir, tile, end_tile);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
if (flags & DC_EXEC) SndPlayTileFx(SND_20_SPLAT_2, tile);
@@ -770,7 +762,6 @@ static CommandCost CmdRailTrackHelper(TileIndex tile, DoCommandFlag flags, uint3
if (ret.Failed()) {
last_error = ret;
- last_error.SetGlobalErrorMessage();
if (last_error.GetErrorMessage() != STR_ERROR_ALREADY_BUILT && !remove) {
if (HasBit(p2, 8)) return last_error;
break;
@@ -924,14 +915,12 @@ CommandCost CmdBuildSingleSignal(TileIndex tile, DoCommandFlag flags, uint32 p1,
return CMD_ERROR;
}
CommandCost ret = EnsureNoTrainOnTrack(tile, track);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
/* Protect against invalid signal copying */
if (p2 != 0 && (p2 & SignalOnTrack(track)) == 0) return CMD_ERROR;
ret = CheckTileOwnership(tile);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
{
@@ -1157,7 +1146,6 @@ static CommandCost CmdSignalTrackHelper(TileIndex tile, DoCommandFlag flags, uin
signal_density *= 2;
CommandCost ret = ValidateAutoDrag(&trackdir, tile, end_tile);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
track = TrackdirToTrack(trackdir); // trackdir might have changed, keep track in sync
@@ -1222,7 +1210,6 @@ static CommandCost CmdSignalTrackHelper(TileIndex tile, DoCommandFlag flags, uin
total_cost.AddCost(ret);
} else {
last_error = ret;
- last_error.SetGlobalErrorMessage();
}
}
@@ -1293,13 +1280,11 @@ CommandCost CmdRemoveSingleSignal(TileIndex tile, DoCommandFlag flags, uint32 p1
return CMD_ERROR;
}
CommandCost ret = EnsureNoTrainOnTrack(tile, track);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
/* Only water can remove signals from anyone */
if (_current_company != OWNER_WATER) {
CommandCost ret = CheckTileOwnership(tile);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
}
@@ -1563,7 +1548,6 @@ CommandCost CmdConvertRail(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
}
}
- error.SetGlobalErrorMessage();
return (cost.GetCost() == 0) ? error : cost;
}
@@ -1571,12 +1555,10 @@ static CommandCost RemoveTrainDepot(TileIndex tile, DoCommandFlag flags)
{
if (_current_company != OWNER_WATER) {
CommandCost ret = CheckTileOwnership(tile);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
}
CommandCost ret = EnsureNoVehicleOnGround(tile);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
if (flags & DC_EXEC) {
@@ -1634,7 +1616,6 @@ static CommandCost ClearTile_Track(TileIndex tile, DoCommandFlag flags)
/* when bankrupting, don't make water dirty, there could be a ship on lower halftile */
if (water_ground && !(flags & DC_BANKRUPT)) {
CommandCost ret = EnsureNoVehicleOnGround(tile);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
/* The track was removed, and left a coast tile. Now also clear the water. */
@@ -2813,7 +2794,6 @@ static CommandCost TerraformTile_Track(TileIndex tile, DoCommandFlag flags, uint
/* 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;
diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp
index 07805be7e..823e9fed0 100644
--- a/src/road_cmd.cpp
+++ b/src/road_cmd.cpp
@@ -132,7 +132,6 @@ CommandCost CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, Owner owner, R
if (owner != OWNER_TOWN) {
if (owner == OWNER_NONE) return CommandCost();
CommandCost ret = CheckOwnership(owner);
- ret.SetGlobalErrorMessage();
return ret;
}
@@ -146,7 +145,6 @@ CommandCost CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, Owner owner, R
/* check if you're allowed to remove the street owned by a town
* removal allowance depends on difficulty setting */
CommandCost ret = CheckforTownRating(flags, t, ROAD_REMOVE);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
/* Get a bitmask of which neighbouring roads has a tile */
@@ -191,7 +189,6 @@ static CommandCost RemoveRoad(TileIndex tile, DoCommandFlag flags, RoadBits piec
switch (GetTileType(tile)) {
case MP_ROAD: {
CommandCost ret = EnsureNoVehicleOnGround(tile);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
} break;
@@ -199,14 +196,12 @@ static CommandCost RemoveRoad(TileIndex tile, DoCommandFlag flags, RoadBits piec
if (!IsDriveThroughStopTile(tile)) return CMD_ERROR;
CommandCost ret = EnsureNoVehicleOnGround(tile);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
} break;
case MP_TUNNELBRIDGE: {
if (GetTunnelBridgeTransportType(tile) != TRANSPORT_ROAD) return CMD_ERROR;
CommandCost ret = TunnelBridgeIsFree(tile, GetOtherTunnelBridgeEnd(tile));
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
} break;
@@ -215,7 +210,6 @@ static CommandCost RemoveRoad(TileIndex tile, DoCommandFlag flags, RoadBits piec
}
CommandCost ret = CheckAllowRemoveRoad(tile, pieces, GetRoadOwner(tile, rt), rt, flags, town_check);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
if (!IsTileType(tile, MP_ROAD)) {
@@ -506,12 +500,10 @@ CommandCost CmdBuildRoad(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
Owner owner = GetRoadOwner(tile, ROADTYPE_ROAD);
if (owner != OWNER_NONE) {
CommandCost ret = CheckOwnership(owner, tile);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
}
CommandCost ret = EnsureNoVehicleOnGround(tile);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
/* Ignore half built tiles */
@@ -569,7 +561,6 @@ CommandCost CmdBuildRoad(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
}
CommandCost ret = EnsureNoVehicleOnGround(tile);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
if (flags & DC_EXEC) {
@@ -602,7 +593,6 @@ CommandCost CmdBuildRoad(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
if (HasTileRoadType(tile, rt)) return_cmd_error(STR_ERROR_ALREADY_BUILT);
/* Don't allow adding roadtype to the bridge/tunnel when vehicles are already driving on it */
CommandCost ret = TunnelBridgeIsFree(tile, GetOtherTunnelBridgeEnd(tile));
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
} break;
@@ -650,7 +640,6 @@ do_clear:;
if (!tile_cleared) {
CommandCost ret = EnsureNoVehicleOnGround(tile);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
}
@@ -778,7 +767,6 @@ CommandCost CmdBuildLongRoad(TileIndex start_tile, DoCommandFlag flags, uint32 p
CommandCost ret = DoCommand(tile, drd << 6 | rt << 4 | bits, 0, flags, CMD_BUILD_ROAD);
if (ret.Failed()) {
last_error = ret;
- last_error.SetGlobalErrorMessage();
if (last_error.GetErrorMessage() != STR_ERROR_ALREADY_BUILT) {
if (HasBit(p2, 6)) return last_error;
break;
@@ -934,12 +922,10 @@ static CommandCost RemoveRoadDepot(TileIndex tile, DoCommandFlag flags)
{
if (_current_company != OWNER_WATER) {
CommandCost ret = CheckTileOwnership(tile);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
}
CommandCost ret = EnsureNoVehicleOnGround(tile);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
if (flags & DC_EXEC) {
diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp
index e82bcfcfc..1b99b18c9 100644
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -334,7 +334,6 @@ CommandCost CmdSellRoadVeh(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
if (v == NULL) return CMD_ERROR;
CommandCost ret = CheckOwnership(v->owner);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
if (v->vehstatus & VS_CRASHED) return_cmd_error(STR_ERROR_CAN_T_SELL_DESTROYED_VEHICLE);
@@ -413,7 +412,6 @@ CommandCost CmdTurnRoadVeh(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
if (v == NULL) return CMD_ERROR;
CommandCost ret = CheckOwnership(v->owner);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
if ((v->vehstatus & VS_STOPPED) ||
@@ -1759,7 +1757,6 @@ CommandCost CmdRefitRoadVeh(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
if (v == NULL) return CMD_ERROR;
CommandCost ret = CheckOwnership(v->owner);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
if (!v->IsStoppedInDepot()) return_cmd_error(STR_ERROR_ROAD_VEHICLE_MUST_BE_STOPPED_INSIDE_DEPOT);
diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp
index 6b5cb91f8..6f5528600 100644
--- a/src/ship_cmd.cpp
+++ b/src/ship_cmd.cpp
@@ -712,7 +712,6 @@ CommandCost CmdSellShip(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p
if (v == NULL) return CMD_ERROR;
CommandCost ret = CheckOwnership(v->owner);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
if (v->vehstatus & VS_CRASHED) return_cmd_error(STR_ERROR_CAN_T_SELL_DESTROYED_VEHICLE);
@@ -787,7 +786,6 @@ CommandCost CmdRefitShip(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
if (v == NULL) return CMD_ERROR;
CommandCost ret = CheckOwnership(v->owner);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
if (!v->IsStoppedInDepot()) return_cmd_error(STR_ERROR_SHIP_MUST_BE_STOPPED_IN_DEPOT);
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index 9a6c21280..b871b49cd 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -672,7 +672,6 @@ CommandCost CheckBuildableTile(TileIndex tile, uint invalid_dirs, int &allowed_z
}
CommandCost ret = EnsureNoVehicleOnGround(tile);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
uint z;
@@ -867,7 +866,6 @@ static CommandCost CheckFlatLandRoadStop(TileArea tile_area, DoCommandFlag flags
if (!_settings_game.construction.road_stop_on_town_road) return_cmd_error(STR_ERROR_DRIVE_THROUGH_ON_TOWN_ROAD);
} else if (!_settings_game.construction.road_stop_on_competitor_road && road_owner != OWNER_NONE) {
CommandCost ret = CheckOwnership(road_owner);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
}
num_roadbits += CountBits(GetRoadBits(cur_tile, ROADTYPE_ROAD));
@@ -878,7 +876,6 @@ static CommandCost CheckFlatLandRoadStop(TileArea tile_area, DoCommandFlag flags
Owner tram_owner = GetRoadOwner(cur_tile, ROADTYPE_TRAM);
if (!_settings_game.construction.road_stop_on_competitor_road && tram_owner != OWNER_NONE) {
CommandCost ret = CheckOwnership(tram_owner);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
}
num_roadbits += CountBits(GetRoadBits(cur_tile, ROADTYPE_TRAM));
@@ -1110,7 +1107,6 @@ CommandCost CmdBuildRailStation(TileIndex tile_org, DoCommandFlag flags, uint32
/* Does the authority allow this? */
CommandCost ret = CheckIfAuthorityAllowsNewStation(tile_org, flags);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
if (!ValParamRailtype(rt)) return CMD_ERROR;
@@ -1151,7 +1147,6 @@ CommandCost CmdBuildRailStation(TileIndex tile_org, DoCommandFlag flags, uint32
Station *st = NULL;
ret = FindJoiningStation(est, station_to_join, adjacent, new_location, &st);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
/* See if there is a deleted station close to us. */
@@ -1167,13 +1162,11 @@ CommandCost CmdBuildRailStation(TileIndex tile_org, DoCommandFlag flags, uint32
if (!_settings_game.station.join_stations) return_cmd_error(STR_ERROR_TOO_CLOSE_TO_ANOTHER_RAILROAD);
CommandCost ret = CanExpandRailStation(st, new_location, axis);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
}
/* XXX can't we pack this in the "else" part of the if above? */
CommandCost ret = st->rect.BeforeAddRect(tile_org, w_org, h_org, StationRect::ADD_TEST);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
} else {
/* allocate and initialize new station */
@@ -1379,10 +1372,7 @@ CommandCost RemoveFromRailBaseStation(TileArea ta, SmallVector<T *, 4> &affected
/* If there is a vehicle on ground, do not allow to remove (flood) the tile */
CommandCost ret = EnsureNoVehicleOnGround(tile);
- if (ret.Failed()) {
- ret.SetGlobalErrorMessage();
- continue;
- }
+ if (ret.Failed()) continue;
/* Check ownership of station */
T *st = T::GetByTile(tile);
@@ -1390,10 +1380,7 @@ CommandCost RemoveFromRailBaseStation(TileArea ta, SmallVector<T *, 4> &affected
if (_current_company != OWNER_WATER) {
CommandCost ret = CheckOwnership(st->owner);
- if (ret.Failed()) {
- ret.SetGlobalErrorMessage();
- continue;
- }
+ if (ret.Failed()) continue;
}
/* Do not allow removing from stations if non-uniform stations are not enabled
@@ -1542,7 +1529,6 @@ CommandCost RemoveRailStation(T *st, DoCommandFlag flags)
/* Current company owns the station? */
if (_current_company != OWNER_WATER) {
CommandCost ret = CheckOwnership(st->owner);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
}
@@ -1558,7 +1544,6 @@ CommandCost RemoveRailStation(T *st, DoCommandFlag flags)
if (!st->TileBelongsToRailStation(tile)) continue;
CommandCost ret = EnsureNoVehicleOnGround(tile);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
cost.AddCost(_price[PR_CLEAR_STATION_RAIL]);
@@ -1725,7 +1710,6 @@ CommandCost CmdBuildRoadStop(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
if (is_drive_through && !IsValidAxis((Axis)ddir)) return CMD_ERROR;
CommandCost ret = CheckIfAuthorityAllowsNewStation(tile, flags);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
/* Total road stop cost. */
@@ -1737,7 +1721,6 @@ CommandCost CmdBuildRoadStop(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
Station *st = NULL;
ret = FindJoiningRoadStop(est, station_to_join, HasBit(p2, 5), roadstop_area, &st);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
/* Find a deleted station close to us */
@@ -1752,7 +1735,6 @@ CommandCost CmdBuildRoadStop(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
}
CommandCost ret = st->rect.BeforeAddRect(roadstop_area.tile, roadstop_area.w, roadstop_area.h, StationRect::ADD_TEST);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
} else {
/* allocate and initialize new station */
@@ -1846,7 +1828,6 @@ static CommandCost RemoveRoadStop(TileIndex tile, DoCommandFlag flags)
if (_current_company != OWNER_WATER) {
CommandCost ret = CheckOwnership(st->owner);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
}
@@ -1870,7 +1851,6 @@ static CommandCost RemoveRoadStop(TileIndex tile, DoCommandFlag flags)
if (flags & DC_EXEC) FindVehicleOnPos(tile, NULL, &ClearRoadStopStatusEnum);
} else {
CommandCost ret = EnsureNoVehicleOnGround(tile);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
}
@@ -2108,7 +2088,6 @@ CommandCost CmdBuildAirport(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
if (airport_type >= NUM_AIRPORTS) return CMD_ERROR;
CommandCost ret = CheckIfAuthorityAllowsNewStation(tile, flags);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
/* Check if a valid, buildable airport was chosen for construction */
@@ -2156,7 +2135,6 @@ CommandCost CmdBuildAirport(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
Station *st = NULL;
ret = FindJoiningStation(INVALID_STATION, station_to_join, HasBit(p2, 0), TileArea(tile, w, h), &st);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
/* Distant join */
@@ -2171,7 +2149,6 @@ CommandCost CmdBuildAirport(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
}
CommandCost ret = st->rect.BeforeAddRect(tile, w, h, StationRect::ADD_TEST);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
if (st->airport.tile != INVALID_TILE) {
@@ -2263,7 +2240,6 @@ static CommandCost RemoveAirport(TileIndex tile, DoCommandFlag flags)
if (_current_company != OWNER_WATER) {
CommandCost ret = CheckOwnership(st->owner);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
}
@@ -2281,7 +2257,6 @@ static CommandCost RemoveAirport(TileIndex tile, DoCommandFlag flags)
if (!st->TileBelongsToAirport(tile_cur)) continue;
CommandCost ret = EnsureNoVehicleOnGround(tile_cur);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
cost.AddCost(_price[PR_CLEAR_STATION_AIRPORT]);
@@ -2381,13 +2356,11 @@ CommandCost CmdBuildDock(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
if (IsWaterTile(tile)) return_cmd_error(STR_ERROR_SITE_UNSUITABLE);
CommandCost ret = CheckIfAuthorityAllowsNewStation(tile, flags);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
if (MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST);
ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
TileIndex tile_cur = tile + TileOffsByDiagDir(direction);
@@ -2402,7 +2375,6 @@ CommandCost CmdBuildDock(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
WaterClass wc = GetWaterClass(tile_cur);
ret = DoCommand(tile_cur, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
tile_cur += TileOffsByDiagDir(direction);
@@ -2415,7 +2387,6 @@ CommandCost CmdBuildDock(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
ret = FindJoiningStation(INVALID_STATION, station_to_join, HasBit(p1, 0),
TileArea(tile + ToTileIndexDiff(_dock_tileoffs_chkaround[direction]),
_dock_w_chk[direction], _dock_h_chk[direction]), &st);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
/* Distant join */
@@ -2432,7 +2403,6 @@ CommandCost CmdBuildDock(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
CommandCost ret = st->rect.BeforeAddRect(
tile + ToTileIndexDiff(_dock_tileoffs_chkaround[direction]),
_dock_w_chk[direction], _dock_h_chk[direction], StationRect::ADD_TEST);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
if (st->dock_tile != INVALID_TILE) return_cmd_error(STR_ERROR_TOO_CLOSE_TO_ANOTHER_DOCK);
@@ -2483,7 +2453,6 @@ static CommandCost RemoveDock(TileIndex tile, DoCommandFlag flags)
{
Station *st = Station::GetByTile(tile);
CommandCost ret = CheckOwnership(st->owner);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
TileIndex tile1 = st->dock_tile;
@@ -2491,7 +2460,6 @@ static CommandCost RemoveDock(TileIndex tile, DoCommandFlag flags)
ret = EnsureNoVehicleOnGround(tile1);
if (ret.Succeeded()) ret = EnsureNoVehicleOnGround(tile2);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
if (flags & DC_EXEC) {
@@ -3222,7 +3190,6 @@ CommandCost CmdRenameStation(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
if (st == NULL) return CMD_ERROR;
CommandCost ret = CheckOwnership(st->owner);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
bool reset = StrEmpty(text);
diff --git a/src/timetable_cmd.cpp b/src/timetable_cmd.cpp
index 80f8a39bc..c003acbee 100644
--- a/src/timetable_cmd.cpp
+++ b/src/timetable_cmd.cpp
@@ -71,7 +71,6 @@ CommandCost CmdChangeTimetable(TileIndex tile, DoCommandFlag flags, uint32 p1, u
if (v == NULL || !v->IsPrimaryVehicle()) return CMD_ERROR;
CommandCost ret = CheckOwnership(v->owner);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
VehicleOrderID order_number = GB(p1, 16, 8);
@@ -135,7 +134,6 @@ CommandCost CmdSetVehicleOnTime(TileIndex tile, DoCommandFlag flags, uint32 p1,
if (v == NULL || !v->IsPrimaryVehicle()) return CMD_ERROR;
CommandCost ret = CheckOwnership(v->owner);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
if (flags & DC_EXEC) {
@@ -161,7 +159,6 @@ CommandCost CmdSetTimetableStart(TileIndex tile, DoCommandFlag flags, uint32 p1,
if (v == NULL || !v->IsPrimaryVehicle()) return CMD_ERROR;
CommandCost ret = CheckOwnership(v->owner);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
/* Don't let a timetable start more than 15 years into the future or 1 year in the past. */
@@ -205,7 +202,6 @@ CommandCost CmdAutofillTimetable(TileIndex tile, DoCommandFlag flags, uint32 p1,
if (v == NULL || !v->IsPrimaryVehicle()) return CMD_ERROR;
CommandCost ret = CheckOwnership(v->owner);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
if (flags & DC_EXEC) {
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index c3e19eb37..97d44291c 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -1172,7 +1172,6 @@ CommandCost CmdMoveRailVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, u
if (src == NULL) return CMD_ERROR;
CommandCost ret = CheckOwnership(src->owner);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
/* Do not allow moving crashed vehicles inside the depot, it is likely to cause asserts later */
@@ -1187,7 +1186,6 @@ CommandCost CmdMoveRailVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, u
if (dst == NULL) return CMD_ERROR;
CommandCost ret = CheckOwnership(dst->owner);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
/* Do not allow appending to crashed vehicles, too */
@@ -1353,7 +1351,6 @@ CommandCost CmdSellRailWagon(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
if (v == NULL) return CMD_ERROR;
CommandCost ret = CheckOwnership(v->owner);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
/* Sell a chain of vehicles or not? */
@@ -1830,7 +1827,6 @@ CommandCost CmdReverseTrainDirection(TileIndex tile, DoCommandFlag flags, uint32
if (v == NULL) return CMD_ERROR;
CommandCost ret = CheckOwnership(v->owner);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
if (p2 != 0) {
@@ -1901,7 +1897,6 @@ CommandCost CmdForceTrainProceed(TileIndex tile, DoCommandFlag flags, uint32 p1,
if (t == NULL) return CMD_ERROR;
CommandCost ret = CheckOwnership(t->owner);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
@@ -1939,7 +1934,6 @@ CommandCost CmdRefitRailVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1,
if (v == NULL) return CMD_ERROR;
CommandCost ret = CheckOwnership(v->owner);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
if (!v->IsStoppedInDepot()) return_cmd_error(STR_TRAIN_MUST_BE_STOPPED);
diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp
index f760d40a8..be686c05c 100644
--- a/src/tunnelbridge_cmd.cpp
+++ b/src/tunnelbridge_cmd.cpp
@@ -609,25 +609,19 @@ static inline CommandCost CheckAllowRemoveTunnelBridge(TileIndex tile)
/* We can remove unowned road and if the town allows it */
if (road_owner == OWNER_TOWN && !(_settings_game.construction.extra_dynamite || _cheats.magic_bulldozer.value)) {
- CommandCost ret = CheckTileOwnership(tile);
- ret.SetGlobalErrorMessage();
- return ret;
+ return CheckTileOwnership(tile);
}
if (road_owner == OWNER_NONE || road_owner == OWNER_TOWN) road_owner = _current_company;
if (tram_owner == OWNER_NONE) tram_owner = _current_company;
CommandCost ret = CheckOwnership(road_owner, tile);
if (ret.Succeeded()) ret = CheckOwnership(tram_owner, tile);
- ret.SetGlobalErrorMessage();
return ret;
}
case TRANSPORT_RAIL:
- case TRANSPORT_WATER: {
- CommandCost ret = CheckOwnership(GetTileOwner(tile));
- ret.SetGlobalErrorMessage();
- return ret;
- }
+ case TRANSPORT_WATER:
+ return CheckOwnership(GetTileOwner(tile));
default: NOT_REACHED();
}
@@ -641,13 +635,11 @@ static inline CommandCost CheckAllowRemoveTunnelBridge(TileIndex tile)
static CommandCost DoClearTunnel(TileIndex tile, DoCommandFlag flags)
{
CommandCost ret = CheckAllowRemoveTunnelBridge(tile);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
TileIndex endtile = GetOtherTunnelEnd(tile);
ret = TunnelBridgeIsFree(tile, endtile);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
_build_tunnel_endtile = endtile;
@@ -659,7 +651,6 @@ static CommandCost DoClearTunnel(TileIndex tile, DoCommandFlag flags)
/* Check if you are allowed to remove the tunnel owned by a town
* Removal depends on difficulty settings */
CommandCost ret = CheckforTownRating(flags, t, TUNNELBRIDGE_REMOVE);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
}
@@ -710,13 +701,11 @@ static CommandCost DoClearTunnel(TileIndex tile, DoCommandFlag flags)
static CommandCost DoClearBridge(TileIndex tile, DoCommandFlag flags)
{
CommandCost ret = CheckAllowRemoveTunnelBridge(tile);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
TileIndex endtile = GetOtherBridgeEnd(tile);
ret = TunnelBridgeIsFree(tile, endtile);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
DiagDirection direction = GetTunnelBridgeDirection(tile);
@@ -729,7 +718,6 @@ static CommandCost DoClearBridge(TileIndex tile, DoCommandFlag flags)
/* Check if you are allowed to remove the bridge owned by a town
* Removal depends on difficulty settings */
CommandCost ret = CheckforTownRating(flags, t, TUNNELBRIDGE_REMOVE);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
}
diff --git a/src/unmovable_cmd.cpp b/src/unmovable_cmd.cpp
index 4098c179c..0e256ee6e 100644
--- a/src/unmovable_cmd.cpp
+++ b/src/unmovable_cmd.cpp
@@ -177,12 +177,10 @@ CommandCost CmdSellLandArea(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
if (!IsOwnedLandTile(tile)) return CMD_ERROR;
if (_current_company != OWNER_WATER) {
CommandCost ret = CheckTileOwnership(tile);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
}
CommandCost ret = EnsureNoVehicleOnGround(tile);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
if (flags & DC_EXEC) DoClearSquare(tile);
@@ -506,7 +504,6 @@ static CommandCost TerraformTile_Unmovable(TileIndex tile, DoCommandFlag flags,
/* Owned land remains unsold */
if (IsOwnedLand(tile)) {
CommandCost ret = CheckTileOwnership(tile);
- ret.SetGlobalErrorMessage();
if (ret.Succeeded()) return CommandCost();
}
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index bb48813a1..822ad7399 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -1666,7 +1666,6 @@ void Vehicle::HandleLoading(bool mode)
CommandCost Vehicle::SendToDepot(DoCommandFlag flags, DepotCommand command)
{
CommandCost ret = CheckOwnership(this->owner);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
if (this->vehstatus & VS_CRASHED) return CMD_ERROR;
diff --git a/src/vehicle_cmd.cpp b/src/vehicle_cmd.cpp
index 87cad761c..843f3625e 100644
--- a/src/vehicle_cmd.cpp
+++ b/src/vehicle_cmd.cpp
@@ -77,7 +77,6 @@ CommandCost CmdStartStopVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1,
if (v == NULL || !v->IsPrimaryVehicle()) return CMD_ERROR;
CommandCost ret = CheckOwnership(v->owner);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
switch (v->type) {
@@ -417,7 +416,6 @@ CommandCost CmdCloneVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
*/
CommandCost ret = CheckOwnership(v->owner);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
if (v->type == VEH_TRAIN && (!Train::From(v)->IsFrontEngine() || Train::From(v)->crash_anim_pos >= 4400)) return CMD_ERROR;
@@ -625,7 +623,6 @@ CommandCost CmdRenameVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
if (v == NULL) return CMD_ERROR;
CommandCost ret = CheckOwnership(v->owner);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
bool reset = StrEmpty(text);
@@ -660,7 +657,6 @@ CommandCost CmdChangeServiceInt(TileIndex tile, DoCommandFlag flags, uint32 p1,
if (v == NULL) return CMD_ERROR;
CommandCost ret = CheckOwnership(v->owner);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
uint16 serv_int = GetServiceIntervalClamped(p2, v->owner); // Double check the service interval from the user-input
diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp
index dd472320b..1216fb213 100644
--- a/src/water_cmd.cpp
+++ b/src/water_cmd.cpp
@@ -166,7 +166,6 @@ static CommandCost RemoveShipDepot(TileIndex tile, DoCommandFlag flags)
if (!IsShipDepot(tile)) return CMD_ERROR;
CommandCost ret = CheckTileOwnership(tile);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
TileIndex tile2 = GetOtherShipDepotTile(tile);
@@ -175,7 +174,6 @@ static CommandCost RemoveShipDepot(TileIndex tile, DoCommandFlag flags)
if (!(flags & DC_BANKRUPT)) {
CommandCost ret = EnsureNoVehicleOnGround(tile);
if (ret.Succeeded()) ret = EnsureNoVehicleOnGround(tile2);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
}
@@ -240,7 +238,6 @@ static CommandCost RemoveShiplift(TileIndex tile, DoCommandFlag flags)
{
if (GetTileOwner(tile) != OWNER_NONE) {
CommandCost ret = CheckTileOwnership(tile);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
}
@@ -250,7 +247,6 @@ static CommandCost RemoveShiplift(TileIndex tile, DoCommandFlag flags)
CommandCost ret = EnsureNoVehicleOnGround(tile);
if (ret.Succeeded()) ret = EnsureNoVehicleOnGround(tile + delta);
if (ret.Succeeded()) ret = EnsureNoVehicleOnGround(tile - delta);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
if (flags & DC_EXEC) {
@@ -357,12 +353,10 @@ static CommandCost ClearTile_Water(TileIndex tile, DoCommandFlag flags)
/* Make sure no vehicle is on the tile */
CommandCost ret = EnsureNoVehicleOnGround(tile);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
if (GetTileOwner(tile) != OWNER_WATER && GetTileOwner(tile) != OWNER_NONE) {
CommandCost ret = CheckTileOwnership(tile);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
}
@@ -378,7 +372,6 @@ static CommandCost ClearTile_Water(TileIndex tile, DoCommandFlag flags)
/* Make sure no vehicle is on the tile */
CommandCost ret = EnsureNoVehicleOnGround(tile);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
if (flags & DC_EXEC) {
diff --git a/src/waypoint_cmd.cpp b/src/waypoint_cmd.cpp
index f9f0b4362..8771f27aa 100644
--- a/src/waypoint_cmd.cpp
+++ b/src/waypoint_cmd.cpp
@@ -179,11 +179,7 @@ static CommandCost IsValidTileForWaypoint(TileIndex tile, Axis axis, StationID *
Owner owner = GetTileOwner(tile);
CommandCost ret = CheckOwnership(owner);
- ret.SetGlobalErrorMessage();
- if (ret.Failed()) return ret;
-
- ret = EnsureNoVehicleOnGround(tile);
- ret.SetGlobalErrorMessage();
+ if (ret.Succeeded()) ret = EnsureNoVehicleOnGround(tile);
if (ret.Failed()) return ret;
Slope tileh = GetTileSlope(tile, NULL);
@@ -258,7 +254,6 @@ CommandCost CmdBuildRailWaypoint(TileIndex start_tile, DoCommandFlag flags, uint
Waypoint *wp = NULL;
TileArea new_location(TileArea(start_tile, width, height));
CommandCost ret = FindJoiningWaypoint(est, station_to_join, adjacent, new_location, &wp);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
/* Check if there is an already existing, deleted, waypoint close to us that we can reuse. */
@@ -276,7 +271,6 @@ CommandCost CmdBuildRailWaypoint(TileIndex start_tile, DoCommandFlag flags, uint
}
CommandCost ret = wp->rect.BeforeAddRect(start_tile, width, height, StationRect::ADD_TEST);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
} else {
/* allocate and initialize new waypoint */
@@ -399,7 +393,6 @@ CommandCost RemoveBuoy(TileIndex tile, DoCommandFlag flags)
/* remove the buoy if there is a ship on tile when company goes bankrupt... */
if (!(flags & DC_BANKRUPT)) {
CommandCost ret = EnsureNoVehicleOnGround(tile);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
}
@@ -451,7 +444,6 @@ CommandCost CmdRenameWaypoint(TileIndex tile, DoCommandFlag flags, uint32 p1, ui
if (wp->owner != OWNER_NONE) {
CommandCost ret = CheckOwnership(wp->owner);
- ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret;
}