diff --git a/src/autoreplace_cmd.cpp b/src/autoreplace_cmd.cpp --- a/src/autoreplace_cmd.cpp +++ b/src/autoreplace_cmd.cpp @@ -340,7 +340,7 @@ static CommandCost BuildReplacementVehic } /* Build the new vehicle */ - cost = DoCommand(old_veh->tile, e | (CT_INVALID << 24), 0, DC_EXEC | DC_AUTOREPLACE, GetCmdBuildVeh(old_veh)); + cost = DoCommand(DC_EXEC | DC_AUTOREPLACE, GetCmdBuildVeh(old_veh), old_veh->tile, e | (CT_INVALID << 24), 0); if (cost.Failed()) return cost; Vehicle *new_veh = Vehicle::Get(_new_vehicle_id); @@ -350,13 +350,13 @@ static CommandCost BuildReplacementVehic if (refit_cargo != CT_NO_REFIT) { byte subtype = GetBestFittingSubType(old_veh, new_veh, refit_cargo); - cost.AddCost(DoCommand(0, new_veh->index, refit_cargo | (subtype << 8), DC_EXEC, GetCmdRefitVeh(new_veh))); + cost.AddCost(DoCommand(DC_EXEC, GetCmdRefitVeh(new_veh), 0, new_veh->index, refit_cargo | (subtype << 8))); assert(cost.Succeeded()); // This should be ensured by GetNewCargoTypeForReplace() } /* Try to reverse the vehicle, but do not care if it fails as the new type might not be reversible */ if (new_veh->type == VEH_TRAIN && HasBit(Train::From(old_veh)->flags, VRF_REVERSE_DIRECTION)) { - DoCommand(0, new_veh->index, true, DC_EXEC, CMD_REVERSE_TRAIN_DIRECTION); + DoCommand(DC_EXEC, CMD_REVERSE_TRAIN_DIRECTION, 0, new_veh->index, true); } return cost; @@ -370,7 +370,7 @@ static CommandCost BuildReplacementVehic */ static inline CommandCost CmdStartStopVehicle(const Vehicle *v, bool evaluate_callback) { - return DoCommand(0, v->index, evaluate_callback ? 1 : 0, DC_EXEC | DC_AUTOREPLACE, CMD_START_STOP_VEHICLE); + return DoCommand(DC_EXEC | DC_AUTOREPLACE, CMD_START_STOP_VEHICLE, 0, v->index, evaluate_callback ? 1 : 0); } /** @@ -383,7 +383,7 @@ static inline CommandCost CmdStartStopVe */ static inline CommandCost CmdMoveVehicle(const Vehicle *v, const Vehicle *after, DoCommandFlag flags, bool whole_chain) { - return DoCommand(0, v->index | (whole_chain ? 1 : 0) << 20, after != nullptr ? after->index : INVALID_VEHICLE, flags | DC_NO_CARGO_CAP_CHECK, CMD_MOVE_RAIL_VEHICLE); + return DoCommand(flags | DC_NO_CARGO_CAP_CHECK, CMD_MOVE_RAIL_VEHICLE, 0, v->index | (whole_chain ? 1 : 0) << 20, after != nullptr ? after->index : INVALID_VEHICLE); } /** @@ -397,10 +397,10 @@ static CommandCost CopyHeadSpecificThing CommandCost cost = CommandCost(); /* Share orders */ - if (cost.Succeeded() && old_head != new_head) cost.AddCost(DoCommand(0, new_head->index | CO_SHARE << 30, old_head->index, DC_EXEC, CMD_CLONE_ORDER)); + if (cost.Succeeded() && old_head != new_head) cost.AddCost(DoCommand(DC_EXEC, CMD_CLONE_ORDER, 0, new_head->index | CO_SHARE << 30, old_head->index)); /* Copy group membership */ - if (cost.Succeeded() && old_head != new_head) cost.AddCost(DoCommand(0, old_head->group_id, new_head->index, DC_EXEC, CMD_ADD_VEHICLE_GROUP)); + if (cost.Succeeded() && old_head != new_head) cost.AddCost(DoCommand(DC_EXEC, CMD_ADD_VEHICLE_GROUP, 0, old_head->group_id, new_head->index)); /* Perform start/stop check whether the new vehicle suits newgrf restrictions etc. */ if (cost.Succeeded()) { @@ -466,11 +466,11 @@ static CommandCost ReplaceFreeUnit(Vehic } /* Sell the old vehicle */ - cost.AddCost(DoCommand(0, old_v->index, 0, flags, GetCmdSellVeh(old_v))); + cost.AddCost(DoCommand(flags, GetCmdSellVeh(old_v), 0, old_v->index, 0)); /* If we are not in DC_EXEC undo everything */ if ((flags & DC_EXEC) == 0) { - DoCommand(0, new_v->index, 0, DC_EXEC, GetCmdSellVeh(new_v)); + DoCommand(DC_EXEC, GetCmdSellVeh(new_v), 0, new_v->index, 0); } } @@ -597,7 +597,7 @@ static CommandCost ReplaceChain(Vehicle assert(RailVehInfo(wagon->engine_type)->railveh_type == RAILVEH_WAGON); /* Sell wagon */ - [[maybe_unused]] CommandCost ret = DoCommand(0, wagon->index, 0, DC_EXEC, GetCmdSellVeh(wagon)); + [[maybe_unused]] CommandCost ret = DoCommand(DC_EXEC, GetCmdSellVeh(wagon), 0, wagon->index, 0); assert(ret.Succeeded()); new_vehs[i] = nullptr; @@ -629,7 +629,7 @@ static CommandCost ReplaceChain(Vehicle /* Sell the vehicle. * Note: This might temporarily construct new trains, so use DC_AUTOREPLACE to prevent * it from failing due to engine limits. */ - cost.AddCost(DoCommand(0, w->index, 0, flags | DC_AUTOREPLACE, GetCmdSellVeh(w))); + cost.AddCost(DoCommand(flags | DC_AUTOREPLACE, GetCmdSellVeh(w), 0, w->index, 0)); if ((flags & DC_EXEC) != 0) { old_vehs[i] = nullptr; if (i == 0) old_head = nullptr; @@ -660,7 +660,7 @@ static CommandCost ReplaceChain(Vehicle if ((flags & DC_EXEC) == 0) { for (int i = num_units - 1; i >= 0; i--) { if (new_vehs[i] != nullptr) { - DoCommand(0, new_vehs[i]->index, 0, DC_EXEC, GetCmdSellVeh(new_vehs[i])); + DoCommand(DC_EXEC, GetCmdSellVeh(new_vehs[i]), 0, new_vehs[i]->index, 0); new_vehs[i] = nullptr; } } @@ -691,12 +691,12 @@ static CommandCost ReplaceChain(Vehicle } /* Sell the old vehicle */ - cost.AddCost(DoCommand(0, old_head->index, 0, flags, GetCmdSellVeh(old_head))); + cost.AddCost(DoCommand(flags, GetCmdSellVeh(old_head), 0, old_head->index, 0)); } /* If we are not in DC_EXEC undo everything */ if ((flags & DC_EXEC) == 0) { - DoCommand(0, new_head->index, 0, DC_EXEC, GetCmdSellVeh(new_head)); + DoCommand(DC_EXEC, GetCmdSellVeh(new_head), 0, new_head->index, 0); } } }