summaryrefslogtreecommitdiff
path: root/src/aircraft_cmd.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/aircraft_cmd.cpp')
-rw-r--r--src/aircraft_cmd.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp
index d53cdb900..52a011673 100644
--- a/src/aircraft_cmd.cpp
+++ b/src/aircraft_cmd.cpp
@@ -405,13 +405,17 @@ CommandCost CmdBuildAircraft(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
CommandCost CmdSellAircraft(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
{
Aircraft *v = Aircraft::GetIfValid(p1);
+ if (v == NULL) return CMD_ERROR;
+
+ CommandCost ret = CheckOwnership(v->owner);
+ ret.SetGlobalErrorMessage();
+ if (ret.Failed()) return ret;
- if (v == NULL || !CheckOwnership(v->owner)) return CMD_ERROR;
if (!v->IsStoppedInDepot()) return_cmd_error(STR_ERROR_AIRCRAFT_MUST_BE_STOPPED);
if (v->vehstatus & VS_CRASHED) return_cmd_error(STR_ERROR_CAN_T_SELL_DESTROYED_VEHICLE);
- CommandCost ret(EXPENSES_NEW_VEHICLES, -v->value);
+ ret = CommandCost(EXPENSES_NEW_VEHICLES, -v->value);
if (flags & DC_EXEC) {
delete v;
@@ -480,7 +484,12 @@ CommandCost CmdRefitAircraft(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
byte new_subtype = GB(p2, 8, 8);
Aircraft *v = Aircraft::GetIfValid(p1);
- if (v == NULL || !CheckOwnership(v->owner)) return CMD_ERROR;
+ 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);
if (v->vehstatus & VS_CRASHED) return_cmd_error(STR_ERROR_CAN_T_REFIT_DESTROYED_VEHICLE);