Codechange: Use EnumBitSet for DoCommandFlags

This commit is contained in:
Rubidium
2025-02-13 23:35:52 +01:00
committed by rubidium42
parent f309b90a1d
commit c3d5e6d2a0
95 changed files with 871 additions and 873 deletions

View File

@@ -679,7 +679,7 @@ uint GetOrderDistance(const Order *prev, const Order *cur, const Vehicle *v, int
* @param new_order order to insert
* @return the cost of this operation or an error
*/
CommandCost CmdInsertOrder(DoCommandFlag flags, VehicleID veh, VehicleOrderID sel_ord, const Order &new_order)
CommandCost CmdInsertOrder(DoCommandFlags flags, VehicleID veh, VehicleOrderID sel_ord, const Order &new_order)
{
Vehicle *v = Vehicle::GetIfValid(veh);
if (v == nullptr || !v->IsPrimaryVehicle()) return CMD_ERROR;
@@ -879,7 +879,7 @@ CommandCost CmdInsertOrder(DoCommandFlag flags, VehicleID veh, VehicleOrderID se
if (!Order::CanAllocateItem()) return CommandCost(STR_ERROR_NO_MORE_SPACE_FOR_ORDERS);
if (v->orders == nullptr && !OrderList::CanAllocateItem()) return CommandCost(STR_ERROR_NO_MORE_SPACE_FOR_ORDERS);
if (flags & DC_EXEC) {
if (flags.Test(DoCommandFlag::Execute)) {
Order *new_o = new Order();
new_o->AssignOrder(new_order);
InsertOrder(v, new_o, sel_ord);
@@ -964,9 +964,9 @@ void InsertOrder(Vehicle *v, Order *new_o, VehicleOrderID sel_ord)
* @param *dst delete the orders of this vehicle
* @param flags execution flags
*/
static CommandCost DecloneOrder(Vehicle *dst, DoCommandFlag flags)
static CommandCost DecloneOrder(Vehicle *dst, DoCommandFlags flags)
{
if (flags & DC_EXEC) {
if (flags.Test(DoCommandFlag::Execute)) {
DeleteVehicleOrders(dst);
InvalidateVehicleOrder(dst, VIWD_REMOVE_ALL_ORDERS);
InvalidateWindowClassesData(GetWindowClassForVehicleType(dst->type), 0);
@@ -981,7 +981,7 @@ static CommandCost DecloneOrder(Vehicle *dst, DoCommandFlag flags)
* @param sel_ord the order to delete (max 255)
* @return the cost of this operation or an error
*/
CommandCost CmdDeleteOrder(DoCommandFlag flags, VehicleID veh_id, VehicleOrderID sel_ord)
CommandCost CmdDeleteOrder(DoCommandFlags flags, VehicleID veh_id, VehicleOrderID sel_ord)
{
Vehicle *v = Vehicle::GetIfValid(veh_id);
@@ -995,7 +995,7 @@ CommandCost CmdDeleteOrder(DoCommandFlag flags, VehicleID veh_id, VehicleOrderID
if (v->GetOrder(sel_ord) == nullptr) return CMD_ERROR;
if (flags & DC_EXEC) DeleteOrder(v, sel_ord);
if (flags.Test(DoCommandFlag::Execute)) DeleteOrder(v, sel_ord);
return CommandCost();
}
@@ -1083,7 +1083,7 @@ void DeleteOrder(Vehicle *v, VehicleOrderID sel_ord)
* @param sel_ord the selected order to which we want to skip
* @return the cost of this operation or an error
*/
CommandCost CmdSkipToOrder(DoCommandFlag flags, VehicleID veh_id, VehicleOrderID sel_ord)
CommandCost CmdSkipToOrder(DoCommandFlags flags, VehicleID veh_id, VehicleOrderID sel_ord)
{
Vehicle *v = Vehicle::GetIfValid(veh_id);
@@ -1092,7 +1092,7 @@ CommandCost CmdSkipToOrder(DoCommandFlag flags, VehicleID veh_id, VehicleOrderID
CommandCost ret = CheckOwnership(v->owner);
if (ret.Failed()) return ret;
if (flags & DC_EXEC) {
if (flags.Test(DoCommandFlag::Execute)) {
if (v->current_order.IsType(OT_LOADING)) v->LeaveStation();
v->cur_implicit_order_index = v->cur_real_order_index = sel_ord;
@@ -1121,7 +1121,7 @@ CommandCost CmdSkipToOrder(DoCommandFlag flags, VehicleID veh_id, VehicleOrderID
* @note The target order will move one place down in the orderlist
* if you move the order upwards else it'll move it one place down
*/
CommandCost CmdMoveOrder(DoCommandFlag flags, VehicleID veh, VehicleOrderID moving_order, VehicleOrderID target_order)
CommandCost CmdMoveOrder(DoCommandFlags flags, VehicleID veh, VehicleOrderID moving_order, VehicleOrderID target_order)
{
Vehicle *v = Vehicle::GetIfValid(veh);
if (v == nullptr || !v->IsPrimaryVehicle()) return CMD_ERROR;
@@ -1137,7 +1137,7 @@ CommandCost CmdMoveOrder(DoCommandFlag flags, VehicleID veh, VehicleOrderID movi
/* Don't move an empty order */
if (moving_one == nullptr) return CMD_ERROR;
if (flags & DC_EXEC) {
if (flags.Test(DoCommandFlag::Execute)) {
v->orders->MoveOrder(moving_order, target_order);
/* Update shared list */
@@ -1219,7 +1219,7 @@ CommandCost CmdMoveOrder(DoCommandFlag flags, VehicleID veh, VehicleOrderID movi
* @param data the data to modify
* @return the cost of this operation or an error
*/
CommandCost CmdModifyOrder(DoCommandFlag flags, VehicleID veh, VehicleOrderID sel_ord, ModifyOrderFlags mof, uint16_t data)
CommandCost CmdModifyOrder(DoCommandFlags flags, VehicleID veh, VehicleOrderID sel_ord, ModifyOrderFlags mof, uint16_t data)
{
if (mof >= MOF_END) return CMD_ERROR;
@@ -1338,7 +1338,7 @@ CommandCost CmdModifyOrder(DoCommandFlag flags, VehicleID veh, VehicleOrderID se
break;
}
if (flags & DC_EXEC) {
if (flags.Test(DoCommandFlag::Execute)) {
switch (mof) {
case MOF_NON_STOP:
order->SetNonStopType((OrderNonStopFlags)data);
@@ -1504,7 +1504,7 @@ static bool CheckAircraftOrderDistance(const Aircraft *v_new, const Vehicle *v_o
* @param veh_src source vehicle to clone orders from, if any (none for CO_UNSHARE)
* @return the cost of this operation or an error
*/
CommandCost CmdCloneOrder(DoCommandFlag flags, CloneOptions action, VehicleID veh_dst, VehicleID veh_src)
CommandCost CmdCloneOrder(DoCommandFlags flags, CloneOptions action, VehicleID veh_dst, VehicleID veh_src)
{
Vehicle *dst = Vehicle::GetIfValid(veh_dst);
if (dst == nullptr || !dst->IsPrimaryVehicle()) return CMD_ERROR;
@@ -1551,7 +1551,7 @@ CommandCost CmdCloneOrder(DoCommandFlag flags, CloneOptions action, VehicleID ve
return CommandCost(STR_ERROR_NO_MORE_SPACE_FOR_ORDERS);
}
if (flags & DC_EXEC) {
if (flags.Test(DoCommandFlag::Execute)) {
/* If the destination vehicle had a OrderList, destroy it.
* We only reset the order indices, if the new orders are obviously different.
* (We mainly do this to keep the order indices valid and in range.) */
@@ -1599,7 +1599,7 @@ CommandCost CmdCloneOrder(DoCommandFlag flags, CloneOptions action, VehicleID ve
return CommandCost(STR_ERROR_NO_MORE_SPACE_FOR_ORDERS);
}
if (flags & DC_EXEC) {
if (flags.Test(DoCommandFlag::Execute)) {
Order *first = nullptr;
Order **order_dst;
@@ -1646,7 +1646,7 @@ CommandCost CmdCloneOrder(DoCommandFlag flags, CloneOptions action, VehicleID ve
* @param cargo CargoType
* @return the cost of this operation or an error
*/
CommandCost CmdOrderRefit(DoCommandFlag flags, VehicleID veh, VehicleOrderID order_number, CargoType cargo)
CommandCost CmdOrderRefit(DoCommandFlags flags, VehicleID veh, VehicleOrderID order_number, CargoType cargo)
{
if (cargo >= NUM_CARGO && cargo != CARGO_NO_REFIT && cargo != CARGO_AUTO_REFIT) return CMD_ERROR;
@@ -1664,7 +1664,7 @@ CommandCost CmdOrderRefit(DoCommandFlag flags, VehicleID veh, VehicleOrderID ord
if (order->GetLoadType() & OLFB_NO_LOAD) return CMD_ERROR;
if (flags & DC_EXEC) {
if (flags.Test(DoCommandFlag::Execute)) {
order->SetRefit(cargo);
/* Make the depot order an 'always go' order. */
@@ -2016,7 +2016,7 @@ bool UpdateOrderDest(Vehicle *v, const Order *order, int conditional_depth, bool
v->current_order.SetDestination(closestDepot.destination);
/* If there is no depot in front, reverse automatically (trains only) */
if (v->type == VEH_TRAIN && closestDepot.reverse) Command<CMD_REVERSE_TRAIN_DIRECTION>::Do(DC_EXEC, v->index, false);
if (v->type == VEH_TRAIN && closestDepot.reverse) Command<CMD_REVERSE_TRAIN_DIRECTION>::Do(DoCommandFlag::Execute, v->index, false);
if (v->type == VEH_AIRCRAFT) {
Aircraft *a = Aircraft::From(v);