1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-17 09:22:42 +01:00

Codechange: Remove unnecessary 'return_cmd_error` macro. (#13160)

This macro is a leftover from when errors used to be packed into a single int32_t.

`return CommandCost` is clearer, and doesn't need a macro.
This commit is contained in:
Peter Nelson
2024-12-08 18:02:30 +00:00
committed by GitHub
parent 369e8a6fe9
commit 1e77fd0b61
27 changed files with 276 additions and 286 deletions

View File

@@ -982,7 +982,7 @@ static CommandCost CheckNewTrain(Train *original_dst, Train *dst, Train *origina
* There will always be a maximum of one new train. */
if (GetFreeUnitNumber(VEH_TRAIN) <= _settings_game.vehicle.max_trains) return CommandCost();
return_cmd_error(STR_ERROR_TOO_MANY_VEHICLES_IN_GAME);
return CommandCost(STR_ERROR_TOO_MANY_VEHICLES_IN_GAME);
}
/**
@@ -1008,7 +1008,7 @@ static CommandCost CheckTrainAttachment(Train *t)
t = t->Next();
}
if (allowed_len < 0) return_cmd_error(STR_ERROR_TRAIN_TOO_LONG);
if (allowed_len < 0) return CommandCost(STR_ERROR_TRAIN_TOO_LONG);
return CommandCost();
}
@@ -1075,7 +1075,7 @@ static CommandCost CheckTrainAttachment(Train *t)
}
}
if (error != STR_NULL) return_cmd_error(error);
if (error != STR_NULL) return CommandCost(error);
}
}
@@ -1085,7 +1085,7 @@ static CommandCost CheckTrainAttachment(Train *t)
t = next;
}
if (allowed_len < 0) return_cmd_error(STR_ERROR_TRAIN_TOO_LONG);
if (allowed_len < 0) return CommandCost(STR_ERROR_TRAIN_TOO_LONG);
return CommandCost();
}
@@ -1237,7 +1237,7 @@ CommandCost CmdMoveRailVehicle(DoCommandFlag flags, VehicleID src_veh, VehicleID
dst_head = nullptr;
}
if (src->IsRearDualheaded()) return_cmd_error(STR_ERROR_REAR_ENGINE_FOLLOW_FRONT);
if (src->IsRearDualheaded()) return CommandCost(STR_ERROR_REAR_ENGINE_FOLLOW_FRONT);
/* When moving all wagons, we can't have the same src_head and dst_head */
if (move_chain && src_head == dst_head) return CommandCost();
@@ -1246,10 +1246,10 @@ CommandCost CmdMoveRailVehicle(DoCommandFlag flags, VehicleID src_veh, VehicleID
if (!move_chain && dst != nullptr && dst->IsRearDualheaded() && src == dst->other_multiheaded_part) return CommandCost();
/* Check if all vehicles in the source train are stopped inside a depot. */
if (!src_head->IsStoppedInDepot()) return_cmd_error(STR_ERROR_TRAINS_CAN_ONLY_BE_ALTERED_INSIDE_A_DEPOT);
if (!src_head->IsStoppedInDepot()) return CommandCost(STR_ERROR_TRAINS_CAN_ONLY_BE_ALTERED_INSIDE_A_DEPOT);
/* Check if all vehicles in the destination train are stopped inside a depot. */
if (dst_head != nullptr && !dst_head->IsStoppedInDepot()) return_cmd_error(STR_ERROR_TRAINS_CAN_ONLY_BE_ALTERED_INSIDE_A_DEPOT);
if (dst_head != nullptr && !dst_head->IsStoppedInDepot()) return CommandCost(STR_ERROR_TRAINS_CAN_ONLY_BE_ALTERED_INSIDE_A_DEPOT);
/* First make a backup of the order of the trains. That way we can do
* whatever we want with the order and later on easily revert. */
@@ -1393,7 +1393,7 @@ CommandCost CmdSellRailWagon(DoCommandFlag flags, Vehicle *t, bool sell_chain, b
Train *v = Train::From(t)->GetFirstEnginePart();
Train *first = v->First();
if (v->IsRearDualheaded()) return_cmd_error(STR_ERROR_REAR_ENGINE_FOLLOW_FRONT);
if (v->IsRearDualheaded()) return CommandCost(STR_ERROR_REAR_ENGINE_FOLLOW_FRONT);
/* First make a backup of the order of the train. That way we can do
* whatever we want with the order and later on easily revert. */
@@ -1418,7 +1418,7 @@ CommandCost CmdSellRailWagon(DoCommandFlag flags, Vehicle *t, bool sell_chain, b
if (first->orders == nullptr && !OrderList::CanAllocateItem()) {
/* Restore the train we had. */
RestoreTrainBackup(original);
return_cmd_error(STR_ERROR_NO_MORE_SPACE_FOR_ORDERS);
return CommandCost(STR_ERROR_NO_MORE_SPACE_FOR_ORDERS);
}
CommandCost cost(EXPENSES_NEW_VEHICLES);
@@ -2068,13 +2068,13 @@ CommandCost CmdReverseTrainDirection(DoCommandFlag flags, VehicleID veh_id, bool
/* turn a single unit around */
if (v->IsMultiheaded() || HasBit(EngInfo(v->engine_type)->callback_mask, CBM_VEHICLE_ARTIC_ENGINE)) {
return_cmd_error(STR_ERROR_CAN_T_REVERSE_DIRECTION_RAIL_VEHICLE_MULTIPLE_UNITS);
return CommandCost(STR_ERROR_CAN_T_REVERSE_DIRECTION_RAIL_VEHICLE_MULTIPLE_UNITS);
}
Train *front = v->First();
/* make sure the vehicle is stopped in the depot */
if (!front->IsStoppedInDepot()) {
return_cmd_error(STR_ERROR_TRAINS_CAN_ONLY_BE_ALTERED_INSIDE_A_DEPOT);
return CommandCost(STR_ERROR_TRAINS_CAN_ONLY_BE_ALTERED_INSIDE_A_DEPOT);
}
if (flags & DC_EXEC) {