1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-25 13:14:19 +01:00

Codechange: Use EnumBitSet for DepotCommand(Flag)s.

This commit is contained in:
Peter Nelson
2025-01-29 17:47:52 +00:00
committed by Peter Nelson
parent 2560339472
commit f51627c76f
9 changed files with 24 additions and 25 deletions

View File

@@ -2580,7 +2580,7 @@ bool Vehicle::IsWaitingForUnbunching() const
* @param command the command to execute.
* @return the cost of the depot action.
*/
CommandCost Vehicle::SendToDepot(DoCommandFlag flags, DepotCommand command)
CommandCost Vehicle::SendToDepot(DoCommandFlag flags, DepotCommandFlags command)
{
CommandCost ret = CheckOwnership(this->owner);
if (ret.Failed()) return ret;
@@ -2593,7 +2593,7 @@ CommandCost Vehicle::SendToDepot(DoCommandFlag flags, DepotCommand command)
if (this->current_order.IsType(OT_GOTO_DEPOT)) {
bool halt_in_depot = (this->current_order.GetDepotActionType() & ODATFB_HALT) != 0;
if (HasFlag(command, DepotCommand::Service) == halt_in_depot) {
if (command.Test(DepotCommandFlag::Service) == halt_in_depot) {
/* We called with a different DEPOT_SERVICE setting.
* Now we change the setting to apply the new one and let the vehicle head for the same depot.
* Note: the if is (true for requesting service == true for ordered to stop in depot) */
@@ -2605,7 +2605,7 @@ CommandCost Vehicle::SendToDepot(DoCommandFlag flags, DepotCommand command)
return CommandCost();
}
if (HasFlag(command, DepotCommand::DontCancel)) return CMD_ERROR; // Requested no cancellation of depot orders
if (command.Test(DepotCommandFlag::DontCancel)) return CMD_ERROR; // Requested no cancellation of depot orders
if (flags & DC_EXEC) {
/* If the orders to 'goto depot' are in the orders list (forced servicing),
* then skip to the next order; effectively cancelling this forced service */
@@ -2636,7 +2636,7 @@ CommandCost Vehicle::SendToDepot(DoCommandFlag flags, DepotCommand command)
this->SetDestTile(closestDepot.location);
this->current_order.MakeGoToDepot(closestDepot.destination, ODTF_MANUAL);
if (!HasFlag(command, DepotCommand::Service)) this->current_order.SetDepotActionType(ODATFB_HALT);
if (!command.Test(DepotCommandFlag::Service)) this->current_order.SetDepotActionType(ODATFB_HALT);
SetWindowWidgetDirty(WC_VEHICLE_VIEW, this->index, WID_VV_START_STOP);
/* If there is no depot in front and the train is not already reversing, reverse automatically (trains only) */