1
0
Fork 0

(svn r19494) -Codechange: Remove _error_message.

release/1.1
alberth 2010-03-20 17:58:24 +00:00
parent a901ab5392
commit 05d705e077
21 changed files with 8 additions and 173 deletions

View File

@ -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 */ /* We failed; set the error and bail out */
if (res.Failed()) { if (res.Failed()) {
res.SetGlobalErrorMessage();
SetLastError(AIError::StringToError(res.GetErrorMessage())); SetLastError(AIError::StringToError(res.GetErrorMessage()));
return false; return false;
} }

View File

@ -394,7 +394,6 @@ CommandCost CmdSellAircraft(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
if (v == NULL) return CMD_ERROR; if (v == NULL) return CMD_ERROR;
CommandCost ret = CheckOwnership(v->owner); CommandCost ret = CheckOwnership(v->owner);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
if (!v->IsStoppedInDepot()) return_cmd_error(STR_ERROR_AIRCRAFT_MUST_BE_STOPPED); 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; if (v == NULL) return CMD_ERROR;
CommandCost ret = CheckOwnership(v->owner); CommandCost ret = CheckOwnership(v->owner);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
if (!v->IsStoppedInDepot()) return_cmd_error(STR_ERROR_AIRCRAFT_MUST_BE_STOPPED); if (!v->IsStoppedInDepot()) return_cmd_error(STR_ERROR_AIRCRAFT_MUST_BE_STOPPED);

View File

@ -620,7 +620,6 @@ CommandCost CmdAutoreplaceVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1
if (v == NULL) return CMD_ERROR; if (v == NULL) return CMD_ERROR;
CommandCost ret = CheckOwnership(v->owner); CommandCost ret = CheckOwnership(v->owner);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
if (!v->IsInDepot()) return CMD_ERROR; if (!v->IsInDepot()) return CMD_ERROR;

View File

@ -29,8 +29,6 @@
#include "table/strings.h" #include "table/strings.h"
StringID _error_message; ///< Global error message. @see CommandCost::SetGlobalErrorMessage()
CommandProc CmdBuildRailroadTrack; CommandProc CmdBuildRailroadTrack;
CommandProc CmdRemoveRailroadTrack; CommandProc CmdRemoveRailroadTrack;
CommandProc CmdBuildSingleRail; 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 */ /* Chop of any CMD_MSG or other flags; we don't need those here */
CommandProc *proc = _command_proc_table[cmd & CMD_ID_MASK].proc; CommandProc *proc = _command_proc_table[cmd & CMD_ID_MASK].proc;
if (_docommand_recursive == 0) _error_message = INVALID_STRING_ID;
_docommand_recursive++; _docommand_recursive++;
/* only execute the test call if it's toplevel, or we're not execing. */ /* 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); res = proc(tile, flags, p1, p2, text);
if (res.Failed()) { if (res.Failed()) {
error: error:
res.SetGlobalErrorMessage();
_docommand_recursive--; _docommand_recursive--;
return res; 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); CommandCost res = DoCommandPInternal(tile, p1, p2, cmd, callback, text, my_cmd, estimate_only);
if (res.Failed()) { if (res.Failed()) {
res.SetGlobalErrorMessage();
/* Only show the error when it's for us. */ /* Only show the error when it's for us. */
StringID error_part1 = GB(cmd, 16, 16); StringID error_part1 = GB(cmd, 16, 16);
if (estimate_only || (IsLocalCompany() && error_part1 != 0 && my_cmd)) { 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; _docommand_recursive = 1;
/* Reset the state. */ /* Reset the state. */
_error_message = INVALID_STRING_ID;
_additional_cash_required = 0; _additional_cash_required = 0;
/* Get pointer to command handler */ /* Get pointer to command handler */

View File

@ -57,7 +57,6 @@ void NetworkSend_Command(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, Comma
#endif /* ENABLE_NETWORK */ #endif /* ENABLE_NETWORK */
extern Money _additional_cash_required; extern Money _additional_cash_required;
extern StringID _error_message;
/** /**
* Checks if a integer value belongs to a command. * Checks if a integer value belongs to a command.

View File

@ -89,16 +89,6 @@ public:
return this->expense_type; return this->expense_type;
} }
/**
* 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. * Makes this #CommandCost behave like an error command.
* @param message The error message. * @param message The error message.
@ -112,15 +102,12 @@ public:
/** /**
* Returns the error message of a command * 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 StringID GetErrorMessage() const
{ {
extern StringID _error_message;
if (this->success) return INVALID_STRING_ID; if (this->success) return INVALID_STRING_ID;
if (this->message != INVALID_STRING_ID) return this->message; return this->message;
return _error_message;
} }
/** /**

View File

@ -1339,7 +1339,6 @@ static CommandCost CheckIfIndustryTilesAreFree(TileIndex tile, const IndustryTil
} }
} else { } else {
CommandCost ret = EnsureNoVehicleOnGround(cur_tile); CommandCost ret = EnsureNoVehicleOnGround(cur_tile);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
if (MayHaveBridgeAbove(cur_tile) && IsBridgeAbove(cur_tile)) return_cmd_error(STR_ERROR_SITE_UNSUITABLE); 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)) { if (HasBit(its->callback_mask, CBM_INDT_SHAPE_CHECK)) {
custom_shape = true; custom_shape = true;
CommandCost ret = PerformIndustryTileSlopeCheck(tile, cur_tile, its, type, gfx, itspec_index); CommandCost ret = PerformIndustryTileSlopeCheck(tile, cur_tile, its, type, gfx, itspec_index);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
} else { } else {
Slope tileh = GetTileSlope(cur_tile, NULL); Slope tileh = GetTileSlope(cur_tile, NULL);
@ -1798,7 +1796,6 @@ CommandCost CmdBuildIndustry(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
*/ */
tile = RandomTile(); tile = RandomTile();
CommandCost ret = CreateNewIndustryHelper(tile, it, flags, indspec, RandomRange(indspec->num_table), p2, founder, &ind); CommandCost ret = CreateNewIndustryHelper(tile, it, flags, indspec, RandomRange(indspec->num_table), p2, founder, &ind);
ret.SetGlobalErrorMessage();
if (ret.Succeeded()) break; if (ret.Succeeded()) break;
} }
} }
@ -1811,16 +1808,13 @@ CommandCost CmdBuildIndustry(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
if (num >= count) return CMD_ERROR; if (num >= count) return CMD_ERROR;
CommandCost ret = CommandCost(STR_ERROR_SITE_UNSUITABLE); CommandCost ret = CommandCost(STR_ERROR_SITE_UNSUITABLE);
ret.SetGlobalErrorMessage();
do { do {
if (--count < 0) return ret; if (--count < 0) return ret;
if (--num < 0) num = indspec->num_table - 1; if (--num < 0) num = indspec->num_table - 1;
ret = CheckIfIndustryTilesAreFree(tile, itt[num], num, it); ret = CheckIfIndustryTilesAreFree(tile, itt[num], num, it);
ret.SetGlobalErrorMessage();
} while (ret.Failed()); } while (ret.Failed());
ret = CreateNewIndustryHelper(tile, it, flags, indspec, num, p2, _current_company, &ind); ret = CreateNewIndustryHelper(tile, it, flags, indspec, num, p2, _current_company, &ind);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
} }
@ -1849,7 +1843,6 @@ static Industry *CreateNewIndustry(TileIndex tile, IndustryType type)
Industry *i = NULL; Industry *i = NULL;
CommandCost ret = CreateNewIndustryHelper(tile, type, DC_EXEC, indspec, RandomRange(indspec->num_table), seed, OWNER_NONE, &i); CommandCost ret = CreateNewIndustryHelper(tile, type, DC_EXEC, indspec, RandomRange(indspec->num_table), seed, OWNER_NONE, &i);
assert(i != NULL || ret.Failed()); assert(i != NULL || ret.Failed());
ret.SetGlobalErrorMessage();
return i; return i;
} }

View File

@ -471,7 +471,6 @@ CommandCost CmdInsertOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
if (v == NULL) return CMD_ERROR; if (v == NULL) return CMD_ERROR;
CommandCost ret = CheckOwnership(v->owner); CommandCost ret = CheckOwnership(v->owner);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
/* Check if the inserted order is to the correct destination (owner, type), /* 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) { if (st->owner != OWNER_NONE) {
CommandCost ret = CheckOwnership(st->owner); CommandCost ret = CheckOwnership(st->owner);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
} }
@ -532,7 +530,6 @@ CommandCost CmdInsertOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
if (st == NULL) return CMD_ERROR; if (st == NULL) return CMD_ERROR;
CommandCost ret = CheckOwnership(st->owner); CommandCost ret = CheckOwnership(st->owner);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
if (!CanVehicleUseStation(v, st) || !st->airport.HasHangar()) { 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; if (dp == NULL) return CMD_ERROR;
CommandCost ret = CheckOwnership(GetTileOwner(dp->xy)); CommandCost ret = CheckOwnership(GetTileOwner(dp->xy));
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
switch (v->type) { 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); if (!(wp->facilities & FACIL_TRAIN)) return_cmd_error(STR_ERROR_CAN_T_ADD_ORDER);
CommandCost ret = CheckOwnership(wp->owner); CommandCost ret = CheckOwnership(wp->owner);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
break; 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->facilities & FACIL_DOCK)) return_cmd_error(STR_ERROR_CAN_T_ADD_ORDER);
if (wp->owner != OWNER_NONE) { if (wp->owner != OWNER_NONE) {
CommandCost ret = CheckOwnership(wp->owner); CommandCost ret = CheckOwnership(wp->owner);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
} }
break; break;
@ -756,7 +750,6 @@ CommandCost CmdDeleteOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
if (v == NULL) return CMD_ERROR; if (v == NULL) return CMD_ERROR;
CommandCost ret = CheckOwnership(v->owner); CommandCost ret = CheckOwnership(v->owner);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
/* If we did not select an order, we maybe want to de-clone the orders */ /* 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; if (v == NULL || sel_ord == v->cur_order_index || sel_ord >= v->GetNumOrders() || v->GetNumOrders() < 2) return CMD_ERROR;
CommandCost ret = CheckOwnership(v->owner); CommandCost ret = CheckOwnership(v->owner);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
@ -867,7 +859,6 @@ CommandCost CmdMoveOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
if (v == NULL) return CMD_ERROR; if (v == NULL) return CMD_ERROR;
CommandCost ret = CheckOwnership(v->owner); CommandCost ret = CheckOwnership(v->owner);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
/* Don't make senseless movements */ /* Don't make senseless movements */
@ -951,7 +942,6 @@ CommandCost CmdModifyOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
if (v == NULL) return CMD_ERROR; if (v == NULL) return CMD_ERROR;
CommandCost ret = CheckOwnership(v->owner); CommandCost ret = CheckOwnership(v->owner);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
/* Is it a valid order? */ /* Is it a valid order? */
@ -1178,7 +1168,6 @@ CommandCost CmdCloneOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
if (dst == NULL) return CMD_ERROR; if (dst == NULL) return CMD_ERROR;
CommandCost ret = CheckOwnership(dst->owner); CommandCost ret = CheckOwnership(dst->owner);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
switch (p2) { 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; if (src == NULL || dst->type != src->type || dst == src) return CMD_ERROR;
CommandCost ret = CheckOwnership(src->owner); CommandCost ret = CheckOwnership(src->owner);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
/* Trucks can't share orders with busses (and visa versa) */ /* 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; if (src == NULL || dst->type != src->type || dst == src) return CMD_ERROR;
CommandCost ret = CheckOwnership(src->owner); CommandCost ret = CheckOwnership(src->owner);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
/* Trucks can't copy all the orders from busses (and visa versa), /* 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; if (v == NULL) return CMD_ERROR;
CommandCost ret = CheckOwnership(v->owner); CommandCost ret = CheckOwnership(v->owner);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
Order *order = v->GetOrder(order_number); Order *order = v->GetOrder(order_number);
@ -1466,7 +1452,6 @@ CommandCost CmdRestoreOrderIndex(TileIndex tile, DoCommandFlag flags, uint32 p1,
if (v == NULL) return CMD_ERROR; if (v == NULL) return CMD_ERROR;
CommandCost ret = CheckOwnership(v->owner); CommandCost ret = CheckOwnership(v->owner);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
if (serv_int != GetServiceIntervalClamped(serv_int, v->owner) || cur_ord >= v->GetNumOrders()) return CMD_ERROR; if (serv_int != GetServiceIntervalClamped(serv_int, v->owner) || cur_ord >= v->GetNumOrders()) return CMD_ERROR;

View File

@ -370,7 +370,6 @@ CommandCost CmdBuildSingleRail(TileIndex tile, DoCommandFlag flags, uint32 p1, u
switch (GetTileType(tile)) { switch (GetTileType(tile)) {
case MP_RAILWAY: { case MP_RAILWAY: {
CommandCost ret = CheckTileOwnership(tile); CommandCost ret = CheckTileOwnership(tile);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
if (!IsPlainRail(tile)) return CMD_ERROR; if (!IsPlainRail(tile)) return CMD_ERROR;
@ -379,7 +378,6 @@ CommandCost CmdBuildSingleRail(TileIndex tile, DoCommandFlag flags, uint32 p1, u
ret = CheckTrackCombination(tile, trackbit, flags); ret = CheckTrackCombination(tile, trackbit, flags);
if (ret.Succeeded()) ret = EnsureNoTrainOnTrack(tile, track); if (ret.Succeeded()) ret = EnsureNoTrainOnTrack(tile, track);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
ret = CheckRailSlope(tileh, trackbit, GetTrackBits(tile), tile); ret = CheckRailSlope(tileh, trackbit, GetTrackBits(tile), tile);
@ -415,7 +413,6 @@ CommandCost CmdBuildSingleRail(TileIndex tile, DoCommandFlag flags, uint32 p1, u
#undef M #undef M
CommandCost ret = EnsureNoVehicleOnGround(tile); CommandCost ret = EnsureNoVehicleOnGround(tile);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
if (IsNormalRoad(tile)) { if (IsNormalRoad(tile)) {
@ -523,13 +520,11 @@ CommandCost CmdRemoveSingleRail(TileIndex tile, DoCommandFlag flags, uint32 p1,
if (_current_company != OWNER_WATER) { if (_current_company != OWNER_WATER) {
CommandCost ret = CheckTileOwnership(tile); CommandCost ret = CheckTileOwnership(tile);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
} }
if (!(flags & DC_BANKRUPT)) { if (!(flags & DC_BANKRUPT)) {
CommandCost ret = EnsureNoVehicleOnGround(tile); CommandCost ret = EnsureNoVehicleOnGround(tile);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
} }
@ -553,12 +548,10 @@ CommandCost CmdRemoveSingleRail(TileIndex tile, DoCommandFlag flags, uint32 p1,
if (_current_company != OWNER_WATER) { if (_current_company != OWNER_WATER) {
CommandCost ret = CheckTileOwnership(tile); CommandCost ret = CheckTileOwnership(tile);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
} }
CommandCost ret = EnsureNoTrainOnTrack(tile, track); CommandCost ret = EnsureNoTrainOnTrack(tile, track);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
present = GetTrackBits(tile); present = GetTrackBits(tile);
@ -758,7 +751,6 @@ static CommandCost CmdRailTrackHelper(TileIndex tile, DoCommandFlag flags, uint3
Trackdir trackdir = TrackToTrackdir(track); Trackdir trackdir = TrackToTrackdir(track);
CommandCost ret = ValidateAutoDrag(&trackdir, tile, end_tile); CommandCost ret = ValidateAutoDrag(&trackdir, tile, end_tile);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
if (flags & DC_EXEC) SndPlayTileFx(SND_20_SPLAT_2, tile); 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()) { if (ret.Failed()) {
last_error = ret; last_error = ret;
last_error.SetGlobalErrorMessage();
if (last_error.GetErrorMessage() != STR_ERROR_ALREADY_BUILT && !remove) { if (last_error.GetErrorMessage() != STR_ERROR_ALREADY_BUILT && !remove) {
if (HasBit(p2, 8)) return last_error; if (HasBit(p2, 8)) return last_error;
break; break;
@ -924,14 +915,12 @@ CommandCost CmdBuildSingleSignal(TileIndex tile, DoCommandFlag flags, uint32 p1,
return CMD_ERROR; return CMD_ERROR;
} }
CommandCost ret = EnsureNoTrainOnTrack(tile, track); CommandCost ret = EnsureNoTrainOnTrack(tile, track);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
/* Protect against invalid signal copying */ /* Protect against invalid signal copying */
if (p2 != 0 && (p2 & SignalOnTrack(track)) == 0) return CMD_ERROR; if (p2 != 0 && (p2 & SignalOnTrack(track)) == 0) return CMD_ERROR;
ret = CheckTileOwnership(tile); ret = CheckTileOwnership(tile);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
{ {
@ -1157,7 +1146,6 @@ static CommandCost CmdSignalTrackHelper(TileIndex tile, DoCommandFlag flags, uin
signal_density *= 2; signal_density *= 2;
CommandCost ret = ValidateAutoDrag(&trackdir, tile, end_tile); CommandCost ret = ValidateAutoDrag(&trackdir, tile, end_tile);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
track = TrackdirToTrack(trackdir); // trackdir might have changed, keep track in sync 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); total_cost.AddCost(ret);
} else { } else {
last_error = ret; last_error = ret;
last_error.SetGlobalErrorMessage();
} }
} }
@ -1293,13 +1280,11 @@ CommandCost CmdRemoveSingleSignal(TileIndex tile, DoCommandFlag flags, uint32 p1
return CMD_ERROR; return CMD_ERROR;
} }
CommandCost ret = EnsureNoTrainOnTrack(tile, track); CommandCost ret = EnsureNoTrainOnTrack(tile, track);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
/* Only water can remove signals from anyone */ /* Only water can remove signals from anyone */
if (_current_company != OWNER_WATER) { if (_current_company != OWNER_WATER) {
CommandCost ret = CheckTileOwnership(tile); CommandCost ret = CheckTileOwnership(tile);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; 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; return (cost.GetCost() == 0) ? error : cost;
} }
@ -1571,12 +1555,10 @@ static CommandCost RemoveTrainDepot(TileIndex tile, DoCommandFlag flags)
{ {
if (_current_company != OWNER_WATER) { if (_current_company != OWNER_WATER) {
CommandCost ret = CheckTileOwnership(tile); CommandCost ret = CheckTileOwnership(tile);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
} }
CommandCost ret = EnsureNoVehicleOnGround(tile); CommandCost ret = EnsureNoVehicleOnGround(tile);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
if (flags & DC_EXEC) { 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 */ /* when bankrupting, don't make water dirty, there could be a ship on lower halftile */
if (water_ground && !(flags & DC_BANKRUPT)) { if (water_ground && !(flags & DC_BANKRUPT)) {
CommandCost ret = EnsureNoVehicleOnGround(tile); CommandCost ret = EnsureNoVehicleOnGround(tile);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
/* The track was removed, and left a coast tile. Now also clear the water. */ /* 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. */ /* 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); 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. */ /* When there is only a single horizontal/vertical track, one corner can be terraformed. */
Corner allowed_corner; Corner allowed_corner;

View File

@ -132,7 +132,6 @@ CommandCost CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, Owner owner, R
if (owner != OWNER_TOWN) { if (owner != OWNER_TOWN) {
if (owner == OWNER_NONE) return CommandCost(); if (owner == OWNER_NONE) return CommandCost();
CommandCost ret = CheckOwnership(owner); CommandCost ret = CheckOwnership(owner);
ret.SetGlobalErrorMessage();
return ret; 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 /* check if you're allowed to remove the street owned by a town
* removal allowance depends on difficulty setting */ * removal allowance depends on difficulty setting */
CommandCost ret = CheckforTownRating(flags, t, ROAD_REMOVE); CommandCost ret = CheckforTownRating(flags, t, ROAD_REMOVE);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
/* Get a bitmask of which neighbouring roads has a tile */ /* 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)) { switch (GetTileType(tile)) {
case MP_ROAD: { case MP_ROAD: {
CommandCost ret = EnsureNoVehicleOnGround(tile); CommandCost ret = EnsureNoVehicleOnGround(tile);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
} break; } break;
@ -199,14 +196,12 @@ static CommandCost RemoveRoad(TileIndex tile, DoCommandFlag flags, RoadBits piec
if (!IsDriveThroughStopTile(tile)) return CMD_ERROR; if (!IsDriveThroughStopTile(tile)) return CMD_ERROR;
CommandCost ret = EnsureNoVehicleOnGround(tile); CommandCost ret = EnsureNoVehicleOnGround(tile);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
} break; } break;
case MP_TUNNELBRIDGE: { case MP_TUNNELBRIDGE: {
if (GetTunnelBridgeTransportType(tile) != TRANSPORT_ROAD) return CMD_ERROR; if (GetTunnelBridgeTransportType(tile) != TRANSPORT_ROAD) return CMD_ERROR;
CommandCost ret = TunnelBridgeIsFree(tile, GetOtherTunnelBridgeEnd(tile)); CommandCost ret = TunnelBridgeIsFree(tile, GetOtherTunnelBridgeEnd(tile));
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
} break; } 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); CommandCost ret = CheckAllowRemoveRoad(tile, pieces, GetRoadOwner(tile, rt), rt, flags, town_check);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
if (!IsTileType(tile, MP_ROAD)) { if (!IsTileType(tile, MP_ROAD)) {
@ -506,12 +500,10 @@ CommandCost CmdBuildRoad(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
Owner owner = GetRoadOwner(tile, ROADTYPE_ROAD); Owner owner = GetRoadOwner(tile, ROADTYPE_ROAD);
if (owner != OWNER_NONE) { if (owner != OWNER_NONE) {
CommandCost ret = CheckOwnership(owner, tile); CommandCost ret = CheckOwnership(owner, tile);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
} }
CommandCost ret = EnsureNoVehicleOnGround(tile); CommandCost ret = EnsureNoVehicleOnGround(tile);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
/* Ignore half built tiles */ /* Ignore half built tiles */
@ -569,7 +561,6 @@ CommandCost CmdBuildRoad(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
} }
CommandCost ret = EnsureNoVehicleOnGround(tile); CommandCost ret = EnsureNoVehicleOnGround(tile);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
if (flags & DC_EXEC) { 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); 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 */ /* Don't allow adding roadtype to the bridge/tunnel when vehicles are already driving on it */
CommandCost ret = TunnelBridgeIsFree(tile, GetOtherTunnelBridgeEnd(tile)); CommandCost ret = TunnelBridgeIsFree(tile, GetOtherTunnelBridgeEnd(tile));
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
} break; } break;
@ -650,7 +640,6 @@ do_clear:;
if (!tile_cleared) { if (!tile_cleared) {
CommandCost ret = EnsureNoVehicleOnGround(tile); CommandCost ret = EnsureNoVehicleOnGround(tile);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; 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); CommandCost ret = DoCommand(tile, drd << 6 | rt << 4 | bits, 0, flags, CMD_BUILD_ROAD);
if (ret.Failed()) { if (ret.Failed()) {
last_error = ret; last_error = ret;
last_error.SetGlobalErrorMessage();
if (last_error.GetErrorMessage() != STR_ERROR_ALREADY_BUILT) { if (last_error.GetErrorMessage() != STR_ERROR_ALREADY_BUILT) {
if (HasBit(p2, 6)) return last_error; if (HasBit(p2, 6)) return last_error;
break; break;
@ -934,12 +922,10 @@ static CommandCost RemoveRoadDepot(TileIndex tile, DoCommandFlag flags)
{ {
if (_current_company != OWNER_WATER) { if (_current_company != OWNER_WATER) {
CommandCost ret = CheckTileOwnership(tile); CommandCost ret = CheckTileOwnership(tile);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
} }
CommandCost ret = EnsureNoVehicleOnGround(tile); CommandCost ret = EnsureNoVehicleOnGround(tile);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
if (flags & DC_EXEC) { if (flags & DC_EXEC) {

View File

@ -334,7 +334,6 @@ CommandCost CmdSellRoadVeh(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
if (v == NULL) return CMD_ERROR; if (v == NULL) return CMD_ERROR;
CommandCost ret = CheckOwnership(v->owner); CommandCost ret = CheckOwnership(v->owner);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
if (v->vehstatus & VS_CRASHED) return_cmd_error(STR_ERROR_CAN_T_SELL_DESTROYED_VEHICLE); 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; if (v == NULL) return CMD_ERROR;
CommandCost ret = CheckOwnership(v->owner); CommandCost ret = CheckOwnership(v->owner);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
if ((v->vehstatus & VS_STOPPED) || if ((v->vehstatus & VS_STOPPED) ||
@ -1759,7 +1757,6 @@ CommandCost CmdRefitRoadVeh(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
if (v == NULL) return CMD_ERROR; if (v == NULL) return CMD_ERROR;
CommandCost ret = CheckOwnership(v->owner); CommandCost ret = CheckOwnership(v->owner);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
if (!v->IsStoppedInDepot()) return_cmd_error(STR_ERROR_ROAD_VEHICLE_MUST_BE_STOPPED_INSIDE_DEPOT); if (!v->IsStoppedInDepot()) return_cmd_error(STR_ERROR_ROAD_VEHICLE_MUST_BE_STOPPED_INSIDE_DEPOT);

View File

@ -712,7 +712,6 @@ CommandCost CmdSellShip(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p
if (v == NULL) return CMD_ERROR; if (v == NULL) return CMD_ERROR;
CommandCost ret = CheckOwnership(v->owner); CommandCost ret = CheckOwnership(v->owner);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
if (v->vehstatus & VS_CRASHED) return_cmd_error(STR_ERROR_CAN_T_SELL_DESTROYED_VEHICLE); 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; if (v == NULL) return CMD_ERROR;
CommandCost ret = CheckOwnership(v->owner); CommandCost ret = CheckOwnership(v->owner);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
if (!v->IsStoppedInDepot()) return_cmd_error(STR_ERROR_SHIP_MUST_BE_STOPPED_IN_DEPOT); if (!v->IsStoppedInDepot()) return_cmd_error(STR_ERROR_SHIP_MUST_BE_STOPPED_IN_DEPOT);

View File

@ -672,7 +672,6 @@ CommandCost CheckBuildableTile(TileIndex tile, uint invalid_dirs, int &allowed_z
} }
CommandCost ret = EnsureNoVehicleOnGround(tile); CommandCost ret = EnsureNoVehicleOnGround(tile);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
uint z; 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); 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) { } else if (!_settings_game.construction.road_stop_on_competitor_road && road_owner != OWNER_NONE) {
CommandCost ret = CheckOwnership(road_owner); CommandCost ret = CheckOwnership(road_owner);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
} }
num_roadbits += CountBits(GetRoadBits(cur_tile, ROADTYPE_ROAD)); 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); Owner tram_owner = GetRoadOwner(cur_tile, ROADTYPE_TRAM);
if (!_settings_game.construction.road_stop_on_competitor_road && tram_owner != OWNER_NONE) { if (!_settings_game.construction.road_stop_on_competitor_road && tram_owner != OWNER_NONE) {
CommandCost ret = CheckOwnership(tram_owner); CommandCost ret = CheckOwnership(tram_owner);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
} }
num_roadbits += CountBits(GetRoadBits(cur_tile, ROADTYPE_TRAM)); 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? */ /* Does the authority allow this? */
CommandCost ret = CheckIfAuthorityAllowsNewStation(tile_org, flags); CommandCost ret = CheckIfAuthorityAllowsNewStation(tile_org, flags);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
if (!ValParamRailtype(rt)) return CMD_ERROR; if (!ValParamRailtype(rt)) return CMD_ERROR;
@ -1151,7 +1147,6 @@ CommandCost CmdBuildRailStation(TileIndex tile_org, DoCommandFlag flags, uint32
Station *st = NULL; Station *st = NULL;
ret = FindJoiningStation(est, station_to_join, adjacent, new_location, &st); ret = FindJoiningStation(est, station_to_join, adjacent, new_location, &st);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
/* See if there is a deleted station close to us. */ /* 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); if (!_settings_game.station.join_stations) return_cmd_error(STR_ERROR_TOO_CLOSE_TO_ANOTHER_RAILROAD);
CommandCost ret = CanExpandRailStation(st, new_location, axis); CommandCost ret = CanExpandRailStation(st, new_location, axis);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
} }
/* XXX can't we pack this in the "else" part of the if above? */ /* 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); CommandCost ret = st->rect.BeforeAddRect(tile_org, w_org, h_org, StationRect::ADD_TEST);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
} else { } else {
/* allocate and initialize new station */ /* 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 */ /* If there is a vehicle on ground, do not allow to remove (flood) the tile */
CommandCost ret = EnsureNoVehicleOnGround(tile); CommandCost ret = EnsureNoVehicleOnGround(tile);
if (ret.Failed()) { if (ret.Failed()) continue;
ret.SetGlobalErrorMessage();
continue;
}
/* Check ownership of station */ /* Check ownership of station */
T *st = T::GetByTile(tile); T *st = T::GetByTile(tile);
@ -1390,10 +1380,7 @@ CommandCost RemoveFromRailBaseStation(TileArea ta, SmallVector<T *, 4> &affected
if (_current_company != OWNER_WATER) { if (_current_company != OWNER_WATER) {
CommandCost ret = CheckOwnership(st->owner); CommandCost ret = CheckOwnership(st->owner);
if (ret.Failed()) { if (ret.Failed()) continue;
ret.SetGlobalErrorMessage();
continue;
}
} }
/* Do not allow removing from stations if non-uniform stations are not enabled /* 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? */ /* Current company owns the station? */
if (_current_company != OWNER_WATER) { if (_current_company != OWNER_WATER) {
CommandCost ret = CheckOwnership(st->owner); CommandCost ret = CheckOwnership(st->owner);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
} }
@ -1558,7 +1544,6 @@ CommandCost RemoveRailStation(T *st, DoCommandFlag flags)
if (!st->TileBelongsToRailStation(tile)) continue; if (!st->TileBelongsToRailStation(tile)) continue;
CommandCost ret = EnsureNoVehicleOnGround(tile); CommandCost ret = EnsureNoVehicleOnGround(tile);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
cost.AddCost(_price[PR_CLEAR_STATION_RAIL]); 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; if (is_drive_through && !IsValidAxis((Axis)ddir)) return CMD_ERROR;
CommandCost ret = CheckIfAuthorityAllowsNewStation(tile, flags); CommandCost ret = CheckIfAuthorityAllowsNewStation(tile, flags);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
/* Total road stop cost. */ /* Total road stop cost. */
@ -1737,7 +1721,6 @@ CommandCost CmdBuildRoadStop(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
Station *st = NULL; Station *st = NULL;
ret = FindJoiningRoadStop(est, station_to_join, HasBit(p2, 5), roadstop_area, &st); ret = FindJoiningRoadStop(est, station_to_join, HasBit(p2, 5), roadstop_area, &st);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
/* Find a deleted station close to us */ /* 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); CommandCost ret = st->rect.BeforeAddRect(roadstop_area.tile, roadstop_area.w, roadstop_area.h, StationRect::ADD_TEST);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
} else { } else {
/* allocate and initialize new station */ /* allocate and initialize new station */
@ -1846,7 +1828,6 @@ static CommandCost RemoveRoadStop(TileIndex tile, DoCommandFlag flags)
if (_current_company != OWNER_WATER) { if (_current_company != OWNER_WATER) {
CommandCost ret = CheckOwnership(st->owner); CommandCost ret = CheckOwnership(st->owner);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
} }
@ -1870,7 +1851,6 @@ static CommandCost RemoveRoadStop(TileIndex tile, DoCommandFlag flags)
if (flags & DC_EXEC) FindVehicleOnPos(tile, NULL, &ClearRoadStopStatusEnum); if (flags & DC_EXEC) FindVehicleOnPos(tile, NULL, &ClearRoadStopStatusEnum);
} else { } else {
CommandCost ret = EnsureNoVehicleOnGround(tile); CommandCost ret = EnsureNoVehicleOnGround(tile);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; 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; if (airport_type >= NUM_AIRPORTS) return CMD_ERROR;
CommandCost ret = CheckIfAuthorityAllowsNewStation(tile, flags); CommandCost ret = CheckIfAuthorityAllowsNewStation(tile, flags);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
/* Check if a valid, buildable airport was chosen for construction */ /* 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; Station *st = NULL;
ret = FindJoiningStation(INVALID_STATION, station_to_join, HasBit(p2, 0), TileArea(tile, w, h), &st); ret = FindJoiningStation(INVALID_STATION, station_to_join, HasBit(p2, 0), TileArea(tile, w, h), &st);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
/* Distant join */ /* 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); CommandCost ret = st->rect.BeforeAddRect(tile, w, h, StationRect::ADD_TEST);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
if (st->airport.tile != INVALID_TILE) { if (st->airport.tile != INVALID_TILE) {
@ -2263,7 +2240,6 @@ static CommandCost RemoveAirport(TileIndex tile, DoCommandFlag flags)
if (_current_company != OWNER_WATER) { if (_current_company != OWNER_WATER) {
CommandCost ret = CheckOwnership(st->owner); CommandCost ret = CheckOwnership(st->owner);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
} }
@ -2281,7 +2257,6 @@ static CommandCost RemoveAirport(TileIndex tile, DoCommandFlag flags)
if (!st->TileBelongsToAirport(tile_cur)) continue; if (!st->TileBelongsToAirport(tile_cur)) continue;
CommandCost ret = EnsureNoVehicleOnGround(tile_cur); CommandCost ret = EnsureNoVehicleOnGround(tile_cur);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
cost.AddCost(_price[PR_CLEAR_STATION_AIRPORT]); 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); if (IsWaterTile(tile)) return_cmd_error(STR_ERROR_SITE_UNSUITABLE);
CommandCost ret = CheckIfAuthorityAllowsNewStation(tile, flags); CommandCost ret = CheckIfAuthorityAllowsNewStation(tile, flags);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
if (MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST); if (MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST);
ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
TileIndex tile_cur = tile + TileOffsByDiagDir(direction); TileIndex tile_cur = tile + TileOffsByDiagDir(direction);
@ -2402,7 +2375,6 @@ CommandCost CmdBuildDock(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
WaterClass wc = GetWaterClass(tile_cur); WaterClass wc = GetWaterClass(tile_cur);
ret = DoCommand(tile_cur, 0, 0, flags, CMD_LANDSCAPE_CLEAR); ret = DoCommand(tile_cur, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
tile_cur += TileOffsByDiagDir(direction); 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), ret = FindJoiningStation(INVALID_STATION, station_to_join, HasBit(p1, 0),
TileArea(tile + ToTileIndexDiff(_dock_tileoffs_chkaround[direction]), TileArea(tile + ToTileIndexDiff(_dock_tileoffs_chkaround[direction]),
_dock_w_chk[direction], _dock_h_chk[direction]), &st); _dock_w_chk[direction], _dock_h_chk[direction]), &st);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
/* Distant join */ /* Distant join */
@ -2432,7 +2403,6 @@ CommandCost CmdBuildDock(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
CommandCost ret = st->rect.BeforeAddRect( CommandCost ret = st->rect.BeforeAddRect(
tile + ToTileIndexDiff(_dock_tileoffs_chkaround[direction]), tile + ToTileIndexDiff(_dock_tileoffs_chkaround[direction]),
_dock_w_chk[direction], _dock_h_chk[direction], StationRect::ADD_TEST); _dock_w_chk[direction], _dock_h_chk[direction], StationRect::ADD_TEST);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
if (st->dock_tile != INVALID_TILE) return_cmd_error(STR_ERROR_TOO_CLOSE_TO_ANOTHER_DOCK); 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); Station *st = Station::GetByTile(tile);
CommandCost ret = CheckOwnership(st->owner); CommandCost ret = CheckOwnership(st->owner);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
TileIndex tile1 = st->dock_tile; TileIndex tile1 = st->dock_tile;
@ -2491,7 +2460,6 @@ static CommandCost RemoveDock(TileIndex tile, DoCommandFlag flags)
ret = EnsureNoVehicleOnGround(tile1); ret = EnsureNoVehicleOnGround(tile1);
if (ret.Succeeded()) ret = EnsureNoVehicleOnGround(tile2); if (ret.Succeeded()) ret = EnsureNoVehicleOnGround(tile2);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
@ -3222,7 +3190,6 @@ CommandCost CmdRenameStation(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
if (st == NULL) return CMD_ERROR; if (st == NULL) return CMD_ERROR;
CommandCost ret = CheckOwnership(st->owner); CommandCost ret = CheckOwnership(st->owner);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
bool reset = StrEmpty(text); bool reset = StrEmpty(text);

View File

@ -71,7 +71,6 @@ CommandCost CmdChangeTimetable(TileIndex tile, DoCommandFlag flags, uint32 p1, u
if (v == NULL || !v->IsPrimaryVehicle()) return CMD_ERROR; if (v == NULL || !v->IsPrimaryVehicle()) return CMD_ERROR;
CommandCost ret = CheckOwnership(v->owner); CommandCost ret = CheckOwnership(v->owner);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
VehicleOrderID order_number = GB(p1, 16, 8); 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; if (v == NULL || !v->IsPrimaryVehicle()) return CMD_ERROR;
CommandCost ret = CheckOwnership(v->owner); CommandCost ret = CheckOwnership(v->owner);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
@ -161,7 +159,6 @@ CommandCost CmdSetTimetableStart(TileIndex tile, DoCommandFlag flags, uint32 p1,
if (v == NULL || !v->IsPrimaryVehicle()) return CMD_ERROR; if (v == NULL || !v->IsPrimaryVehicle()) return CMD_ERROR;
CommandCost ret = CheckOwnership(v->owner); CommandCost ret = CheckOwnership(v->owner);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
/* Don't let a timetable start more than 15 years into the future or 1 year in the past. */ /* 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; if (v == NULL || !v->IsPrimaryVehicle()) return CMD_ERROR;
CommandCost ret = CheckOwnership(v->owner); CommandCost ret = CheckOwnership(v->owner);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
if (flags & DC_EXEC) { if (flags & DC_EXEC) {

View File

@ -1172,7 +1172,6 @@ CommandCost CmdMoveRailVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, u
if (src == NULL) return CMD_ERROR; if (src == NULL) return CMD_ERROR;
CommandCost ret = CheckOwnership(src->owner); CommandCost ret = CheckOwnership(src->owner);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
/* Do not allow moving crashed vehicles inside the depot, it is likely to cause asserts later */ /* 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; if (dst == NULL) return CMD_ERROR;
CommandCost ret = CheckOwnership(dst->owner); CommandCost ret = CheckOwnership(dst->owner);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
/* Do not allow appending to crashed vehicles, too */ /* 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; if (v == NULL) return CMD_ERROR;
CommandCost ret = CheckOwnership(v->owner); CommandCost ret = CheckOwnership(v->owner);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
/* Sell a chain of vehicles or not? */ /* Sell a chain of vehicles or not? */
@ -1830,7 +1827,6 @@ CommandCost CmdReverseTrainDirection(TileIndex tile, DoCommandFlag flags, uint32
if (v == NULL) return CMD_ERROR; if (v == NULL) return CMD_ERROR;
CommandCost ret = CheckOwnership(v->owner); CommandCost ret = CheckOwnership(v->owner);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
if (p2 != 0) { if (p2 != 0) {
@ -1901,7 +1897,6 @@ CommandCost CmdForceTrainProceed(TileIndex tile, DoCommandFlag flags, uint32 p1,
if (t == NULL) return CMD_ERROR; if (t == NULL) return CMD_ERROR;
CommandCost ret = CheckOwnership(t->owner); CommandCost ret = CheckOwnership(t->owner);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
@ -1939,7 +1934,6 @@ CommandCost CmdRefitRailVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1,
if (v == NULL) return CMD_ERROR; if (v == NULL) return CMD_ERROR;
CommandCost ret = CheckOwnership(v->owner); CommandCost ret = CheckOwnership(v->owner);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
if (!v->IsStoppedInDepot()) return_cmd_error(STR_TRAIN_MUST_BE_STOPPED); if (!v->IsStoppedInDepot()) return_cmd_error(STR_TRAIN_MUST_BE_STOPPED);

View File

@ -609,25 +609,19 @@ static inline CommandCost CheckAllowRemoveTunnelBridge(TileIndex tile)
/* We can remove unowned road and if the town allows it */ /* 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)) { if (road_owner == OWNER_TOWN && !(_settings_game.construction.extra_dynamite || _cheats.magic_bulldozer.value)) {
CommandCost ret = CheckTileOwnership(tile); return CheckTileOwnership(tile);
ret.SetGlobalErrorMessage();
return ret;
} }
if (road_owner == OWNER_NONE || road_owner == OWNER_TOWN) road_owner = _current_company; if (road_owner == OWNER_NONE || road_owner == OWNER_TOWN) road_owner = _current_company;
if (tram_owner == OWNER_NONE) tram_owner = _current_company; if (tram_owner == OWNER_NONE) tram_owner = _current_company;
CommandCost ret = CheckOwnership(road_owner, tile); CommandCost ret = CheckOwnership(road_owner, tile);
if (ret.Succeeded()) ret = CheckOwnership(tram_owner, tile); if (ret.Succeeded()) ret = CheckOwnership(tram_owner, tile);
ret.SetGlobalErrorMessage();
return ret; return ret;
} }
case TRANSPORT_RAIL: case TRANSPORT_RAIL:
case TRANSPORT_WATER: { case TRANSPORT_WATER:
CommandCost ret = CheckOwnership(GetTileOwner(tile)); return CheckOwnership(GetTileOwner(tile));
ret.SetGlobalErrorMessage();
return ret;
}
default: NOT_REACHED(); default: NOT_REACHED();
} }
@ -641,13 +635,11 @@ static inline CommandCost CheckAllowRemoveTunnelBridge(TileIndex tile)
static CommandCost DoClearTunnel(TileIndex tile, DoCommandFlag flags) static CommandCost DoClearTunnel(TileIndex tile, DoCommandFlag flags)
{ {
CommandCost ret = CheckAllowRemoveTunnelBridge(tile); CommandCost ret = CheckAllowRemoveTunnelBridge(tile);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
TileIndex endtile = GetOtherTunnelEnd(tile); TileIndex endtile = GetOtherTunnelEnd(tile);
ret = TunnelBridgeIsFree(tile, endtile); ret = TunnelBridgeIsFree(tile, endtile);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
_build_tunnel_endtile = endtile; _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 /* Check if you are allowed to remove the tunnel owned by a town
* Removal depends on difficulty settings */ * Removal depends on difficulty settings */
CommandCost ret = CheckforTownRating(flags, t, TUNNELBRIDGE_REMOVE); CommandCost ret = CheckforTownRating(flags, t, TUNNELBRIDGE_REMOVE);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
} }
@ -710,13 +701,11 @@ static CommandCost DoClearTunnel(TileIndex tile, DoCommandFlag flags)
static CommandCost DoClearBridge(TileIndex tile, DoCommandFlag flags) static CommandCost DoClearBridge(TileIndex tile, DoCommandFlag flags)
{ {
CommandCost ret = CheckAllowRemoveTunnelBridge(tile); CommandCost ret = CheckAllowRemoveTunnelBridge(tile);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
TileIndex endtile = GetOtherBridgeEnd(tile); TileIndex endtile = GetOtherBridgeEnd(tile);
ret = TunnelBridgeIsFree(tile, endtile); ret = TunnelBridgeIsFree(tile, endtile);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
DiagDirection direction = GetTunnelBridgeDirection(tile); 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 /* Check if you are allowed to remove the bridge owned by a town
* Removal depends on difficulty settings */ * Removal depends on difficulty settings */
CommandCost ret = CheckforTownRating(flags, t, TUNNELBRIDGE_REMOVE); CommandCost ret = CheckforTownRating(flags, t, TUNNELBRIDGE_REMOVE);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
} }

View File

@ -177,12 +177,10 @@ CommandCost CmdSellLandArea(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
if (!IsOwnedLandTile(tile)) return CMD_ERROR; if (!IsOwnedLandTile(tile)) return CMD_ERROR;
if (_current_company != OWNER_WATER) { if (_current_company != OWNER_WATER) {
CommandCost ret = CheckTileOwnership(tile); CommandCost ret = CheckTileOwnership(tile);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
} }
CommandCost ret = EnsureNoVehicleOnGround(tile); CommandCost ret = EnsureNoVehicleOnGround(tile);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
if (flags & DC_EXEC) DoClearSquare(tile); if (flags & DC_EXEC) DoClearSquare(tile);
@ -506,7 +504,6 @@ static CommandCost TerraformTile_Unmovable(TileIndex tile, DoCommandFlag flags,
/* Owned land remains unsold */ /* Owned land remains unsold */
if (IsOwnedLand(tile)) { if (IsOwnedLand(tile)) {
CommandCost ret = CheckTileOwnership(tile); CommandCost ret = CheckTileOwnership(tile);
ret.SetGlobalErrorMessage();
if (ret.Succeeded()) return CommandCost(); if (ret.Succeeded()) return CommandCost();
} }

View File

@ -1666,7 +1666,6 @@ void Vehicle::HandleLoading(bool mode)
CommandCost Vehicle::SendToDepot(DoCommandFlag flags, DepotCommand command) CommandCost Vehicle::SendToDepot(DoCommandFlag flags, DepotCommand command)
{ {
CommandCost ret = CheckOwnership(this->owner); CommandCost ret = CheckOwnership(this->owner);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
if (this->vehstatus & VS_CRASHED) return CMD_ERROR; if (this->vehstatus & VS_CRASHED) return CMD_ERROR;

View File

@ -77,7 +77,6 @@ CommandCost CmdStartStopVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1,
if (v == NULL || !v->IsPrimaryVehicle()) return CMD_ERROR; if (v == NULL || !v->IsPrimaryVehicle()) return CMD_ERROR;
CommandCost ret = CheckOwnership(v->owner); CommandCost ret = CheckOwnership(v->owner);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
switch (v->type) { switch (v->type) {
@ -417,7 +416,6 @@ CommandCost CmdCloneVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
*/ */
CommandCost ret = CheckOwnership(v->owner); CommandCost ret = CheckOwnership(v->owner);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
if (v->type == VEH_TRAIN && (!Train::From(v)->IsFrontEngine() || Train::From(v)->crash_anim_pos >= 4400)) return CMD_ERROR; 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; if (v == NULL) return CMD_ERROR;
CommandCost ret = CheckOwnership(v->owner); CommandCost ret = CheckOwnership(v->owner);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
bool reset = StrEmpty(text); bool reset = StrEmpty(text);
@ -660,7 +657,6 @@ CommandCost CmdChangeServiceInt(TileIndex tile, DoCommandFlag flags, uint32 p1,
if (v == NULL) return CMD_ERROR; if (v == NULL) return CMD_ERROR;
CommandCost ret = CheckOwnership(v->owner); CommandCost ret = CheckOwnership(v->owner);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
uint16 serv_int = GetServiceIntervalClamped(p2, v->owner); // Double check the service interval from the user-input uint16 serv_int = GetServiceIntervalClamped(p2, v->owner); // Double check the service interval from the user-input

View File

@ -166,7 +166,6 @@ static CommandCost RemoveShipDepot(TileIndex tile, DoCommandFlag flags)
if (!IsShipDepot(tile)) return CMD_ERROR; if (!IsShipDepot(tile)) return CMD_ERROR;
CommandCost ret = CheckTileOwnership(tile); CommandCost ret = CheckTileOwnership(tile);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
TileIndex tile2 = GetOtherShipDepotTile(tile); TileIndex tile2 = GetOtherShipDepotTile(tile);
@ -175,7 +174,6 @@ static CommandCost RemoveShipDepot(TileIndex tile, DoCommandFlag flags)
if (!(flags & DC_BANKRUPT)) { if (!(flags & DC_BANKRUPT)) {
CommandCost ret = EnsureNoVehicleOnGround(tile); CommandCost ret = EnsureNoVehicleOnGround(tile);
if (ret.Succeeded()) ret = EnsureNoVehicleOnGround(tile2); if (ret.Succeeded()) ret = EnsureNoVehicleOnGround(tile2);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
} }
@ -240,7 +238,6 @@ static CommandCost RemoveShiplift(TileIndex tile, DoCommandFlag flags)
{ {
if (GetTileOwner(tile) != OWNER_NONE) { if (GetTileOwner(tile) != OWNER_NONE) {
CommandCost ret = CheckTileOwnership(tile); CommandCost ret = CheckTileOwnership(tile);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
} }
@ -250,7 +247,6 @@ static CommandCost RemoveShiplift(TileIndex tile, DoCommandFlag flags)
CommandCost ret = EnsureNoVehicleOnGround(tile); CommandCost ret = EnsureNoVehicleOnGround(tile);
if (ret.Succeeded()) ret = EnsureNoVehicleOnGround(tile + delta); if (ret.Succeeded()) ret = EnsureNoVehicleOnGround(tile + delta);
if (ret.Succeeded()) ret = EnsureNoVehicleOnGround(tile - delta); if (ret.Succeeded()) ret = EnsureNoVehicleOnGround(tile - delta);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
@ -357,12 +353,10 @@ static CommandCost ClearTile_Water(TileIndex tile, DoCommandFlag flags)
/* Make sure no vehicle is on the tile */ /* Make sure no vehicle is on the tile */
CommandCost ret = EnsureNoVehicleOnGround(tile); CommandCost ret = EnsureNoVehicleOnGround(tile);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
if (GetTileOwner(tile) != OWNER_WATER && GetTileOwner(tile) != OWNER_NONE) { if (GetTileOwner(tile) != OWNER_WATER && GetTileOwner(tile) != OWNER_NONE) {
CommandCost ret = CheckTileOwnership(tile); CommandCost ret = CheckTileOwnership(tile);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; 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 */ /* Make sure no vehicle is on the tile */
CommandCost ret = EnsureNoVehicleOnGround(tile); CommandCost ret = EnsureNoVehicleOnGround(tile);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
if (flags & DC_EXEC) { if (flags & DC_EXEC) {

View File

@ -179,11 +179,7 @@ static CommandCost IsValidTileForWaypoint(TileIndex tile, Axis axis, StationID *
Owner owner = GetTileOwner(tile); Owner owner = GetTileOwner(tile);
CommandCost ret = CheckOwnership(owner); CommandCost ret = CheckOwnership(owner);
ret.SetGlobalErrorMessage(); if (ret.Succeeded()) ret = EnsureNoVehicleOnGround(tile);
if (ret.Failed()) return ret;
ret = EnsureNoVehicleOnGround(tile);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
Slope tileh = GetTileSlope(tile, NULL); Slope tileh = GetTileSlope(tile, NULL);
@ -258,7 +254,6 @@ CommandCost CmdBuildRailWaypoint(TileIndex start_tile, DoCommandFlag flags, uint
Waypoint *wp = NULL; Waypoint *wp = NULL;
TileArea new_location(TileArea(start_tile, width, height)); TileArea new_location(TileArea(start_tile, width, height));
CommandCost ret = FindJoiningWaypoint(est, station_to_join, adjacent, new_location, &wp); CommandCost ret = FindJoiningWaypoint(est, station_to_join, adjacent, new_location, &wp);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
/* Check if there is an already existing, deleted, waypoint close to us that we can reuse. */ /* 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); CommandCost ret = wp->rect.BeforeAddRect(start_tile, width, height, StationRect::ADD_TEST);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
} else { } else {
/* allocate and initialize new waypoint */ /* 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... */ /* remove the buoy if there is a ship on tile when company goes bankrupt... */
if (!(flags & DC_BANKRUPT)) { if (!(flags & DC_BANKRUPT)) {
CommandCost ret = EnsureNoVehicleOnGround(tile); CommandCost ret = EnsureNoVehicleOnGround(tile);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
} }
@ -451,7 +444,6 @@ CommandCost CmdRenameWaypoint(TileIndex tile, DoCommandFlag flags, uint32 p1, ui
if (wp->owner != OWNER_NONE) { if (wp->owner != OWNER_NONE) {
CommandCost ret = CheckOwnership(wp->owner); CommandCost ret = CheckOwnership(wp->owner);
ret.SetGlobalErrorMessage();
if (ret.Failed()) return ret; if (ret.Failed()) return ret;
} }