diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp index d773b1ff80..0dc45b059d 100644 --- a/src/aircraft_cmd.cpp +++ b/src/aircraft_cmd.cpp @@ -1299,7 +1299,7 @@ void HandleMissingAircraftOrders(Aircraft *v) const Station *st = GetTargetAirportIfValid(v); if (st == nullptr) { Backup cur_company(_current_company, v->owner); - CommandCost ret = Command::Do(DoCommandFlag::Execute, v->index, DepotCommandFlag{}, {}); + CommandCost ret = Command::Do(DoCommandFlag::Execute, v->index, DepotCommandFlag{}, {}); cur_company.Restore(); if (ret.Failed()) CrashAirplane(v); @@ -1663,7 +1663,7 @@ static void AircraftEventHandler_HeliTakeOff(Aircraft *v, const AirportFTAClass /* Send the helicopter to a hangar if needed for replacement */ if (v->NeedsAutomaticServicing()) { Backup cur_company(_current_company, v->owner); - Command::Do(DoCommandFlag::Execute, v->index, DepotCommandFlag::Service, {}); + Command::Do(DoCommandFlag::Execute, v->index, DepotCommandFlag::Service, {}); cur_company.Restore(); } } @@ -1714,7 +1714,7 @@ static void AircraftEventHandler_Landing(Aircraft *v, const AirportFTAClass *) /* check if the aircraft needs to be replaced or renewed and send it to a hangar if needed */ if (v->NeedsAutomaticServicing()) { Backup cur_company(_current_company, v->owner); - Command::Do(DoCommandFlag::Execute, v->index, DepotCommandFlag::Service, {}); + Command::Do(DoCommandFlag::Execute, v->index, DepotCommandFlag::Service, {}); cur_company.Restore(); } } diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp index e02570a7d4..e93b300ea9 100644 --- a/src/airport_gui.cpp +++ b/src/airport_gui.cpp @@ -73,9 +73,9 @@ static void PlaceAirport(TileIndex tile) auto proc = [=](bool test, StationID to_join) -> bool { if (test) { - return Command::Do(CommandFlagsToDCFlags(GetCommandFlags()), tile, airport_type, layout, StationID::Invalid(), adjacent).Succeeded(); + return Command::Do(CommandFlagsToDCFlags(GetCommandFlags()), tile, airport_type, layout, StationID::Invalid(), adjacent).Succeeded(); } else { - return Command::Post(STR_ERROR_CAN_T_BUILD_AIRPORT_HERE, CcBuildAirport, tile, airport_type, layout, to_join, adjacent); + return Command::Post(STR_ERROR_CAN_T_BUILD_AIRPORT_HERE, CcBuildAirport, tile, airport_type, layout, to_join, adjacent); } }; diff --git a/src/autoreplace_cmd.cpp b/src/autoreplace_cmd.cpp index e746d62188..dddae41e21 100644 --- a/src/autoreplace_cmd.cpp +++ b/src/autoreplace_cmd.cpp @@ -357,7 +357,7 @@ static CommandCost BuildReplacementVehicle(Vehicle *old_veh, Vehicle **new_vehic /* Build the new vehicle */ VehicleID new_veh_id; - std::tie(cost, new_veh_id, std::ignore, std::ignore, std::ignore) = Command::Do({DoCommandFlag::Execute, DoCommandFlag::AutoReplace}, old_veh->tile, e, true, INVALID_CARGO, INVALID_CLIENT_ID); + std::tie(cost, new_veh_id, std::ignore, std::ignore, std::ignore) = Command::Do({DoCommandFlag::Execute, DoCommandFlag::AutoReplace}, old_veh->tile, e, true, INVALID_CARGO, INVALID_CLIENT_ID); if (cost.Failed()) return cost; Vehicle *new_veh = Vehicle::Get(new_veh_id); @@ -367,7 +367,7 @@ static CommandCost BuildReplacementVehicle(Vehicle *old_veh, Vehicle **new_vehic if (refit_cargo != CARGO_NO_REFIT) { uint8_t subtype = GetBestFittingSubType(old_veh, new_veh, refit_cargo); - cost.AddCost(std::get<0>(Command::Do(DoCommandFlag::Execute, new_veh->index, refit_cargo, subtype, false, false, 0))); + cost.AddCost(std::get<0>(Command::Do(DoCommandFlag::Execute, new_veh->index, refit_cargo, subtype, false, false, 0))); assert(cost.Succeeded()); // This should be ensured by GetNewCargoTypeForReplace() } @@ -376,7 +376,7 @@ static CommandCost BuildReplacementVehicle(Vehicle *old_veh, Vehicle **new_vehic /* Only copy the reverse state if neither old or new vehicle implements reverse-on-build probability callback. */ if (!TestVehicleBuildProbability(old_veh, old_veh->engine_type, BuildProbabilityType::Reversed).has_value() && !TestVehicleBuildProbability(new_veh, new_veh->engine_type, BuildProbabilityType::Reversed).has_value()) { - Command::Do(DoCommandFlag::Execute, new_veh->index, true); + Command::Do(DoCommandFlag::Execute, new_veh->index, true); } } @@ -391,7 +391,7 @@ static CommandCost BuildReplacementVehicle(Vehicle *old_veh, Vehicle **new_vehic */ static inline CommandCost DoCmdStartStopVehicle(const Vehicle *v, bool evaluate_callback) { - return Command::Do({DoCommandFlag::Execute, DoCommandFlag::AutoReplace}, v->index, evaluate_callback); + return Command::Do({DoCommandFlag::Execute, DoCommandFlag::AutoReplace}, v->index, evaluate_callback); } /** @@ -404,7 +404,7 @@ static inline CommandCost DoCmdStartStopVehicle(const Vehicle *v, bool evaluate_ */ static inline CommandCost CmdMoveVehicle(const Vehicle *v, const Vehicle *after, DoCommandFlags flags, bool whole_chain) { - return Command::Do(flags.Set(DoCommandFlag::NoCargoCapacityCheck), v->index, after != nullptr ? after->index : VehicleID::Invalid(), whole_chain); + return Command::Do(flags.Set(DoCommandFlag::NoCargoCapacityCheck), v->index, after != nullptr ? after->index : VehicleID::Invalid(), whole_chain); } /** @@ -418,10 +418,10 @@ static CommandCost CopyHeadSpecificThings(Vehicle *old_head, Vehicle *new_head, CommandCost cost = CommandCost(); /* Share orders */ - if (cost.Succeeded() && old_head != new_head) cost.AddCost(Command::Do(DoCommandFlag::Execute, CO_SHARE, new_head->index, old_head->index)); + if (cost.Succeeded() && old_head != new_head) cost.AddCost(Command::Do(DoCommandFlag::Execute, CO_SHARE, new_head->index, old_head->index)); /* Copy group membership */ - if (cost.Succeeded() && old_head != new_head) cost.AddCost(std::get<0>(Command::Do(DoCommandFlag::Execute, old_head->group_id, new_head->index, false, VehicleListIdentifier{}))); + if (cost.Succeeded() && old_head != new_head) cost.AddCost(std::get<0>(Command::Do(DoCommandFlag::Execute, old_head->group_id, new_head->index, false, VehicleListIdentifier{}))); /* Perform start/stop check whether the new vehicle suits newgrf restrictions etc. */ if (cost.Succeeded()) { @@ -488,11 +488,11 @@ static CommandCost ReplaceFreeUnit(Vehicle **single_unit, DoCommandFlags flags, } /* Sell the old vehicle */ - cost.AddCost(Command::Do(flags, old_v->index, false, false, INVALID_CLIENT_ID)); + cost.AddCost(Command::Do(flags, old_v->index, false, false, INVALID_CLIENT_ID)); /* If we are not in DoCommandFlag::Execute undo everything */ if (!flags.Test(DoCommandFlag::Execute)) { - Command::Do(DoCommandFlag::Execute, new_v->index, false, false, INVALID_CLIENT_ID); + Command::Do(DoCommandFlag::Execute, new_v->index, false, false, INVALID_CLIENT_ID); } } @@ -626,7 +626,7 @@ static CommandCost ReplaceChain(Vehicle **chain, DoCommandFlags flags, bool wago assert(RailVehInfo(wagon->engine_type)->railveh_type == RAILVEH_WAGON); /* Sell wagon */ - [[maybe_unused]] CommandCost ret = Command::Do(DoCommandFlag::Execute, wagon->index, false, false, INVALID_CLIENT_ID); + [[maybe_unused]] CommandCost ret = Command::Do(DoCommandFlag::Execute, wagon->index, false, false, INVALID_CLIENT_ID); assert(ret.Succeeded()); it->new_veh = nullptr; @@ -658,7 +658,7 @@ static CommandCost ReplaceChain(Vehicle **chain, DoCommandFlags flags, bool wago /* Sell the vehicle. * Note: This might temporarily construct new trains, so use DoCommandFlag::AutoReplace to prevent * it from failing due to engine limits. */ - cost.AddCost(Command::Do(DoCommandFlags{flags}.Set(DoCommandFlag::AutoReplace), w->index, false, false, INVALID_CLIENT_ID)); + cost.AddCost(Command::Do(DoCommandFlags{flags}.Set(DoCommandFlag::AutoReplace), w->index, false, false, INVALID_CLIENT_ID)); if (flags.Test(DoCommandFlag::Execute)) { it->old_veh = nullptr; if (it == std::begin(replacements)) old_head = nullptr; @@ -689,7 +689,7 @@ static CommandCost ReplaceChain(Vehicle **chain, DoCommandFlags flags, bool wago if (!flags.Test(DoCommandFlag::Execute)) { for (auto it = std::rbegin(replacements); it != std::rend(replacements); ++it) { if (it->new_veh != nullptr) { - Command::Do(DoCommandFlag::Execute, it->new_veh->index, false, false, INVALID_CLIENT_ID); + Command::Do(DoCommandFlag::Execute, it->new_veh->index, false, false, INVALID_CLIENT_ID); it->new_veh = nullptr; } } @@ -716,12 +716,12 @@ static CommandCost ReplaceChain(Vehicle **chain, DoCommandFlags flags, bool wago } /* Sell the old vehicle */ - cost.AddCost(Command::Do(flags, old_head->index, false, false, INVALID_CLIENT_ID)); + cost.AddCost(Command::Do(flags, old_head->index, false, false, INVALID_CLIENT_ID)); } /* If we are not in DoCommandFlag::Execute undo everything */ if (!flags.Test(DoCommandFlag::Execute)) { - Command::Do(DoCommandFlag::Execute, new_head->index, false, false, INVALID_CLIENT_ID); + Command::Do(DoCommandFlag::Execute, new_head->index, false, false, INVALID_CLIENT_ID); } } } diff --git a/src/autoreplace_cmd.h b/src/autoreplace_cmd.h index 994f766cf4..f0b5a78868 100644 --- a/src/autoreplace_cmd.h +++ b/src/autoreplace_cmd.h @@ -18,7 +18,7 @@ CommandCost CmdAutoreplaceVehicle(DoCommandFlags flags, VehicleID veh_id); CommandCost CmdSetAutoReplace(DoCommandFlags flags, GroupID id_g, EngineID old_engine_type, EngineID new_engine_type, bool when_old); -DEF_CMD_TRAIT(CMD_AUTOREPLACE_VEHICLE, CmdAutoreplaceVehicle, {}, CommandType::VehicleManagement) -DEF_CMD_TRAIT(CMD_SET_AUTOREPLACE, CmdSetAutoReplace, {}, CommandType::VehicleManagement) +DEF_CMD_TRAIT(Commands::AutoreplaceVehicle, CmdAutoreplaceVehicle, {}, CommandType::VehicleManagement) +DEF_CMD_TRAIT(Commands::SetAutoreplace, CmdSetAutoReplace, {}, CommandType::VehicleManagement) #endif /* AUTOREPLACE_CMD_H */ diff --git a/src/autoreplace_gui.cpp b/src/autoreplace_gui.cpp index c302ee9bd7..16f8800d6e 100644 --- a/src/autoreplace_gui.cpp +++ b/src/autoreplace_gui.cpp @@ -248,7 +248,7 @@ class ReplaceVehicleWindow : public Window { { EngineID veh_from = this->sel_engine[0]; EngineID veh_to = this->sel_engine[1]; - Command::Post(this->sel_group, veh_from, veh_to, replace_when_old); + Command::Post(this->sel_group, veh_from, veh_to, replace_when_old); } /** @@ -549,10 +549,10 @@ public: case WID_RV_TRAIN_WAGONREMOVE_TOGGLE: { const Group *g = Group::GetIfValid(this->sel_group); if (g != nullptr) { - Command::Post(this->sel_group, GroupFlag::ReplaceWagonRemoval, !g->flags.Test(GroupFlag::ReplaceWagonRemoval), _ctrl_pressed); + Command::Post(this->sel_group, GroupFlag::ReplaceWagonRemoval, !g->flags.Test(GroupFlag::ReplaceWagonRemoval), _ctrl_pressed); } else { /* toggle renew_keep_length */ - Command::Post("company.renew_keep_length", Company::Get(_local_company)->settings.renew_keep_length ? 0 : 1); + Command::Post("company.renew_keep_length", Company::Get(_local_company)->settings.renew_keep_length ? 0 : 1); } break; } @@ -570,7 +570,7 @@ public: case WID_RV_STOP_REPLACE: { // Stop replacing EngineID veh_from = this->sel_engine[0]; - Command::Post(this->sel_group, veh_from, EngineID::Invalid(), false); + Command::Post(this->sel_group, veh_from, EngineID::Invalid(), false); break; } @@ -606,7 +606,7 @@ public: if (click_side == 0 && _ctrl_pressed && e != EngineID::Invalid() && (GetGroupNumEngines(_local_company, sel_group, e) == 0 || GetGroupNumEngines(_local_company, ALL_GROUP, e) == 0)) { EngineID veh_from = e; - Command::Post(this->sel_group, veh_from, EngineID::Invalid(), false); + Command::Post(this->sel_group, veh_from, EngineID::Invalid(), false); break; } diff --git a/src/bridge_gui.cpp b/src/bridge_gui.cpp index 538c287f02..8bfecf460f 100644 --- a/src/bridge_gui.cpp +++ b/src/bridge_gui.cpp @@ -116,7 +116,7 @@ private: case TRANSPORT_ROAD: _last_roadbridge_type = type; break; default: break; } - Command::Post(STR_ERROR_CAN_T_BUILD_BRIDGE_HERE, CcBuildBridge, + Command::Post(STR_ERROR_CAN_T_BUILD_BRIDGE_HERE, CcBuildBridge, this->end_tile, this->start_tile, this->transport_type, type, this->road_rail_type); } @@ -373,13 +373,13 @@ void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transpo default: break; // water ways and air routes don't have bridge types } if (_ctrl_pressed && CheckBridgeAvailability(last_bridge_type, bridge_len).Succeeded()) { - Command::Post(STR_ERROR_CAN_T_BUILD_BRIDGE_HERE, CcBuildBridge, end, start, transport_type, last_bridge_type, road_rail_type); + Command::Post(STR_ERROR_CAN_T_BUILD_BRIDGE_HERE, CcBuildBridge, end, start, transport_type, last_bridge_type, road_rail_type); return; } /* only query bridge building possibility once, result is the same for all bridges! * returns CMD_ERROR on failure, and price on success */ - CommandCost ret = Command::Do(CommandFlagsToDCFlags(GetCommandFlags()) | DoCommandFlag::QueryCost, end, start, transport_type, 0, road_rail_type); + CommandCost ret = Command::Do(CommandFlagsToDCFlags(GetCommandFlags()) | DoCommandFlag::QueryCost, end, start, transport_type, 0, road_rail_type); GUIBridgeList bl; if (!ret.Failed()) { diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp index 2cba8cc6b3..23089acc72 100644 --- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -1313,7 +1313,7 @@ struct BuildVehicleWindow : Window { if (!this->listview_mode) { /* Query for cost and refitted capacity */ - auto [ret, veh_id, refit_capacity, refit_mail, cargo_capacities] = Command::Do(DoCommandFlag::QueryCost, TileIndex(this->window_number), this->sel_engine, true, cargo, INVALID_CLIENT_ID); + auto [ret, veh_id, refit_capacity, refit_mail, cargo_capacities] = Command::Do(DoCommandFlag::QueryCost, TileIndex(this->window_number), this->sel_engine, true, cargo, INVALID_CLIENT_ID); if (ret.Succeeded()) { this->te.cost = ret.GetCost() - e->GetCost(); this->te.capacity = refit_capacity; @@ -1627,9 +1627,9 @@ struct BuildVehicleWindow : Window { CargoType cargo = this->cargo_filter_criteria; if (cargo == CargoFilterCriteria::CF_ANY || cargo == CargoFilterCriteria::CF_ENGINES || cargo == CargoFilterCriteria::CF_NONE) cargo = INVALID_CARGO; if (this->vehicle_type == VEH_TRAIN && RailVehInfo(sel_eng)->railveh_type == RAILVEH_WAGON) { - Command::Post(GetCmdBuildVehMsg(this->vehicle_type), CcBuildWagon, TileIndex(this->window_number), sel_eng, true, cargo, INVALID_CLIENT_ID); + Command::Post(GetCmdBuildVehMsg(this->vehicle_type), CcBuildWagon, TileIndex(this->window_number), sel_eng, true, cargo, INVALID_CLIENT_ID); } else { - Command::Post(GetCmdBuildVehMsg(this->vehicle_type), CcBuildPrimaryVehicle, TileIndex(this->window_number), sel_eng, true, cargo, INVALID_CLIENT_ID); + Command::Post(GetCmdBuildVehMsg(this->vehicle_type), CcBuildPrimaryVehicle, TileIndex(this->window_number), sel_eng, true, cargo, INVALID_CLIENT_ID); } /* Update last used variant in hierarchy and refresh if necessary. */ @@ -1710,7 +1710,7 @@ struct BuildVehicleWindow : Window { case WID_BV_SHOW_HIDE: { const Engine *e = (this->sel_engine == EngineID::Invalid()) ? nullptr : Engine::Get(this->sel_engine); if (e != nullptr) { - Command::Post(this->sel_engine, !e->IsHidden(_current_company)); + Command::Post(this->sel_engine, !e->IsHidden(_current_company)); } break; } @@ -1893,7 +1893,7 @@ struct BuildVehicleWindow : Window { { if (!str.has_value()) return; - Command::Post(STR_ERROR_CAN_T_RENAME_TRAIN_TYPE + this->vehicle_type, this->rename_engine, *str); + Command::Post(STR_ERROR_CAN_T_RENAME_TRAIN_TYPE + this->vehicle_type, this->rename_engine, *str); } void OnDropdownSelect(WidgetID widget, int index, int click_result) override diff --git a/src/cheat_gui.cpp b/src/cheat_gui.cpp index 61df946d7d..cec28bc73d 100644 --- a/src/cheat_gui.cpp +++ b/src/cheat_gui.cpp @@ -61,7 +61,7 @@ static int32_t _money_cheat_amount = 10000000; */ static int32_t ClickMoneyCheat(int32_t, int32_t change_direction) { - Command::Post(Money(_money_cheat_amount) * change_direction); + Command::Post(Money(_money_cheat_amount) * change_direction); return _money_cheat_amount; } diff --git a/src/clear_cmd.cpp b/src/clear_cmd.cpp index f36babca62..d99c905362 100644 --- a/src/clear_cmd.cpp +++ b/src/clear_cmd.cpp @@ -395,7 +395,7 @@ static void ChangeTileOwner_Clear(TileIndex, Owner, Owner) static CommandCost TerraformTile_Clear(TileIndex tile, DoCommandFlags flags, int, Slope) { - return Command::Do(flags, tile); + return Command::Do(flags, tile); } static CommandCost CheckBuildAbove_Clear(TileIndex, DoCommandFlags, Axis, int) diff --git a/src/command.cpp b/src/command.cpp index 305a8b2726..c2bcf4a6be 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -84,7 +84,7 @@ inline constexpr CommandInfo CommandFromTrait() noexcept { return { T::name, T:: template inline constexpr auto MakeCommandsFromTraits(std::integer_sequence) noexcept { - return std::array{{ CommandFromTrait(i)>>()... }}; + return EnumClassIndexContainer, Commands>{{{ CommandFromTrait(i)>>()... }}}; } /** @@ -94,7 +94,7 @@ inline constexpr auto MakeCommandsFromTraits(std::integer_sequence) noe * the flags which belongs to it. The indices are the same * as the value from the CMD_* enums. */ -static constexpr auto _command_proc_table = MakeCommandsFromTraits(std::make_integer_sequence, CMD_END>{}); +static constexpr auto _command_proc_table = MakeCommandsFromTraits(std::make_integer_sequence, to_underlying(Commands::End)>{}); /** @@ -105,7 +105,7 @@ static constexpr auto _command_proc_table = MakeCommandsFromTraits(std::make_int */ bool IsValidCommand(Commands cmd) { - return cmd < _command_proc_table.size(); + return to_underlying(cmd) < _command_proc_table.size(); } /** @@ -343,7 +343,7 @@ CommandCost CommandHelperBase::InternalExecuteProcessResult(Commands cmd, Comman { BasePersistentStorageArray::SwitchMode(PSM_LEAVE_COMMAND); - if (cmd == CMD_COMPANY_CTRL) { + if (cmd == Commands::CompanyControl) { cur_company.Trash(); /* We are a new company -> Switch to new local company. * We were closed down -> Switch to spectator diff --git a/src/command_func.h b/src/command_func.h index ecbaba2bf4..ab67a82085 100644 --- a/src/command_func.h +++ b/src/command_func.h @@ -97,7 +97,7 @@ protected: /** * Templated wrapper that exposes the command parameter arguments - * for the various Command::Do/Post calls. + * for the various Commands::Do/Post calls. * @tparam Tcmd The command-id to execute. * @tparam Tret Return type of the command. * @tparam Targs The command parameter types. diff --git a/src/command_type.h b/src/command_type.h index 1a5cc841d8..8a2648cfbc 100644 --- a/src/command_type.h +++ b/src/command_type.h @@ -193,190 +193,190 @@ CommandCost CommandCostWithParam(StringID str, ConvertibleThroughBase auto value * * @see _command_proc_table */ -enum Commands : uint8_t { - CMD_BUILD_RAILROAD_TRACK, ///< build a rail track - CMD_REMOVE_RAILROAD_TRACK, ///< remove a rail track - CMD_BUILD_SINGLE_RAIL, ///< build a single rail track - CMD_REMOVE_SINGLE_RAIL, ///< remove a single rail track - CMD_LANDSCAPE_CLEAR, ///< demolish a tile - CMD_BUILD_BRIDGE, ///< build a bridge - CMD_BUILD_RAIL_STATION, ///< build a rail station - CMD_BUILD_TRAIN_DEPOT, ///< build a train depot - CMD_BUILD_SINGLE_SIGNAL, ///< build a signal - CMD_REMOVE_SINGLE_SIGNAL, ///< remove a signal - CMD_TERRAFORM_LAND, ///< terraform a tile - CMD_BUILD_OBJECT, ///< build an object - CMD_BUILD_OBJECT_AREA, ///< build an area of objects - CMD_BUILD_TUNNEL, ///< build a tunnel +enum class Commands : uint8_t { + BuildRailLong, ///< build a rail track + RemoveRailLong, ///< remove a rail track + BuildRail, ///< build a single rail track + RemoveRail, ///< remove a single rail track + LandscapeClear, ///< demolish a tile + BuildBridge, ///< build a bridge + BuildRailStation, ///< build a rail station + BuildRailDepot, ///< build a train depot + BuildSignal, ///< build a signal + RemoveSignal, ///< remove a signal + TerraformLand, ///< terraform a tile + BuildObject, ///< build an object + BuildObjectArea, ///< build an area of objects + BuildTunnel, ///< build a tunnel - CMD_REMOVE_FROM_RAIL_STATION, ///< remove a (rectangle of) tiles from a rail station - CMD_CONVERT_RAIL, ///< convert a rail type + RemoveFromRailStation, ///< remove a (rectangle of) tiles from a rail station + ConvertRail, ///< convert a rail type - CMD_BUILD_RAIL_WAYPOINT, ///< build a waypoint - CMD_RENAME_WAYPOINT, ///< rename a waypoint - CMD_MOVE_WAYPOINT_NAME, ///< move a waypoint name - CMD_REMOVE_FROM_RAIL_WAYPOINT, ///< remove a (rectangle of) tiles from a rail waypoint + BuildRailWaypoint, ///< build a waypoint + RenameWaypoint, ///< rename a waypoint + MoveWaypointNAme, ///< move a waypoint name + RemoveFromRailWaypoint, ///< remove a (rectangle of) tiles from a rail waypoint - CMD_BUILD_ROAD_WAYPOINT, ///< build a road waypoint - CMD_REMOVE_FROM_ROAD_WAYPOINT, ///< remove a (rectangle of) tiles from a road waypoint + BuildRoadWaypoint, ///< build a road waypoint + RemoveFromRoadWaypoint, ///< remove a (rectangle of) tiles from a road waypoint - CMD_BUILD_ROAD_STOP, ///< build a road stop - CMD_REMOVE_ROAD_STOP, ///< remove a road stop - CMD_BUILD_LONG_ROAD, ///< build a complete road (not a "half" one) - CMD_REMOVE_LONG_ROAD, ///< remove a complete road (not a "half" one) - CMD_BUILD_ROAD, ///< build a "half" road - CMD_BUILD_ROAD_DEPOT, ///< build a road depot - CMD_CONVERT_ROAD, ///< convert a road type + BuildRoadStop, ///< build a road stop + RemoveRoadStop, ///< remove a road stop + BuildRoadLong, ///< build a complete road (not a "half" one) + RemoveRoadLong, ///< remove a complete road (not a "half" one) + BuildRoad, ///< build a "half" road + BuildRoadDepot, ///< build a road depot + ConvertRoad, ///< convert a road type - CMD_BUILD_AIRPORT, ///< build an airport + BuildAirport, ///< build an airport - CMD_BUILD_DOCK, ///< build a dock + BuildDock, ///< build a dock - CMD_BUILD_SHIP_DEPOT, ///< build a ship depot - CMD_BUILD_BUOY, ///< build a buoy + BuildShipDepot, ///< build a ship depot + BuildBuoy, ///< build a buoy - CMD_PLANT_TREE, ///< plant a tree + PlantTree, ///< plant a tree - CMD_BUILD_VEHICLE, ///< build a vehicle - CMD_SELL_VEHICLE, ///< sell a vehicle - CMD_REFIT_VEHICLE, ///< refit the cargo space of a vehicle - CMD_SEND_VEHICLE_TO_DEPOT, ///< send a vehicle to a depot - CMD_SET_VEHICLE_VISIBILITY, ///< hide or unhide a vehicle in the build vehicle and autoreplace GUIs + BuildVehicle, ///< build a vehicle + SellVehicle, ///< sell a vehicle + RefitVehicle, ///< refit the cargo space of a vehicle + SendVehicleToDepot, ///< send a vehicle to a depot + SetVehicleVisibility, ///< hide or unhide a vehicle in the build vehicle and autoreplace GUIs - CMD_MOVE_RAIL_VEHICLE, ///< move a rail vehicle (in the depot) - CMD_FORCE_TRAIN_PROCEED, ///< proceed a train to pass a red signal - CMD_REVERSE_TRAIN_DIRECTION, ///< turn a train around + MoveRailVehicle, ///< move a rail vehicle (in the depot) + ForceTrainProceed, ///< proceed a train to pass a red signal + ReverseTrainDirection, ///< turn a train around - CMD_CLEAR_ORDER_BACKUP, ///< clear the order backup of a given user/tile - CMD_MODIFY_ORDER, ///< modify an order (like set full-load) - CMD_SKIP_TO_ORDER, ///< skip an order to the next of specific one - CMD_DELETE_ORDER, ///< delete an order - CMD_INSERT_ORDER, ///< insert a new order + ClearOrderBackup, ///< clear the order backup of a given user/tile + ModifyOrder, ///< modify an order (like set full-load) + SkipToOrder, ///< skip an order to the next of specific one + DeleteOrder, ///< delete an order + InsertOrder, ///< insert a new order - CMD_CHANGE_SERVICE_INT, ///< change the server interval of a vehicle + ChangeServiceInterval, ///< change the server interval of a vehicle - CMD_BUILD_INDUSTRY, ///< build a new industry - CMD_INDUSTRY_SET_FLAGS, ///< change industry control flags - CMD_INDUSTRY_SET_EXCLUSIVITY, ///< change industry exclusive consumer/supplier - CMD_INDUSTRY_SET_TEXT, ///< change additional text for the industry - CMD_INDUSTRY_SET_PRODUCTION, ///< change industry production + BuildIndustry, ///< build a new industry + IndustrySetFlags, ///< change industry control flags + IndustrySetExclusivity, ///< change industry exclusive consumer/supplier + IndustrySetText, ///< change additional text for the industry + IndustrySetProduction, ///< change industry production - CMD_SET_COMPANY_MANAGER_FACE, ///< set the manager's face of the company - CMD_SET_COMPANY_COLOUR, ///< set the colour of the company + SetCompanyManagerFace, ///< set the manager's face of the company + SetCompanyColour, ///< set the colour of the company - CMD_INCREASE_LOAN, ///< increase the loan from the bank - CMD_DECREASE_LOAN, ///< decrease the loan from the bank - CMD_SET_COMPANY_MAX_LOAN, ///< sets the max loan for the company + IncreaseLoan, ///< increase the loan from the bank + DecreaseLoan, ///< decrease the loan from the bank + SetCompanyMaxLoan, ///< sets the max loan for the company - CMD_WANT_ENGINE_PREVIEW, ///< confirm the preview of an engine - CMD_ENGINE_CTRL, ///< control availability of the engine for companies + WantEnginePreview, ///< confirm the preview of an engine + EngineControl, ///< control availability of the engine for companies - CMD_RENAME_VEHICLE, ///< rename a whole vehicle - CMD_RENAME_ENGINE, ///< rename a engine (in the engine list) - CMD_RENAME_COMPANY, ///< change the company name - CMD_RENAME_PRESIDENT, ///< change the president name - CMD_RENAME_STATION, ///< rename a station - CMD_MOVE_STATION_NAME, ///< move a station name - CMD_RENAME_DEPOT, ///< rename a depot + RenameVehicle, ///< rename a whole vehicle + RenameEngine, ///< rename a engine (in the engine list) + RenameCompany, ///< change the company name + RenamePresident, ///< change the president name + RenameStation, ///< rename a station + MoveStationName, ///< move a station name + RenameDepot, ///< rename a depot - CMD_PLACE_SIGN, ///< place a sign - CMD_RENAME_SIGN, ///< rename a sign - CMD_MOVE_SIGN, ///< move a sign + PlaceSign, ///< place a sign + RenameSign, ///< rename a sign + MoveSign, ///< move a sign - CMD_TURN_ROADVEH, ///< turn a road vehicle around + TurnRoadVehicle, ///< turn a road vehicle around - CMD_PAUSE, ///< pause the game + Pause, ///< pause the game - CMD_BUY_COMPANY, ///< buy a company which is bankrupt + BuyCompany, ///< buy a company which is bankrupt - CMD_FOUND_TOWN, ///< found a town - CMD_RENAME_TOWN, ///< rename a town - CMD_DO_TOWN_ACTION, ///< do a action from the town detail window (like advertises or bribe) - CMD_TOWN_CARGO_GOAL, ///< set the goal of a cargo for a town - CMD_TOWN_GROWTH_RATE, ///< set the town growth rate - CMD_TOWN_RATING, ///< set rating of a company in a town - CMD_TOWN_SET_TEXT, ///< set the custom text of a town - CMD_EXPAND_TOWN, ///< expand a town - CMD_DELETE_TOWN, ///< delete a town - CMD_PLACE_HOUSE, ///< place a house - CMD_PLACE_HOUSE_AREA, ///< place an area of houses + FoundTown, ///< found a town + RenameTown, ///< rename a town + TownAction, ///< do a action from the town detail window (like advertises or bribe) + TownCargoGoal, ///< set the goal of a cargo for a town + TownGrowthRate, ///< set the town growth rate + TownRating, ///< set rating of a company in a town + TownSetText, ///< set the custom text of a town + ExpandTown, ///< expand a town + DeleteTown, ///< delete a town + PlaceHouse, ///< place a house + PlaceHouseArea, ///< place an area of houses - CMD_ORDER_REFIT, ///< change the refit information of an order (for "goto depot" ) - CMD_CLONE_ORDER, ///< clone (and share) an order - CMD_CLEAR_AREA, ///< clear an area + OrderRefit, ///< change the refit information of an order (for "goto depot" ) + CloneOrder, ///< clone (and share) an order + ClearArea, ///< clear an area - CMD_MONEY_CHEAT, ///< do the money cheat - CMD_CHANGE_BANK_BALANCE, ///< change bank balance to charge costs or give money from a GS - CMD_BUILD_CANAL, ///< build a canal + MoneyCheat, ///< do the money cheat + ChangeBankBalance, ///< change bank balance to charge costs or give money from a GS + BuildCanal, ///< build a canal - CMD_CREATE_SUBSIDY, ///< create a new subsidy - CMD_COMPANY_CTRL, ///< used in multiplayer to create a new companies etc. - CMD_COMPANY_ALLOW_LIST_CTRL, ///< Used in multiplayer to add/remove a client's public key to/from the company's allow list. - CMD_CUSTOM_NEWS_ITEM, ///< create a custom news message - CMD_CREATE_GOAL, ///< create a new goal - CMD_REMOVE_GOAL, ///< remove a goal - CMD_SET_GOAL_DESTINATION, ///< update goal destination of a goal - CMD_SET_GOAL_TEXT, ///< update goal text of a goal - CMD_SET_GOAL_PROGRESS, ///< update goal progress text of a goal - CMD_SET_GOAL_COMPLETED, ///< update goal completed status of a goal - CMD_GOAL_QUESTION, ///< ask a goal related question - CMD_GOAL_QUESTION_ANSWER, ///< answer(s) to CMD_GOAL_QUESTION - CMD_CREATE_STORY_PAGE, ///< create a new story page - CMD_CREATE_STORY_PAGE_ELEMENT, ///< create a new story page element - CMD_UPDATE_STORY_PAGE_ELEMENT, ///< update a story page element - CMD_SET_STORY_PAGE_TITLE, ///< update title of a story page - CMD_SET_STORY_PAGE_DATE, ///< update date of a story page - CMD_SHOW_STORY_PAGE, ///< show a story page - CMD_REMOVE_STORY_PAGE, ///< remove a story page - CMD_REMOVE_STORY_PAGE_ELEMENT, ///< remove a story page element - CMD_SCROLL_VIEWPORT, ///< scroll main viewport of players - CMD_STORY_PAGE_BUTTON, ///< selection via story page button + CreateSubsidy, ///< create a new subsidy + CompanyControl, ///< used in multiplayer to create a new companies etc. + CompanyAllowListControl, ///< Used in multiplayer to add/remove a client's public key to/from the company's allow list. + CreateCustomNewsItem, ///< create a custom news message + CreateGoal, ///< create a new goal + RemoveGoal, ///< remove a goal + SetGoalDestination, ///< update goal destination of a goal + SetGoalText, ///< update goal text of a goal + SetGoalProgress, ///< update goal progress text of a goal + SetGoalCompleted, ///< update goal completed status of a goal + GoalQuestion, ///< ask a goal related question + GoalQuestionAnswer, ///< answer(s) to Commands::GoalQuestion + CreateStoryPage, ///< create a new story page + CreateStoryPageElement, ///< create a new story page element + UpdateStoryPageElement, ///< update a story page element + SetStoryPageTitle, ///< update title of a story page + SetStoryPageDate, ///< update date of a story page + ShowStoryPage, ///< show a story page + RemoveStoryPage, ///< remove a story page + RemoveStoryPageElement, ///< remove a story page element + ScrollViewport, ///< scroll main viewport of players + StoryPageButton, ///< selection via story page button - CMD_LEVEL_LAND, ///< level land + LevelLand, ///< level land - CMD_BUILD_LOCK, ///< build a lock + BuildLock, ///< build a lock - CMD_BUILD_SIGNAL_TRACK, ///< add signals along a track (by dragging) - CMD_REMOVE_SIGNAL_TRACK, ///< remove signals along a track (by dragging) + BuildSignalLong, ///< add signals along a track (by dragging) + RemoveSignalLong, ///< remove signals along a track (by dragging) - CMD_GIVE_MONEY, ///< give money to another company - CMD_CHANGE_SETTING, ///< change a setting - CMD_CHANGE_COMPANY_SETTING, ///< change a company setting + GiveMoney, ///< give money to another company + ChangeSetting, ///< change a setting + ChangeCompanySetting, ///< change a company setting - CMD_SET_AUTOREPLACE, ///< set an autoreplace entry + SetAutoreplace, ///< set an autoreplace entry - CMD_CLONE_VEHICLE, ///< clone a vehicle - CMD_START_STOP_VEHICLE, ///< start or stop a vehicle - CMD_MASS_START_STOP, ///< start/stop all vehicles (in a depot) - CMD_AUTOREPLACE_VEHICLE, ///< replace/renew a vehicle while it is in a depot - CMD_DEPOT_SELL_ALL_VEHICLES, ///< sell all vehicles which are in a given depot - CMD_DEPOT_MASS_AUTOREPLACE, ///< force the autoreplace to take action in a given depot + CloneVehicle, ///< clone a vehicle + StartStopVehicle, ///< start or stop a vehicle + MassStartStop, ///< start/stop all vehicles (in a depot) + AutoreplaceVehicle, ///< replace/renew a vehicle while it is in a depot + DepotMassSell, ///< sell all vehicles which are in a given depot + DepotMassAutoreplace, ///< force the autoreplace to take action in a given depot - CMD_CREATE_GROUP, ///< create a new group - CMD_DELETE_GROUP, ///< delete a group - CMD_ALTER_GROUP, ///< alter a group - CMD_ADD_VEHICLE_GROUP, ///< add a vehicle to a group - CMD_ADD_SHARED_VEHICLE_GROUP, ///< add all other shared vehicles to a group which are missing - CMD_REMOVE_ALL_VEHICLES_GROUP, ///< remove all vehicles from a group - CMD_SET_GROUP_FLAG, ///< set/clear a flag for a group - CMD_SET_GROUP_LIVERY, ///< set the livery for a group + CreateGroup, ///< create a new group + DeleteGroup, ///< delete a group + AlterGroup, ///< alter a group + AddVehicleToGroup, ///< add a vehicle to a group + AddSharedVehiclesToGroup, ///< add all other shared vehicles to a group which are missing + RemoveAllVehiclesGroup, ///< remove all vehicles from a group + SetGroupFlag, ///< set/clear a flag for a group + SetGroupLivery, ///< set the livery for a group - CMD_MOVE_ORDER, ///< move an order - CMD_CHANGE_TIMETABLE, ///< change the timetable for a vehicle - CMD_BULK_CHANGE_TIMETABLE, ///< change the timetable for all orders of a vehicle - CMD_SET_VEHICLE_ON_TIME, ///< set the vehicle on time feature (timetable) - CMD_AUTOFILL_TIMETABLE, ///< autofill the timetable - CMD_SET_TIMETABLE_START, ///< set the date that a timetable should start + MoveOrder, ///< move an order + ChangeTimetable, ///< change the timetable for a vehicle + ChangeTimetableBulk, ///< change the timetable for all orders of a vehicle + SetVehicleOnTime, ///< set the vehicle on time feature (timetable) + AutofillTimetable, ///< autofill the timetable + SetTimetableStart, ///< set the date that a timetable should start - CMD_OPEN_CLOSE_AIRPORT, ///< open/close an airport to incoming aircraft + OpenCloseAirport, ///< open/close an airport to incoming aircraft - CMD_CREATE_LEAGUE_TABLE, ///< create a new league table - CMD_CREATE_LEAGUE_TABLE_ELEMENT, ///< create a new element in a league table - CMD_UPDATE_LEAGUE_TABLE_ELEMENT_DATA, ///< update the data fields of a league table element - CMD_UPDATE_LEAGUE_TABLE_ELEMENT_SCORE, ///< update the score of a league table element - CMD_REMOVE_LEAGUE_TABLE_ELEMENT, ///< remove a league table element + CreateLeagueTable, ///< create a new league table + CreateLeagueTableElement, ///< create a new element in a league table + UpdateLeagueTableElementData, ///< update the data fields of a league table element + UpdateLeagueTableElementScore, ///< update the score of a league table element + RemoveLeagueTableElement, ///< remove a league table element - CMD_END, ///< Must ALWAYS be on the end of this list!! (period) + End, ///< @important Must ALWAYS be on the end of this list!! (period) }; /** diff --git a/src/company_cmd.cpp b/src/company_cmd.cpp index 167c09c7e1..f2d7f889f7 100644 --- a/src/company_cmd.cpp +++ b/src/company_cmd.cpp @@ -672,7 +672,7 @@ TimeoutTimer _new_competitor_timeout({ TimerGameTick::Priority::C /* Send a command to all clients to start up a new AI. * Works fine for Multiplayer and Singleplayer */ - Command::Post(CCA_NEW_AI, CompanyID::Invalid(), CRR_NONE, INVALID_CLIENT_ID); + Command::Post(CCA_NEW_AI, CompanyID::Invalid(), CRR_NONE, INVALID_CLIENT_ID); }); /** Start of a new game. */ @@ -793,7 +793,7 @@ void OnTick_Companies() for (auto i = 0; i < _settings_game.difficulty.max_no_competitors; i++) { if (_networking && num_companies++ >= _settings_client.network.max_companies) break; if (num_ais++ >= _settings_game.difficulty.max_no_competitors) break; - Command::Post(CCA_NEW_AI, CompanyID::Invalid(), CRR_NONE, INVALID_CLIENT_ID); + Command::Post(CCA_NEW_AI, CompanyID::Invalid(), CRR_NONE, INVALID_CLIENT_ID); } timeout = 10 * 60 * Ticks::TICKS_PER_SECOND; } @@ -927,7 +927,7 @@ CommandCost CmdCompanyCtrl(DoCommandFlags flags, CompanyCtrlAction cca, CompanyI if (!_company_manager_face.empty()) { auto cmf = ParseCompanyManagerFaceCode(_company_manager_face); if (cmf.has_value()) { - Command::SendNet(STR_NULL, c->index, cmf->style, cmf->bits); + Command::SendNet(STR_NULL, c->index, cmf->style, cmf->bits); } } @@ -1259,7 +1259,7 @@ CommandCost CmdRenamePresident(DoCommandFlags flags, const std::string &text) c->president_name = text; if (c->name_1 == STR_SV_UNNAMED && c->name.empty()) { - Command::Do(DoCommandFlag::Execute, text + " Transport"); + Command::Do(DoCommandFlag::Execute, text + " Transport"); } } diff --git a/src/company_cmd.h b/src/company_cmd.h index fd763c10b8..80e31414f6 100644 --- a/src/company_cmd.h +++ b/src/company_cmd.h @@ -25,12 +25,12 @@ CommandCost CmdRenamePresident(DoCommandFlags flags, const std::string &text); CommandCost CmdSetCompanyManagerFace(DoCommandFlags flags, uint style, uint32_t bits); CommandCost CmdSetCompanyColour(DoCommandFlags flags, LiveryScheme scheme, bool primary, Colours colour); -DEF_CMD_TRAIT(CMD_COMPANY_CTRL, CmdCompanyCtrl, CommandFlags({CommandFlag::Spectator, CommandFlag::ClientID, CommandFlag::NoEst}), CommandType::ServerSetting) -DEF_CMD_TRAIT(CMD_COMPANY_ALLOW_LIST_CTRL, CmdCompanyAllowListCtrl, CommandFlag::NoEst, CommandType::ServerSetting) -DEF_CMD_TRAIT(CMD_GIVE_MONEY, CmdGiveMoney, {}, CommandType::MoneyManagement) -DEF_CMD_TRAIT(CMD_RENAME_COMPANY, CmdRenameCompany, {}, CommandType::CompanySetting) -DEF_CMD_TRAIT(CMD_RENAME_PRESIDENT, CmdRenamePresident, {}, CommandType::CompanySetting) -DEF_CMD_TRAIT(CMD_SET_COMPANY_MANAGER_FACE, CmdSetCompanyManagerFace, {}, CommandType::CompanySetting) -DEF_CMD_TRAIT(CMD_SET_COMPANY_COLOUR, CmdSetCompanyColour, {}, CommandType::CompanySetting) +DEF_CMD_TRAIT(Commands::CompanyControl, CmdCompanyCtrl, CommandFlags({CommandFlag::Spectator, CommandFlag::ClientID, CommandFlag::NoEst}), CommandType::ServerSetting) +DEF_CMD_TRAIT(Commands::CompanyAllowListControl, CmdCompanyAllowListCtrl, CommandFlag::NoEst, CommandType::ServerSetting) +DEF_CMD_TRAIT(Commands::GiveMoney, CmdGiveMoney, {}, CommandType::MoneyManagement) +DEF_CMD_TRAIT(Commands::RenameCompany, CmdRenameCompany, {}, CommandType::CompanySetting) +DEF_CMD_TRAIT(Commands::RenamePresident, CmdRenamePresident, {}, CommandType::CompanySetting) +DEF_CMD_TRAIT(Commands::SetCompanyManagerFace, CmdSetCompanyManagerFace, {}, CommandType::CompanySetting) +DEF_CMD_TRAIT(Commands::SetCompanyColour, CmdSetCompanyColour, {}, CommandType::CompanySetting) #endif /* COMPANY_CMD_H */ diff --git a/src/company_gui.cpp b/src/company_gui.cpp index c08b8b7b2c..280b9f9a6a 100644 --- a/src/company_gui.cpp +++ b/src/company_gui.cpp @@ -506,11 +506,11 @@ struct CompanyFinancesWindow : Window { break; case WID_CF_INCREASE_LOAN: // increase loan - Command::Post(STR_ERROR_CAN_T_BORROW_ANY_MORE_MONEY, _ctrl_pressed ? LoanCommand::Max : LoanCommand::Interval, 0); + Command::Post(STR_ERROR_CAN_T_BORROW_ANY_MORE_MONEY, _ctrl_pressed ? LoanCommand::Max : LoanCommand::Interval, 0); break; case WID_CF_REPAY_LOAN: // repay loan - Command::Post(STR_ERROR_CAN_T_REPAY_LOAN, _ctrl_pressed ? LoanCommand::Max : LoanCommand::Interval, 0); + Command::Post(STR_ERROR_CAN_T_REPAY_LOAN, _ctrl_pressed ? LoanCommand::Max : LoanCommand::Interval, 0); break; case WID_CF_INFRASTRUCTURE: // show infrastructure details @@ -1004,12 +1004,12 @@ public: for (LiveryScheme scheme = LS_DEFAULT; scheme < LS_END; scheme++) { /* Changed colour for the selected scheme, or all visible schemes if CTRL is pressed. */ if (HasBit(this->sel, scheme) || (_ctrl_pressed && _livery_class[scheme] == this->livery_class && HasBit(_loaded_newgrf_features.used_liveries, scheme))) { - Command::Post(scheme, widget == WID_SCL_PRI_COL_DROPDOWN, colour); + Command::Post(scheme, widget == WID_SCL_PRI_COL_DROPDOWN, colour); } } } else { /* Setting group livery */ - Command::Post(static_cast(this->sel), widget == WID_SCL_PRI_COL_DROPDOWN, colour); + Command::Post(static_cast(this->sel), widget == WID_SCL_PRI_COL_DROPDOWN, colour); } } @@ -1384,7 +1384,7 @@ public: /* OK button */ case WID_SCMF_ACCEPT: - Command::Post(this->face.style, this->face.bits); + Command::Post(this->face.style, this->face.bits); [[fallthrough]]; /* Cancel button */ @@ -2251,7 +2251,7 @@ struct CompanyWindow : Window void OnPlaceObject([[maybe_unused]] Point pt, TileIndex tile) override { - if (Command::Post(STR_ERROR_CAN_T_BUILD_COMPANY_HEADQUARTERS, tile, OBJECT_HQ, 0) && !_shift_pressed) { + if (Command::Post(STR_ERROR_CAN_T_BUILD_COMPANY_HEADQUARTERS, tile, OBJECT_HQ, 0) && !_shift_pressed) { ResetObjectToPlace(); this->RaiseButtons(); } @@ -2276,16 +2276,16 @@ struct CompanyWindow : Window auto value = ParseInteger(*str, 10, true); if (!value.has_value()) return; Money money = *value / GetCurrency().rate; - Command::Post(STR_ERROR_CAN_T_GIVE_MONEY, money, this->window_number); + Command::Post(STR_ERROR_CAN_T_GIVE_MONEY, money, this->window_number); break; } case WID_C_PRESIDENT_NAME: - Command::Post(STR_ERROR_CAN_T_CHANGE_PRESIDENT, *str); + Command::Post(STR_ERROR_CAN_T_CHANGE_PRESIDENT, *str); break; case WID_C_COMPANY_NAME: - Command::Post(STR_ERROR_CAN_T_CHANGE_COMPANY_NAME, *str); + Command::Post(STR_ERROR_CAN_T_CHANGE_COMPANY_NAME, *str); break; } } @@ -2391,7 +2391,7 @@ struct BuyCompanyWindow : Window { break; case WID_BC_YES: - Command::Post(STR_ERROR_CAN_T_BUY_COMPANY, this->window_number, this->hostile_takeover); + Command::Post(STR_ERROR_CAN_T_BUY_COMPANY, this->window_number, this->hostile_takeover); break; } } diff --git a/src/company_type.h b/src/company_type.h index 74c99bf890..614f5e9d56 100644 --- a/src/company_type.h +++ b/src/company_type.h @@ -67,7 +67,7 @@ enum CompanyRemoveReason : uint8_t { CRR_NONE = CRR_MANUAL, ///< Dummy reason for actions that don't need one. }; -/** The action to do with CMD_COMPANY_CTRL. */ +/** The action to do with Commands::CompanyControl. */ enum CompanyCtrlAction : uint8_t { CCA_NEW, ///< Create a new company. CCA_NEW_AI, ///< Create a new AI company. @@ -76,7 +76,7 @@ enum CompanyCtrlAction : uint8_t { CCA_END, ///< Sentinel for end. }; -/** The action to do with CMD_COMPANY_ALLOW_LIST_CTRL. */ +/** The action to do with Commands::CompanyAllowListControl. */ enum CompanyAllowListCtrlAction : uint8_t { CALCA_ADD, ///< Create a public key. CALCA_REMOVE, ///< Remove a public key. diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp index 32b6d679ab..eaeed7a29e 100644 --- a/src/console_cmds.cpp +++ b/src/console_cmds.cpp @@ -830,7 +830,7 @@ static bool ConPauseGame(std::span argv) } if (!_pause_mode.Test(PauseMode::Normal)) { - Command::Post(PauseMode::Normal, true); + Command::Post(PauseMode::Normal, true); if (!_networking) IConsolePrint(CC_DEFAULT, "Game paused."); } else { IConsolePrint(CC_DEFAULT, "Game is already paused."); @@ -852,7 +852,7 @@ static bool ConUnpauseGame(std::span argv) } if (_pause_mode.Test(PauseMode::Normal)) { - Command::Post(PauseMode::Normal, false); + Command::Post(PauseMode::Normal, false); if (!_networking) IConsolePrint(CC_DEFAULT, "Game unpaused."); } else if (_pause_mode.Test(PauseMode::Error)) { IConsolePrint(CC_DEFAULT, "Game is in error state and cannot be unpaused via console."); @@ -1098,7 +1098,7 @@ static bool ConResetCompany(std::span argv) } /* It is safe to remove this company */ - Command::Post(CCA_DELETE, *index, CRR_MANUAL, INVALID_CLIENT_ID); + Command::Post(CCA_DELETE, *index, CRR_MANUAL, INVALID_CLIENT_ID); IConsolePrint(CC_DEFAULT, "Company deleted."); return true; @@ -1512,7 +1512,7 @@ static bool ConStartAI(std::span argv) } /* Start a new AI company */ - Command::Post(CCA_NEW_AI, CompanyID::Invalid(), CRR_NONE, INVALID_CLIENT_ID); + Command::Post(CCA_NEW_AI, CompanyID::Invalid(), CRR_NONE, INVALID_CLIENT_ID); return true; } @@ -1553,8 +1553,8 @@ static bool ConReloadAI(std::span argv) } /* First kill the company of the AI, then start a new one. This should start the current AI again */ - Command::Post(CCA_DELETE, *company_id, CRR_MANUAL, INVALID_CLIENT_ID); - Command::Post(CCA_NEW_AI, *company_id, CRR_NONE, INVALID_CLIENT_ID); + Command::Post(CCA_DELETE, *company_id, CRR_MANUAL, INVALID_CLIENT_ID); + Command::Post(CCA_NEW_AI, *company_id, CRR_NONE, INVALID_CLIENT_ID); IConsolePrint(CC_DEFAULT, "AI reloaded."); return true; @@ -1596,7 +1596,7 @@ static bool ConStopAI(std::span argv) } /* Now kill the company of the AI. */ - Command::Post(CCA_DELETE, *company_id, CRR_MANUAL, INVALID_CLIENT_ID); + Command::Post(CCA_DELETE, *company_id, CRR_MANUAL, INVALID_CLIENT_ID); IConsolePrint(CC_DEFAULT, "AI stopped, company deleted."); return true; @@ -2074,7 +2074,7 @@ static void PerformNetworkAuthorizedKeyAction(std::string_view name, NetworkAuth authorized_keys->Add(authorized_key); } else { AutoRestoreBackup backup(_current_company, company); - Command::Post(CALCA_ADD, authorized_key); + Command::Post(CALCA_ADD, authorized_key); } IConsolePrint(CC_INFO, "Added {} to {}.", authorized_key, name); return; @@ -2089,7 +2089,7 @@ static void PerformNetworkAuthorizedKeyAction(std::string_view name, NetworkAuth authorized_keys->Remove(authorized_key); } else { AutoRestoreBackup backup(_current_company, company); - Command::Post(CALCA_REMOVE, authorized_key); + Command::Post(CALCA_REMOVE, authorized_key); } IConsolePrint(CC_INFO, "Removed {} from {}.", authorized_key, name); return; diff --git a/src/depot_cmd.h b/src/depot_cmd.h index 361d9efb0f..0051130584 100644 --- a/src/depot_cmd.h +++ b/src/depot_cmd.h @@ -16,7 +16,7 @@ CommandCost CmdRenameDepot(DoCommandFlags flags, DepotID depot_id, const std::string &text); -DEF_CMD_TRAIT(CMD_RENAME_DEPOT, CmdRenameDepot, {}, CommandType::OtherManagement) +DEF_CMD_TRAIT(Commands::RenameDepot, CmdRenameDepot, {}, CommandType::OtherManagement) void CcCloneVehicle(Commands cmd, const CommandCost &result, VehicleID veh_id); diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp index 6d1bf1a509..72a633a67e 100644 --- a/src/depot_gui.cpp +++ b/src/depot_gui.cpp @@ -145,7 +145,7 @@ static void TrainDepotMoveVehicle(const Vehicle *wagon, VehicleID sel, const Veh if (wagon == v) return; - Command::Post(STR_ERROR_CAN_T_MOVE_VEHICLE, v->tile, v->index, wagon == nullptr ? VehicleID::Invalid() : wagon->index, _ctrl_pressed); + Command::Post(STR_ERROR_CAN_T_MOVE_VEHICLE, v->tile, v->index, wagon == nullptr ? VehicleID::Invalid() : wagon->index, _ctrl_pressed); } static VehicleCellSize _base_block_sizes_depot[VEH_COMPANY_END]; ///< Cell size for vehicle images in the depot view. @@ -835,7 +835,7 @@ struct DepotWindow : Window { case WID_D_STOP_ALL: case WID_D_START_ALL: { VehicleListIdentifier vli(VL_DEPOT_LIST, this->type, this->owner); - Command::Post(TileIndex(this->window_number), widget == WID_D_START_ALL, false, vli); + Command::Post(TileIndex(this->window_number), widget == WID_D_START_ALL, false, vli); break; } @@ -856,7 +856,7 @@ struct DepotWindow : Window { break; case WID_D_AUTOREPLACE: - Command::Post(GetCmdAutoreplaceVehMsg(this->type), TileIndex(this->window_number), this->type); + Command::Post(GetCmdAutoreplaceVehMsg(this->type), TileIndex(this->window_number), this->type); break; } @@ -867,7 +867,7 @@ struct DepotWindow : Window { if (!str.has_value()) return; /* Do depot renaming */ - Command::Post(STR_ERROR_CAN_T_RENAME_DEPOT, this->GetDestinationIndex().ToDepotID(), *str); + Command::Post(STR_ERROR_CAN_T_RENAME_DEPOT, this->GetDestinationIndex().ToDepotID(), *str); } bool OnRightClick([[maybe_unused]] Point pt, WidgetID widget) override @@ -932,10 +932,10 @@ struct DepotWindow : Window { { if (_ctrl_pressed) { /* Share-clone, do not open new viewport, and keep tool active */ - Command::Post(STR_ERROR_CAN_T_BUY_TRAIN + v->type, TileIndex(this->window_number), v->index, true); + Command::Post(STR_ERROR_CAN_T_BUY_TRAIN + v->type, TileIndex(this->window_number), v->index, true); } else { /* Copy-clone, open viewport for new vehicle, and deselect the tool (assume player wants to change things on new vehicle) */ - if (Command::Post(STR_ERROR_CAN_T_BUY_TRAIN + v->type, CcCloneVehicle, TileIndex(this->window_number), v->index, false)) { + if (Command::Post(STR_ERROR_CAN_T_BUY_TRAIN + v->type, CcCloneVehicle, TileIndex(this->window_number), v->index, false)) { ResetObjectToPlace(); } } @@ -1082,7 +1082,7 @@ struct DepotWindow : Window { if (this->GetVehicleFromDepotWndPt(pt.x, pt.y, &v, &gdvp) == MODE_DRAG_VEHICLE && sel != VehicleID::Invalid()) { if (gdvp.wagon != nullptr && gdvp.wagon->index == sel && _ctrl_pressed) { - Command::Post(STR_ERROR_CAN_T_REVERSE_DIRECTION_RAIL_VEHICLE, Vehicle::Get(sel)->tile, Vehicle::Get(sel)->index, true); + Command::Post(STR_ERROR_CAN_T_REVERSE_DIRECTION_RAIL_VEHICLE, Vehicle::Get(sel)->tile, Vehicle::Get(sel)->index, true); } else if (gdvp.wagon == nullptr || gdvp.wagon->index != sel) { this->vehicle_over = VehicleID::Invalid(); TrainDepotMoveVehicle(gdvp.wagon, sel, gdvp.head); @@ -1107,7 +1107,7 @@ struct DepotWindow : Window { this->SetDirty(); bool sell_cmd = (v->type == VEH_TRAIN && (widget == WID_D_SELL_CHAIN || _ctrl_pressed)); - Command::Post(GetCmdSellVehMsg(v->type), v->tile, v->index, sell_cmd, true, INVALID_CLIENT_ID); + Command::Post(GetCmdSellVehMsg(v->type), v->tile, v->index, sell_cmd, true, INVALID_CLIENT_ID); break; } @@ -1171,7 +1171,7 @@ static void DepotSellAllConfirmationCallback(Window *win, bool confirmed) DepotWindow *w = (DepotWindow*)win; TileIndex tile(w->window_number); VehicleType vehtype = w->type; - Command::Post(GetCmdSellAllVehMsg(vehtype), tile, vehtype); + Command::Post(GetCmdSellAllVehMsg(vehtype), tile, vehtype); } } diff --git a/src/disaster_vehicle.cpp b/src/disaster_vehicle.cpp index b4340da820..9dde3ea657 100644 --- a/src/disaster_vehicle.cpp +++ b/src/disaster_vehicle.cpp @@ -64,7 +64,7 @@ static void DisasterClearSquare(TileIndex tile) case TileType::Railway: if (Company::IsHumanID(GetTileOwner(tile)) && !IsRailDepot(tile)) { Backup cur_company(_current_company, OWNER_WATER); - Command::Do(DoCommandFlag::Execute, tile); + Command::Do(DoCommandFlag::Execute, tile); cur_company.Restore(); /* update signals in buffer */ @@ -74,7 +74,7 @@ static void DisasterClearSquare(TileIndex tile) case TileType::House: { Backup cur_company(_current_company, OWNER_NONE); - Command::Do(DoCommandFlag::Execute, tile); + Command::Do(DoCommandFlag::Execute, tile); cur_company.Restore(); break; } diff --git a/src/dock_gui.cpp b/src/dock_gui.cpp index c2d9f46ec4..f9cf2d1e74 100644 --- a/src/dock_gui.cpp +++ b/src/dock_gui.cpp @@ -200,7 +200,7 @@ struct BuildDocksToolbarWindow : Window { break; case WID_DT_LOCK: // Build lock button - Command::Post(STR_ERROR_CAN_T_BUILD_LOCKS, CcBuildDocks, tile); + Command::Post(STR_ERROR_CAN_T_BUILD_LOCKS, CcBuildDocks, tile); break; case WID_DT_DEMOLISH: // Demolish aka dynamite button @@ -208,7 +208,7 @@ struct BuildDocksToolbarWindow : Window { break; case WID_DT_DEPOT: // Build depot button - Command::Post(STR_ERROR_CAN_T_BUILD_SHIP_DEPOT, CcBuildDocks, tile, _ship_depot_direction); + Command::Post(STR_ERROR_CAN_T_BUILD_SHIP_DEPOT, CcBuildDocks, tile, _ship_depot_direction); break; case WID_DT_STATION: { // Build station button @@ -219,9 +219,9 @@ struct BuildDocksToolbarWindow : Window { bool adjacent = _ctrl_pressed; auto proc = [=](bool test, StationID to_join) -> bool { if (test) { - return Command::Do(CommandFlagsToDCFlags(GetCommandFlags()), tile, StationID::Invalid(), adjacent).Succeeded(); + return Command::Do(CommandFlagsToDCFlags(GetCommandFlags()), tile, StationID::Invalid(), adjacent).Succeeded(); } else { - return Command::Post(STR_ERROR_CAN_T_BUILD_DOCK_HERE, CcBuildDocks, tile, to_join, adjacent); + return Command::Post(STR_ERROR_CAN_T_BUILD_DOCK_HERE, CcBuildDocks, tile, to_join, adjacent); } }; @@ -230,7 +230,7 @@ struct BuildDocksToolbarWindow : Window { } case WID_DT_BUOY: // Build buoy button - Command::Post(STR_ERROR_CAN_T_POSITION_BUOY_HERE, CcBuildDocks, tile); + Command::Post(STR_ERROR_CAN_T_POSITION_BUOY_HERE, CcBuildDocks, tile); break; case WID_DT_RIVER: // Build river button (in scenario editor) @@ -238,7 +238,7 @@ struct BuildDocksToolbarWindow : Window { break; case WID_DT_BUILD_AQUEDUCT: // Build aqueduct button - Command::Post(STR_ERROR_CAN_T_BUILD_AQUEDUCT_HERE, CcBuildBridge, tile, GetOtherAqueductEnd(tile), TRANSPORT_WATER, 0, 0); + Command::Post(STR_ERROR_CAN_T_BUILD_AQUEDUCT_HERE, CcBuildBridge, tile, GetOtherAqueductEnd(tile), TRANSPORT_WATER, 0, 0); break; default: NOT_REACHED(); @@ -264,13 +264,13 @@ struct BuildDocksToolbarWindow : Window { break; case DDSP_CREATE_WATER: if (_game_mode == GM_EDITOR) { - Command::Post(STR_ERROR_CAN_T_BUILD_CANALS, CcPlaySound_CONSTRUCTION_WATER, end_tile, start_tile, _ctrl_pressed ? WaterClass::Sea : WaterClass::Canal, false); + Command::Post(STR_ERROR_CAN_T_BUILD_CANALS, CcPlaySound_CONSTRUCTION_WATER, end_tile, start_tile, _ctrl_pressed ? WaterClass::Sea : WaterClass::Canal, false); } else { - Command::Post(STR_ERROR_CAN_T_BUILD_CANALS, CcPlaySound_CONSTRUCTION_WATER, end_tile, start_tile, WaterClass::Canal, _ctrl_pressed); + Command::Post(STR_ERROR_CAN_T_BUILD_CANALS, CcPlaySound_CONSTRUCTION_WATER, end_tile, start_tile, WaterClass::Canal, _ctrl_pressed); } break; case DDSP_CREATE_RIVER: - Command::Post(STR_ERROR_CAN_T_PLACE_RIVERS, CcPlaySound_CONSTRUCTION_WATER, end_tile, start_tile, WaterClass::River, _ctrl_pressed); + Command::Post(STR_ERROR_CAN_T_PLACE_RIVERS, CcPlaySound_CONSTRUCTION_WATER, end_tile, start_tile, WaterClass::River, _ctrl_pressed); break; default: break; diff --git a/src/economy.cpp b/src/economy.cpp index 709f9f79f4..b4d6632ea3 100644 --- a/src/economy.cpp +++ b/src/economy.cpp @@ -449,7 +449,7 @@ void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner) * However, do not rely on that behaviour. */ int interval = CompanyServiceInterval(new_company, v->type); - Command::Do({DoCommandFlag::Execute, DoCommandFlag::Bankrupt}, v->index, interval, false, new_company->settings.vehicle.servint_ispercent); + Command::Do({DoCommandFlag::Execute, DoCommandFlag::Bankrupt}, v->index, interval, false, new_company->settings.vehicle.servint_ispercent); } v->owner = new_owner; @@ -624,7 +624,7 @@ static void CompanyCheckBankrupt(Company *c) * player we are sure (the above check) that we are not the local * company and thus we won't be moved. */ if (!_networking || _network_server) { - Command::Post(CCA_DELETE, c->index, CRR_BANKRUPT, INVALID_CLIENT_ID); + Command::Post(CCA_DELETE, c->index, CRR_BANKRUPT, INVALID_CLIENT_ID); return; } break; @@ -1485,7 +1485,7 @@ static void HandleStationRefit(Vehicle *v, CargoArray &consist_capleft, Station if (st->goods[cargo_type].HasData() && st->goods[cargo_type].GetData().cargo.HasCargoFor(next_station)) { /* Try to find out if auto-refitting would succeed. In case the refit is allowed, * the returned refit capacity will be greater than zero. */ - auto [cc, refit_capacity, mail_capacity, cargo_capacities] = Command::Do(DoCommandFlag::QueryCost, v_start->index, cargo_type, 0xFF, true, false, 1); // Auto-refit and only this vehicle including artic parts. + auto [cc, refit_capacity, mail_capacity, cargo_capacities] = Command::Do(DoCommandFlag::QueryCost, v_start->index, cargo_type, 0xFF, true, false, 1); // Auto-refit and only this vehicle including artic parts. /* Try to balance different loadable cargoes between parts of the consist, so that * all of them can be loaded. Avoid a situation where all vehicles suddenly switch * to the first loadable cargo for which there is only one packet. If the capacities @@ -1508,7 +1508,7 @@ static void HandleStationRefit(Vehicle *v, CargoArray &consist_capleft, Station * "via any station" before reserving. We rather produce some more "any station" cargo than * misrouting it. */ IterateVehicleParts(v_start, ReturnCargoAction(st, StationID::Invalid())); - CommandCost cost = std::get<0>(Command::Do(DoCommandFlag::Execute, v_start->index, new_cargo_type, 0xFF, true, false, 1)); // Auto-refit and only this vehicle including artic parts. + CommandCost cost = std::get<0>(Command::Do(DoCommandFlag::Execute, v_start->index, new_cargo_type, 0xFF, true, false, 1)); // Auto-refit and only this vehicle including artic parts. if (cost.Succeeded()) v->First()->profit_this_year -= cost.GetCost() << 8; } diff --git a/src/economy_cmd.h b/src/economy_cmd.h index 4757e08043..79cdbe1089 100644 --- a/src/economy_cmd.h +++ b/src/economy_cmd.h @@ -15,6 +15,6 @@ CommandCost CmdBuyCompany(DoCommandFlags flags, CompanyID target_company, bool hostile_takeover); -DEF_CMD_TRAIT(CMD_BUY_COMPANY, CmdBuyCompany, {}, CommandType::MoneyManagement) +DEF_CMD_TRAIT(Commands::BuyCompany, CmdBuyCompany, {}, CommandType::MoneyManagement) #endif /* ECONOMY_CMD_H */ diff --git a/src/engine_cmd.h b/src/engine_cmd.h index 863150529a..b72e2a69f6 100644 --- a/src/engine_cmd.h +++ b/src/engine_cmd.h @@ -17,9 +17,9 @@ CommandCost CmdEngineCtrl(DoCommandFlags flags, EngineID engine_id, CompanyID co CommandCost CmdRenameEngine(DoCommandFlags flags, EngineID engine_id, const std::string &text); CommandCost CmdSetVehicleVisibility(DoCommandFlags flags, EngineID engine_id, bool hide); -DEF_CMD_TRAIT(CMD_WANT_ENGINE_PREVIEW, CmdWantEnginePreview, {}, CommandType::VehicleManagement) -DEF_CMD_TRAIT(CMD_ENGINE_CTRL, CmdEngineCtrl, CommandFlag::Deity, CommandType::VehicleManagement) -DEF_CMD_TRAIT(CMD_RENAME_ENGINE, CmdRenameEngine, CommandFlag::Server, CommandType::OtherManagement) -DEF_CMD_TRAIT(CMD_SET_VEHICLE_VISIBILITY, CmdSetVehicleVisibility, {}, CommandType::CompanySetting) +DEF_CMD_TRAIT(Commands::WantEnginePreview, CmdWantEnginePreview, {}, CommandType::VehicleManagement) +DEF_CMD_TRAIT(Commands::EngineControl, CmdEngineCtrl, CommandFlag::Deity, CommandType::VehicleManagement) +DEF_CMD_TRAIT(Commands::RenameEngine, CmdRenameEngine, CommandFlag::Server, CommandType::OtherManagement) +DEF_CMD_TRAIT(Commands::SetVehicleVisibility, CmdSetVehicleVisibility, {}, CommandType::CompanySetting) #endif /* ENGINE_CMD_H */ diff --git a/src/engine_gui.cpp b/src/engine_gui.cpp index ea5c8224f6..bbbe0fbf01 100644 --- a/src/engine_gui.cpp +++ b/src/engine_gui.cpp @@ -182,7 +182,7 @@ struct EnginePreviewWindow : Window { switch (widget) { case WID_EP_YES: if (this->selected_index < this->engines.size()) { - Command::Post(this->engines[this->selected_index]); + Command::Post(this->engines[this->selected_index]); } [[fallthrough]]; diff --git a/src/fios_gui.cpp b/src/fios_gui.cpp index 97a6a72c3a..312f5dd3f8 100644 --- a/src/fios_gui.cpp +++ b/src/fios_gui.cpp @@ -438,7 +438,7 @@ public: /* pause is only used in single-player, non-editor mode, non-menu mode. It * will be unpaused in the WE_DESTROY event handler. */ if (_game_mode != GM_MENU && !_networking && _game_mode != GM_EDITOR) { - Command::Post(PauseMode::SaveLoad, true); + Command::Post(PauseMode::SaveLoad, true); } SetObjectToPlace(SPR_CURSOR_ZZZ, PAL_NONE, HT_NONE, WC_MAIN_WINDOW, 0); @@ -481,7 +481,7 @@ public: { /* pause is only used in single-player, non-editor mode, non menu mode */ if (!_networking && _game_mode != GM_EDITOR && _game_mode != GM_MENU) { - Command::Post(PauseMode::SaveLoad, false); + Command::Post(PauseMode::SaveLoad, false); } this->Window::Close(); } diff --git a/src/genworld.cpp b/src/genworld.cpp index ce1e212d2e..596d8683b0 100644 --- a/src/genworld.cpp +++ b/src/genworld.cpp @@ -461,7 +461,7 @@ void LoadTownData() /* Try founding on the target tile, and if that doesn't work, find the nearest suitable tile up to 16 tiles away. * The target might be on water, blocked somehow, or on a steep slope that can't be terraformed by the founding command. */ for (auto tile : SpiralTileSequence(target_tile, 16, 0, 0)) { - std::tuple result = Command::Do(DoCommandFlag::Execute, tile, TSZ_SMALL, is_city, _settings_game.economy.town_layout, false, 0, name); + std::tuple result = Command::Do(DoCommandFlag::Execute, tile, TSZ_SMALL, is_city, _settings_game.economy.town_layout, false, 0, name); town_id = std::get(result); @@ -472,7 +472,7 @@ void LoadTownData() /* If we still fail to found the town, we'll create a sign at the intended location and tell the player how many towns we failed to create in an error message. * This allows the player to diagnose a heightmap misalignment, if towns end up in the sea, or place towns manually, if in rough terrain. */ if (town_id == TownID::Invalid()) { - Command::Post(target_tile, name); + Command::Post(target_tile, name); failed_towns++; continue; } @@ -503,7 +503,7 @@ void LoadTownData() do { uint before = t->cache.num_houses; - Command::Post(t->index, HOUSES_TO_GROW, {TownExpandMode::Buildings, TownExpandMode::Roads}); + Command::Post(t->index, HOUSES_TO_GROW, {TownExpandMode::Buildings, TownExpandMode::Roads}); if (t->cache.num_houses <= before) fail_limit--; } while (fail_limit > 0 && try_limit-- > 0 && t->cache.population < population); } diff --git a/src/goal_cmd.h b/src/goal_cmd.h index 07728078d1..8c0d3d8349 100644 --- a/src/goal_cmd.h +++ b/src/goal_cmd.h @@ -22,13 +22,13 @@ CommandCost CmdSetGoalCompleted(DoCommandFlags flags, GoalID goal, bool complete CommandCost CmdGoalQuestion(DoCommandFlags flags, uint16_t uniqueid, uint32_t target, bool is_client, uint32_t button_mask, GoalQuestionType type, const EncodedString &text); CommandCost CmdGoalQuestionAnswer(DoCommandFlags flags, uint16_t uniqueid, uint8_t button); -DEF_CMD_TRAIT(CMD_CREATE_GOAL, CmdCreateGoal, CommandFlags({CommandFlag::Deity, CommandFlag::StrCtrl}), CommandType::OtherManagement) -DEF_CMD_TRAIT(CMD_REMOVE_GOAL, CmdRemoveGoal, CommandFlag::Deity, CommandType::OtherManagement) -DEF_CMD_TRAIT(CMD_SET_GOAL_DESTINATION, CmdSetGoalDestination, CommandFlags({CommandFlag::Deity, CommandFlag::StrCtrl}), CommandType::OtherManagement) -DEF_CMD_TRAIT(CMD_SET_GOAL_TEXT, CmdSetGoalText, CommandFlags({CommandFlag::Deity, CommandFlag::StrCtrl}), CommandType::OtherManagement) -DEF_CMD_TRAIT(CMD_SET_GOAL_PROGRESS, CmdSetGoalProgress, CommandFlags({CommandFlag::Deity, CommandFlag::StrCtrl}), CommandType::OtherManagement) -DEF_CMD_TRAIT(CMD_SET_GOAL_COMPLETED, CmdSetGoalCompleted, CommandFlags({CommandFlag::Deity, CommandFlag::StrCtrl}), CommandType::OtherManagement) -DEF_CMD_TRAIT(CMD_GOAL_QUESTION, CmdGoalQuestion, CommandFlags({CommandFlag::Deity, CommandFlag::StrCtrl}), CommandType::OtherManagement) -DEF_CMD_TRAIT(CMD_GOAL_QUESTION_ANSWER, CmdGoalQuestionAnswer, CommandFlag::Deity, CommandType::OtherManagement) +DEF_CMD_TRAIT(Commands::CreateGoal, CmdCreateGoal, CommandFlags({CommandFlag::Deity, CommandFlag::StrCtrl}), CommandType::OtherManagement) +DEF_CMD_TRAIT(Commands::RemoveGoal, CmdRemoveGoal, CommandFlag::Deity, CommandType::OtherManagement) +DEF_CMD_TRAIT(Commands::SetGoalDestination, CmdSetGoalDestination, CommandFlags({CommandFlag::Deity, CommandFlag::StrCtrl}), CommandType::OtherManagement) +DEF_CMD_TRAIT(Commands::SetGoalText, CmdSetGoalText, CommandFlags({CommandFlag::Deity, CommandFlag::StrCtrl}), CommandType::OtherManagement) +DEF_CMD_TRAIT(Commands::SetGoalProgress, CmdSetGoalProgress, CommandFlags({CommandFlag::Deity, CommandFlag::StrCtrl}), CommandType::OtherManagement) +DEF_CMD_TRAIT(Commands::SetGoalCompleted, CmdSetGoalCompleted, CommandFlags({CommandFlag::Deity, CommandFlag::StrCtrl}), CommandType::OtherManagement) +DEF_CMD_TRAIT(Commands::GoalQuestion, CmdGoalQuestion, CommandFlags({CommandFlag::Deity, CommandFlag::StrCtrl}), CommandType::OtherManagement) +DEF_CMD_TRAIT(Commands::GoalQuestionAnswer, CmdGoalQuestionAnswer, CommandFlag::Deity, CommandType::OtherManagement) #endif /* GOAL_CMD_H */ diff --git a/src/goal_gui.cpp b/src/goal_gui.cpp index d7ac6c4965..ea6d8f01b3 100644 --- a/src/goal_gui.cpp +++ b/src/goal_gui.cpp @@ -367,17 +367,17 @@ struct GoalQuestionWindow : public Window { { switch (widget) { case WID_GQ_BUTTON_1: - Command::Post(this->window_number, this->button[0]); + Command::Post(this->window_number, this->button[0]); this->Close(); break; case WID_GQ_BUTTON_2: - Command::Post(this->window_number, this->button[1]); + Command::Post(this->window_number, this->button[1]); this->Close(); break; case WID_GQ_BUTTON_3: - Command::Post(this->window_number, this->button[2]); + Command::Post(this->window_number, this->button[2]); this->Close(); break; } diff --git a/src/group_cmd.cpp b/src/group_cmd.cpp index 9dd52bbce9..3dec1893c8 100644 --- a/src/group_cmd.cpp +++ b/src/group_cmd.cpp @@ -396,12 +396,12 @@ CommandCost CmdDeleteGroup(DoCommandFlags flags, GroupID group_id) if (g == nullptr || g->owner != _current_company) return CMD_ERROR; /* Remove all vehicles from the group */ - Command::Do(flags, group_id); + Command::Do(flags, group_id); /* Delete sub-groups, using a copy to avoid invalid iteration. */ FlatSet children = g->children; for (const GroupID &childgroup : children) { - Command::Do(flags, childgroup); + Command::Do(flags, childgroup); } if (flags.Test(DoCommandFlag::Execute)) { @@ -636,7 +636,7 @@ CommandCost CmdAddSharedVehicleGroup(DoCommandFlags flags, GroupID id_g, Vehicle /* For each shared vehicles add it to the group */ for (Vehicle *v2 = v->FirstShared(); v2 != nullptr; v2 = v2->NextShared()) { - if (v2->group_id != id_g) Command::Do(flags, id_g, v2->index, false, VehicleListIdentifier{}); + if (v2->group_id != id_g) Command::Do(flags, id_g, v2->index, false, VehicleListIdentifier{}); } } } @@ -667,7 +667,7 @@ CommandCost CmdRemoveAllVehiclesGroup(DoCommandFlags flags, GroupID group_id) if (v->group_id != group_id) continue; /* Add The Vehicle to the default group */ - Command::Do(flags, DEFAULT_GROUP, v->index, false, VehicleListIdentifier{}); + Command::Do(flags, DEFAULT_GROUP, v->index, false, VehicleListIdentifier{}); } } diff --git a/src/group_cmd.h b/src/group_cmd.h index e886ffd1ea..26707fcf56 100644 --- a/src/group_cmd.h +++ b/src/group_cmd.h @@ -34,14 +34,14 @@ CommandCost CmdRemoveAllVehiclesGroup(DoCommandFlags flags, GroupID group_id); CommandCost CmdSetGroupFlag(DoCommandFlags flags, GroupID group_id, GroupFlag flag, bool value, bool recursive); CommandCost CmdSetGroupLivery(DoCommandFlags flags, GroupID group_id, bool primary, Colours colour); -DEF_CMD_TRAIT(CMD_CREATE_GROUP, CmdCreateGroup, {}, CommandType::RouteManagement) -DEF_CMD_TRAIT(CMD_DELETE_GROUP, CmdDeleteGroup, {}, CommandType::RouteManagement) -DEF_CMD_TRAIT(CMD_ALTER_GROUP, CmdAlterGroup, {}, CommandType::OtherManagement) -DEF_CMD_TRAIT(CMD_ADD_VEHICLE_GROUP, CmdAddVehicleGroup, {}, CommandType::RouteManagement) -DEF_CMD_TRAIT(CMD_ADD_SHARED_VEHICLE_GROUP, CmdAddSharedVehicleGroup, {}, CommandType::RouteManagement) -DEF_CMD_TRAIT(CMD_REMOVE_ALL_VEHICLES_GROUP, CmdRemoveAllVehiclesGroup, {}, CommandType::RouteManagement) -DEF_CMD_TRAIT(CMD_SET_GROUP_FLAG, CmdSetGroupFlag, {}, CommandType::RouteManagement) -DEF_CMD_TRAIT(CMD_SET_GROUP_LIVERY, CmdSetGroupLivery, {}, CommandType::RouteManagement) +DEF_CMD_TRAIT(Commands::CreateGroup, CmdCreateGroup, {}, CommandType::RouteManagement) +DEF_CMD_TRAIT(Commands::DeleteGroup, CmdDeleteGroup, {}, CommandType::RouteManagement) +DEF_CMD_TRAIT(Commands::AlterGroup, CmdAlterGroup, {}, CommandType::OtherManagement) +DEF_CMD_TRAIT(Commands::AddVehicleToGroup, CmdAddVehicleGroup, {}, CommandType::RouteManagement) +DEF_CMD_TRAIT(Commands::AddSharedVehiclesToGroup, CmdAddSharedVehicleGroup, {}, CommandType::RouteManagement) +DEF_CMD_TRAIT(Commands::RemoveAllVehiclesGroup, CmdRemoveAllVehiclesGroup, {}, CommandType::RouteManagement) +DEF_CMD_TRAIT(Commands::SetGroupFlag, CmdSetGroupFlag, {}, CommandType::RouteManagement) +DEF_CMD_TRAIT(Commands::SetGroupLivery, CmdSetGroupLivery, {}, CommandType::RouteManagement) void CcCreateGroup(Commands cmd, const CommandCost &result, GroupID new_group, VehicleType vt, GroupID parent_group); void CcAddVehicleNewGroup(Commands cmd, const CommandCost &result, GroupID new_group, GroupID, VehicleID veh_id, bool, const VehicleListIdentifier &); diff --git a/src/group_gui.cpp b/src/group_gui.cpp index dc93c06d54..907f3d8a4e 100644 --- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -722,7 +722,7 @@ public: if (confirmed) { VehicleGroupWindow *w = (VehicleGroupWindow*)win; w->vli.SetIndex(ALL_GROUP); - Command::Post(STR_ERROR_GROUP_CAN_T_DELETE, w->group_confirm); + Command::Post(STR_ERROR_GROUP_CAN_T_DELETE, w->group_confirm); } } @@ -865,7 +865,7 @@ public: } case WID_GL_CREATE_GROUP: { // Create a new group - Command::Post(STR_ERROR_GROUP_CAN_T_CREATE, CcCreateGroup, this->vli.vtype, this->vli.ToGroupID()); + Command::Post(STR_ERROR_GROUP_CAN_T_CREATE, CcCreateGroup, this->vli.vtype, this->vli.ToGroupID()); break; } @@ -897,14 +897,14 @@ public: case WID_GL_START_ALL: case WID_GL_STOP_ALL: { // Start/stop all vehicles of the list - Command::Post(TileIndex{}, widget == WID_GL_START_ALL, true, this->vli); + Command::Post(TileIndex{}, widget == WID_GL_START_ALL, true, this->vli); break; } case WID_GL_REPLACE_PROTECTION: { const Group *g = Group::GetIfValid(this->vli.ToGroupID()); if (g != nullptr) { - Command::Post(this->vli.ToGroupID(), GroupFlag::ReplaceProtection, !g->flags.Test(GroupFlag::ReplaceProtection), _ctrl_pressed); + Command::Post(this->vli.ToGroupID(), GroupFlag::ReplaceProtection, !g->flags.Test(GroupFlag::ReplaceProtection), _ctrl_pressed); } break; } @@ -919,7 +919,7 @@ public: case WID_GL_ALL_VEHICLES: // All vehicles case WID_GL_DEFAULT_VEHICLES: // Ungrouped vehicles if (g->parent != GroupID::Invalid()) { - Command::Post(STR_ERROR_GROUP_CAN_T_SET_PARENT, AlterGroupMode::SetParent, this->group_sel, GroupID::Invalid(), {}); + Command::Post(STR_ERROR_GROUP_CAN_T_SET_PARENT, AlterGroupMode::SetParent, this->group_sel, GroupID::Invalid(), {}); } this->group_sel = GroupID::Invalid(); @@ -932,7 +932,7 @@ public: GroupID new_g = it == this->groups.end() ? GroupID::Invalid() : it->group->index; if (this->group_sel != new_g && g->parent != new_g) { - Command::Post(STR_ERROR_GROUP_CAN_T_SET_PARENT, AlterGroupMode::SetParent, this->group_sel, new_g, {}); + Command::Post(STR_ERROR_GROUP_CAN_T_SET_PARENT, AlterGroupMode::SetParent, this->group_sel, new_g, {}); } this->group_sel = GroupID::Invalid(); @@ -947,7 +947,7 @@ public: { switch (widget) { case WID_GL_DEFAULT_VEHICLES: // Ungrouped vehicles - Command::Post(STR_ERROR_GROUP_CAN_T_ADD_VEHICLE, DEFAULT_GROUP, this->vehicle_sel, _ctrl_pressed || this->grouping == GB_SHARED_ORDERS, VehicleListIdentifier{}); + Command::Post(STR_ERROR_GROUP_CAN_T_ADD_VEHICLE, DEFAULT_GROUP, this->vehicle_sel, _ctrl_pressed || this->grouping == GB_SHARED_ORDERS, VehicleListIdentifier{}); this->vehicle_sel = VehicleID::Invalid(); this->group_over = GroupID::Invalid(); @@ -964,7 +964,7 @@ public: auto it = this->group_sb->GetScrolledItemFromWidget(this->groups, pt.y, this, WID_GL_LIST_GROUP); GroupID new_g = it == this->groups.end() ? NEW_GROUP : it->group->index; - Command::Post(STR_ERROR_GROUP_CAN_T_ADD_VEHICLE, new_g == NEW_GROUP ? CcAddVehicleNewGroup : nullptr, new_g, vindex, _ctrl_pressed || this->grouping == GB_SHARED_ORDERS, VehicleListIdentifier{}); + Command::Post(STR_ERROR_GROUP_CAN_T_ADD_VEHICLE, new_g == NEW_GROUP ? CcAddVehicleNewGroup : nullptr, new_g, vindex, _ctrl_pressed || this->grouping == GB_SHARED_ORDERS, VehicleListIdentifier{}); break; } @@ -1019,7 +1019,7 @@ public: void OnQueryTextFinished(std::optional str) override { - if (str.has_value()) Command::Post(STR_ERROR_GROUP_CAN_T_RENAME, AlterGroupMode::Rename, this->group_rename, GroupID::Invalid(), *str); + if (str.has_value()) Command::Post(STR_ERROR_GROUP_CAN_T_RENAME, AlterGroupMode::Rename, this->group_rename, GroupID::Invalid(), *str); this->group_rename = GroupID::Invalid(); } @@ -1054,23 +1054,23 @@ public: break; case ADI_SERVICE: // Send for servicing case ADI_DEPOT: { // Send to Depots - Command::Post(GetCmdSendToDepotMsg(this->vli.vtype), VehicleID::Invalid(), (index == ADI_SERVICE ? DepotCommandFlag::Service : DepotCommandFlags{}) | DepotCommandFlag::MassSend, this->vli); + Command::Post(GetCmdSendToDepotMsg(this->vli.vtype), VehicleID::Invalid(), (index == ADI_SERVICE ? DepotCommandFlag::Service : DepotCommandFlags{}) | DepotCommandFlag::MassSend, this->vli); break; } case ADI_CREATE_GROUP: // Create group - Command::Post(CcAddVehicleNewGroup, NEW_GROUP, VehicleID::Invalid(), false, this->vli); + Command::Post(CcAddVehicleNewGroup, NEW_GROUP, VehicleID::Invalid(), false, this->vli); break; case ADI_ADD_SHARED: // Add shared Vehicles assert(Group::IsValidID(this->vli.ToGroupID())); - Command::Post(STR_ERROR_GROUP_CAN_T_ADD_SHARED_VEHICLE, this->vli.ToGroupID(), this->vli.vtype); + Command::Post(STR_ERROR_GROUP_CAN_T_ADD_SHARED_VEHICLE, this->vli.ToGroupID(), this->vli.vtype); break; case ADI_REMOVE_ALL: // Remove all Vehicles from the selected group assert(Group::IsValidID(this->vli.ToGroupID())); - Command::Post(STR_ERROR_GROUP_CAN_T_REMOVE_ALL_VEHICLES, this->vli.ToGroupID()); + Command::Post(STR_ERROR_GROUP_CAN_T_REMOVE_ALL_VEHICLES, this->vli.ToGroupID()); break; default: NOT_REACHED(); } diff --git a/src/highscore_gui.cpp b/src/highscore_gui.cpp index 06f7fb73d1..a802caa3ff 100644 --- a/src/highscore_gui.cpp +++ b/src/highscore_gui.cpp @@ -108,7 +108,7 @@ struct EndGameWindow : EndGameHighScoreBaseWindow { EndGameWindow(WindowDesc &desc) : EndGameHighScoreBaseWindow(desc) { /* Pause in single-player to have a look at the highscore at your own leisure */ - if (!_networking) Command::Post(PauseMode::Normal, true); + if (!_networking) Command::Post(PauseMode::Normal, true); this->background_img = SPR_TYCOON_IMG1_BEGIN; @@ -136,7 +136,7 @@ struct EndGameWindow : EndGameHighScoreBaseWindow { void Close([[maybe_unused]] int data = 0) override { - if (!_networking) Command::Post(PauseMode::Normal, false); // unpause + if (!_networking) Command::Post(PauseMode::Normal, false); // unpause if (_game_mode != GM_MENU && !_exit_game) ShowHighscoreTable(this->window_number, this->rank); this->EndGameHighScoreBaseWindow::Close(); } @@ -170,7 +170,7 @@ struct HighScoreWindow : EndGameHighScoreBaseWindow { { /* pause game to show the chart */ this->game_paused_by_player = _pause_mode == PauseMode::Normal; - if (!_networking && !this->game_paused_by_player) Command::Post(PauseMode::Normal, true); + if (!_networking && !this->game_paused_by_player) Command::Post(PauseMode::Normal, true); /* Close all always on-top windows to get a clean screen */ if (_game_mode != GM_MENU) HideVitalWindows(); @@ -185,7 +185,7 @@ struct HighScoreWindow : EndGameHighScoreBaseWindow { { if (_game_mode != GM_MENU && !_exit_game) ShowVitalWindows(); - if (!_networking && !this->game_paused_by_player) Command::Post(PauseMode::Normal, false); // unpause + if (!_networking && !this->game_paused_by_player) Command::Post(PauseMode::Normal, false); // unpause this->EndGameHighScoreBaseWindow::Close(); } diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp index a05d850b67..72d7258f3d 100644 --- a/src/industry_cmd.cpp +++ b/src/industry_cmd.cpp @@ -1132,7 +1132,7 @@ static void ChopLumberMillTrees(Industry *i) if (_settings_client.sound.ambient) SndPlayTileFx(SND_38_LUMBER_MILL_1, tile); AutoRestoreBackup cur_company(_current_company, OWNER_NONE); - Command::Do(DoCommandFlag::Execute, tile); + Command::Do(DoCommandFlag::Execute, tile); /* Add according value to waiting cargo. */ itp->waiting = ClampTo(itp->waiting + ScaleByCargoScale(45, false)); @@ -1504,13 +1504,13 @@ static CommandCost CheckIfIndustryTilesAreFree(TileIndex tile, const IndustryTil /* Clear the tiles as OWNER_TOWN to not affect town rating, and to not clear protected buildings */ Backup cur_company(_current_company, OWNER_TOWN); - ret = Command::Do({}, cur_tile); + ret = Command::Do({}, cur_tile); cur_company.Restore(); if (ret.Failed()) return ret; } else { /* Clear the tiles, but do not affect town ratings */ - ret = Command::Do({DoCommandFlag::Auto, DoCommandFlag::NoTestTownRating, DoCommandFlag::NoModifyTownRating}, cur_tile); + ret = Command::Do({DoCommandFlag::Auto, DoCommandFlag::NoTestTownRating, DoCommandFlag::NoModifyTownRating}, cur_tile); if (ret.Failed()) return ret; } } @@ -1658,7 +1658,7 @@ static bool CheckIfCanLevelIndustryPlatform(TileIndex tile, DoCommandFlags flags } /* This is not 100% correct check, but the best we can do without modifying the map. * What is missing, is if the difference in height is more than 1.. */ - if (std::get<0>(Command::Do(DoCommandFlags{flags}.Reset(DoCommandFlag::Execute), tile_walk, SLOPE_N, curh <= h)).Failed()) { + if (std::get<0>(Command::Do(DoCommandFlags{flags}.Reset(DoCommandFlag::Execute), tile_walk, SLOPE_N, curh <= h)).Failed()) { cur_company.Restore(); return false; } @@ -1673,7 +1673,7 @@ static bool CheckIfCanLevelIndustryPlatform(TileIndex tile, DoCommandFlags flags /* We give the terraforming for free here, because we can't calculate * exact cost in the test-round, and as we all know, that will cause * a nice assert if they don't match ;) */ - Command::Do(flags, tile_walk, SLOPE_N, curh <= h); + Command::Do(flags, tile_walk, SLOPE_N, curh <= h); curh += (curh > h) ? -1 : 1; } } @@ -1947,7 +1947,7 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, IndustryType type, WaterClass wc = (IsWaterTile(cur_tile) ? GetWaterClass(cur_tile) : WaterClass::Invalid); - Command::Do({DoCommandFlag::Execute, DoCommandFlag::NoTestTownRating, DoCommandFlag::NoModifyTownRating}, cur_tile); + Command::Do({DoCommandFlag::Execute, DoCommandFlag::NoTestTownRating, DoCommandFlag::NoModifyTownRating}, cur_tile); MakeIndustry(cur_tile, i->index, it.gfx, Random(), wc); @@ -3259,7 +3259,7 @@ static CommandCost TerraformTile_Industry(TileIndex tile, DoCommandFlags flags, } } } - return Command::Do(flags, tile); + return Command::Do(flags, tile); } extern const TileTypeProcs _tile_type_industry_procs = { diff --git a/src/industry_cmd.h b/src/industry_cmd.h index 42c4fb20ae..d92b77db3b 100644 --- a/src/industry_cmd.h +++ b/src/industry_cmd.h @@ -21,10 +21,10 @@ CommandCost CmdIndustrySetExclusivity(DoCommandFlags flags, IndustryID ind_id, O CommandCost CmdIndustrySetText(DoCommandFlags flags, IndustryID ind_id, const EncodedString &text); CommandCost CmdIndustrySetProduction(DoCommandFlags flags, IndustryID ind_id, uint8_t prod_level, bool show_news, const EncodedString &text); -DEF_CMD_TRAIT(CMD_BUILD_INDUSTRY, CmdBuildIndustry, CommandFlag::Deity, CommandType::LandscapeConstruction) -DEF_CMD_TRAIT(CMD_INDUSTRY_SET_FLAGS, CmdIndustrySetFlags, CommandFlag::Deity, CommandType::OtherManagement) -DEF_CMD_TRAIT(CMD_INDUSTRY_SET_EXCLUSIVITY, CmdIndustrySetExclusivity, CommandFlag::Deity, CommandType::OtherManagement) -DEF_CMD_TRAIT(CMD_INDUSTRY_SET_TEXT, CmdIndustrySetText, CommandFlags({CommandFlag::Deity, CommandFlag::StrCtrl}), CommandType::OtherManagement) -DEF_CMD_TRAIT(CMD_INDUSTRY_SET_PRODUCTION, CmdIndustrySetProduction, CommandFlag::Deity, CommandType::OtherManagement) +DEF_CMD_TRAIT(Commands::BuildIndustry, CmdBuildIndustry, CommandFlag::Deity, CommandType::LandscapeConstruction) +DEF_CMD_TRAIT(Commands::IndustrySetFlags, CmdIndustrySetFlags, CommandFlag::Deity, CommandType::OtherManagement) +DEF_CMD_TRAIT(Commands::IndustrySetExclusivity, CmdIndustrySetExclusivity, CommandFlag::Deity, CommandType::OtherManagement) +DEF_CMD_TRAIT(Commands::IndustrySetText, CmdIndustrySetText, CommandFlags({CommandFlag::Deity, CommandFlag::StrCtrl}), CommandType::OtherManagement) +DEF_CMD_TRAIT(Commands::IndustrySetProduction, CmdIndustrySetProduction, CommandFlag::Deity, CommandType::OtherManagement) #endif /* INDUSTRY_CMD_H */ diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp index 51751c76ec..fbab9074e7 100644 --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -680,7 +680,7 @@ public: case WID_DPI_FUND_WIDGET: { if (this->selected_type != IT_INVALID) { if (_game_mode != GM_EDITOR && _settings_game.construction.raw_industry_construction == 2 && GetIndustrySpec(this->selected_type)->IsRawIndustry()) { - Command::Post(STR_ERROR_CAN_T_CONSTRUCT_THIS_INDUSTRY, TileIndex{}, this->selected_type, 0, false, InteractiveRandom()); + Command::Post(STR_ERROR_CAN_T_CONSTRUCT_THIS_INDUSTRY, TileIndex{}, this->selected_type, 0, false, InteractiveRandom()); this->HandleButtonClick(WID_DPI_FUND_WIDGET); } else { HandlePlacePushButton(this, WID_DPI_FUND_WIDGET, SPR_CURSOR_INDUSTRY, HT_RECT); @@ -717,9 +717,9 @@ public: AutoRestoreBackup backup_generating_world(_generating_world, true); AutoRestoreBackup backup_ignore_industry_restritions(_ignore_industry_restrictions, true); - Command::Post(STR_ERROR_CAN_T_CONSTRUCT_THIS_INDUSTRY, tile, this->selected_type, layout_index, false, seed); + Command::Post(STR_ERROR_CAN_T_CONSTRUCT_THIS_INDUSTRY, tile, this->selected_type, layout_index, false, seed); } else { - success = Command::Post(STR_ERROR_CAN_T_CONSTRUCT_THIS_INDUSTRY, tile, this->selected_type, layout_index, false, seed); + success = Command::Post(STR_ERROR_CAN_T_CONSTRUCT_THIS_INDUSTRY, tile, this->selected_type, layout_index, false, seed); } /* If an industry has been built, just reset the cursor and the system */ diff --git a/src/intro_gui.cpp b/src/intro_gui.cpp index fad80953db..c9561abc2b 100644 --- a/src/intro_gui.cpp +++ b/src/intro_gui.cpp @@ -112,7 +112,7 @@ struct SelectGameWindow : public Window { * Find and parse all viewport command signs. * Fills the intro_viewport_commands vector and deletes parsed signs from the world. */ - void ReadIntroGameViewportCommands() + void ReadIntroGameViewportCommand() { intro_viewport_commands.clear(); @@ -183,7 +183,7 @@ struct SelectGameWindow : public Window { this->FinishInitNested(0); this->OnInvalidateData(); - this->ReadIntroGameViewportCommands(); + this->ReadIntroGameViewportCommand(); } void OnRealtimeTick(uint delta_ms) override diff --git a/src/landscape.cpp b/src/landscape.cpp index 423616a457..08687a2596 100644 --- a/src/landscape.cpp +++ b/src/landscape.cpp @@ -760,7 +760,7 @@ std::tuple CmdClearArea(DoCommandFlags flags, TileIndex tile std::unique_ptr iter = TileIterator::Create(tile, start_tile, diagonal); for (; *iter != INVALID_TILE; ++(*iter)) { TileIndex t = *iter; - CommandCost ret = Command::Do(DoCommandFlags{flags}.Reset(DoCommandFlag::Execute), t); + CommandCost ret = Command::Do(DoCommandFlags{flags}.Reset(DoCommandFlag::Execute), t); if (ret.Failed()) { last_error = std::move(ret); @@ -775,7 +775,7 @@ std::tuple CmdClearArea(DoCommandFlags flags, TileIndex tile if (ret.GetCost() > 0 && money < 0) { return { cost, ret.GetCost() }; } - Command::Do(flags, t); + Command::Do(flags, t); /* draw explosion animation... * Disable explosions when game is paused. Looks silly and blocks the view. */ @@ -1244,7 +1244,7 @@ void RiverMakeWider(TileIndex tile, TileIndex origin_tile) TileIndex other_tile = TileAddByDiagDir(tile, d); if (IsInclinedSlope(GetTileSlope(other_tile)) && IsWaterTile(other_tile)) return; } - Command::Do({DoCommandFlag::Execute, DoCommandFlag::Auto}, tile, ComplementSlope(cur_slope), true); + Command::Do({DoCommandFlag::Execute, DoCommandFlag::Auto}, tile, ComplementSlope(cur_slope), true); /* If the river is descending and the adjacent tile has either one or three corners raised, we want to make it match the slope. */ } else if (IsInclinedSlope(desired_slope)) { @@ -1265,14 +1265,14 @@ void RiverMakeWider(TileIndex tile, TileIndex origin_tile) /* Lower unwanted corners first. If only one corner is raised, no corners need lowering. */ if (!IsSlopeWithOneCornerRaised(cur_slope)) { to_change = to_change & ComplementSlope(desired_slope); - Command::Do({DoCommandFlag::Execute, DoCommandFlag::Auto}, tile, to_change, false); + Command::Do({DoCommandFlag::Execute, DoCommandFlag::Auto}, tile, to_change, false); } /* Now check the match and raise any corners needed. */ cur_slope = GetTileSlope(tile); if (cur_slope != desired_slope && IsSlopeWithOneCornerRaised(cur_slope)) { to_change = cur_slope ^ desired_slope; - Command::Do({DoCommandFlag::Execute, DoCommandFlag::Auto}, tile, to_change, true); + Command::Do({DoCommandFlag::Execute, DoCommandFlag::Auto}, tile, to_change, true); } } /* Update cur_slope after possibly terraforming. */ @@ -1420,9 +1420,9 @@ static std::tuple FlowRiver(TileIndex spring, TileIndex begin, uint } else { /* Sea is too small, flatten it so the river keeps looking or forms a lake / wetland. */ for (TileIndex sea_tile : sea) { - Command::Do(DoCommandFlag::Execute, sea_tile, SLOPE_ELEVATED, false); + Command::Do(DoCommandFlag::Execute, sea_tile, SLOPE_ELEVATED, false); Slope slope = ComplementSlope(GetTileSlope(sea_tile)); - Command::Do(DoCommandFlag::Execute, sea_tile, slope, true); + Command::Do(DoCommandFlag::Execute, sea_tile, slope, true); } } } else { diff --git a/src/landscape_cmd.h b/src/landscape_cmd.h index b17832faba..f712fec731 100644 --- a/src/landscape_cmd.h +++ b/src/landscape_cmd.h @@ -15,7 +15,7 @@ CommandCost CmdLandscapeClear(DoCommandFlags flags, TileIndex tile); std::tuple CmdClearArea(DoCommandFlags flags, TileIndex tile, TileIndex start_tile, bool diagonal); -DEF_CMD_TRAIT(CMD_LANDSCAPE_CLEAR, CmdLandscapeClear, CommandFlag::Deity, CommandType::LandscapeConstruction) -DEF_CMD_TRAIT(CMD_CLEAR_AREA, CmdClearArea, CommandFlag::NoTest, CommandType::LandscapeConstruction) // destroying multi-tile houses makes town rating differ between test and execution +DEF_CMD_TRAIT(Commands::LandscapeClear, CmdLandscapeClear, CommandFlag::Deity, CommandType::LandscapeConstruction) +DEF_CMD_TRAIT(Commands::ClearArea, CmdClearArea, CommandFlag::NoTest, CommandType::LandscapeConstruction) // destroying multi-tile houses makes town rating differ between test and execution #endif /* LANDSCAPE_CMD_H */ diff --git a/src/league_cmd.h b/src/league_cmd.h index c7378c9af9..c2ea133319 100644 --- a/src/league_cmd.h +++ b/src/league_cmd.h @@ -20,10 +20,10 @@ CommandCost CmdUpdateLeagueTableElementData(DoCommandFlags flags, LeagueTableEle CommandCost CmdUpdateLeagueTableElementScore(DoCommandFlags flags, LeagueTableElementID element, int64_t rating, const EncodedString &score); CommandCost CmdRemoveLeagueTableElement(DoCommandFlags flags, LeagueTableElementID element); -DEF_CMD_TRAIT(CMD_CREATE_LEAGUE_TABLE, CmdCreateLeagueTable, CommandFlags({CommandFlag::Deity, CommandFlag::StrCtrl}), CommandType::OtherManagement) -DEF_CMD_TRAIT(CMD_CREATE_LEAGUE_TABLE_ELEMENT, CmdCreateLeagueTableElement, CommandFlags({CommandFlag::Deity, CommandFlag::StrCtrl}), CommandType::OtherManagement) -DEF_CMD_TRAIT(CMD_UPDATE_LEAGUE_TABLE_ELEMENT_DATA, CmdUpdateLeagueTableElementData, CommandFlags({CommandFlag::Deity, CommandFlag::StrCtrl}), CommandType::OtherManagement) -DEF_CMD_TRAIT(CMD_UPDATE_LEAGUE_TABLE_ELEMENT_SCORE, CmdUpdateLeagueTableElementScore, CommandFlags({CommandFlag::Deity, CommandFlag::StrCtrl}), CommandType::OtherManagement) -DEF_CMD_TRAIT(CMD_REMOVE_LEAGUE_TABLE_ELEMENT, CmdRemoveLeagueTableElement, CommandFlag::Deity, CommandType::OtherManagement) +DEF_CMD_TRAIT(Commands::CreateLeagueTable, CmdCreateLeagueTable, CommandFlags({CommandFlag::Deity, CommandFlag::StrCtrl}), CommandType::OtherManagement) +DEF_CMD_TRAIT(Commands::CreateLeagueTableElement, CmdCreateLeagueTableElement, CommandFlags({CommandFlag::Deity, CommandFlag::StrCtrl}), CommandType::OtherManagement) +DEF_CMD_TRAIT(Commands::UpdateLeagueTableElementData, CmdUpdateLeagueTableElementData, CommandFlags({CommandFlag::Deity, CommandFlag::StrCtrl}), CommandType::OtherManagement) +DEF_CMD_TRAIT(Commands::UpdateLeagueTableElementScore, CmdUpdateLeagueTableElementScore, CommandFlags({CommandFlag::Deity, CommandFlag::StrCtrl}), CommandType::OtherManagement) +DEF_CMD_TRAIT(Commands::RemoveLeagueTableElement, CmdRemoveLeagueTableElement, CommandFlag::Deity, CommandType::OtherManagement) #endif /* LEAGUE_CMD_H */ diff --git a/src/linkgraph/linkgraphschedule.cpp b/src/linkgraph/linkgraphschedule.cpp index 30957b9bb0..10f5a16478 100644 --- a/src/linkgraph/linkgraphschedule.cpp +++ b/src/linkgraph/linkgraphschedule.cpp @@ -171,7 +171,7 @@ void StateGameLoop_LinkGraphPauseControl() if (_pause_mode.Test(PauseMode::LinkGraph)) { /* We are paused waiting on a job, check the job every tick. */ if (!LinkGraphSchedule::instance.IsJoinWithUnfinishedJobDue()) { - Command::Post(PauseMode::LinkGraph, false); + Command::Post(PauseMode::LinkGraph, false); } } else if (_pause_mode.None() && TimerGameEconomy::date_fract == LinkGraphSchedule::SPAWN_JOIN_TICK - 2 && @@ -179,7 +179,7 @@ void StateGameLoop_LinkGraphPauseControl() LinkGraphSchedule::instance.IsJoinWithUnfinishedJobDue()) { /* Perform check two TimerGameEconomy::date_fract ticks before we would join, to make * sure it also works in multiplayer. */ - Command::Post(PauseMode::LinkGraph, true); + Command::Post(PauseMode::LinkGraph, true); } } diff --git a/src/main_gui.cpp b/src/main_gui.cpp index ea54a1dcef..366ee1ce77 100644 --- a/src/main_gui.cpp +++ b/src/main_gui.cpp @@ -344,7 +344,7 @@ struct MainWindow : Window case GHK_MONEY: // Gimme money /* You can only cheat for money in singleplayer mode. */ - if (!_networking) Command::Post(10000000); + if (!_networking) Command::Post(10000000); break; case GHK_UPDATE_COORDS: // Update the coordinates of all station signs diff --git a/src/misc_cmd.cpp b/src/misc_cmd.cpp index 343f657a50..163c27ea5a 100644 --- a/src/misc_cmd.cpp +++ b/src/misc_cmd.cpp @@ -152,7 +152,7 @@ CommandCost CmdSetCompanyMaxLoan(DoCommandFlags flags, CompanyID company, Money static void AskUnsafeUnpauseCallback(Window *, bool confirmed) { if (confirmed) { - Command::Post(PauseMode::Error, false); + Command::Post(PauseMode::Error, false); } } diff --git a/src/misc_cmd.h b/src/misc_cmd.h index abb5745872..de710952ab 100644 --- a/src/misc_cmd.h +++ b/src/misc_cmd.h @@ -28,11 +28,11 @@ CommandCost CmdDecreaseLoan(DoCommandFlags flags, LoanCommand cmd, Money amount) CommandCost CmdSetCompanyMaxLoan(DoCommandFlags flags, CompanyID company, Money amount); CommandCost CmdPause(DoCommandFlags flags, PauseMode mode, bool pause); -DEF_CMD_TRAIT(CMD_MONEY_CHEAT, CmdMoneyCheat, CommandFlags({CommandFlag::Offline, CommandFlag::NoEst}), CommandType::Cheat) -DEF_CMD_TRAIT(CMD_CHANGE_BANK_BALANCE, CmdChangeBankBalance, CommandFlag::Deity, CommandType::MoneyManagement) -DEF_CMD_TRAIT(CMD_INCREASE_LOAN, CmdIncreaseLoan, {}, CommandType::MoneyManagement) -DEF_CMD_TRAIT(CMD_DECREASE_LOAN, CmdDecreaseLoan, {}, CommandType::MoneyManagement) -DEF_CMD_TRAIT(CMD_SET_COMPANY_MAX_LOAN, CmdSetCompanyMaxLoan, CommandFlag::Deity, CommandType::MoneyManagement) -DEF_CMD_TRAIT(CMD_PAUSE, CmdPause, CommandFlags({CommandFlag::Server, CommandFlag::NoEst}), CommandType::ServerSetting) +DEF_CMD_TRAIT(Commands::MoneyCheat, CmdMoneyCheat, CommandFlags({CommandFlag::Offline, CommandFlag::NoEst}), CommandType::Cheat) +DEF_CMD_TRAIT(Commands::ChangeBankBalance, CmdChangeBankBalance, CommandFlag::Deity, CommandType::MoneyManagement) +DEF_CMD_TRAIT(Commands::IncreaseLoan, CmdIncreaseLoan, {}, CommandType::MoneyManagement) +DEF_CMD_TRAIT(Commands::DecreaseLoan, CmdDecreaseLoan, {}, CommandType::MoneyManagement) +DEF_CMD_TRAIT(Commands::SetCompanyMaxLoan, CmdSetCompanyMaxLoan, CommandFlag::Deity, CommandType::MoneyManagement) +DEF_CMD_TRAIT(Commands::Pause, CmdPause, CommandFlags({CommandFlag::Server, CommandFlag::NoEst}), CommandType::ServerSetting) #endif /* MISC_CMD_H */ diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp index 18cea888cc..5519d65640 100644 --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -167,7 +167,7 @@ public: Company *c = Company::GetIfValid(_local_company); if (c != nullptr) { assert(_current_company == _local_company); - CommandCost costclear = Command::Do(DoCommandFlag::QueryCost, tile); + CommandCost costclear = Command::Do(DoCommandFlag::QueryCost, tile); if (costclear.Succeeded()) { Money cost = costclear.GetCost(); StringID str; @@ -984,10 +984,10 @@ struct QueryStringWindow : public Window case WID_QS_MOVE: // Move name button if (Station::IsExpected(Station::Get(this->parent->window_number))) { /* this is a station */ - Command::Post(STR_ERROR_CAN_T_MOVE_STATION_NAME, CcMoveStationName, this->parent->window_number, tile); + Command::Post(STR_ERROR_CAN_T_MOVE_STATION_NAME, CcMoveStationName, this->parent->window_number, tile); } else { /* this is a waypoint */ - Command::Post(STR_ERROR_CAN_T_MOVE_WAYPOINT_NAME, CcMoveWaypointName, this->parent->window_number, tile); + Command::Post(STR_ERROR_CAN_T_MOVE_WAYPOINT_NAME, CcMoveWaypointName, this->parent->window_number, tile); } break; diff --git a/src/network/network.cpp b/src/network/network.cpp index 68f18ab6ec..7e82f6ce73 100644 --- a/src/network/network.cpp +++ b/src/network/network.cpp @@ -407,7 +407,7 @@ static void CheckPauseHelper(bool pause, PauseMode pm) { if (pause == _pause_mode.Test(pm)) return; - Command::Post(pm, pause); + Command::Post(pm, pause); } /** @@ -1198,8 +1198,8 @@ void NetworkGameLoop() Debug(desync, 0, "Injecting pause for join at {:08x}:{:02x}; please join when paused", next_date, next_date_fract); cp = new CommandPacket(); cp->company = COMPANY_SPECTATOR; - cp->cmd = CMD_PAUSE; - cp->data = EndianBufferWriter<>::FromValue(CommandTraits::Args{ PauseMode::Normal, true }); + cp->cmd = Commands::Pause; + cp->data = EndianBufferWriter<>::FromValue(CommandTraits::Args{ PauseMode::Normal, true }); _ddc_fastforward = false; } else if (consumer.ReadIf("sync: ")) { next_date = TimerGameEconomy::Date(consumer.ReadIntegerBase(16)); diff --git a/src/network/network_admin.cpp b/src/network/network_admin.cpp index 5eb57208cf..e45defaa69 100644 --- a/src/network/network_admin.cpp +++ b/src/network/network_admin.cpp @@ -575,7 +575,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendCmdNames() { auto p = std::make_unique(this, ADMIN_PACKET_SERVER_CMD_NAMES); - for (uint16_t i = 0; i < CMD_END; i++) { + for (uint16_t i = 0; i < to_underlying(Commands::End); i++) { std::string_view cmdname = GetCommandName(static_cast(i)); /* Should COMPAT_MTU be exceeded, start a new packet @@ -611,7 +611,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendCmdLogging(ClientID clien p->Send_uint32(client_id); p->Send_uint8 (cp.company); - p->Send_uint16(cp.cmd); + p->Send_uint16(to_underlying(cp.cmd)); p->Send_buffer(cp.data); p->Send_uint32(cp.frame); diff --git a/src/network/network_client.cpp b/src/network/network_client.cpp index 87cb5ce561..a431518213 100644 --- a/src/network/network_client.cpp +++ b/src/network/network_client.cpp @@ -848,7 +848,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_MAP_DONE(Packet Debug(net, 9, "Client::join_status = REGISTERING"); _network_join_status = NETWORK_JOIN_STATUS_REGISTERING; ShowJoinStatusWindow(); - Command::Post(CCA_NEW, CompanyID::Invalid(), CRR_NONE, _network_own_client_id); + Command::Post(CCA_NEW, CompanyID::Invalid(), CRR_NONE, _network_own_client_id); } } else { /* take control over an existing company */ diff --git a/src/network/network_command.cpp b/src/network/network_command.cpp index 76003f0d5d..5c5326011f 100644 --- a/src/network/network_command.cpp +++ b/src/network/network_command.cpp @@ -167,10 +167,10 @@ constexpr UnpackDispatchT MakeUnpackNetworkCommand(std::index_sequence) no template inline constexpr auto MakeDispatchTable(std::integer_sequence, std::index_sequence) noexcept { - return std::array{{ { &SanitizeCmdStrings(i)>, &NetworkReplaceCommandClientId(i)>, MakeUnpackNetworkCommand(i)>(std::make_index_sequence<_callback_tuple_size>{}) }... }}; + return EnumClassIndexContainer, Commands>{{{ { &SanitizeCmdStrings(i)>, &NetworkReplaceCommandClientId(i)>, MakeUnpackNetworkCommand(i)>(std::make_index_sequence<_callback_tuple_size>{}) }... }}}; } /** Command dispatch table. */ -static constexpr auto _cmd_dispatch = MakeDispatchTable(std::make_integer_sequence, CMD_END>{}, std::make_index_sequence<_callback_tuple_size>{}); +static constexpr auto _cmd_dispatch = MakeDispatchTable(std::make_integer_sequence, to_underlying(Commands::End)>{}, std::make_index_sequence<_callback_tuple_size>{}); #ifdef SILENCE_GCC_FUNCTION_POINTER_CAST # pragma GCC diagnostic pop @@ -395,7 +395,7 @@ std::optional NetworkGameSocketHandler::ReceiveCommand(Packet void NetworkGameSocketHandler::SendCommand(Packet &p, const CommandPacket &cp) { p.Send_uint8(cp.company); - p.Send_uint16(cp.cmd); + p.Send_uint16(to_underlying(cp.cmd)); p.Send_uint16(cp.err_msg); p.Send_buffer(cp.data); diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index f752a94e63..51c286cfc5 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -1313,7 +1313,7 @@ static void AdminCompanyResetCallback(Window *, bool confirmed) { if (confirmed) { if (NetworkCompanyHasClients(_admin_company_id)) return; - Command::Post(CCA_DELETE, _admin_company_id, CRR_MANUAL, INVALID_CLIENT_ID); + Command::Post(CCA_DELETE, _admin_company_id, CRR_MANUAL, INVALID_CLIENT_ID); } } @@ -1584,7 +1584,7 @@ private: */ static void OnClickCompanyNew([[maybe_unused]] NetworkClientListWindow *w, [[maybe_unused]] Point pt, CompanyID) { - Command::Post(CCA_NEW, CompanyID::Invalid(), CRR_NONE, _network_own_client_id); + Command::Post(CCA_NEW, CompanyID::Invalid(), CRR_NONE, _network_own_client_id); } /** @@ -1643,7 +1643,7 @@ private: static void OnClickClientAuthorize([[maybe_unused]] NetworkClientListWindow *w, [[maybe_unused]] Point pt, ClientID client_id) { AutoRestoreBackup cur_company(_current_company, NetworkClientInfo::GetByClientID(_network_own_client_id)->client_playas); - Command::Post(CALCA_ADD, NetworkClientInfo::GetByClientID(client_id)->public_key); + Command::Post(CALCA_ADD, NetworkClientInfo::GetByClientID(client_id)->public_key); } /** diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp index 8fe830dc97..602eda7bd1 100644 --- a/src/network/network_server.cpp +++ b/src/network/network_server.cpp @@ -1090,35 +1090,35 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_COMMAND(Packet } /** - * Only CMD_COMPANY_CTRL is always allowed, for the rest, playas needs + * Only Commands::CompanyControl is always allowed, for the rest, playas needs * to match the company in the packet. If it doesn't, the client has done * something pretty naughty (or a bug), and will be kicked */ - CompanyCtrlAction cca = cp.cmd == CMD_COMPANY_CTRL ? std::get<0>(EndianBufferReader::ToValue::Args>(cp.data)) : CCA_NEW; - if (!(cp.cmd == CMD_COMPANY_CTRL && cca == CCA_NEW && ci->client_playas == COMPANY_NEW_COMPANY) && ci->client_playas != cp.company) { + CompanyCtrlAction cca = cp.cmd == Commands::CompanyControl ? std::get<0>(EndianBufferReader::ToValue::Args>(cp.data)) : CCA_NEW; + if (!(cp.cmd == Commands::CompanyControl && cca == CCA_NEW && ci->client_playas == COMPANY_NEW_COMPANY) && ci->client_playas != cp.company) { IConsolePrint(CC_WARNING, "Kicking client #{} (IP: {}) due to calling a command as another company {}.", ci->client_playas + 1, this->GetClientIP(), cp.company + 1); return this->SendError(NETWORK_ERROR_COMPANY_MISMATCH); } - if (cp.cmd == CMD_COMPANY_CTRL) { + if (cp.cmd == Commands::CompanyControl) { if (cca != CCA_NEW || cp.company != COMPANY_SPECTATOR) { return this->SendError(NETWORK_ERROR_CHEATER); } - /* Check if we are full - else it's possible for spectators to send a CMD_COMPANY_CTRL and the company is created regardless of max_companies! */ + /* Check if we are full - else it's possible for spectators to send a Commands::CompanyControl and the company is created regardless of max_companies! */ if (Company::GetNumItems() >= _settings_client.network.max_companies) { NetworkServerSendChat(NETWORK_ACTION_SERVER_MESSAGE, DESTTYPE_CLIENT, ci->client_id, "cannot create new company, server full", CLIENT_ID_SERVER); return NETWORK_RECV_STATUS_OKAY; } } - if (cp.cmd == CMD_COMPANY_ALLOW_LIST_CTRL) { + if (cp.cmd == Commands::CompanyAllowListControl) { /* Maybe the client just got moved before allowing? */ if (ci->client_id != CLIENT_ID_SERVER && ci->client_playas != cp.company) return NETWORK_RECV_STATUS_OKAY; /* Only allow clients to add/remove currently joined clients. The server owner does not go via this method, so is allowed to do more. */ - std::string public_key = std::get<1>(EndianBufferReader::ToValue::Args>(cp.data)); + std::string public_key = std::get<1>(EndianBufferReader::ToValue::Args>(cp.data)); bool found = false; for (const NetworkClientInfo *info : NetworkClientInfo::Iterate()) { if (info->public_key == public_key) { @@ -1586,13 +1586,13 @@ static void NetworkAutoCleanCompanies() /* Is the company empty for autoclean_protected-months? */ if (_settings_client.network.autoclean_protected != 0 && c->months_empty > _settings_client.network.autoclean_protected) { /* Shut the company down */ - Command::Post(CCA_DELETE, c->index, CRR_AUTOCLEAN, INVALID_CLIENT_ID); + Command::Post(CCA_DELETE, c->index, CRR_AUTOCLEAN, INVALID_CLIENT_ID); IConsolePrint(CC_INFO, "Auto-cleaned company #{}.", c->index + 1); } /* Is the company empty for autoclean_novehicles-months, and has no vehicles? */ if (_settings_client.network.autoclean_novehicles != 0 && c->months_empty > _settings_client.network.autoclean_novehicles && !has_vehicles.Test(c->index)) { /* Shut the company down */ - Command::Post(CCA_DELETE, c->index, CRR_AUTOCLEAN, INVALID_CLIENT_ID); + Command::Post(CCA_DELETE, c->index, CRR_AUTOCLEAN, INVALID_CLIENT_ID); IConsolePrint(CC_INFO, "Auto-cleaned company #{} with no vehicles.", c->index + 1); } } else { @@ -2166,8 +2166,8 @@ void NetworkServerNewCompany(const Company *c, NetworkClientInfo *ci) * different state/president/company name in the different clients, we need to * circumvent the normal ::Post logic and go directly to sending the command. */ - Command::SendNet(STR_NULL, c->index, CALCA_ADD, ci->public_key); - Command::SendNet(STR_NULL, c->index, ci->client_name); + Command::SendNet(STR_NULL, c->index, CALCA_ADD, ci->public_key); + Command::SendNet(STR_NULL, c->index, ci->client_name); NetworkServerSendChat(NETWORK_ACTION_COMPANY_NEW, DESTTYPE_BROADCAST, 0, "", ci->client_id, c->index + 1); } diff --git a/src/news_cmd.h b/src/news_cmd.h index eb800167b8..008177a33f 100644 --- a/src/news_cmd.h +++ b/src/news_cmd.h @@ -16,6 +16,6 @@ CommandCost CmdCustomNewsItem(DoCommandFlags flags, NewsType type, CompanyID company, NewsReference reference, const EncodedString &text); -DEF_CMD_TRAIT(CMD_CUSTOM_NEWS_ITEM, CmdCustomNewsItem, CommandFlags({CommandFlag::StrCtrl, CommandFlag::Deity}), CommandType::OtherManagement) +DEF_CMD_TRAIT(Commands::CreateCustomNewsItem, CmdCustomNewsItem, CommandFlags({CommandFlag::StrCtrl, CommandFlag::Deity}), CommandType::OtherManagement) #endif /* NEWS_CMD_H */ diff --git a/src/object_cmd.cpp b/src/object_cmd.cpp index c9492f20eb..22847b5cc0 100644 --- a/src/object_cmd.cpp +++ b/src/object_cmd.cpp @@ -232,7 +232,7 @@ CommandCost CmdBuildObject(DoCommandFlags flags, TileIndex tile, ObjectType type if (type == OBJECT_OWNED_LAND) { /* Owned land is special as it can be placed on any slope. */ - cost.AddCost(Command::Do(flags, tile)); + cost.AddCost(Command::Do(flags, tile)); } else { /* Check the surface to build on. At this time we can't actually execute the * the CLEAR_TILE commands since the newgrf callback later on can check @@ -245,7 +245,7 @@ CommandCost CmdBuildObject(DoCommandFlags flags, TileIndex tile, ObjectType type if (!IsWaterTile(t)) { /* Normal water tiles don't have to be cleared. For all other tile types clear * the tile but leave the water. */ - cost.AddCost(Command::Do(DoCommandFlags{flags}.Reset({DoCommandFlag::NoWater, DoCommandFlag::Execute}), t)); + cost.AddCost(Command::Do(DoCommandFlags{flags}.Reset({DoCommandFlag::NoWater, DoCommandFlag::Execute}), t)); } else { /* Can't build on water owned by another company. */ Owner o = GetTileOwner(t); @@ -268,7 +268,7 @@ CommandCost CmdBuildObject(DoCommandFlags flags, TileIndex tile, ObjectType type IsTileType(t, TileType::Object) && IsTileOwner(t, _current_company) && IsObjectType(t, OBJECT_HQ))) { - cost.AddCost(Command::Do(DoCommandFlags{flags}.Reset(DoCommandFlag::Execute), t)); + cost.AddCost(Command::Do(DoCommandFlags{flags}.Reset(DoCommandFlag::Execute), t)); } } } @@ -301,10 +301,10 @@ CommandCost CmdBuildObject(DoCommandFlags flags, TileIndex tile, ObjectType type for (TileIndex t : ta) { if (HasTileWaterGround(t)) { if (!IsWaterTile(t)) { - Command::Do(DoCommandFlags{flags}.Reset(DoCommandFlag::NoWater), t); + Command::Do(DoCommandFlags{flags}.Reset(DoCommandFlag::NoWater), t); } } else { - Command::Do(flags, t); + Command::Do(flags, t); } } } @@ -415,7 +415,7 @@ CommandCost CmdBuildObjectArea(DoCommandFlags flags, TileIndex tile, TileIndex s std::unique_ptr iter = TileIterator::Create(tile, start_tile, diagonal); for (; *iter != INVALID_TILE; ++(*iter)) { TileIndex t = *iter; - CommandCost ret = Command::Do(DoCommandFlags{flags}.Reset(DoCommandFlag::Execute), t, type, view); + CommandCost ret = Command::Do(DoCommandFlags{flags}.Reset(DoCommandFlag::Execute), t, type, view); /* If we've reached the limit, stop building (or testing). */ if (c != nullptr && limit-- <= 0) break; @@ -431,7 +431,7 @@ CommandCost CmdBuildObjectArea(DoCommandFlags flags, TileIndex tile, TileIndex s /* If we run out of money, stop building. */ if (ret.GetCost() > 0 && money < 0) break; - Command::Do(flags, t, type, view); + Command::Do(flags, t, type, view); } cost.AddCost(ret.GetCost()); } @@ -933,7 +933,7 @@ static CommandCost TerraformTile_Object(TileIndex tile, DoCommandFlags flags, in } } - return Command::Do(flags, tile); + return Command::Do(flags, tile); } static CommandCost CheckBuildAbove_Object(TileIndex tile, DoCommandFlags flags, Axis, int height) @@ -943,7 +943,7 @@ static CommandCost CheckBuildAbove_Object(TileIndex tile, DoCommandFlags flags, return CommandCost(); } - return Command::Do(flags, tile); + return Command::Do(flags, tile); } extern const TileTypeProcs _tile_type_object_procs = { diff --git a/src/object_cmd.h b/src/object_cmd.h index b7c32241bb..a024564100 100644 --- a/src/object_cmd.h +++ b/src/object_cmd.h @@ -16,7 +16,7 @@ CommandCost CmdBuildObject(DoCommandFlags flags, TileIndex tile, ObjectType type, uint8_t view); CommandCost CmdBuildObjectArea(DoCommandFlags flags, TileIndex tile, TileIndex start_tile, ObjectType type, uint8_t view, bool diagonal); -DEF_CMD_TRAIT(CMD_BUILD_OBJECT, CmdBuildObject, CommandFlags({CommandFlag::Deity, CommandFlag::NoWater, CommandFlag::Auto}), CommandType::LandscapeConstruction) -DEF_CMD_TRAIT(CMD_BUILD_OBJECT_AREA, CmdBuildObjectArea, CommandFlags({CommandFlag::Deity, CommandFlag::NoWater, CommandFlag::NoTest, CommandFlag::Auto}), CommandType::LandscapeConstruction) +DEF_CMD_TRAIT(Commands::BuildObject, CmdBuildObject, CommandFlags({CommandFlag::Deity, CommandFlag::NoWater, CommandFlag::Auto}), CommandType::LandscapeConstruction) +DEF_CMD_TRAIT(Commands::BuildObjectArea, CmdBuildObjectArea, CommandFlags({CommandFlag::Deity, CommandFlag::NoWater, CommandFlag::NoTest, CommandFlag::Auto}), CommandType::LandscapeConstruction) #endif /* OBJECT_CMD_H */ diff --git a/src/object_gui.cpp b/src/object_gui.cpp index b40a342c88..85298e9681 100644 --- a/src/object_gui.cpp +++ b/src/object_gui.cpp @@ -337,7 +337,7 @@ public: if (spec->size == OBJECT_SIZE_1X1) { VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_BUILD_OBJECT); } else { - Command::Post(STR_ERROR_CAN_T_BUILD_OBJECT, CcPlaySound_CONSTRUCTION_OTHER, tile, spec->Index(), _object_gui.sel_view); + Command::Post(STR_ERROR_CAN_T_BUILD_OBJECT, CcPlaySound_CONSTRUCTION_OTHER, tile, spec->Index(), _object_gui.sel_view); } } @@ -353,7 +353,7 @@ public: assert(select_proc == DDSP_BUILD_OBJECT); const ObjectSpec *spec = ObjectClass::Get(_object_gui.sel_class)->GetSpec(_object_gui.sel_type); - Command::Post(STR_ERROR_CAN_T_BUILD_OBJECT, CcPlaySound_CONSTRUCTION_OTHER, + Command::Post(STR_ERROR_CAN_T_BUILD_OBJECT, CcPlaySound_CONSTRUCTION_OTHER, end_tile, start_tile, spec->Index(), _object_gui.sel_view, _ctrl_pressed); } diff --git a/src/openttd.cpp b/src/openttd.cpp index a04386b397..9357539c95 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -864,7 +864,7 @@ static void MakeNewGameDone() /* In a dedicated server, the server does not play */ if (!VideoDriver::GetInstance()->HasGUI()) { OnStartGame(true); - if (_settings_client.gui.pause_on_newgame) Command::Post(PauseMode::Normal, true); + if (_settings_client.gui.pause_on_newgame) Command::Post(PauseMode::Normal, true); return; } @@ -878,11 +878,11 @@ static void MakeNewGameDone() * COLOUR_END corresponds to Random colour */ if (_settings_client.gui.starting_colour != COLOUR_END) { - Command::Post(LS_DEFAULT, true, _settings_client.gui.starting_colour); + Command::Post(LS_DEFAULT, true, _settings_client.gui.starting_colour); } if (_settings_client.gui.starting_colour_secondary != COLOUR_END && HasBit(_loaded_newgrf_features.used_liveries, LS_DEFAULT)) { - Command::Post(LS_DEFAULT, false, _settings_client.gui.starting_colour_secondary); + Command::Post(LS_DEFAULT, false, _settings_client.gui.starting_colour_secondary); } OnStartGame(false); @@ -890,7 +890,7 @@ static void MakeNewGameDone() InitializeRailGUI(); InitializeRoadGUI(); - if (_settings_client.gui.pause_on_newgame) Command::Post(PauseMode::Normal, true); + if (_settings_client.gui.pause_on_newgame) Command::Post(PauseMode::Normal, true); CheckEngines(); CheckIndustries(); @@ -1108,7 +1108,7 @@ void SwitchToMode(SwitchMode new_mode) } OnStartGame(_network_dedicated); /* Decrease pause counter (was increased from opening load dialog) */ - Command::Post(PauseMode::SaveLoad, false); + Command::Post(PauseMode::SaveLoad, false); } UpdateSocialIntegration(GM_NORMAL); @@ -1141,7 +1141,7 @@ void SwitchToMode(SwitchMode new_mode) GenerateSavegameId(); _settings_newgame.game_creation.starting_year = TimerGameCalendar::year; /* Cancel the saveload pausing */ - Command::Post(PauseMode::SaveLoad, false); + Command::Post(PauseMode::SaveLoad, false); } else { ShowErrorMessage(GetSaveLoadErrorType(), GetSaveLoadErrorMessage(), WL_CRITICAL); } diff --git a/src/order_backup.cpp b/src/order_backup.cpp index 6b4dd9fab9..5617c62f23 100644 --- a/src/order_backup.cpp +++ b/src/order_backup.cpp @@ -66,7 +66,7 @@ void OrderBackup::DoRestore(Vehicle *v) { /* If we had shared orders, recover that */ if (this->clone != nullptr) { - Command::Do(DoCommandFlag::Execute, CO_SHARE, v->index, this->clone->index); + Command::Do(DoCommandFlag::Execute, CO_SHARE, v->index, this->clone->index); } else if (!this->orders.empty() && OrderList::CanAllocateItem()) { v->orders = OrderList::Create(std::move(this->orders), v); /* Make sure buoys/oil rigs are updated in the station list. */ @@ -83,7 +83,7 @@ void OrderBackup::DoRestore(Vehicle *v) if (v->cur_implicit_order_index >= v->GetNumOrders()) v->cur_implicit_order_index = v->cur_real_order_index; /* Restore vehicle group */ - Command::Do(DoCommandFlag::Execute, this->group, v->index, false, VehicleListIdentifier{}); + Command::Do(DoCommandFlag::Execute, this->group, v->index, false, VehicleListIdentifier{}); } /** @@ -162,7 +162,7 @@ CommandCost CmdClearOrderBackup(DoCommandFlags flags, TileIndex tile, ClientID u /* If it's not a backup of us, ignore it. */ if (ob->user != user) continue; - Command::Post(TileIndex{}, static_cast(user)); + Command::Post(TileIndex{}, static_cast(user)); return; } } @@ -191,7 +191,7 @@ CommandCost CmdClearOrderBackup(DoCommandFlags flags, TileIndex tile, ClientID u /* We need to circumvent the "prevention" from this command being executed * while the game is paused, so use the internal method. Nor do we want * this command to get its cost estimated when shift is pressed. */ - Command::Unsafe(STR_NULL, nullptr, true, false, ob->tile, CommandTraits::Args{ ob->tile, static_cast(user) }); + Command::Unsafe(STR_NULL, nullptr, true, false, ob->tile, CommandTraits::Args{ ob->tile, static_cast(user) }); } else { /* The command came from the game logic, i.e. the clearing of a tile. * In that case we have no need to actually sync this, just do it. */ diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp index 03baf3c719..3b24d2b5fc 100644 --- a/src/order_cmd.cpp +++ b/src/order_cmd.cpp @@ -1984,7 +1984,7 @@ bool UpdateOrderDest(Vehicle *v, const Order *order, int conditional_depth, bool v->current_order.SetDestination(closest_depot.destination); /* If there is no depot in front, reverse automatically (trains only) */ - if (v->type == VEH_TRAIN && closest_depot.reverse) Command::Do(DoCommandFlag::Execute, v->index, false); + if (v->type == VEH_TRAIN && closest_depot.reverse) Command::Do(DoCommandFlag::Execute, v->index, false); if (v->type == VEH_AIRCRAFT) { Aircraft *a = Aircraft::From(v); diff --git a/src/order_cmd.h b/src/order_cmd.h index 9c341c8c71..0ced612a04 100644 --- a/src/order_cmd.h +++ b/src/order_cmd.h @@ -23,14 +23,14 @@ CommandCost CmdCloneOrder(DoCommandFlags flags, CloneOptions action, VehicleID v CommandCost CmdMoveOrder(DoCommandFlags flags, VehicleID veh, VehicleOrderID moving_order, VehicleOrderID target_order); CommandCost CmdClearOrderBackup(DoCommandFlags flags, TileIndex tile, ClientID user_id); -DEF_CMD_TRAIT(CMD_MODIFY_ORDER, CmdModifyOrder, CommandFlag::Location, CommandType::RouteManagement) -DEF_CMD_TRAIT(CMD_SKIP_TO_ORDER, CmdSkipToOrder, CommandFlag::Location, CommandType::RouteManagement) -DEF_CMD_TRAIT(CMD_DELETE_ORDER, CmdDeleteOrder, CommandFlag::Location, CommandType::RouteManagement) -DEF_CMD_TRAIT(CMD_INSERT_ORDER, CmdInsertOrder, CommandFlag::Location, CommandType::RouteManagement) -DEF_CMD_TRAIT(CMD_ORDER_REFIT, CmdOrderRefit, CommandFlag::Location, CommandType::RouteManagement) -DEF_CMD_TRAIT(CMD_CLONE_ORDER, CmdCloneOrder, CommandFlag::Location, CommandType::RouteManagement) -DEF_CMD_TRAIT(CMD_MOVE_ORDER, CmdMoveOrder, CommandFlag::Location, CommandType::RouteManagement) -DEF_CMD_TRAIT(CMD_CLEAR_ORDER_BACKUP, CmdClearOrderBackup, CommandFlag::ClientID, CommandType::ServerSetting) +DEF_CMD_TRAIT(Commands::ModifyOrder, CmdModifyOrder, CommandFlag::Location, CommandType::RouteManagement) +DEF_CMD_TRAIT(Commands::SkipToOrder, CmdSkipToOrder, CommandFlag::Location, CommandType::RouteManagement) +DEF_CMD_TRAIT(Commands::DeleteOrder, CmdDeleteOrder, CommandFlag::Location, CommandType::RouteManagement) +DEF_CMD_TRAIT(Commands::InsertOrder, CmdInsertOrder, CommandFlag::Location, CommandType::RouteManagement) +DEF_CMD_TRAIT(Commands::OrderRefit, CmdOrderRefit, CommandFlag::Location, CommandType::RouteManagement) +DEF_CMD_TRAIT(Commands::CloneOrder, CmdCloneOrder, CommandFlag::Location, CommandType::RouteManagement) +DEF_CMD_TRAIT(Commands::MoveOrder, CmdMoveOrder, CommandFlag::Location, CommandType::RouteManagement) +DEF_CMD_TRAIT(Commands::ClearOrderBackup, CmdClearOrderBackup, CommandFlag::ClientID, CommandType::ServerSetting) template inline EndianBufferWriter &operator <<(EndianBufferWriter &buffer, const Order &order) diff --git a/src/order_gui.cpp b/src/order_gui.cpp index ae8176f1c9..ace4c55536 100644 --- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -604,7 +604,7 @@ private: } if (order->GetLoadType() == load_type) return; // If we still match, do nothing - Command::Post(STR_ERROR_CAN_T_MODIFY_THIS_ORDER, this->vehicle->tile, this->vehicle->index, sel_ord, MOF_LOAD, to_underlying(load_type)); + Command::Post(STR_ERROR_CAN_T_MODIFY_THIS_ORDER, this->vehicle->tile, this->vehicle->index, sel_ord, MOF_LOAD, to_underlying(load_type)); } /** @@ -619,7 +619,7 @@ private: if (order == nullptr) return; i = order->GetDepotOrderType().Test(OrderDepotTypeFlag::Service) ? OrderDepotAction::AlwaysGo : OrderDepotAction::Service; } - Command::Post(STR_ERROR_CAN_T_MODIFY_THIS_ORDER, this->vehicle->tile, this->vehicle->index, sel_ord, MOF_DEPOT_ACTION, to_underlying(i.value())); + Command::Post(STR_ERROR_CAN_T_MODIFY_THIS_ORDER, this->vehicle->tile, this->vehicle->index, sel_ord, MOF_DEPOT_ACTION, to_underlying(i.value())); } /** @@ -632,7 +632,7 @@ private: _settings_client.gui.new_nonstop && this->vehicle->IsGroundVehicle() ? OrderNonStopFlag::NoIntermediate : OrderNonStopFlags{}); order.SetDepotActionType(OrderDepotActionFlag::NearestDepot); - Command::Post(STR_ERROR_CAN_T_INSERT_NEW_ORDER, this->vehicle->tile, this->vehicle->index, this->OrderGetSel(), order); + Command::Post(STR_ERROR_CAN_T_INSERT_NEW_ORDER, this->vehicle->tile, this->vehicle->index, this->OrderGetSel(), order); } /** @@ -652,11 +652,11 @@ private: } if (order->GetUnloadType() == unload_type) return; // If we still match, do nothing - Command::Post(STR_ERROR_CAN_T_MODIFY_THIS_ORDER, this->vehicle->tile, this->vehicle->index, sel_ord, MOF_UNLOAD, to_underlying(unload_type)); + Command::Post(STR_ERROR_CAN_T_MODIFY_THIS_ORDER, this->vehicle->tile, this->vehicle->index, sel_ord, MOF_UNLOAD, to_underlying(unload_type)); /* Transfer and unload orders with leave empty as default */ if (unload_type == OrderUnloadType::Transfer || unload_type == OrderUnloadType::Unload) { - Command::Post(this->vehicle->tile, this->vehicle->index, sel_ord, MOF_LOAD, to_underlying(OrderLoadType::NoLoad)); + Command::Post(this->vehicle->tile, this->vehicle->index, sel_ord, MOF_LOAD, to_underlying(OrderLoadType::NoLoad)); this->SetWidgetDirty(WID_O_FULL_LOAD); } } @@ -680,7 +680,7 @@ private: } this->SetWidgetDirty(WID_O_NON_STOP); - Command::Post(STR_ERROR_CAN_T_MODIFY_THIS_ORDER, this->vehicle->tile, this->vehicle->index, sel_ord, MOF_NON_STOP, non_stop.value().base()); + Command::Post(STR_ERROR_CAN_T_MODIFY_THIS_ORDER, this->vehicle->tile, this->vehicle->index, sel_ord, MOF_NON_STOP, non_stop.value().base()); } /** @@ -693,7 +693,7 @@ private: if (_ctrl_pressed && this->vehicle->cur_implicit_order_index == this->OrderGetSel()) return; if (this->vehicle->GetNumOrders() <= 1) return; - Command::Post(_ctrl_pressed ? STR_ERROR_CAN_T_SKIP_TO_ORDER : STR_ERROR_CAN_T_SKIP_ORDER, + Command::Post(_ctrl_pressed ? STR_ERROR_CAN_T_SKIP_TO_ORDER : STR_ERROR_CAN_T_SKIP_ORDER, this->vehicle->tile, this->vehicle->index, _ctrl_pressed ? this->OrderGetSel() : ((this->vehicle->cur_implicit_order_index + 1) % this->vehicle->GetNumOrders())); } @@ -705,7 +705,7 @@ private: /* When networking, move one order lower */ int selected = this->selected_order + (int)_networking; - if (Command::Post(STR_ERROR_CAN_T_DELETE_THIS_ORDER, this->vehicle->tile, this->vehicle->index, this->OrderGetSel())) { + if (Command::Post(STR_ERROR_CAN_T_DELETE_THIS_ORDER, this->vehicle->tile, this->vehicle->index, this->OrderGetSel())) { this->selected_order = selected >= this->vehicle->GetNumOrders() ? -1 : selected; this->UpdateButtonState(); } @@ -730,7 +730,7 @@ private: /* Get another vehicle that share orders with this vehicle. */ Vehicle *other_shared = (this->vehicle->FirstShared() == this->vehicle) ? this->vehicle->NextShared() : this->vehicle->PreviousShared(); /* Copy the order list of the other vehicle. */ - if (Command::Post(STR_ERROR_CAN_T_STOP_SHARING_ORDER_LIST, this->vehicle->tile, CO_COPY, this->vehicle->index, other_shared->index)) { + if (Command::Post(STR_ERROR_CAN_T_STOP_SHARING_ORDER_LIST, this->vehicle->tile, CO_COPY, this->vehicle->index, other_shared->index)) { this->UpdateButtonState(); } } @@ -745,10 +745,10 @@ private: { if (_ctrl_pressed) { /* Cancel refitting */ - Command::Post(this->vehicle->tile, this->vehicle->index, this->OrderGetSel(), CARGO_NO_REFIT); + Command::Post(this->vehicle->tile, this->vehicle->index, this->OrderGetSel(), CARGO_NO_REFIT); } else { if (i == 1) { // Auto-refit to available cargo type. - Command::Post(this->vehicle->tile, this->vehicle->index, this->OrderGetSel(), CARGO_AUTO_REFIT); + Command::Post(this->vehicle->tile, this->vehicle->index, this->OrderGetSel(), CARGO_AUTO_REFIT); } else { ShowVehicleRefitWindow(this->vehicle, this->OrderGetSel(), this, auto_refit); } @@ -1169,7 +1169,7 @@ public: Order order{}; order.MakeConditional(order_id); - Command::Post(STR_ERROR_CAN_T_INSERT_NEW_ORDER, this->vehicle->tile, this->vehicle->index, this->OrderGetSel(), order); + Command::Post(STR_ERROR_CAN_T_INSERT_NEW_ORDER, this->vehicle->tile, this->vehicle->index, this->OrderGetSel(), order); } ResetObjectToPlace(); break; @@ -1191,7 +1191,7 @@ public: this->selected_order = -1; } else if (sel == this->selected_order && click_count > 1) { if (this->vehicle->type == VEH_TRAIN && sel < this->vehicle->GetNumOrders()) { - Command::Post(STR_ERROR_CAN_T_MODIFY_THIS_ORDER, + Command::Post(STR_ERROR_CAN_T_MODIFY_THIS_ORDER, this->vehicle->tile, this->vehicle->index, sel, MOF_STOP_LOCATION, (to_underlying(this->vehicle->GetOrder(sel)->GetStopLocation()) + 1) % to_underlying(OrderStopLocation::End)); } @@ -1340,7 +1340,7 @@ public: default: break; } - Command::Post(STR_ERROR_CAN_T_MODIFY_THIS_ORDER, this->vehicle->tile, this->vehicle->index, sel, MOF_COND_VALUE, Clamp(*value, 0, 2047)); + Command::Post(STR_ERROR_CAN_T_MODIFY_THIS_ORDER, this->vehicle->tile, this->vehicle->index, sel, MOF_COND_VALUE, Clamp(*value, 0, 2047)); } void OnDropdownSelect(WidgetID widget, int index, int) override @@ -1377,11 +1377,11 @@ public: break; case WID_O_COND_VARIABLE: - Command::Post(STR_ERROR_CAN_T_MODIFY_THIS_ORDER, this->vehicle->tile, this->vehicle->index, this->OrderGetSel(), MOF_COND_VARIABLE, index); + Command::Post(STR_ERROR_CAN_T_MODIFY_THIS_ORDER, this->vehicle->tile, this->vehicle->index, this->OrderGetSel(), MOF_COND_VARIABLE, index); break; case WID_O_COND_COMPARATOR: - Command::Post(STR_ERROR_CAN_T_MODIFY_THIS_ORDER, this->vehicle->tile, this->vehicle->index, this->OrderGetSel(), MOF_COND_COMPARATOR, index); + Command::Post(STR_ERROR_CAN_T_MODIFY_THIS_ORDER, this->vehicle->tile, this->vehicle->index, this->OrderGetSel(), MOF_COND_COMPARATOR, index); break; } } @@ -1394,7 +1394,7 @@ public: VehicleOrderID to_order = this->GetOrderFromPt(pt.y); if (!(from_order == to_order || from_order == INVALID_VEH_ORDER_ID || from_order > this->vehicle->GetNumOrders() || to_order == INVALID_VEH_ORDER_ID || to_order > this->vehicle->GetNumOrders()) && - Command::Post(STR_ERROR_CAN_T_MOVE_THIS_ORDER, this->vehicle->tile, this->vehicle->index, from_order, to_order)) { + Command::Post(STR_ERROR_CAN_T_MOVE_THIS_ORDER, this->vehicle->tile, this->vehicle->index, from_order, to_order)) { this->selected_order = -1; this->UpdateButtonState(); } @@ -1446,7 +1446,7 @@ public: const Order cmd = GetOrderCmdFromTile(this->vehicle, tile); if (cmd.IsType(OT_NOTHING)) return; - if (Command::Post(STR_ERROR_CAN_T_INSERT_NEW_ORDER, this->vehicle->tile, this->vehicle->index, this->OrderGetSel(), cmd)) { + if (Command::Post(STR_ERROR_CAN_T_INSERT_NEW_ORDER, this->vehicle->tile, this->vehicle->index, this->OrderGetSel(), cmd)) { /* With quick goto the Go To button stays active */ if (!_settings_client.gui.quick_goto) ResetObjectToPlace(); } @@ -1463,7 +1463,7 @@ public: bool share_order = _ctrl_pressed || this->goto_type == OPOS_SHARE; if (this->vehicle->GetNumOrders() != 0 && !share_order) return false; - if (Command::Post(share_order ? STR_ERROR_CAN_T_SHARE_ORDER_LIST : STR_ERROR_CAN_T_COPY_ORDER_LIST, + if (Command::Post(share_order ? STR_ERROR_CAN_T_SHARE_ORDER_LIST : STR_ERROR_CAN_T_COPY_ORDER_LIST, this->vehicle->tile, share_order ? CO_SHARE : CO_COPY, this->vehicle->index, v->index)) { this->selected_order = -1; ResetObjectToPlace(); diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp index 7d27a7f493..0732e7097a 100644 --- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -434,7 +434,7 @@ CommandCost CmdBuildSingleRail(DoCommandFlags flags, TileIndex tile, RailType ra CommandCost ret = CheckTileOwnership(tile); if (ret.Failed()) return ret; - if (!IsPlainRail(tile)) return Command::Do(flags, tile); // just get appropriate error message + if (!IsPlainRail(tile)) return Command::Do(flags, tile); // just get appropriate error message if (!IsCompatibleRail(GetRailType(tile), railtype)) return CommandCost(STR_ERROR_IMPOSSIBLE_TRACK_COMBINATION); @@ -452,7 +452,7 @@ CommandCost CmdBuildSingleRail(DoCommandFlags flags, TileIndex tile, RailType ra for (Track track_it = TRACK_BEGIN; track_it < TRACK_END; track_it++) { if (HasTrack(tile, track_it) && HasSignalOnTrack(tile, track_it)) { - CommandCost ret_remove_signals = Command::Do(flags, tile, track_it); + CommandCost ret_remove_signals = Command::Do(flags, tile, track_it); if (ret_remove_signals.Failed()) return ret_remove_signals; cost.AddCost(ret_remove_signals.GetCost()); } @@ -464,7 +464,7 @@ CommandCost CmdBuildSingleRail(DoCommandFlags flags, TileIndex tile, RailType ra * the present rail type are powered on the new rail type. */ if (GetRailType(tile) != railtype && !HasPowerOnRail(railtype, GetRailType(tile))) { if (HasPowerOnRail(GetRailType(tile), railtype)) { - ret = Command::Do(flags, tile, tile, railtype, false); + ret = Command::Do(flags, tile, tile, railtype, false); if (ret.Failed()) return ret; cost.AddCost(ret.GetCost()); } else { @@ -570,7 +570,7 @@ CommandCost CmdBuildSingleRail(DoCommandFlags flags, TileIndex tile, RailType ra if (ret.Failed()) return ret; cost.AddCost(ret.GetCost()); - ret = Command::Do(flags, tile); + ret = Command::Do(flags, tile); if (ret.Failed()) return ret; cost.AddCost(ret.GetCost()); @@ -679,7 +679,7 @@ CommandCost CmdRemoveSingleRail(DoCommandFlags flags, TileIndex tile, Track trac /* Charge extra to remove signals on the track, if they are there */ if (HasSignalOnTrack(tile, track)) { - cost.AddCost(Command::Do(flags, tile, track)); + cost.AddCost(Command::Do(flags, tile, track)); } if (flags.Test(DoCommandFlag::Execute)) { @@ -772,7 +772,7 @@ bool FloodHalftile(TileIndex t) TrackBits to_remove = lower_track & rail_bits; if (to_remove != TRACK_BIT_NONE) { Backup cur_company(_current_company, OWNER_WATER); - flooded = Command::Do(DoCommandFlag::Execute, t, FindFirstTrack(to_remove)).Succeeded(); + flooded = Command::Do(DoCommandFlag::Execute, t, FindFirstTrack(to_remove)).Succeeded(); cur_company.Restore(); if (!flooded) return flooded; // not yet floodable rail_bits = rail_bits & ~to_remove; @@ -885,7 +885,7 @@ static CommandCost CmdRailTrackHelper(DoCommandFlags flags, TileIndex tile, Tile bool had_success = false; CommandCost last_error = CMD_ERROR; for (;;) { - ret = remove ? Command::Do(flags, tile, TrackdirToTrack(trackdir)) : Command::Do(flags, tile, railtype, TrackdirToTrack(trackdir), auto_remove_signals); + ret = remove ? Command::Do(flags, tile, TrackdirToTrack(trackdir)) : Command::Do(flags, tile, railtype, TrackdirToTrack(trackdir), auto_remove_signals); if (!remove && !fail_on_obstacle && last_error.GetErrorMessage() == STR_ERROR_ALREADY_BUILT) had_success = true; if (ret.Failed()) { @@ -996,7 +996,7 @@ CommandCost CmdBuildTrainDepot(DoCommandFlags flags, TileIndex tile, RailType ra } if (!rotate_existing_depot) { - cost.AddCost(Command::Do(flags, tile)); + cost.AddCost(Command::Do(flags, tile)); if (cost.Failed()) return cost; if (IsBridgeAbove(tile)) return CommandCost(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST); @@ -1322,7 +1322,7 @@ static CommandCost CmdSignalTrackHelper(DoCommandFlags flags, TileIndex tile, Ti if (HasBit(signal_dir, 1)) signals |= SignalAgainstTrackdir(trackdir); DoCommandFlags do_flags = test_only ? DoCommandFlags{flags}.Reset(DoCommandFlag::Execute) : flags; - CommandCost ret = remove ? Command::Do(do_flags, tile, TrackdirToTrack(trackdir)) : Command::Do(do_flags, tile, TrackdirToTrack(trackdir), sigtype, sigvar, false, signal_ctr == 0, mode, SIGTYPE_BLOCK, SIGTYPE_BLOCK, 0, signals); + CommandCost ret = remove ? Command::Do(do_flags, tile, TrackdirToTrack(trackdir)) : Command::Do(do_flags, tile, TrackdirToTrack(trackdir), sigtype, sigvar, false, signal_ctr == 0, mode, SIGTYPE_BLOCK, SIGTYPE_BLOCK, 0, signals); if (test_only) return ret.Succeeded(); @@ -1817,7 +1817,7 @@ static CommandCost ClearTile_Track(TileIndex tile, DoCommandFlags flags) TrackBits tracks = GetTrackBits(tile); while (tracks != TRACK_BIT_NONE) { Track track = RemoveFirstTrack(&tracks); - CommandCost ret = Command::Do(flags, tile, track); + CommandCost ret = Command::Do(flags, tile, track); if (ret.Failed()) return ret; cost.AddCost(ret.GetCost()); } @@ -2907,7 +2907,7 @@ static void ChangeTileOwner_Track(TileIndex tile, Owner old_owner, Owner new_own SetTileOwner(tile, new_owner); } else { - Command::Do({DoCommandFlag::Execute, DoCommandFlag::Bankrupt}, tile); + Command::Do({DoCommandFlag::Execute, DoCommandFlag::Bankrupt}, tile); } } @@ -3088,13 +3088,13 @@ static CommandCost TerraformTile_Track(TileIndex tile, DoCommandFlags flags, int AutoslopeCheckForEntranceEdge(tile, z_new, tileh_new, GetRailDepotDirection(tile))) { return CommandCost(EXPENSES_CONSTRUCTION, _price[Price::BuildFoundation]); } - return Command::Do(flags, tile); + return Command::Do(flags, tile); } static CommandCost CheckBuildAbove_Track(TileIndex tile, DoCommandFlags flags, Axis, int) { if (IsPlainRail(tile)) return CommandCost(); - return Command::Do(flags, tile); + return Command::Do(flags, tile); } extern const TileTypeProcs _tile_type_rail_procs = { diff --git a/src/rail_cmd.h b/src/rail_cmd.h index 9650c3b724..12814cc131 100644 --- a/src/rail_cmd.h +++ b/src/rail_cmd.h @@ -27,16 +27,16 @@ CommandCost CmdConvertRail(DoCommandFlags flags, TileIndex tile, TileIndex area_ CommandCost CmdBuildSignalTrack(DoCommandFlags flags, TileIndex tile, TileIndex end_tile, Track track, SignalType sigtype, SignalVariant sigvar, bool mode, bool autofill, bool minimise_gaps, uint8_t signal_density); CommandCost CmdRemoveSignalTrack(DoCommandFlags flags, TileIndex tile, TileIndex end_tile, Track track, bool autofill); -DEF_CMD_TRAIT(CMD_BUILD_RAILROAD_TRACK, CmdBuildRailroadTrack, CommandFlags({CommandFlag::Auto, CommandFlag::NoWater}), CommandType::LandscapeConstruction) -DEF_CMD_TRAIT(CMD_REMOVE_RAILROAD_TRACK, CmdRemoveRailroadTrack, CommandFlag::Auto, CommandType::LandscapeConstruction) -DEF_CMD_TRAIT(CMD_BUILD_SINGLE_RAIL, CmdBuildSingleRail, CommandFlags({CommandFlag::Auto, CommandFlag::NoWater}), CommandType::LandscapeConstruction) -DEF_CMD_TRAIT(CMD_REMOVE_SINGLE_RAIL, CmdRemoveSingleRail, CommandFlag::Auto, CommandType::LandscapeConstruction) -DEF_CMD_TRAIT(CMD_BUILD_TRAIN_DEPOT, CmdBuildTrainDepot, CommandFlags({CommandFlag::Auto, CommandFlag::NoWater}), CommandType::LandscapeConstruction) -DEF_CMD_TRAIT(CMD_BUILD_SINGLE_SIGNAL, CmdBuildSingleSignal, CommandFlag::Auto, CommandType::LandscapeConstruction) -DEF_CMD_TRAIT(CMD_REMOVE_SINGLE_SIGNAL, CmdRemoveSingleSignal, CommandFlag::Auto, CommandType::LandscapeConstruction) -DEF_CMD_TRAIT(CMD_CONVERT_RAIL, CmdConvertRail, {}, CommandType::LandscapeConstruction) -DEF_CMD_TRAIT(CMD_BUILD_SIGNAL_TRACK, CmdBuildSignalTrack, CommandFlag::Auto, CommandType::LandscapeConstruction) -DEF_CMD_TRAIT(CMD_REMOVE_SIGNAL_TRACK, CmdRemoveSignalTrack, CommandFlag::Auto, CommandType::LandscapeConstruction) +DEF_CMD_TRAIT(Commands::BuildRailLong, CmdBuildRailroadTrack, CommandFlags({CommandFlag::Auto, CommandFlag::NoWater}), CommandType::LandscapeConstruction) +DEF_CMD_TRAIT(Commands::RemoveRailLong, CmdRemoveRailroadTrack, CommandFlag::Auto, CommandType::LandscapeConstruction) +DEF_CMD_TRAIT(Commands::BuildRail, CmdBuildSingleRail, CommandFlags({CommandFlag::Auto, CommandFlag::NoWater}), CommandType::LandscapeConstruction) +DEF_CMD_TRAIT(Commands::RemoveRail, CmdRemoveSingleRail, CommandFlag::Auto, CommandType::LandscapeConstruction) +DEF_CMD_TRAIT(Commands::BuildRailDepot, CmdBuildTrainDepot, CommandFlags({CommandFlag::Auto, CommandFlag::NoWater}), CommandType::LandscapeConstruction) +DEF_CMD_TRAIT(Commands::BuildSignal, CmdBuildSingleSignal, CommandFlag::Auto, CommandType::LandscapeConstruction) +DEF_CMD_TRAIT(Commands::RemoveSignal, CmdRemoveSingleSignal, CommandFlag::Auto, CommandType::LandscapeConstruction) +DEF_CMD_TRAIT(Commands::ConvertRail, CmdConvertRail, {}, CommandType::LandscapeConstruction) +DEF_CMD_TRAIT(Commands::BuildSignalLong, CmdBuildSignalTrack, CommandFlag::Auto, CommandType::LandscapeConstruction) +DEF_CMD_TRAIT(Commands::RemoveSignalLong, CmdRemoveSignalTrack, CommandFlag::Auto, CommandType::LandscapeConstruction) CommandCallback CcPlaySound_CONSTRUCTION_RAIL; CommandCallback CcStation; diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index 059bd6c2b0..3ac34ccf31 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -102,10 +102,10 @@ void CcPlaySound_CONSTRUCTION_RAIL(Commands, const CommandCost &result, TileInde static void GenericPlaceRail(TileIndex tile, Track track) { if (_remove_button_clicked) { - Command::Post(STR_ERROR_CAN_T_REMOVE_RAILROAD_TRACK, CcPlaySound_CONSTRUCTION_RAIL, + Command::Post(STR_ERROR_CAN_T_REMOVE_RAILROAD_TRACK, CcPlaySound_CONSTRUCTION_RAIL, tile, track); } else { - Command::Post(STR_ERROR_CAN_T_BUILD_RAILROAD_TRACK, CcPlaySound_CONSTRUCTION_RAIL, + Command::Post(STR_ERROR_CAN_T_BUILD_RAILROAD_TRACK, CcPlaySound_CONSTRUCTION_RAIL, tile, _cur_railtype, track, _settings_client.gui.auto_remove_signals); } } @@ -123,7 +123,7 @@ static void PlaceExtraDepotRail(TileIndex tile, DiagDirection dir, Track track) if (GetRailTileType(tile) == RailTileType::Signals && !_settings_client.gui.auto_remove_signals) return; if ((GetTrackBits(tile) & DiagdirReachesTracks(dir)) == 0) return; - Command::Post(tile, _cur_railtype, track, _settings_client.gui.auto_remove_signals); + Command::Post(tile, _cur_railtype, track, _settings_client.gui.auto_remove_signals); } /** Additional pieces of track to add at the entrance of a depot. */ @@ -180,7 +180,7 @@ static void PlaceRail_Waypoint(TileIndex tile) } else { /* Tile where we can't build rail waypoints. This is always going to fail, * but provides the user with a proper error message. */ - Command::Post(STR_ERROR_CAN_T_BUILD_RAIL_WAYPOINT , tile, AXIS_X, 1, 1, STAT_CLASS_WAYP, 0, StationID::Invalid(), false); + Command::Post(STR_ERROR_CAN_T_BUILD_RAIL_WAYPOINT , tile, AXIS_X, 1, 1, STAT_CLASS_WAYP, 0, StationID::Invalid(), false); } } @@ -218,9 +218,9 @@ static void PlaceRail_Station(TileIndex tile) auto proc = [=](bool test, StationID to_join) -> bool { if (test) { - return Command::Do(CommandFlagsToDCFlags(GetCommandFlags()), tile, rt, params.axis, numtracks, platlength, params.sel_class, params.sel_type, StationID::Invalid(), adjacent).Succeeded(); + return Command::Do(CommandFlagsToDCFlags(GetCommandFlags()), tile, rt, params.axis, numtracks, platlength, params.sel_class, params.sel_type, StationID::Invalid(), adjacent).Succeeded(); } else { - return Command::Post(STR_ERROR_CAN_T_BUILD_RAILROAD_STATION, CcStation, tile, rt, params.axis, numtracks, platlength, params.sel_class, params.sel_type, to_join, adjacent); + return Command::Post(STR_ERROR_CAN_T_BUILD_RAILROAD_STATION, CcStation, tile, rt, params.axis, numtracks, platlength, params.sel_class, params.sel_type, to_join, adjacent); } }; @@ -248,7 +248,7 @@ static void GenericPlaceSignals(TileIndex tile) Track track = FindFirstTrack(trackbits); if (_remove_button_clicked) { - Command::Post(STR_ERROR_CAN_T_REMOVE_SIGNALS_FROM, CcPlaySound_CONSTRUCTION_RAIL, tile, track); + Command::Post(STR_ERROR_CAN_T_REMOVE_SIGNALS_FROM, CcPlaySound_CONSTRUCTION_RAIL, tile, track); } else { /* Which signals should we cycle through? */ bool tile_has_signal = IsPlainRailTile(tile) && IsValidTrack(track) && HasSignalOnTrack(tile, track); @@ -275,11 +275,11 @@ static void GenericPlaceSignals(TileIndex tile) if (FindWindowById(WC_BUILD_SIGNAL, 0) != nullptr) { /* signal GUI is used */ - Command::Post(_convert_signal_button ? STR_ERROR_SIGNAL_CAN_T_CONVERT_SIGNALS_HERE : STR_ERROR_CAN_T_BUILD_SIGNALS_HERE, CcPlaySound_CONSTRUCTION_RAIL, + Command::Post(_convert_signal_button ? STR_ERROR_SIGNAL_CAN_T_CONVERT_SIGNALS_HERE : STR_ERROR_CAN_T_BUILD_SIGNALS_HERE, CcPlaySound_CONSTRUCTION_RAIL, tile, track, _cur_signal_type, _cur_signal_variant, _convert_signal_button, false, _ctrl_pressed, cycle_start, cycle_end, 0, 0); } else { SignalVariant sigvar = TimerGameCalendar::year < _settings_client.gui.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC; - Command::Post(STR_ERROR_CAN_T_BUILD_SIGNALS_HERE, CcPlaySound_CONSTRUCTION_RAIL, + Command::Post(STR_ERROR_CAN_T_BUILD_SIGNALS_HERE, CcPlaySound_CONSTRUCTION_RAIL, tile, track, _settings_client.gui.default_signal_type, sigvar, false, false, _ctrl_pressed, cycle_start, cycle_end, 0, 0); } @@ -384,10 +384,10 @@ static void BuildRailClick_Remove(Window *w) static void DoRailroadTrack(Track track) { if (_remove_button_clicked) { - Command::Post(STR_ERROR_CAN_T_REMOVE_RAILROAD_TRACK, CcPlaySound_CONSTRUCTION_RAIL, + Command::Post(STR_ERROR_CAN_T_REMOVE_RAILROAD_TRACK, CcPlaySound_CONSTRUCTION_RAIL, TileVirtXY(_thd.selend.x, _thd.selend.y), TileVirtXY(_thd.selstart.x, _thd.selstart.y), track); } else { - Command::Post(STR_ERROR_CAN_T_BUILD_RAILROAD_TRACK, CcPlaySound_CONSTRUCTION_RAIL, + Command::Post(STR_ERROR_CAN_T_BUILD_RAILROAD_TRACK, CcPlaySound_CONSTRUCTION_RAIL, TileVirtXY(_thd.selend.x, _thd.selend.y), TileVirtXY(_thd.selstart.x, _thd.selstart.y), _cur_railtype, track, _settings_client.gui.auto_remove_signals, false); } } @@ -422,13 +422,13 @@ static void HandleAutoSignalPlacement() /* _settings_client.gui.drag_signals_density is given as a parameter such that each user * in a network game can specify their own signal density */ if (_remove_button_clicked) { - Command::Post(STR_ERROR_CAN_T_REMOVE_SIGNALS_FROM, CcPlaySound_CONSTRUCTION_RAIL, + Command::Post(STR_ERROR_CAN_T_REMOVE_SIGNALS_FROM, CcPlaySound_CONSTRUCTION_RAIL, TileVirtXY(_thd.selstart.x, _thd.selstart.y), TileVirtXY(_thd.selend.x, _thd.selend.y), track, _ctrl_pressed); } else { bool sig_gui = FindWindowById(WC_BUILD_SIGNAL, 0) != nullptr; SignalType sigtype = sig_gui ? _cur_signal_type : _settings_client.gui.default_signal_type; SignalVariant sigvar = sig_gui ? _cur_signal_variant : (TimerGameCalendar::year < _settings_client.gui.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC); - Command::Post(STR_ERROR_CAN_T_BUILD_SIGNALS_HERE, CcPlaySound_CONSTRUCTION_RAIL, + Command::Post(STR_ERROR_CAN_T_BUILD_SIGNALS_HERE, CcPlaySound_CONSTRUCTION_RAIL, TileVirtXY(_thd.selstart.x, _thd.selstart.y), TileVirtXY(_thd.selend.x, _thd.selend.y), track, sigtype, sigvar, false, _ctrl_pressed, !_settings_client.gui.drag_signals_fixed_distance, _settings_client.gui.drag_signals_density); } } @@ -689,7 +689,7 @@ struct BuildRailToolbarWindow : Window { break; case WID_RAT_BUILD_DEPOT: - Command::Post(STR_ERROR_CAN_T_BUILD_TRAIN_DEPOT, CcRailDepot, tile, _cur_railtype, _build_depot_direction); + Command::Post(STR_ERROR_CAN_T_BUILD_TRAIN_DEPOT, CcRailDepot, tile, _cur_railtype, _build_depot_direction); break; case WID_RAT_BUILD_WAYPOINT: @@ -709,7 +709,7 @@ struct BuildRailToolbarWindow : Window { break; case WID_RAT_BUILD_TUNNEL: - Command::Post(STR_ERROR_CAN_T_BUILD_TUNNEL_HERE, CcBuildRailTunnel, tile, TRANSPORT_RAIL, _cur_railtype); + Command::Post(STR_ERROR_CAN_T_BUILD_TUNNEL_HERE, CcBuildRailTunnel, tile, TRANSPORT_RAIL, _cur_railtype); break; case WID_RAT_CONVERT_RAIL: @@ -756,7 +756,7 @@ struct BuildRailToolbarWindow : Window { break; case DDSP_CONVERT_RAIL: - Command::Post(STR_ERROR_CAN_T_CONVERT_RAIL, CcPlaySound_CONSTRUCTION_RAIL, end_tile, start_tile, _cur_railtype, _ctrl_pressed); + Command::Post(STR_ERROR_CAN_T_CONVERT_RAIL, CcPlaySound_CONSTRUCTION_RAIL, end_tile, start_tile, _cur_railtype, _ctrl_pressed); break; case DDSP_REMOVE_STATION: @@ -765,7 +765,7 @@ struct BuildRailToolbarWindow : Window { /* Station */ if (_remove_button_clicked) { bool keep_rail = !_ctrl_pressed; - Command::Post(STR_ERROR_CAN_T_REMOVE_PART_OF_STATION, CcPlaySound_CONSTRUCTION_RAIL, end_tile, start_tile, keep_rail); + Command::Post(STR_ERROR_CAN_T_REMOVE_PART_OF_STATION, CcPlaySound_CONSTRUCTION_RAIL, end_tile, start_tile, keep_rail); } else { HandleStationPlacement(start_tile, end_tile); } @@ -773,7 +773,7 @@ struct BuildRailToolbarWindow : Window { /* Waypoint */ if (_remove_button_clicked) { bool keep_rail = !_ctrl_pressed; - Command::Post(STR_ERROR_CAN_T_REMOVE_RAIL_WAYPOINT , CcPlaySound_CONSTRUCTION_RAIL, end_tile, start_tile, keep_rail); + Command::Post(STR_ERROR_CAN_T_REMOVE_RAIL_WAYPOINT , CcPlaySound_CONSTRUCTION_RAIL, end_tile, start_tile, keep_rail); } else { TileArea ta(start_tile, end_tile); Axis axis = select_method == VPM_X_LIMITED ? AXIS_X : AXIS_Y; @@ -781,9 +781,9 @@ struct BuildRailToolbarWindow : Window { auto proc = [=](bool test, StationID to_join) -> bool { if (test) { - return Command::Do(CommandFlagsToDCFlags(GetCommandFlags()), ta.tile, axis, ta.w, ta.h, _waypoint_gui.sel_class, _waypoint_gui.sel_type, StationID::Invalid(), adjacent).Succeeded(); + return Command::Do(CommandFlagsToDCFlags(GetCommandFlags()), ta.tile, axis, ta.w, ta.h, _waypoint_gui.sel_class, _waypoint_gui.sel_type, StationID::Invalid(), adjacent).Succeeded(); } else { - return Command::Post(STR_ERROR_CAN_T_BUILD_RAIL_WAYPOINT , CcPlaySound_CONSTRUCTION_RAIL, ta.tile, axis, ta.w, ta.h, _waypoint_gui.sel_class, _waypoint_gui.sel_type, to_join, adjacent); + return Command::Post(STR_ERROR_CAN_T_BUILD_RAIL_WAYPOINT , CcPlaySound_CONSTRUCTION_RAIL, ta.tile, axis, ta.w, ta.h, _waypoint_gui.sel_class, _waypoint_gui.sel_type, to_join, adjacent); } }; @@ -814,7 +814,7 @@ struct BuildRailToolbarWindow : Window { void OnPlacePresize([[maybe_unused]] Point pt, TileIndex tile) override { - Command::Do(DoCommandFlag::Auto, tile, TRANSPORT_RAIL, _cur_railtype); + Command::Do(DoCommandFlag::Auto, tile, TRANSPORT_RAIL, _cur_railtype); VpSetPresizeRange(tile, _build_tunnel_endtile == 0 ? tile : _build_tunnel_endtile); } @@ -948,9 +948,9 @@ static void HandleStationPlacement(TileIndex start, TileIndex end) auto proc = [=](bool test, StationID to_join) -> bool { if (test) { - return Command::Do(CommandFlagsToDCFlags(GetCommandFlags()), ta.tile, rt, params.axis, numtracks, platlength, params.sel_class, params.sel_type, StationID::Invalid(), adjacent).Succeeded(); + return Command::Do(CommandFlagsToDCFlags(GetCommandFlags()), ta.tile, rt, params.axis, numtracks, platlength, params.sel_class, params.sel_type, StationID::Invalid(), adjacent).Succeeded(); } else { - return Command::Post(STR_ERROR_CAN_T_BUILD_RAILROAD_STATION, CcStation, ta.tile, rt, params.axis, numtracks, platlength, params.sel_class, params.sel_type, to_join, adjacent); + return Command::Post(STR_ERROR_CAN_T_BUILD_RAILROAD_STATION, CcStation, ta.tile, rt, params.axis, numtracks, platlength, params.sel_class, params.sel_type, to_join, adjacent); } }; diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp index f76c316cd0..2c9cad7a2a 100644 --- a/src/road_cmd.cpp +++ b/src/road_cmd.cpp @@ -350,7 +350,7 @@ static CommandCost RemoveRoad(TileIndex tile, DoCommandFlags flags, RoadBits pie if (!IsTileType(tile, TileType::Road)) { /* If it's the last roadtype, just clear the whole tile */ - if (GetRoadType(tile, OtherRoadTramType(rtt)) == INVALID_ROADTYPE) return Command::Do(flags, tile); + if (GetRoadType(tile, OtherRoadTramType(rtt)) == INVALID_ROADTYPE) return Command::Do(flags, tile); CommandCost cost(EXPENSES_CONSTRUCTION); if (IsTileType(tile, TileType::TunnelBridge)) { @@ -805,7 +805,7 @@ do_clear:; } if (need_to_clear) { - CommandCost ret = Command::Do(flags, tile); + CommandCost ret = Command::Do(flags, tile); if (ret.Failed()) return ret; cost.AddCost(ret.GetCost()); } @@ -851,7 +851,7 @@ do_clear:; if (HasPowerOnRoad(rt, existing_rt)) { rt = existing_rt; } else if (HasPowerOnRoad(existing_rt, rt)) { - ret = Command::Do(flags, tile, tile, rt, false); + ret = Command::Do(flags, tile, tile, rt, false); if (ret.Failed()) return ret; cost.AddCost(ret.GetCost()); } else { @@ -1013,7 +1013,7 @@ CommandCost CmdBuildLongRoad(DoCommandFlags flags, TileIndex end_tile, TileIndex if (tile == start_tile && start_half) bits &= DiagDirToRoadBits(dir); } - CommandCost ret = Command::Do(flags, tile, bits, rt, drd, TownID::Invalid()); + CommandCost ret = Command::Do(flags, tile, bits, rt, drd, TownID::Invalid()); if (!is_ai && ret.GetErrorMessage() == STR_ERROR_ALREADY_BUILT) had_success = true; if (ret.Failed()) { last_error = std::move(ret); @@ -1097,7 +1097,7 @@ std::tuple CmdRemoveLongRoad(DoCommandFlags flags, TileIndex if (flags.Test(DoCommandFlag::Execute)) { money_spent += ret.GetCost(); if (money_spent > 0 && money_spent > money_available) { - return { cost, std::get<0>(Command::Do(DoCommandFlags{flags}.Reset(DoCommandFlag::Execute), end_tile, start_tile, rt, axis, start_half, end_half)).GetCost() }; + return { cost, std::get<0>(Command::Do(DoCommandFlags{flags}.Reset(DoCommandFlag::Execute), end_tile, start_tile, rt, axis, start_half, end_half)).GetCost() }; } RemoveRoad(tile, flags, bits, rtt, false); } @@ -1164,7 +1164,7 @@ CommandCost CmdBuildRoadDepot(DoCommandFlags flags, TileIndex tile, RoadType rt, } if (!rotate_existing_depot) { - cost.AddCost(Command::Do(flags, tile)); + cost.AddCost(Command::Do(flags, tile)); if (cost.Failed()) return cost; if (IsBridgeAbove(tile)) return CommandCost(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST); @@ -1255,7 +1255,7 @@ static CommandCost ClearTile_Road(TileIndex tile, DoCommandFlags flags) } if (flags.Test(DoCommandFlag::Execute)) { - Command::Do(flags, tile); + Command::Do(flags, tile); } return ret; } @@ -2315,7 +2315,7 @@ static void ChangeTileOwner_Road(TileIndex tile, Owner old_owner, Owner new_owne if (IsRoadDepot(tile)) { if (GetTileOwner(tile) == old_owner) { if (new_owner == INVALID_OWNER) { - Command::Do({DoCommandFlag::Execute, DoCommandFlag::Bankrupt}, tile); + Command::Do({DoCommandFlag::Execute, DoCommandFlag::Bankrupt}, tile); } else { /* A road depot has two road bits. No need to dirty windows here, we'll redraw the whole screen anyway. */ RoadType rt = GetRoadTypeRoad(tile); @@ -2352,7 +2352,7 @@ static void ChangeTileOwner_Road(TileIndex tile, Owner old_owner, Owner new_owne if (IsLevelCrossing(tile)) { if (GetTileOwner(tile) == old_owner) { if (new_owner == INVALID_OWNER) { - Command::Do({DoCommandFlag::Execute, DoCommandFlag::Bankrupt}, tile, GetCrossingRailTrack(tile)); + Command::Do({DoCommandFlag::Execute, DoCommandFlag::Bankrupt}, tile, GetCrossingRailTrack(tile)); } else { /* Update infrastructure counts. No need to dirty windows here, we'll redraw the whole screen anyway. */ Company::Get(old_owner)->infrastructure.rail[GetRailType(tile)] -= LEVELCROSSING_TRACKBIT_FACTOR; @@ -2400,7 +2400,7 @@ static CommandCost TerraformTile_Road(TileIndex tile, DoCommandFlags flags, int } } - return Command::Do(flags, tile); + return Command::Do(flags, tile); } /** @@ -2649,7 +2649,7 @@ CommandCost CmdConvertRoad(DoCommandFlags flags, TileIndex tile, TileIndex area_ static CommandCost CheckBuildAbove_Road(TileIndex tile, DoCommandFlags flags, Axis, int) { if (!IsRoadDepot(tile)) return CommandCost(); - return Command::Do(flags, tile); + return Command::Do(flags, tile); } /** Tile callback functions for road tiles */ diff --git a/src/road_cmd.h b/src/road_cmd.h index 20f66db986..4b0cfcd4d6 100644 --- a/src/road_cmd.h +++ b/src/road_cmd.h @@ -27,11 +27,11 @@ CommandCost CmdBuildRoad(DoCommandFlags flags, TileIndex tile, RoadBits pieces, CommandCost CmdBuildRoadDepot(DoCommandFlags flags, TileIndex tile, RoadType rt, DiagDirection dir); CommandCost CmdConvertRoad(DoCommandFlags flags, TileIndex tile, TileIndex area_start, RoadType to_type, bool diagonal); -DEF_CMD_TRAIT(CMD_BUILD_LONG_ROAD, CmdBuildLongRoad, CommandFlags({CommandFlag::Auto, CommandFlag::NoWater, CommandFlag::Deity}), CommandType::LandscapeConstruction) -DEF_CMD_TRAIT(CMD_REMOVE_LONG_ROAD, CmdRemoveLongRoad, CommandFlags({CommandFlag::Auto, CommandFlag::NoTest}), CommandType::LandscapeConstruction) // towns may disallow removing road bits (as they are connected) in test, but in exec they're removed and thus removing is allowed. -DEF_CMD_TRAIT(CMD_BUILD_ROAD, CmdBuildRoad, CommandFlags({CommandFlag::Auto, CommandFlag::NoWater, CommandFlag::Deity}), CommandType::LandscapeConstruction) -DEF_CMD_TRAIT(CMD_BUILD_ROAD_DEPOT, CmdBuildRoadDepot, CommandFlags({CommandFlag::Auto, CommandFlag::NoWater}), CommandType::LandscapeConstruction) -DEF_CMD_TRAIT(CMD_CONVERT_ROAD, CmdConvertRoad, {}, CommandType::LandscapeConstruction) +DEF_CMD_TRAIT(Commands::BuildRoadLong, CmdBuildLongRoad, CommandFlags({CommandFlag::Auto, CommandFlag::NoWater, CommandFlag::Deity}), CommandType::LandscapeConstruction) +DEF_CMD_TRAIT(Commands::RemoveRoadLong, CmdRemoveLongRoad, CommandFlags({CommandFlag::Auto, CommandFlag::NoTest}), CommandType::LandscapeConstruction) // towns may disallow removing road bits (as they are connected) in test, but in exec they're removed and thus removing is allowed. +DEF_CMD_TRAIT(Commands::BuildRoad, CmdBuildRoad, CommandFlags({CommandFlag::Auto, CommandFlag::NoWater, CommandFlag::Deity}), CommandType::LandscapeConstruction) +DEF_CMD_TRAIT(Commands::BuildRoadDepot, CmdBuildRoadDepot, CommandFlags({CommandFlag::Auto, CommandFlag::NoWater}), CommandType::LandscapeConstruction) +DEF_CMD_TRAIT(Commands::ConvertRoad, CmdConvertRoad, {}, CommandType::LandscapeConstruction) CommandCallback CcPlaySound_CONSTRUCTION_OTHER; CommandCallback CcBuildRoadTunnel; diff --git a/src/road_gui.cpp b/src/road_gui.cpp index 7bc74b76f7..475be95796 100644 --- a/src/road_gui.cpp +++ b/src/road_gui.cpp @@ -166,7 +166,7 @@ void ConnectRoadToStructure(TileIndex tile, DiagDirection direction) /* if there is a roadpiece just outside of the station entrance, build a connecting route */ if (IsNormalRoadTile(tile)) { if (GetRoadBits(tile, GetRoadTramType(_cur_roadtype)) != ROAD_NONE) { - Command::Post(tile, DiagDirToRoadBits(ReverseDiagDir(direction)), _cur_roadtype, DRD_NONE, TownID::Invalid()); + Command::Post(tile, DiagDirToRoadBits(ReverseDiagDir(direction)), _cur_roadtype, DRD_NONE, TownID::Invalid()); } } } @@ -237,10 +237,10 @@ static void PlaceRoadStop(TileIndex start_tile, TileIndex end_tile, RoadStopType auto proc = [=](bool test, StationID to_join) -> bool { if (test) { - return Command::Do(CommandFlagsToDCFlags(GetCommandFlags()), ta.tile, ta.w, ta.h, stop_type, drive_through, + return Command::Do(CommandFlagsToDCFlags(GetCommandFlags()), ta.tile, ta.w, ta.h, stop_type, drive_through, ddir, rt, spec_class, spec_index, StationID::Invalid(), adjacent).Succeeded(); } else { - return Command::Post(err_msg, CcRoadStop, ta.tile, ta.w, ta.h, stop_type, drive_through, + return Command::Post(err_msg, CcRoadStop, ta.tile, ta.w, ta.h, stop_type, drive_through, ddir, rt, spec_class, spec_index, to_join, adjacent); } }; @@ -267,7 +267,7 @@ static void PlaceRoad_Waypoint(TileIndex tile) } else { /* Tile where we can't build road waypoints. This is always going to fail, * but provides the user with a proper error message. */ - Command::Post(STR_ERROR_CAN_T_BUILD_ROAD_WAYPOINT, tile, AXIS_X, 1, 1, ROADSTOP_CLASS_WAYP, 0, StationID::Invalid(), false); + Command::Post(STR_ERROR_CAN_T_BUILD_ROAD_WAYPOINT, tile, AXIS_X, 1, 1, ROADSTOP_CLASS_WAYP, 0, StationID::Invalid(), false); } } @@ -631,7 +631,7 @@ struct BuildRoadToolbarWindow : Window { break; case WID_ROT_DEPOT: - Command::Post(GetRoadTypeInfo(this->roadtype)->strings.err_depot, CcRoadDepot, + Command::Post(GetRoadTypeInfo(this->roadtype)->strings.err_depot, CcRoadDepot, tile, _cur_roadtype, _road_depot_orientation); break; @@ -652,7 +652,7 @@ struct BuildRoadToolbarWindow : Window { break; case WID_ROT_BUILD_TUNNEL: - Command::Post(STR_ERROR_CAN_T_BUILD_TUNNEL_HERE, CcBuildRoadTunnel, + Command::Post(STR_ERROR_CAN_T_BUILD_TUNNEL_HERE, CcBuildRoadTunnel, tile, TRANSPORT_ROAD, _cur_roadtype); break; @@ -749,10 +749,10 @@ struct BuildRoadToolbarWindow : Window { bool start_half = _place_road_dir == AXIS_Y ? _place_road_start_half_y : _place_road_start_half_x; if (_remove_button_clicked) { - Command::Post(GetRoadTypeInfo(this->roadtype)->strings.err_remove_road, CcPlaySound_CONSTRUCTION_OTHER, + Command::Post(GetRoadTypeInfo(this->roadtype)->strings.err_remove_road, CcPlaySound_CONSTRUCTION_OTHER, end_tile, start_tile, _cur_roadtype, _place_road_dir, start_half, _place_road_end_half); } else { - Command::Post(GetRoadTypeInfo(this->roadtype)->strings.err_build_road, CcPlaySound_CONSTRUCTION_OTHER, + Command::Post(GetRoadTypeInfo(this->roadtype)->strings.err_build_road, CcPlaySound_CONSTRUCTION_OTHER, end_tile, start_tile, _cur_roadtype, _place_road_dir, _one_way_button_clicked ? DRD_NORTHBOUND : DRD_NONE, start_half, _place_road_end_half, false); } break; @@ -762,7 +762,7 @@ struct BuildRoadToolbarWindow : Window { case DDSP_REMOVE_ROAD_WAYPOINT: if (this->IsWidgetLowered(WID_ROT_BUILD_WAYPOINT)) { if (_remove_button_clicked) { - Command::Post(STR_ERROR_CAN_T_REMOVE_ROAD_WAYPOINT, CcPlaySound_CONSTRUCTION_OTHER, end_tile, start_tile); + Command::Post(STR_ERROR_CAN_T_REMOVE_ROAD_WAYPOINT, CcPlaySound_CONSTRUCTION_OTHER, end_tile, start_tile); } else { TileArea ta(start_tile, end_tile); Axis axis = select_method == VPM_X_LIMITED ? AXIS_X : AXIS_Y; @@ -770,9 +770,9 @@ struct BuildRoadToolbarWindow : Window { auto proc = [=](bool test, StationID to_join) -> bool { if (test) { - return Command::Do(CommandFlagsToDCFlags(GetCommandFlags()), ta.tile, axis, ta.w, ta.h, _waypoint_gui.sel_class, _waypoint_gui.sel_type, StationID::Invalid(), adjacent).Succeeded(); + return Command::Do(CommandFlagsToDCFlags(GetCommandFlags()), ta.tile, axis, ta.w, ta.h, _waypoint_gui.sel_class, _waypoint_gui.sel_type, StationID::Invalid(), adjacent).Succeeded(); } else { - return Command::Post(STR_ERROR_CAN_T_BUILD_ROAD_WAYPOINT, CcPlaySound_CONSTRUCTION_OTHER, ta.tile, axis, ta.w, ta.h, _waypoint_gui.sel_class, _waypoint_gui.sel_type, to_join, adjacent); + return Command::Post(STR_ERROR_CAN_T_BUILD_ROAD_WAYPOINT, CcPlaySound_CONSTRUCTION_OTHER, ta.tile, axis, ta.w, ta.h, _waypoint_gui.sel_class, _waypoint_gui.sel_type, to_join, adjacent); } }; @@ -787,7 +787,7 @@ struct BuildRoadToolbarWindow : Window { if (_remove_button_clicked) { TileArea ta(start_tile, end_tile); StringID str = GetRoadTypeInfo(this->roadtype)->strings.err_remove_station[to_underlying(RoadStopType::Bus)]; - Command::Post(str, CcPlaySound_CONSTRUCTION_OTHER, ta.tile, ta.w, ta.h, RoadStopType::Bus, _ctrl_pressed); + Command::Post(str, CcPlaySound_CONSTRUCTION_OTHER, ta.tile, ta.w, ta.h, RoadStopType::Bus, _ctrl_pressed); } else { StringID str = GetRoadTypeInfo(this->roadtype)->strings.err_build_station[to_underlying(RoadStopType::Bus)]; PlaceRoadStop(start_tile, end_tile, RoadStopType::Bus, _ctrl_pressed, _cur_roadtype, str); @@ -801,7 +801,7 @@ struct BuildRoadToolbarWindow : Window { if (_remove_button_clicked) { TileArea ta(start_tile, end_tile); StringID str = GetRoadTypeInfo(this->roadtype)->strings.err_remove_station[to_underlying(RoadStopType::Truck)]; - Command::Post(str, CcPlaySound_CONSTRUCTION_OTHER, ta.tile, ta.w, ta.h, RoadStopType::Truck, _ctrl_pressed); + Command::Post(str, CcPlaySound_CONSTRUCTION_OTHER, ta.tile, ta.w, ta.h, RoadStopType::Truck, _ctrl_pressed); } else { StringID str = GetRoadTypeInfo(this->roadtype)->strings.err_build_station[to_underlying(RoadStopType::Truck)]; PlaceRoadStop(start_tile, end_tile, RoadStopType::Truck, _ctrl_pressed, _cur_roadtype, str); @@ -810,7 +810,7 @@ struct BuildRoadToolbarWindow : Window { break; case DDSP_CONVERT_ROAD: - Command::Post(GetRoadTypeInfo(this->roadtype)->strings.err_convert_road, CcPlaySound_CONSTRUCTION_OTHER, end_tile, start_tile, _cur_roadtype, _ctrl_pressed); + Command::Post(GetRoadTypeInfo(this->roadtype)->strings.err_convert_road, CcPlaySound_CONSTRUCTION_OTHER, end_tile, start_tile, _cur_roadtype, _ctrl_pressed); break; } } @@ -818,7 +818,7 @@ struct BuildRoadToolbarWindow : Window { void OnPlacePresize([[maybe_unused]] Point pt, TileIndex tile) override { - Command::Do(DoCommandFlag::Auto, tile, TRANSPORT_ROAD, _cur_roadtype); + Command::Do(DoCommandFlag::Auto, tile, TRANSPORT_ROAD, _cur_roadtype); VpSetPresizeRange(tile, _build_tunnel_endtile == 0 ? tile : _build_tunnel_endtile); } diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp index 5201b53b53..34eae98a53 100644 --- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -1138,7 +1138,7 @@ static bool CanBuildTramTrackOnTile(CompanyID c, TileIndex t, RoadType rt, RoadB /* The 'current' company is not necessarily the owner of the vehicle. */ Backup cur_company(_current_company, c); - CommandCost ret = Command::Do(DoCommandFlag::NoWater, t, r, rt, DRD_NONE, TownID::Invalid()); + CommandCost ret = Command::Do(DoCommandFlag::NoWater, t, r, rt, DRD_NONE, TownID::Invalid()); cur_company.Restore(); return ret.Succeeded(); diff --git a/src/roadveh_cmd.h b/src/roadveh_cmd.h index 7e3edc531d..14d6b6b509 100644 --- a/src/roadveh_cmd.h +++ b/src/roadveh_cmd.h @@ -22,6 +22,6 @@ CommandCost CmdBuildRoadVehicle(DoCommandFlags flags, TileIndex tile, const Engi CommandCost CmdTurnRoadVeh(DoCommandFlags flags, VehicleID veh_id); -DEF_CMD_TRAIT(CMD_TURN_ROADVEH, CmdTurnRoadVeh, CommandFlag::Location, CommandType::VehicleManagement) +DEF_CMD_TRAIT(Commands::TurnRoadVehicle, CmdTurnRoadVeh, CommandFlag::Location, CommandType::VehicleManagement) #endif /* ROADVEH_CMD_H */ diff --git a/src/script/api/script_airport.cpp b/src/script/api/script_airport.cpp index e0a96c5909..a39f41328e 100644 --- a/src/script/api/script_airport.cpp +++ b/src/script/api/script_airport.cpp @@ -77,7 +77,7 @@ EnforcePrecondition(false, IsValidAirportType(type)); EnforcePrecondition(false, station_id == ScriptStation::STATION_NEW || station_id == ScriptStation::STATION_JOIN_ADJACENT || ScriptStation::IsValidStation(station_id)); - return ScriptObject::Command::Do(tile, type, 0, (ScriptStation::IsValidStation(station_id) ? station_id : StationID::Invalid()), station_id != ScriptStation::STATION_JOIN_ADJACENT); + return ScriptObject::Command::Do(tile, type, 0, (ScriptStation::IsValidStation(station_id) ? station_id : StationID::Invalid()), station_id != ScriptStation::STATION_JOIN_ADJACENT); } /* static */ bool ScriptAirport::RemoveAirport(TileIndex tile) @@ -86,7 +86,7 @@ EnforcePrecondition(false, ::IsValidTile(tile)) EnforcePrecondition(false, IsAirportTile(tile) || IsHangarTile(tile)); - return ScriptObject::Command::Do(tile); + return ScriptObject::Command::Do(tile); } /* static */ SQInteger ScriptAirport::GetNumHangars(TileIndex tile) diff --git a/src/script/api/script_basestation.cpp b/src/script/api/script_basestation.cpp index 5f183c30e5..42b54047a2 100644 --- a/src/script/api/script_basestation.cpp +++ b/src/script/api/script_basestation.cpp @@ -53,9 +53,9 @@ EnforcePreconditionCustomError(false, ::Utf8StringLength(text) < MAX_LENGTH_STATION_NAME_CHARS, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG); if (::Station::IsValidID(station_id)) { - return ScriptObject::Command::Do(station_id, text); + return ScriptObject::Command::Do(station_id, text); } else { - return ScriptObject::Command::Do(station_id, text); + return ScriptObject::Command::Do(station_id, text); } } diff --git a/src/script/api/script_bridge.cpp b/src/script/api/script_bridge.cpp index d1f400d636..c5c1d7cb0d 100644 --- a/src/script/api/script_bridge.cpp +++ b/src/script/api/script_bridge.cpp @@ -86,11 +86,11 @@ static void _DoCommandReturnBuildBridge1(class ScriptInstance &instance) case ScriptVehicle::VT_ROAD: ScriptObject::SetCallbackVariable(0, start.base()); ScriptObject::SetCallbackVariable(1, end.base()); - return ScriptObject::Command::Do(&::_DoCommandReturnBuildBridge1, end, start, TRANSPORT_ROAD, bridge_type, ScriptRoad::GetCurrentRoadType()); + return ScriptObject::Command::Do(&::_DoCommandReturnBuildBridge1, end, start, TRANSPORT_ROAD, bridge_type, ScriptRoad::GetCurrentRoadType()); case ScriptVehicle::VT_RAIL: - return ScriptObject::Command::Do(end, start, TRANSPORT_RAIL, bridge_type, ScriptRail::GetCurrentRailType()); + return ScriptObject::Command::Do(end, start, TRANSPORT_RAIL, bridge_type, ScriptRail::GetCurrentRailType()); case ScriptVehicle::VT_WATER: - return ScriptObject::Command::Do(end, start, TRANSPORT_WATER, bridge_type, 0); + return ScriptObject::Command::Do(end, start, TRANSPORT_WATER, bridge_type, 0); default: NOT_REACHED(); } } @@ -106,7 +106,7 @@ static void _DoCommandReturnBuildBridge1(class ScriptInstance &instance) DiagDirection dir_1 = ::DiagdirBetweenTiles(end, start); DiagDirection dir_2 = ::ReverseDiagDir(dir_1); - return ScriptObject::Command::Do(&::_DoCommandReturnBuildBridge2, start + ::TileOffsByDiagDir(dir_1), ::DiagDirToRoadBits(dir_2), (::RoadType)ScriptRoad::GetCurrentRoadType(), DRD_NONE, TownID::Invalid()); + return ScriptObject::Command::Do(&::_DoCommandReturnBuildBridge2, start + ::TileOffsByDiagDir(dir_1), ::DiagDirToRoadBits(dir_2), (::RoadType)ScriptRoad::GetCurrentRoadType(), DRD_NONE, TownID::Invalid()); } /* static */ bool ScriptBridge::_BuildBridgeRoad2() @@ -120,14 +120,14 @@ static void _DoCommandReturnBuildBridge1(class ScriptInstance &instance) DiagDirection dir_1 = ::DiagdirBetweenTiles(end, start); DiagDirection dir_2 = ::ReverseDiagDir(dir_1); - return ScriptObject::Command::Do(end + ::TileOffsByDiagDir(dir_2), ::DiagDirToRoadBits(dir_1), (::RoadType)ScriptRoad::GetCurrentRoadType(), DRD_NONE, TownID::Invalid()); + return ScriptObject::Command::Do(end + ::TileOffsByDiagDir(dir_2), ::DiagDirToRoadBits(dir_1), (::RoadType)ScriptRoad::GetCurrentRoadType(), DRD_NONE, TownID::Invalid()); } /* static */ bool ScriptBridge::RemoveBridge(TileIndex tile) { EnforceCompanyModeValid(false); EnforcePrecondition(false, IsBridgeTile(tile)); - return ScriptObject::Command::Do(tile); + return ScriptObject::Command::Do(tile); } /* static */ std::optional ScriptBridge::GetName(BridgeType bridge_type, ScriptVehicle::VehicleType vehicle_type) diff --git a/src/script/api/script_company.cpp b/src/script/api/script_company.cpp index 4b85b33b61..844ccab851 100644 --- a/src/script/api/script_company.cpp +++ b/src/script/api/script_company.cpp @@ -70,7 +70,7 @@ EnforcePreconditionEncodedText(false, text); EnforcePreconditionCustomError(false, ::Utf8StringLength(text) < MAX_LENGTH_COMPANY_NAME_CHARS, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG); - return ScriptObject::Command::Do(text); + return ScriptObject::Command::Do(text); } /* static */ std::optional ScriptCompany::GetName(ScriptCompany::CompanyID company) @@ -91,7 +91,7 @@ EnforcePreconditionEncodedText(false, text); EnforcePreconditionCustomError(false, ::Utf8StringLength(text) < MAX_LENGTH_PRESIDENT_NAME_CHARS, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG); - return ScriptObject::Command::Do(text); + return ScriptObject::Command::Do(text); } /* static */ std::optional ScriptCompany::GetPresidentName(ScriptCompany::CompanyID company) @@ -119,7 +119,7 @@ RandomiseCompanyManagerFaceBits(cmf, GetCompanyManagerFaceVars(cmf.style), randomizer); - return ScriptObject::Command::Do(cmf.style, cmf.bits); + return ScriptObject::Command::Do(cmf.style, cmf.bits); } /* static */ ScriptCompany::Gender ScriptCompany::GetPresidentGender(ScriptCompany::CompanyID company) @@ -231,7 +231,7 @@ company = ResolveCompanyID(company); EnforcePrecondition(false, company != ScriptCompany::COMPANY_INVALID); - return ScriptObject::Command::Do(ScriptCompany::FromScriptCompanyID(company), amount); + return ScriptObject::Command::Do(ScriptCompany::FromScriptCompanyID(company), amount); } /* static */ bool ScriptCompany::ResetMaxLoanAmountForCompany(ScriptCompany::CompanyID company) @@ -241,7 +241,7 @@ company = ResolveCompanyID(company); EnforcePrecondition(false, company != ScriptCompany::COMPANY_INVALID); - return ScriptObject::Command::Do(ScriptCompany::FromScriptCompanyID(company), COMPANY_MAX_LOAN_DEFAULT); + return ScriptObject::Command::Do(ScriptCompany::FromScriptCompanyID(company), COMPANY_MAX_LOAN_DEFAULT); } /* static */ Money ScriptCompany::GetLoanInterval() @@ -262,9 +262,9 @@ Money amount = abs(loan - GetLoanAmount()); if (loan > GetLoanAmount()) { - return ScriptObject::Command::Do(LoanCommand::Amount, amount); + return ScriptObject::Command::Do(LoanCommand::Amount, amount); } else { - return ScriptObject::Command::Do(LoanCommand::Amount, amount); + return ScriptObject::Command::Do(LoanCommand::Amount, amount); } } @@ -293,7 +293,7 @@ EnforcePrecondition(false, company != ScriptCompany::COMPANY_INVALID); /* Network commands only allow 0 to indicate invalid tiles, not INVALID_TILE */ - return ScriptObject::Command::Do(tile == INVALID_TILE ? (TileIndex)0U : tile, delta, ScriptCompany::FromScriptCompanyID(company), (::ExpensesType)expenses_type); + return ScriptObject::Command::Do(tile == INVALID_TILE ? (TileIndex)0U : tile, delta, ScriptCompany::FromScriptCompanyID(company), (::ExpensesType)expenses_type); } /* static */ bool ScriptCompany::BuildCompanyHQ(TileIndex tile) @@ -301,7 +301,7 @@ EnforceCompanyModeValid(false); EnforcePrecondition(false, ::IsValidTile(tile)); - return ScriptObject::Command::Do(tile, OBJECT_HQ, 0); + return ScriptObject::Command::Do(tile, OBJECT_HQ, 0); } /* static */ TileIndex ScriptCompany::GetCompanyHQ(ScriptCompany::CompanyID company) @@ -316,7 +316,7 @@ /* static */ bool ScriptCompany::SetAutoRenewStatus(bool autorenew) { EnforceCompanyModeValid(false); - return ScriptObject::Command::Do("company.engine_renew", autorenew ? 1 : 0); + return ScriptObject::Command::Do("company.engine_renew", autorenew ? 1 : 0); } /* static */ bool ScriptCompany::GetAutoRenewStatus(ScriptCompany::CompanyID company) @@ -332,7 +332,7 @@ EnforceCompanyModeValid(false); months = Clamp(months, INT16_MIN, INT16_MAX); - return ScriptObject::Command::Do("company.engine_renew_months", months); + return ScriptObject::Command::Do("company.engine_renew_months", months); } /* static */ SQInteger ScriptCompany::GetAutoRenewMonths(ScriptCompany::CompanyID company) @@ -348,7 +348,7 @@ EnforceCompanyModeValid(false); EnforcePrecondition(false, money >= 0); EnforcePrecondition(false, (int64_t)money <= UINT32_MAX); - return ScriptObject::Command::Do("company.engine_renew_money", money); + return ScriptObject::Command::Do("company.engine_renew_money", money); } /* static */ Money ScriptCompany::GetAutoRenewMoney(ScriptCompany::CompanyID company) @@ -362,13 +362,13 @@ /* static */ bool ScriptCompany::SetPrimaryLiveryColour(LiveryScheme scheme, Colours colour) { EnforceCompanyModeValid(false); - return ScriptObject::Command::Do((::LiveryScheme)scheme, true, (::Colours)colour); + return ScriptObject::Command::Do((::LiveryScheme)scheme, true, (::Colours)colour); } /* static */ bool ScriptCompany::SetSecondaryLiveryColour(LiveryScheme scheme, Colours colour) { EnforceCompanyModeValid(false); - return ScriptObject::Command::Do((::LiveryScheme)scheme, false, (::Colours)colour); + return ScriptObject::Command::Do((::LiveryScheme)scheme, false, (::Colours)colour); } /* static */ ScriptCompany::Colours ScriptCompany::GetPrimaryLiveryColour(ScriptCompany::LiveryScheme scheme) diff --git a/src/script/api/script_controller.cpp b/src/script/api/script_controller.cpp index f0a382f60a..9ca48c0d01 100644 --- a/src/script/api/script_controller.cpp +++ b/src/script/api/script_controller.cpp @@ -58,7 +58,7 @@ ShowScriptDebugWindow(ScriptObject::GetRootCompany()); if (!_pause_mode.Test(PauseMode::Normal)) { - ScriptObject::Command::Do(PauseMode::Normal, true); + ScriptObject::Command::Do(PauseMode::Normal, true); } } diff --git a/src/script/api/script_engine.cpp b/src/script/api/script_engine.cpp index 4ac0a3b52f..8fdabf1096 100644 --- a/src/script/api/script_engine.cpp +++ b/src/script/api/script_engine.cpp @@ -293,7 +293,7 @@ EnforcePrecondition(false, IsValidEngine(engine_id)); EnforcePrecondition(false, company != ScriptCompany::COMPANY_INVALID); - return ScriptObject::Command::Do(engine_id, ScriptCompany::FromScriptCompanyID(company), true); + return ScriptObject::Command::Do(engine_id, ScriptCompany::FromScriptCompanyID(company), true); } /* static */ bool ScriptEngine::DisableForCompany(EngineID engine_id, ScriptCompany::CompanyID company) @@ -304,5 +304,5 @@ EnforcePrecondition(false, IsValidEngine(engine_id)); EnforcePrecondition(false, company != ScriptCompany::COMPANY_INVALID); - return ScriptObject::Command::Do(engine_id, ScriptCompany::FromScriptCompanyID(company), false); + return ScriptObject::Command::Do(engine_id, ScriptCompany::FromScriptCompanyID(company), false); } diff --git a/src/script/api/script_event_types.cpp b/src/script/api/script_event_types.cpp index 110e14b021..3647529ee5 100644 --- a/src/script/api/script_event_types.cpp +++ b/src/script/api/script_event_types.cpp @@ -107,13 +107,13 @@ bool ScriptEventEnginePreview::AcceptPreview() { EnforceCompanyModeValid(false); if (!this->IsEngineValid()) return false; - return ScriptObject::Command::Do(this->engine); + return ScriptObject::Command::Do(this->engine); } bool ScriptEventCompanyAskMerger::AcceptMerger() { EnforceCompanyModeValid(false); - return ScriptObject::Command::Do(ScriptCompany::FromScriptCompanyID(this->owner), false); + return ScriptObject::Command::Do(ScriptCompany::FromScriptCompanyID(this->owner), false); } ScriptEventAdminPort::ScriptEventAdminPort(const std::string &json) : diff --git a/src/script/api/script_game.cpp b/src/script/api/script_game.cpp index 7354ddd64a..a7c04cc495 100644 --- a/src/script/api/script_game.cpp +++ b/src/script/api/script_game.cpp @@ -19,12 +19,12 @@ /* static */ bool ScriptGame::Pause() { - return ScriptObject::Command::Do(PauseMode::GameScript, true); + return ScriptObject::Command::Do(PauseMode::GameScript, true); } /* static */ bool ScriptGame::Unpause() { - return ScriptObject::Command::Do(PauseMode::GameScript, false); + return ScriptObject::Command::Do(PauseMode::GameScript, false); } /* static */ bool ScriptGame::IsPaused() diff --git a/src/script/api/script_gamesettings.cpp b/src/script/api/script_gamesettings.cpp index 96d075a7cd..a8fcb712d6 100644 --- a/src/script/api/script_gamesettings.cpp +++ b/src/script/api/script_gamesettings.cpp @@ -43,7 +43,7 @@ value = Clamp(value, INT32_MIN, INT32_MAX); - return ScriptObject::Command::Do(sd->GetName(), value); + return ScriptObject::Command::Do(sd->GetName(), value); } /* static */ bool ScriptGameSettings::IsDisabledVehicleType(ScriptVehicle::VehicleType vehicle_type) diff --git a/src/script/api/script_goal.cpp b/src/script/api/script_goal.cpp index 5a45b0457b..942d28cc28 100644 --- a/src/script/api/script_goal.cpp +++ b/src/script/api/script_goal.cpp @@ -61,7 +61,7 @@ EnforcePrecondition(GOAL_INVALID, company == ScriptCompany::COMPANY_INVALID || ScriptCompany::ResolveCompanyID(company) != ScriptCompany::COMPANY_INVALID); EnforcePrecondition(GOAL_INVALID, IsValidGoalDestination(company, type, destination)); - if (!ScriptObject::Command::Do(&ScriptInstance::DoCommandReturnGoalID, ScriptCompany::FromScriptCompanyID(company), (::GoalType)type, destination, text)) return GOAL_INVALID; + if (!ScriptObject::Command::Do(&ScriptInstance::DoCommandReturnGoalID, ScriptCompany::FromScriptCompanyID(company), (::GoalType)type, destination, text)) return GOAL_INVALID; /* In case of test-mode, we return GoalID 0 */ return GoalID::Begin(); @@ -72,7 +72,7 @@ EnforceDeityMode(false); EnforcePrecondition(false, IsValidGoal(goal_id)); - return ScriptObject::Command::Do(goal_id); + return ScriptObject::Command::Do(goal_id); } /* static */ bool ScriptGoal::SetDestination(GoalID goal_id, GoalType type, SQInteger destination) @@ -82,7 +82,7 @@ const Goal *g = Goal::Get(goal_id); EnforcePrecondition(false, IsValidGoalDestination(ScriptCompany::ToScriptCompanyID(g->company), type, destination)); - return ScriptObject::Command::Do(goal_id, (::GoalType)type, destination); + return ScriptObject::Command::Do(goal_id, (::GoalType)type, destination); } /* static */ bool ScriptGoal::SetText(GoalID goal_id, Text *goal) @@ -95,7 +95,7 @@ EncodedString text = goal->GetEncodedText(); EnforcePreconditionEncodedText(false, text); - return ScriptObject::Command::Do(goal_id, text); + return ScriptObject::Command::Do(goal_id, text); } /* static */ bool ScriptGoal::SetProgress(GoalID goal_id, Text *progress) @@ -105,7 +105,7 @@ EnforcePrecondition(false, IsValidGoal(goal_id)); EnforceDeityMode(false); - return ScriptObject::Command::Do(goal_id, progress != nullptr ? progress->GetEncodedText() : EncodedString{}); + return ScriptObject::Command::Do(goal_id, progress != nullptr ? progress->GetEncodedText() : EncodedString{}); } /* static */ bool ScriptGoal::SetCompleted(GoalID goal_id, bool completed) @@ -113,7 +113,7 @@ EnforcePrecondition(false, IsValidGoal(goal_id)); EnforceDeityMode(false); - return ScriptObject::Command::Do(goal_id, completed); + return ScriptObject::Command::Do(goal_id, completed); } /* static */ bool ScriptGoal::IsCompleted(GoalID goal_id) @@ -139,7 +139,7 @@ EnforcePrecondition(false, (int)type < ::GQT_END); EnforcePrecondition(false, uniqueid >= 0 && uniqueid <= UINT16_MAX); - return ScriptObject::Command::Do(uniqueid, target, is_client, buttons, (::GoalQuestionType)type, text); + return ScriptObject::Command::Do(uniqueid, target, is_client, buttons, (::GoalQuestionType)type, text); } /* static */ bool ScriptGoal::Question(SQInteger uniqueid, ScriptCompany::CompanyID company, Text *question, QuestionType type, SQInteger buttons) @@ -160,5 +160,5 @@ EnforceDeityMode(false); EnforcePrecondition(false, uniqueid >= 0 && uniqueid <= UINT16_MAX); - return ScriptObject::Command::Do(uniqueid, 0); + return ScriptObject::Command::Do(uniqueid, 0); } diff --git a/src/script/api/script_group.cpp b/src/script/api/script_group.cpp index eda5666985..ac889218a2 100644 --- a/src/script/api/script_group.cpp +++ b/src/script/api/script_group.cpp @@ -34,7 +34,7 @@ /* static */ GroupID ScriptGroup::CreateGroup(ScriptVehicle::VehicleType vehicle_type, GroupID parent_group_id) { EnforceCompanyModeValid(GROUP_INVALID); - if (!ScriptObject::Command::Do(&ScriptInstance::DoCommandReturnGroupID, (::VehicleType)vehicle_type, parent_group_id)) return GROUP_INVALID; + if (!ScriptObject::Command::Do(&ScriptInstance::DoCommandReturnGroupID, (::VehicleType)vehicle_type, parent_group_id)) return GROUP_INVALID; /* In case of test-mode, we return GroupID 0 */ return GroupID::Begin(); @@ -45,7 +45,7 @@ EnforceCompanyModeValid(false); EnforcePrecondition(false, IsValidGroup(group_id)); - return ScriptObject::Command::Do(group_id); + return ScriptObject::Command::Do(group_id); } /* static */ ScriptVehicle::VehicleType ScriptGroup::GetVehicleType(GroupID group_id) @@ -66,7 +66,7 @@ EnforcePreconditionEncodedText(false, text); EnforcePreconditionCustomError(false, ::Utf8StringLength(text) < MAX_LENGTH_GROUP_NAME_CHARS, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG); - return ScriptObject::Command::Do(AlterGroupMode::Rename, group_id, ::GroupID::Invalid(), text); + return ScriptObject::Command::Do(AlterGroupMode::Rename, group_id, ::GroupID::Invalid(), text); } /* static */ std::optional ScriptGroup::GetName(GroupID group_id) @@ -82,7 +82,7 @@ EnforcePrecondition(false, IsValidGroup(group_id)); EnforcePrecondition(false, IsValidGroup(parent_group_id)); - return ScriptObject::Command::Do(AlterGroupMode::SetParent, group_id, parent_group_id, {}); + return ScriptObject::Command::Do(AlterGroupMode::SetParent, group_id, parent_group_id, {}); } /* static */ GroupID ScriptGroup::GetParent(GroupID group_id) @@ -98,7 +98,7 @@ EnforceCompanyModeValid(false); EnforcePrecondition(false, IsValidGroup(group_id)); - return ScriptObject::Command::Do(group_id, GroupFlag::ReplaceProtection, enable, false); + return ScriptObject::Command::Do(group_id, GroupFlag::ReplaceProtection, enable, false); } /* static */ bool ScriptGroup::GetAutoReplaceProtection(GroupID group_id) @@ -135,7 +135,7 @@ EnforcePrecondition(false, IsValidGroup(group_id) || group_id == GROUP_DEFAULT); EnforcePrecondition(false, ScriptVehicle::IsPrimaryVehicle(vehicle_id)); - return ScriptObject::Command::Do(group_id, vehicle_id, false, VehicleListIdentifier{}); + return ScriptObject::Command::Do(group_id, vehicle_id, false, VehicleListIdentifier{}); } /* static */ bool ScriptGroup::EnableWagonRemoval(bool enable_removal) @@ -143,7 +143,7 @@ EnforceCompanyModeValid(false); if (HasWagonRemoval() == enable_removal) return true; - return ScriptObject::Command::Do("company.renew_keep_length", enable_removal ? 1 : 0); + return ScriptObject::Command::Do("company.renew_keep_length", enable_removal ? 1 : 0); } /* static */ bool ScriptGroup::HasWagonRemoval() @@ -158,7 +158,7 @@ EnforcePrecondition(false, IsValidGroup(group_id) || group_id == GROUP_DEFAULT || group_id == GROUP_ALL); EnforcePrecondition(false, ScriptEngine::IsBuildable(engine_id_new)); - return ScriptObject::Command::Do(group_id, engine_id_old, engine_id_new, false); + return ScriptObject::Command::Do(group_id, engine_id_old, engine_id_new, false); } /* static */ EngineID ScriptGroup::GetEngineReplacement(GroupID group_id, EngineID engine_id) @@ -174,7 +174,7 @@ EnforceCompanyModeValid(false); EnforcePrecondition(false, IsValidGroup(group_id) || group_id == GROUP_DEFAULT || group_id == GROUP_ALL); - return ScriptObject::Command::Do(group_id, engine_id, ::EngineID::Invalid(), false); + return ScriptObject::Command::Do(group_id, engine_id, ::EngineID::Invalid(), false); } /* static */ Money ScriptGroup::GetProfitThisYear(GroupID group_id) @@ -225,7 +225,7 @@ EnforceCompanyModeValid(false); EnforcePrecondition(false, IsValidGroup(group_id)); - return ScriptObject::Command::Do(group_id, true, (::Colours)colour); + return ScriptObject::Command::Do(group_id, true, (::Colours)colour); } /* static */ bool ScriptGroup::SetSecondaryColour(GroupID group_id, ScriptCompany::Colours colour) @@ -233,7 +233,7 @@ EnforceCompanyModeValid(false); EnforcePrecondition(false, IsValidGroup(group_id)); - return ScriptObject::Command::Do(group_id, false, (::Colours)colour); + return ScriptObject::Command::Do(group_id, false, (::Colours)colour); } /* static */ ScriptCompany::Colours ScriptGroup::GetPrimaryColour(GroupID group_id) diff --git a/src/script/api/script_industry.cpp b/src/script/api/script_industry.cpp index b0e19b945d..04cff30c32 100644 --- a/src/script/api/script_industry.cpp +++ b/src/script/api/script_industry.cpp @@ -63,7 +63,7 @@ EnforceDeityMode(false); EnforcePrecondition(false, IsValidIndustry(industry_id)); - return ScriptObject::Command::Do(industry_id, text != nullptr ? text->GetEncodedText() : EncodedString{}); + return ScriptObject::Command::Do(industry_id, text != nullptr ? text->GetEncodedText() : EncodedString{}); } /* static */ ScriptIndustry::CargoAcceptState ScriptIndustry::IsCargoAccepted(IndustryID industry_id, CargoType cargo_type) @@ -253,7 +253,7 @@ EnforceDeityMode(false); if (!IsValidIndustry(industry_id)) return false; - return ScriptObject::Command::Do(industry_id, ::IndustryControlFlags(control_flags)); + return ScriptObject::Command::Do(industry_id, ::IndustryControlFlags(control_flags)); } /* static */ ScriptCompany::CompanyID ScriptIndustry::GetExclusiveSupplier(IndustryID industry_id) @@ -273,7 +273,7 @@ auto company = ScriptCompany::ResolveCompanyID(company_id); ::Owner owner = (company == ScriptCompany::COMPANY_INVALID ? ::INVALID_OWNER : (::Owner)company); - return ScriptObject::Command::Do(industry_id, owner, false); + return ScriptObject::Command::Do(industry_id, owner, false); } /* static */ ScriptCompany::CompanyID ScriptIndustry::GetExclusiveConsumer(IndustryID industry_id) @@ -293,7 +293,7 @@ auto company = ScriptCompany::ResolveCompanyID(company_id); ::Owner owner = (company == ScriptCompany::COMPANY_INVALID ? ::INVALID_OWNER : (::Owner)company); - return ScriptObject::Command::Do(industry_id, owner, true); + return ScriptObject::Command::Do(industry_id, owner, true); } /* static */ SQInteger ScriptIndustry::GetProductionLevel(IndustryID industry_id) @@ -311,5 +311,5 @@ EnforcePrecondition(false, IsValidIndustry(industry_id)); EnforcePrecondition(false, prod_level >= PRODLEVEL_MINIMUM && prod_level <= PRODLEVEL_MAXIMUM); - return ScriptObject::Command::Do(industry_id, prod_level, show_news, custom_news != nullptr ? custom_news->GetEncodedText() : EncodedString{}); + return ScriptObject::Command::Do(industry_id, prod_level, show_news, custom_news != nullptr ? custom_news->GetEncodedText() : EncodedString{}); } diff --git a/src/script/api/script_industrytype.cpp b/src/script/api/script_industrytype.cpp index 13553471be..ffc1bc8b74 100644 --- a/src/script/api/script_industrytype.cpp +++ b/src/script/api/script_industrytype.cpp @@ -124,7 +124,7 @@ uint32_t seed = ScriptBase::Rand(); uint32_t layout_index = ScriptBase::RandRange((uint32_t)::GetIndustrySpec(industry_type)->layouts.size()); - return ScriptObject::Command::Do(tile, industry_type, layout_index, true, seed); + return ScriptObject::Command::Do(tile, industry_type, layout_index, true, seed); } /* static */ bool ScriptIndustryType::ProspectIndustry(IndustryType industry_type) @@ -133,7 +133,7 @@ EnforcePrecondition(false, CanProspectIndustry(industry_type)); uint32_t seed = ScriptBase::Rand(); - return ScriptObject::Command::Do(TileIndex{}, industry_type, 0, false, seed); + return ScriptObject::Command::Do(TileIndex{}, industry_type, 0, false, seed); } /* static */ bool ScriptIndustryType::IsBuiltOnWater(IndustryType industry_type) diff --git a/src/script/api/script_league.cpp b/src/script/api/script_league.cpp index e24efb051d..fd2c4dca9e 100644 --- a/src/script/api/script_league.cpp +++ b/src/script/api/script_league.cpp @@ -38,7 +38,7 @@ EncodedString encoded_header = (header != nullptr ? header->GetEncodedText() : EncodedString{}); EncodedString encoded_footer = (footer != nullptr ? footer->GetEncodedText() : EncodedString{}); - if (!ScriptObject::Command::Do(&ScriptInstance::DoCommandReturnLeagueTableID, encoded_title, encoded_header, encoded_footer)) return LEAGUE_TABLE_INVALID; + if (!ScriptObject::Command::Do(&ScriptInstance::DoCommandReturnLeagueTableID, encoded_title, encoded_header, encoded_footer)) return LEAGUE_TABLE_INVALID; /* In case of test-mode, we return LeagueTableID 0 */ return LeagueTableID::Begin(); @@ -71,7 +71,7 @@ EnforcePrecondition(LEAGUE_TABLE_ELEMENT_INVALID, IsValidLink(Link((::LinkType)link_type, link_target))); - if (!ScriptObject::Command::Do(&ScriptInstance::DoCommandReturnLeagueTableElementID, table, rating, c, encoded_text, encoded_score, (::LinkType)link_type, (::LinkTargetID)link_target)) return LEAGUE_TABLE_ELEMENT_INVALID; + if (!ScriptObject::Command::Do(&ScriptInstance::DoCommandReturnLeagueTableElementID, table, rating, c, encoded_text, encoded_score, (::LinkType)link_type, (::LinkTargetID)link_target)) return LEAGUE_TABLE_ELEMENT_INVALID; /* In case of test-mode, we return LeagueTableElementID 0 */ return LeagueTableElementID::Begin(); @@ -93,7 +93,7 @@ EnforcePrecondition(false, IsValidLink(Link((::LinkType)link_type, link_target))); - return ScriptObject::Command::Do(element, c, encoded_text, (::LinkType)link_type, (::LinkTargetID)link_target); + return ScriptObject::Command::Do(element, c, encoded_text, (::LinkType)link_type, (::LinkTargetID)link_target); } /* static */ bool ScriptLeagueTable::UpdateElementScore(LeagueTableElementID element, SQInteger rating, Text *score) @@ -107,7 +107,7 @@ EncodedString encoded_score = score->GetEncodedText(); EnforcePreconditionEncodedText(false, encoded_score); - return ScriptObject::Command::Do(element, rating, encoded_score); + return ScriptObject::Command::Do(element, rating, encoded_score); } /* static */ bool ScriptLeagueTable::RemoveElement(LeagueTableElementID element) @@ -115,5 +115,5 @@ EnforceDeityMode(false); EnforcePrecondition(false, IsValidLeagueTableElement(element)); - return ScriptObject::Command::Do(element); + return ScriptObject::Command::Do(element); } diff --git a/src/script/api/script_marine.cpp b/src/script/api/script_marine.cpp index 1a32301511..716abfc82d 100644 --- a/src/script/api/script_marine.cpp +++ b/src/script/api/script_marine.cpp @@ -83,7 +83,7 @@ EnforcePrecondition(false, ::IsValidTile(front)); EnforcePrecondition(false, (::TileX(front) == ::TileX(tile)) != (::TileY(front) == ::TileY(tile))); - return ScriptObject::Command::Do(tile, ::TileX(front) == ::TileX(tile) ? AXIS_Y : AXIS_X); + return ScriptObject::Command::Do(tile, ::TileX(front) == ::TileX(tile) ? AXIS_Y : AXIS_X); } /* static */ bool ScriptMarine::BuildDock(TileIndex tile, StationID station_id) @@ -92,7 +92,7 @@ EnforcePrecondition(false, ::IsValidTile(tile)); EnforcePrecondition(false, station_id == ScriptStation::STATION_NEW || station_id == ScriptStation::STATION_JOIN_ADJACENT || ScriptStation::IsValidStation(station_id)); - return ScriptObject::Command::Do(tile, ScriptStation::IsValidStation(station_id) ? station_id : StationID::Invalid(), station_id != ScriptStation::STATION_JOIN_ADJACENT); + return ScriptObject::Command::Do(tile, ScriptStation::IsValidStation(station_id) ? station_id : StationID::Invalid(), station_id != ScriptStation::STATION_JOIN_ADJACENT); } /* static */ bool ScriptMarine::BuildBuoy(TileIndex tile) @@ -100,7 +100,7 @@ EnforceCompanyModeValid(false); EnforcePrecondition(false, ::IsValidTile(tile)); - return ScriptObject::Command::Do(tile); + return ScriptObject::Command::Do(tile); } /* static */ bool ScriptMarine::BuildLock(TileIndex tile) @@ -108,7 +108,7 @@ EnforceCompanyModeValid(false); EnforcePrecondition(false, ::IsValidTile(tile)); - return ScriptObject::Command::Do(tile); + return ScriptObject::Command::Do(tile); } /* static */ bool ScriptMarine::BuildCanal(TileIndex tile) @@ -116,7 +116,7 @@ EnforceCompanyModeValid(false); EnforcePrecondition(false, ::IsValidTile(tile)); - return ScriptObject::Command::Do(tile, tile, WaterClass::Canal, false); + return ScriptObject::Command::Do(tile, tile, WaterClass::Canal, false); } /* static */ bool ScriptMarine::RemoveWaterDepot(TileIndex tile) @@ -125,7 +125,7 @@ EnforcePrecondition(false, ::IsValidTile(tile)); EnforcePrecondition(false, IsWaterDepotTile(tile)); - return ScriptObject::Command::Do(tile); + return ScriptObject::Command::Do(tile); } /* static */ bool ScriptMarine::RemoveDock(TileIndex tile) @@ -134,7 +134,7 @@ EnforcePrecondition(false, ::IsValidTile(tile)); EnforcePrecondition(false, IsDockTile(tile)); - return ScriptObject::Command::Do(tile); + return ScriptObject::Command::Do(tile); } /* static */ bool ScriptMarine::RemoveBuoy(TileIndex tile) @@ -143,7 +143,7 @@ EnforcePrecondition(false, ::IsValidTile(tile)); EnforcePrecondition(false, IsBuoyTile(tile)); - return ScriptObject::Command::Do(tile); + return ScriptObject::Command::Do(tile); } /* static */ bool ScriptMarine::RemoveLock(TileIndex tile) @@ -152,7 +152,7 @@ EnforcePrecondition(false, ::IsValidTile(tile)); EnforcePrecondition(false, IsLockTile(tile)); - return ScriptObject::Command::Do(tile); + return ScriptObject::Command::Do(tile); } /* static */ bool ScriptMarine::RemoveCanal(TileIndex tile) @@ -161,7 +161,7 @@ EnforcePrecondition(false, ::IsValidTile(tile)); EnforcePrecondition(false, IsCanalTile(tile)); - return ScriptObject::Command::Do(tile); + return ScriptObject::Command::Do(tile); } /* static */ Money ScriptMarine::GetBuildCost(BuildType build_type) diff --git a/src/script/api/script_news.cpp b/src/script/api/script_news.cpp index 67526c699c..b83267fb17 100644 --- a/src/script/api/script_news.cpp +++ b/src/script/api/script_news.cpp @@ -50,5 +50,5 @@ static NewsReference CreateReference(ScriptNews::NewsReferenceType ref_type, SQI ::CompanyID c = ScriptCompany::FromScriptCompanyID(company); - return ScriptObject::Command::Do((::NewsType)type, c, CreateReference(ref_type, reference), encoded); + return ScriptObject::Command::Do((::NewsType)type, c, CreateReference(ref_type, reference), encoded); } diff --git a/src/script/api/script_objecttype.cpp b/src/script/api/script_objecttype.cpp index 1d57b0f213..28bfa1627b 100644 --- a/src/script/api/script_objecttype.cpp +++ b/src/script/api/script_objecttype.cpp @@ -45,7 +45,7 @@ EnforcePrecondition(false, view >= 0 && view < GetViews(object_type)); EnforcePrecondition(false, ScriptMap::IsValidTile(tile)); - return ScriptObject::Command::Do(tile, object_type, view); + return ScriptObject::Command::Do(tile, object_type, view); } /* static */ ObjectType ScriptObjectType::ResolveNewGRFID(SQInteger grfid, SQInteger grf_local_id) diff --git a/src/script/api/script_order.cpp b/src/script/api/script_order.cpp index b86de59903..8a9cd370d4 100644 --- a/src/script/api/script_order.cpp +++ b/src/script/api/script_order.cpp @@ -391,7 +391,7 @@ static ScriptOrder::OrderPosition RealOrderPositionToScriptOrderPosition(Vehicle int order_pos = ScriptOrderPositionToRealOrderPosition(vehicle_id, order_position); int jump_pos = ScriptOrderPositionToRealOrderPosition(vehicle_id, jump_to); - return ScriptObject::Command::Do(0, vehicle_id, order_pos, MOF_COND_DESTINATION, jump_pos); + return ScriptObject::Command::Do(0, vehicle_id, order_pos, MOF_COND_DESTINATION, jump_pos); } /* static */ bool ScriptOrder::SetOrderCondition(VehicleID vehicle_id, OrderPosition order_position, OrderCondition condition) @@ -402,7 +402,7 @@ static ScriptOrder::OrderPosition RealOrderPositionToScriptOrderPosition(Vehicle EnforcePrecondition(false, condition >= OC_LOAD_PERCENTAGE && condition <= OC_REMAINING_LIFETIME); int order_pos = ScriptOrderPositionToRealOrderPosition(vehicle_id, order_position); - return ScriptObject::Command::Do(0, vehicle_id, order_pos, MOF_COND_VARIABLE, condition); + return ScriptObject::Command::Do(0, vehicle_id, order_pos, MOF_COND_VARIABLE, condition); } /* static */ bool ScriptOrder::SetOrderCompareFunction(VehicleID vehicle_id, OrderPosition order_position, CompareFunction compare) @@ -413,7 +413,7 @@ static ScriptOrder::OrderPosition RealOrderPositionToScriptOrderPosition(Vehicle EnforcePrecondition(false, compare >= CF_EQUALS && compare <= CF_IS_FALSE); int order_pos = ScriptOrderPositionToRealOrderPosition(vehicle_id, order_position); - return ScriptObject::Command::Do(0, vehicle_id, order_pos, MOF_COND_COMPARATOR, compare); + return ScriptObject::Command::Do(0, vehicle_id, order_pos, MOF_COND_COMPARATOR, compare); } /* static */ bool ScriptOrder::SetOrderCompareValue(VehicleID vehicle_id, OrderPosition order_position, SQInteger value) @@ -425,7 +425,7 @@ static ScriptOrder::OrderPosition RealOrderPositionToScriptOrderPosition(Vehicle if (GetOrderCondition(vehicle_id, order_position) == OC_MAX_SPEED) value = value * 10 / 16; int order_pos = ScriptOrderPositionToRealOrderPosition(vehicle_id, order_position); - return ScriptObject::Command::Do(0, vehicle_id, order_pos, MOF_COND_VALUE, value); + return ScriptObject::Command::Do(0, vehicle_id, order_pos, MOF_COND_VALUE, value); } /* static */ bool ScriptOrder::SetStopLocation(VehicleID vehicle_id, OrderPosition order_position, StopLocation stop_location) @@ -439,7 +439,7 @@ static ScriptOrder::OrderPosition RealOrderPositionToScriptOrderPosition(Vehicle order_position = ScriptOrder::ResolveOrderPosition(vehicle_id, order_position); int order_pos = ScriptOrderPositionToRealOrderPosition(vehicle_id, order_position); - return ScriptObject::Command::Do(0, vehicle_id, order_pos, MOF_STOP_LOCATION, stop_location); + return ScriptObject::Command::Do(0, vehicle_id, order_pos, MOF_STOP_LOCATION, stop_location); } /* static */ bool ScriptOrder::SetOrderRefit(VehicleID vehicle_id, OrderPosition order_position, CargoType refit_cargo) @@ -449,7 +449,7 @@ static ScriptOrder::OrderPosition RealOrderPositionToScriptOrderPosition(Vehicle EnforcePrecondition(false, IsGotoStationOrder(vehicle_id, order_position) || (IsGotoDepotOrder(vehicle_id, order_position) && refit_cargo != CARGO_AUTO_REFIT)); EnforcePrecondition(false, ScriptCargo::IsValidCargo(refit_cargo) || refit_cargo == CARGO_AUTO_REFIT || refit_cargo == CARGO_NO_REFIT); - return ScriptObject::Command::Do(0, vehicle_id, ScriptOrderPositionToRealOrderPosition(vehicle_id, ScriptOrder::ResolveOrderPosition(vehicle_id, order_position)), refit_cargo); + return ScriptObject::Command::Do(0, vehicle_id, ScriptOrderPositionToRealOrderPosition(vehicle_id, ScriptOrder::ResolveOrderPosition(vehicle_id, order_position)), refit_cargo); } /* static */ bool ScriptOrder::AppendOrder(VehicleID vehicle_id, TileIndex destination, ScriptOrderFlags order_flags) @@ -527,7 +527,7 @@ static ScriptOrder::OrderPosition RealOrderPositionToScriptOrderPosition(Vehicle order.SetNonStopType(static_cast(GB(order_flags, 0, 2))); int order_pos = ScriptOrderPositionToRealOrderPosition(vehicle_id, order_position); - return ScriptObject::Command::Do(0, vehicle_id, order_pos, order); + return ScriptObject::Command::Do(0, vehicle_id, order_pos, order); } /* static */ bool ScriptOrder::InsertConditionalOrder(VehicleID vehicle_id, OrderPosition order_position, OrderPosition jump_to) @@ -545,7 +545,7 @@ static ScriptOrder::OrderPosition RealOrderPositionToScriptOrderPosition(Vehicle order.MakeConditional(jump_pos); int order_pos = ScriptOrderPositionToRealOrderPosition(vehicle_id, order_position); - return ScriptObject::Command::Do(0, vehicle_id, order_pos, order); + return ScriptObject::Command::Do(0, vehicle_id, order_pos, order); } /* static */ bool ScriptOrder::RemoveOrder(VehicleID vehicle_id, OrderPosition order_position) @@ -556,7 +556,7 @@ static ScriptOrder::OrderPosition RealOrderPositionToScriptOrderPosition(Vehicle EnforcePrecondition(false, IsValidVehicleOrder(vehicle_id, order_position)); int order_pos = ScriptOrderPositionToRealOrderPosition(vehicle_id, order_position); - return ScriptObject::Command::Do(0, vehicle_id, order_pos); + return ScriptObject::Command::Do(0, vehicle_id, order_pos); } /* static */ bool ScriptOrder::SkipToOrder(VehicleID vehicle_id, OrderPosition next_order) @@ -567,7 +567,7 @@ static ScriptOrder::OrderPosition RealOrderPositionToScriptOrderPosition(Vehicle EnforcePrecondition(false, IsValidVehicleOrder(vehicle_id, next_order)); int order_pos = ScriptOrderPositionToRealOrderPosition(vehicle_id, next_order); - return ScriptObject::Command::Do(0, vehicle_id, order_pos); + return ScriptObject::Command::Do(0, vehicle_id, order_pos); } /** @@ -612,7 +612,7 @@ static void _DoCommandReturnSetOrderFlags(class ScriptInstance &instance) EnforcePrecondition(false, (order_flags & OF_GOTO_NEAREST_DEPOT) == (current & OF_GOTO_NEAREST_DEPOT)); if ((current & OF_NON_STOP_FLAGS) != (order_flags & OF_NON_STOP_FLAGS)) { - return ScriptObject::Command::Do(&::_DoCommandReturnSetOrderFlags, vehicle_id, order_pos, MOF_NON_STOP, order_flags & OF_NON_STOP_FLAGS); + return ScriptObject::Command::Do(&::_DoCommandReturnSetOrderFlags, vehicle_id, order_pos, MOF_NON_STOP, order_flags & OF_NON_STOP_FLAGS); } switch (order->GetType()) { @@ -621,16 +621,16 @@ static void _DoCommandReturnSetOrderFlags(class ScriptInstance &instance) OrderDepotAction data = OrderDepotAction::AlwaysGo; if ((order_flags & OF_SERVICE_IF_NEEDED) != 0) data = OrderDepotAction::Service; if ((order_flags & OF_STOP_IN_DEPOT) != 0) data = OrderDepotAction::Stop; - return ScriptObject::Command::Do(&::_DoCommandReturnSetOrderFlags, vehicle_id, order_pos, MOF_DEPOT_ACTION, to_underlying(data)); + return ScriptObject::Command::Do(&::_DoCommandReturnSetOrderFlags, vehicle_id, order_pos, MOF_DEPOT_ACTION, to_underlying(data)); } break; case OT_GOTO_STATION: if ((current & OF_UNLOAD_FLAGS) != (order_flags & OF_UNLOAD_FLAGS)) { - return ScriptObject::Command::Do(&::_DoCommandReturnSetOrderFlags, vehicle_id, order_pos, MOF_UNLOAD, (order_flags & OF_UNLOAD_FLAGS) >> 2); + return ScriptObject::Command::Do(&::_DoCommandReturnSetOrderFlags, vehicle_id, order_pos, MOF_UNLOAD, (order_flags & OF_UNLOAD_FLAGS) >> 2); } if ((current & OF_LOAD_FLAGS) != (order_flags & OF_LOAD_FLAGS)) { - return ScriptObject::Command::Do(&::_DoCommandReturnSetOrderFlags, vehicle_id, order_pos, MOF_LOAD, (order_flags & OF_LOAD_FLAGS) >> 5); + return ScriptObject::Command::Do(&::_DoCommandReturnSetOrderFlags, vehicle_id, order_pos, MOF_LOAD, (order_flags & OF_LOAD_FLAGS) >> 5); } break; @@ -665,7 +665,7 @@ static void _DoCommandReturnSetOrderFlags(class ScriptInstance &instance) int order_pos_move = ScriptOrderPositionToRealOrderPosition(vehicle_id, order_position_move); int order_pos_target = ScriptOrderPositionToRealOrderPosition(vehicle_id, order_position_target); - return ScriptObject::Command::Do(0, vehicle_id, order_pos_move, order_pos_target); + return ScriptObject::Command::Do(0, vehicle_id, order_pos_move, order_pos_target); } /* static */ bool ScriptOrder::CopyOrders(VehicleID vehicle_id, VehicleID main_vehicle_id) @@ -674,7 +674,7 @@ static void _DoCommandReturnSetOrderFlags(class ScriptInstance &instance) EnforcePrecondition(false, ScriptVehicle::IsPrimaryVehicle(vehicle_id)); EnforcePrecondition(false, ScriptVehicle::IsPrimaryVehicle(main_vehicle_id)); - return ScriptObject::Command::Do(0, CO_COPY, vehicle_id, main_vehicle_id); + return ScriptObject::Command::Do(0, CO_COPY, vehicle_id, main_vehicle_id); } /* static */ bool ScriptOrder::ShareOrders(VehicleID vehicle_id, VehicleID main_vehicle_id) @@ -683,7 +683,7 @@ static void _DoCommandReturnSetOrderFlags(class ScriptInstance &instance) EnforcePrecondition(false, ScriptVehicle::IsPrimaryVehicle(vehicle_id)); EnforcePrecondition(false, ScriptVehicle::IsPrimaryVehicle(main_vehicle_id)); - return ScriptObject::Command::Do(0, CO_SHARE, vehicle_id, main_vehicle_id); + return ScriptObject::Command::Do(0, CO_SHARE, vehicle_id, main_vehicle_id); } /* static */ bool ScriptOrder::UnshareOrders(VehicleID vehicle_id) @@ -691,7 +691,7 @@ static void _DoCommandReturnSetOrderFlags(class ScriptInstance &instance) EnforceCompanyModeValid(false); EnforcePrecondition(false, ScriptVehicle::IsPrimaryVehicle(vehicle_id)); - return ScriptObject::Command::Do(0, CO_UNSHARE, vehicle_id, VehicleID::Invalid()); + return ScriptObject::Command::Do(0, CO_UNSHARE, vehicle_id, VehicleID::Invalid()); } /* static */ SQInteger ScriptOrder::GetOrderDistance(ScriptVehicle::VehicleType vehicle_type, TileIndex origin_tile, TileIndex dest_tile) diff --git a/src/script/api/script_rail.cpp b/src/script/api/script_rail.cpp index 7ced9d6285..1bbc5d6431 100644 --- a/src/script/api/script_rail.cpp +++ b/src/script/api/script_rail.cpp @@ -117,7 +117,7 @@ EnforcePrecondition(false, ::IsValidTile(end_tile)); EnforcePrecondition(false, IsRailTypeAvailable(convert_to)); - return ScriptObject::Command::Do(start_tile, end_tile, (::RailType)convert_to, false); + return ScriptObject::Command::Do(start_tile, end_tile, (::RailType)convert_to, false); } /* static */ TileIndex ScriptRail::GetRailDepotFrontTile(TileIndex depot) @@ -145,7 +145,7 @@ DiagDirection entrance_dir = (::TileX(tile) == ::TileX(front)) ? (::TileY(tile) < ::TileY(front) ? DIAGDIR_SE : DIAGDIR_NW) : (::TileX(tile) < ::TileX(front) ? DIAGDIR_SW : DIAGDIR_NE); - return ScriptObject::Command::Do(tile, (::RailType)ScriptObject::GetRailType(), entrance_dir); + return ScriptObject::Command::Do(tile, (::RailType)ScriptObject::GetRailType(), entrance_dir); } /* static */ bool ScriptRail::BuildRailStation(TileIndex tile, RailTrack direction, SQInteger num_platforms, SQInteger platform_length, StationID station_id) @@ -159,7 +159,7 @@ EnforcePrecondition(false, station_id == ScriptStation::STATION_NEW || station_id == ScriptStation::STATION_JOIN_ADJACENT || ScriptStation::IsValidStation(station_id)); bool adjacent = station_id != ScriptStation::STATION_JOIN_ADJACENT; - return ScriptObject::Command::Do(tile, (::RailType)GetCurrentRailType(), direction == RAILTRACK_NW_SE ? AXIS_Y : AXIS_X, num_platforms, platform_length, STAT_CLASS_DFLT, 0, ScriptStation::IsValidStation(station_id) ? station_id : StationID::Invalid(), adjacent); + return ScriptObject::Command::Do(tile, (::RailType)GetCurrentRailType(), direction == RAILTRACK_NW_SE ? AXIS_Y : AXIS_X, num_platforms, platform_length, STAT_CLASS_DFLT, 0, ScriptStation::IsValidStation(station_id) ? station_id : StationID::Invalid(), adjacent); } /* static */ bool ScriptRail::BuildNewGRFRailStation(TileIndex tile, RailTrack direction, SQInteger num_platforms, SQInteger platform_length, StationID station_id, CargoType cargo_type, IndustryType source_industry, IndustryType goal_industry, SQInteger distance, bool source_station) @@ -196,11 +196,11 @@ Debug(grf, 1, "{} returned an invalid station ID for 'AI construction/purchase selection (18)' callback", res.first->filename); } else { /* We might have gotten an usable station spec. Try to build it, but if it fails we'll fall back to the original station. */ - if (ScriptObject::Command::Do(tile, (::RailType)GetCurrentRailType(), axis, num_platforms, platform_length, spec->class_index, spec->index, to_join, adjacent)) return true; + if (ScriptObject::Command::Do(tile, (::RailType)GetCurrentRailType(), axis, num_platforms, platform_length, spec->class_index, spec->index, to_join, adjacent)) return true; } } - return ScriptObject::Command::Do(tile, (::RailType)GetCurrentRailType(), axis, num_platforms, platform_length, STAT_CLASS_DFLT, 0, to_join, adjacent); + return ScriptObject::Command::Do(tile, (::RailType)GetCurrentRailType(), axis, num_platforms, platform_length, STAT_CLASS_DFLT, 0, to_join, adjacent); } /* static */ bool ScriptRail::BuildRailWaypoint(TileIndex tile) @@ -211,7 +211,7 @@ EnforcePrecondition(false, GetRailTracks(tile) == RAILTRACK_NE_SW || GetRailTracks(tile) == RAILTRACK_NW_SE); EnforcePrecondition(false, IsRailTypeAvailable(GetCurrentRailType())); - return ScriptObject::Command::Do(tile, GetRailTracks(tile) == RAILTRACK_NE_SW ? AXIS_X : AXIS_Y, 1, 1, STAT_CLASS_WAYP, 0, StationID::Invalid(), false); + return ScriptObject::Command::Do(tile, GetRailTracks(tile) == RAILTRACK_NE_SW ? AXIS_X : AXIS_Y, 1, 1, STAT_CLASS_WAYP, 0, StationID::Invalid(), false); } /* static */ bool ScriptRail::RemoveRailWaypointTileRectangle(TileIndex tile, TileIndex tile2, bool keep_rail) @@ -220,7 +220,7 @@ EnforcePrecondition(false, ::IsValidTile(tile)); EnforcePrecondition(false, ::IsValidTile(tile2)); - return ScriptObject::Command::Do(tile, tile2, keep_rail); + return ScriptObject::Command::Do(tile, tile2, keep_rail); } /* static */ bool ScriptRail::RemoveRailStationTileRectangle(TileIndex tile, TileIndex tile2, bool keep_rail) @@ -229,7 +229,7 @@ EnforcePrecondition(false, ::IsValidTile(tile)); EnforcePrecondition(false, ::IsValidTile(tile2)); - return ScriptObject::Command::Do(tile, tile2, keep_rail); + return ScriptObject::Command::Do(tile, tile2, keep_rail); } /* static */ uint ScriptRail::GetRailTracks(TileIndex tile) @@ -251,7 +251,7 @@ EnforcePrecondition(false, KillFirstBit((uint)rail_track) == 0); EnforcePrecondition(false, IsRailTypeAvailable(GetCurrentRailType())); - return ScriptObject::Command::Do(tile, tile, (::RailType)GetCurrentRailType(), FindFirstTrack((::TrackBits)rail_track), false, false); + return ScriptObject::Command::Do(tile, tile, (::RailType)GetCurrentRailType(), FindFirstTrack((::TrackBits)rail_track), false, false); } /* static */ bool ScriptRail::RemoveRailTrack(TileIndex tile, RailTrack rail_track) @@ -262,7 +262,7 @@ EnforcePrecondition(false, GetRailTracks(tile) & rail_track); EnforcePrecondition(false, KillFirstBit((uint)rail_track) == 0); - return ScriptObject::Command::Do(tile, tile, FindFirstTrack((::TrackBits)rail_track)); + return ScriptObject::Command::Do(tile, tile, FindFirstTrack((::TrackBits)rail_track)); } /* static */ bool ScriptRail::AreTilesConnected(TileIndex from, TileIndex tile, TileIndex to) @@ -363,7 +363,7 @@ static Track SimulateDrag(TileIndex from, TileIndex tile, TileIndex *to) (::TileY(from) == ::TileY(tile) && ::TileY(tile) == ::TileY(to))); Track track = SimulateDrag(from, tile, &to); - return ScriptObject::Command::Do(to, tile, (::RailType)ScriptRail::GetCurrentRailType(), track, false, true); + return ScriptObject::Command::Do(to, tile, (::RailType)ScriptRail::GetCurrentRailType(), track, false, true); } /* static */ bool ScriptRail::RemoveRail(TileIndex from, TileIndex tile, TileIndex to) @@ -380,7 +380,7 @@ static Track SimulateDrag(TileIndex from, TileIndex tile, TileIndex *to) (::TileY(from) == ::TileY(tile) && ::TileY(tile) == ::TileY(to))); Track track = SimulateDrag(from, tile, &to); - return ScriptObject::Command::Do(to, tile, track); + return ScriptObject::Command::Do(to, tile, track); } /** @@ -466,7 +466,7 @@ static bool IsValidSignalType(int signal_type) } ::SignalType sig_type = (::SignalType)(signal >= SIGNALTYPE_TWOWAY ? signal ^ SIGNALTYPE_TWOWAY : signal); - return ScriptObject::Command::Do(tile, track, sig_type, ::SIG_ELECTRIC, false, false, false, ::SIGTYPE_BLOCK, ::SIGTYPE_BLOCK, signal_cycles, 0); + return ScriptObject::Command::Do(tile, track, sig_type, ::SIG_ELECTRIC, false, false, false, ::SIGTYPE_BLOCK, ::SIGTYPE_BLOCK, signal_cycles, 0); } /* static */ bool ScriptRail::RemoveSignal(TileIndex tile, TileIndex front) @@ -485,7 +485,7 @@ static bool IsValidSignalType(int signal_type) } EnforcePrecondition(false, track != INVALID_TRACK); - return ScriptObject::Command::Do(tile, track); + return ScriptObject::Command::Do(tile, track); } /* static */ Money ScriptRail::GetBuildCost(RailType railtype, BuildType build_type) diff --git a/src/script/api/script_road.cpp b/src/script/api/script_road.cpp index 68a620f5f6..d67297bf98 100644 --- a/src/script/api/script_road.cpp +++ b/src/script/api/script_road.cpp @@ -132,7 +132,7 @@ EnforcePrecondition(false, ::IsValidTile(end_tile)); EnforcePrecondition(false, IsRoadTypeAvailable(road_type)); - return ScriptObject::Command::Do(start_tile, end_tile, (::RoadType)road_type, false); + return ScriptObject::Command::Do(start_tile, end_tile, (::RoadType)road_type, false); } /* Helper functions for ScriptRoad::CanBuildConnectedRoadParts(). */ @@ -531,7 +531,7 @@ static bool NeighbourHasReachableRoad(::RoadType rt, TileIndex start_tile, DiagD EnforcePrecondition(false, IsRoadTypeAvailable(GetCurrentRoadType())); Axis axis = ::TileY(start) != ::TileY(end) ? AXIS_Y : AXIS_X; - return ScriptObject::Command::Do(end, start, ScriptObject::GetRoadType(), axis, one_way ? DRD_NORTHBOUND : DRD_NONE, (start < end) == !full, (start < end) != !full, true); + return ScriptObject::Command::Do(end, start, ScriptObject::GetRoadType(), axis, one_way ? DRD_NORTHBOUND : DRD_NONE, (start < end) == !full, (start < end) != !full, true); } /* static */ bool ScriptRoad::BuildRoad(TileIndex start, TileIndex end) @@ -567,7 +567,7 @@ static bool NeighbourHasReachableRoad(::RoadType rt, TileIndex start_tile, DiagD DiagDirection entrance_dir = (::TileX(tile) == ::TileX(front)) ? (::TileY(tile) < ::TileY(front) ? DIAGDIR_SE : DIAGDIR_NW) : (::TileX(tile) < ::TileX(front) ? DIAGDIR_SW : DIAGDIR_NE); - return ScriptObject::Command::Do(tile, ScriptObject::GetRoadType(), entrance_dir); + return ScriptObject::Command::Do(tile, ScriptObject::GetRoadType(), entrance_dir); } /* static */ bool ScriptRoad::_BuildRoadStationInternal(TileIndex tile, TileIndex front, RoadVehicleType road_veh_type, bool drive_through, StationID station_id) @@ -584,7 +584,7 @@ static bool NeighbourHasReachableRoad(::RoadType rt, TileIndex start_tile, DiagD DiagDirection entrance_dir = DiagdirBetweenTiles(tile, front); RoadStopType stop_type = road_veh_type == ROADVEHTYPE_TRUCK ? RoadStopType::Truck : RoadStopType::Bus; StationID to_join = ScriptStation::IsValidStation(station_id) ? station_id : StationID::Invalid(); - return ScriptObject::Command::Do(tile, 1, 1, stop_type, drive_through, entrance_dir, ScriptObject::GetRoadType(), ROADSTOP_CLASS_DFLT, 0, to_join, station_id != ScriptStation::STATION_JOIN_ADJACENT); + return ScriptObject::Command::Do(tile, 1, 1, stop_type, drive_through, entrance_dir, ScriptObject::GetRoadType(), ROADSTOP_CLASS_DFLT, 0, to_join, station_id != ScriptStation::STATION_JOIN_ADJACENT); } /* static */ bool ScriptRoad::BuildRoadStation(TileIndex tile, TileIndex front, RoadVehicleType road_veh_type, StationID station_id) @@ -606,7 +606,7 @@ static bool NeighbourHasReachableRoad(::RoadType rt, TileIndex start_tile, DiagD EnforcePrecondition(false, ::TileX(start) == ::TileX(end) || ::TileY(start) == ::TileY(end)); EnforcePrecondition(false, IsRoadTypeAvailable(GetCurrentRoadType())); - return ScriptObject::Command::Do(end, start, ScriptObject::GetRoadType(), ::TileY(start) != ::TileY(end) ? AXIS_Y : AXIS_X, start < end, start >= end); + return ScriptObject::Command::Do(end, start, ScriptObject::GetRoadType(), ::TileY(start) != ::TileY(end) ? AXIS_Y : AXIS_X, start < end, start >= end); } /* static */ bool ScriptRoad::RemoveRoadFull(TileIndex start, TileIndex end) @@ -618,7 +618,7 @@ static bool NeighbourHasReachableRoad(::RoadType rt, TileIndex start_tile, DiagD EnforcePrecondition(false, ::TileX(start) == ::TileX(end) || ::TileY(start) == ::TileY(end)); EnforcePrecondition(false, IsRoadTypeAvailable(GetCurrentRoadType())); - return ScriptObject::Command::Do(end, start, ScriptObject::GetRoadType(), ::TileY(start) != ::TileY(end) ? AXIS_Y : AXIS_X, start >= end, start < end); + return ScriptObject::Command::Do(end, start, ScriptObject::GetRoadType(), ::TileY(start) != ::TileY(end) ? AXIS_Y : AXIS_X, start >= end, start < end); } /* static */ bool ScriptRoad::RemoveRoadDepot(TileIndex tile) @@ -628,7 +628,7 @@ static bool NeighbourHasReachableRoad(::RoadType rt, TileIndex start_tile, DiagD EnforcePrecondition(false, IsTileType(tile, TileType::Road)) EnforcePrecondition(false, GetRoadTileType(tile) == RoadTileType::Depot); - return ScriptObject::Command::Do(tile); + return ScriptObject::Command::Do(tile); } /* static */ bool ScriptRoad::RemoveRoadStation(TileIndex tile) @@ -638,7 +638,7 @@ static bool NeighbourHasReachableRoad(::RoadType rt, TileIndex start_tile, DiagD EnforcePrecondition(false, IsTileType(tile, TileType::Station)); EnforcePrecondition(false, IsStationRoadStop(tile)); - return ScriptObject::Command::Do(tile, 1, 1, GetRoadStopType(tile), false); + return ScriptObject::Command::Do(tile, 1, 1, GetRoadStopType(tile), false); } /* static */ Money ScriptRoad::GetBuildCost(RoadType roadtype, BuildType build_type) diff --git a/src/script/api/script_sign.cpp b/src/script/api/script_sign.cpp index 3a3730378e..bce41a8537 100644 --- a/src/script/api/script_sign.cpp +++ b/src/script/api/script_sign.cpp @@ -45,7 +45,7 @@ EnforcePreconditionEncodedText(false, text); EnforcePreconditionCustomError(false, ::Utf8StringLength(text) < MAX_LENGTH_SIGN_NAME_CHARS, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG); - return ScriptObject::Command::Do(sign_id, text, INVALID_COLOUR); + return ScriptObject::Command::Do(sign_id, text, INVALID_COLOUR); } /* static */ std::optional ScriptSign::GetName(SignID sign_id) @@ -67,7 +67,7 @@ { EnforceDeityOrCompanyModeValid(false); EnforcePrecondition(false, IsValidSign(sign_id)); - return ScriptObject::Command::Do(sign_id, "", INVALID_COLOUR); + return ScriptObject::Command::Do(sign_id, "", INVALID_COLOUR); } /* static */ SignID ScriptSign::BuildSign(TileIndex location, Text *name) @@ -81,7 +81,7 @@ EnforcePreconditionEncodedText(SignID::Invalid(), text); EnforcePreconditionCustomError(SignID::Invalid(), ::Utf8StringLength(text) < MAX_LENGTH_SIGN_NAME_CHARS, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG); - if (!ScriptObject::Command::Do(&ScriptInstance::DoCommandReturnSignID, location, text)) return SignID::Invalid(); + if (!ScriptObject::Command::Do(&ScriptInstance::DoCommandReturnSignID, location, text)) return SignID::Invalid(); /* In case of test-mode, we return SignID 0 */ return SignID::Begin(); diff --git a/src/script/api/script_station.cpp b/src/script/api/script_station.cpp index be6ae0cc70..8af91ae19b 100644 --- a/src/script/api/script_station.cpp +++ b/src/script/api/script_station.cpp @@ -241,5 +241,5 @@ template EnforcePrecondition(false, IsValidStation(station_id)); EnforcePrecondition(false, HasStationType(station_id, STATION_AIRPORT)); - return ScriptObject::Command::Do(station_id); + return ScriptObject::Command::Do(station_id); } diff --git a/src/script/api/script_story_page.cpp b/src/script/api/script_story_page.cpp index c5c8ad86da..b6d957c57e 100644 --- a/src/script/api/script_story_page.cpp +++ b/src/script/api/script_story_page.cpp @@ -52,7 +52,7 @@ static inline bool StoryPageElementTypeRequiresText(StoryPageElementType type) ::CompanyID c = ScriptCompany::FromScriptCompanyID(company); - if (!ScriptObject::Command::Do(&ScriptInstance::DoCommandReturnStoryPageID, + if (!ScriptObject::Command::Do(&ScriptInstance::DoCommandReturnStoryPageID, c, title != nullptr ? title->GetEncodedText() : EncodedString{})) return STORY_PAGE_INVALID; /* In case of test-mode, we return StoryPageID 0 */ @@ -96,7 +96,7 @@ static inline bool StoryPageElementTypeRequiresText(StoryPageElementType type) NOT_REACHED(); } - if (!ScriptObject::Command::Do(&ScriptInstance::DoCommandReturnStoryPageElementID, + if (!ScriptObject::Command::Do(&ScriptInstance::DoCommandReturnStoryPageElementID, reftile, (::StoryPageID)story_page_id, (::StoryPageElementType)type, refid, @@ -145,7 +145,7 @@ static inline bool StoryPageElementTypeRequiresText(StoryPageElementType type) NOT_REACHED(); } - return ScriptObject::Command::Do(reftile, story_page_element_id, refid, encoded_text); + return ScriptObject::Command::Do(reftile, story_page_element_id, refid, encoded_text); } /* static */ SQInteger ScriptStoryPage::GetPageSortValue(StoryPageID story_page_id) @@ -169,7 +169,7 @@ static inline bool StoryPageElementTypeRequiresText(StoryPageElementType type) EnforcePrecondition(false, IsValidStoryPage(story_page_id)); EnforceDeityMode(false); - return ScriptObject::Command::Do(story_page_id, title != nullptr ? title->GetEncodedText() : EncodedString{}); + return ScriptObject::Command::Do(story_page_id, title != nullptr ? title->GetEncodedText() : EncodedString{}); } /* static */ ScriptCompany::CompanyID ScriptStoryPage::GetCompany(StoryPageID story_page_id) @@ -192,7 +192,7 @@ static inline bool StoryPageElementTypeRequiresText(StoryPageElementType type) EnforcePrecondition(false, IsValidStoryPage(story_page_id)); EnforceDeityMode(false); - return ScriptObject::Command::Do(story_page_id, ::TimerGameCalendar::Date{date}); + return ScriptObject::Command::Do(story_page_id, ::TimerGameCalendar::Date{date}); } @@ -201,7 +201,7 @@ static inline bool StoryPageElementTypeRequiresText(StoryPageElementType type) EnforcePrecondition(false, IsValidStoryPage(story_page_id)); EnforceDeityMode(false); - return ScriptObject::Command::Do(story_page_id); + return ScriptObject::Command::Do(story_page_id); } /* static */ bool ScriptStoryPage::Remove(StoryPageID story_page_id) @@ -209,7 +209,7 @@ static inline bool StoryPageElementTypeRequiresText(StoryPageElementType type) EnforceDeityMode(false); EnforcePrecondition(false, IsValidStoryPage(story_page_id)); - return ScriptObject::Command::Do(story_page_id); + return ScriptObject::Command::Do(story_page_id); } /* static */ bool ScriptStoryPage::RemoveElement(StoryPageElementID story_page_element_id) @@ -217,7 +217,7 @@ static inline bool StoryPageElementTypeRequiresText(StoryPageElementType type) EnforceDeityMode(false); EnforcePrecondition(false, IsValidStoryPageElement(story_page_element_id)); - return ScriptObject::Command::Do(story_page_element_id); + return ScriptObject::Command::Do(story_page_element_id); } /* static */ bool ScriptStoryPage::IsValidStoryPageButtonColour(StoryPageButtonColour colour) diff --git a/src/script/api/script_subsidy.cpp b/src/script/api/script_subsidy.cpp index 092ade9ad6..f3b5ae3335 100644 --- a/src/script/api/script_subsidy.cpp +++ b/src/script/api/script_subsidy.cpp @@ -43,7 +43,7 @@ Source from{static_cast(from_id), static_cast(from_type)}; Source to{static_cast(to_id), static_cast(to_type)}; - return ScriptObject::Command::Do(cargo_type, from, to); + return ScriptObject::Command::Do(cargo_type, from, to); } /* static */ ScriptCompany::CompanyID ScriptSubsidy::GetAwardedTo(SubsidyID subsidy_id) diff --git a/src/script/api/script_tile.cpp b/src/script/api/script_tile.cpp index e8eb4e9619..21b5129ff0 100644 --- a/src/script/api/script_tile.cpp +++ b/src/script/api/script_tile.cpp @@ -262,7 +262,7 @@ EnforceCompanyModeValid(false); EnforcePrecondition(false, tile < ScriptMap::GetMapSize()); - return ScriptObject::Command::Do(tile, (::Slope)slope, true); + return ScriptObject::Command::Do(tile, (::Slope)slope, true); } /* static */ bool ScriptTile::LowerTile(TileIndex tile, Slope slope) @@ -270,7 +270,7 @@ EnforceCompanyModeValid(false); EnforcePrecondition(false, tile < ScriptMap::GetMapSize()); - return ScriptObject::Command::Do(tile, (::Slope)slope, false); + return ScriptObject::Command::Do(tile, (::Slope)slope, false); } /* static */ bool ScriptTile::LevelTiles(TileIndex start_tile, TileIndex end_tile) @@ -279,7 +279,7 @@ EnforcePrecondition(false, start_tile < ScriptMap::GetMapSize()); EnforcePrecondition(false, end_tile < ScriptMap::GetMapSize()); - return ScriptObject::Command::Do(end_tile, start_tile, false, LM_LEVEL); + return ScriptObject::Command::Do(end_tile, start_tile, false, LM_LEVEL); } /* static */ bool ScriptTile::DemolishTile(TileIndex tile) @@ -287,7 +287,7 @@ EnforceDeityOrCompanyModeValid(false); EnforcePrecondition(false, ::IsValidTile(tile)); - return ScriptObject::Command::Do(tile); + return ScriptObject::Command::Do(tile); } /* static */ bool ScriptTile::PlantTree(TileIndex tile) @@ -295,7 +295,7 @@ EnforceCompanyModeValid(false); EnforcePrecondition(false, ::IsValidTile(tile)); - return ScriptObject::Command::Do(tile, tile, TREE_INVALID, false); + return ScriptObject::Command::Do(tile, tile, TREE_INVALID, false); } /* static */ bool ScriptTile::PlantTreeRectangle(TileIndex tile, SQInteger width, SQInteger height) @@ -307,7 +307,7 @@ TileIndex end_tile = TileAddWrap(tile, width - 1, height - 1); EnforcePrecondition(false, ::IsValidTile(end_tile)); - return ScriptObject::Command::Do(tile, end_tile, TREE_INVALID, false); + return ScriptObject::Command::Do(tile, end_tile, TREE_INVALID, false); } /* static */ bool ScriptTile::IsWithinTownInfluence(TileIndex tile, TownID town_id) diff --git a/src/script/api/script_town.cpp b/src/script/api/script_town.cpp index 602ffdc9fa..8f33cdf8af 100644 --- a/src/script/api/script_town.cpp +++ b/src/script/api/script_town.cpp @@ -52,7 +52,7 @@ EnforcePreconditionCustomError(false, ::Utf8StringLength(text) < MAX_LENGTH_TOWN_NAME_CHARS, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG); } - return ScriptObject::Command::Do(town_id, text); + return ScriptObject::Command::Do(town_id, text); } /* static */ bool ScriptTown::SetText(TownID town_id, Text *text) @@ -62,7 +62,7 @@ EnforceDeityMode(false); EnforcePrecondition(false, IsValidTown(town_id)); - return ScriptObject::Command::Do(town_id, text != nullptr ? text->GetEncodedText() : EncodedString{}); + return ScriptObject::Command::Do(town_id, text != nullptr ? text->GetEncodedText() : EncodedString{}); } /* static */ SQInteger ScriptTown::GetPopulation(TownID town_id) @@ -139,7 +139,7 @@ goal = Clamp(goal, 0, UINT32_MAX); - return ScriptObject::Command::Do(town_id, (::TownAcceptanceEffect)towneffect_id, goal); + return ScriptObject::Command::Do(town_id, (::TownAcceptanceEffect)towneffect_id, goal); } /* static */ SQInteger ScriptTown::GetCargoGoal(TownID town_id, ScriptCargo::TownEffect towneffect_id) @@ -183,7 +183,7 @@ break; } - return ScriptObject::Command::Do(town_id, growth_rate); + return ScriptObject::Command::Do(town_id, growth_rate); } /* static */ SQInteger ScriptTown::GetGrowthRate(TownID town_id) @@ -273,7 +273,7 @@ EnforcePrecondition(false, IsValidTown(town_id)); EnforcePrecondition(false, IsActionAvailable(town_id, town_action)); - return ScriptObject::Command::Do(town_id, ::TownAction(town_action)); + return ScriptObject::Command::Do(town_id, ::TownAction(town_action)); } /* static */ bool ScriptTown::ExpandTown(TownID town_id, SQInteger houses) @@ -284,7 +284,7 @@ houses = std::min(houses, UINT32_MAX); - return ScriptObject::Command::Do(town_id, houses, {TownExpandMode::Buildings, TownExpandMode::Roads}); + return ScriptObject::Command::Do(town_id, houses, {TownExpandMode::Buildings, TownExpandMode::Roads}); } /* static */ bool ScriptTown::FoundTown(TileIndex tile, TownSize size, bool city, RoadLayout layout, Text *name) @@ -314,7 +314,7 @@ return false; } - return ScriptObject::Command::Do(tile, (::TownSize)size, city, (::TownLayout)layout, false, townnameparts, text); + return ScriptObject::Command::Do(tile, (::TownSize)size, city, (::TownLayout)layout, false, townnameparts, text); } /* static */ ScriptTown::TownRating ScriptTown::GetRating(TownID town_id, ScriptCompany::CompanyID company_id) @@ -368,7 +368,7 @@ int16_t new_rating = Clamp(t->ratings[c] + delta, RATING_MINIMUM, RATING_MAXIMUM); if (new_rating == t->ratings[c]) return false; - return ScriptObject::Command::Do(town_id, c, new_rating); + return ScriptObject::Command::Do(town_id, c, new_rating); } /* static */ SQInteger ScriptTown::GetAllowedNoise(TownID town_id) diff --git a/src/script/api/script_tunnel.cpp b/src/script/api/script_tunnel.cpp index 4eb064353a..b0de5393ad 100644 --- a/src/script/api/script_tunnel.cpp +++ b/src/script/api/script_tunnel.cpp @@ -90,10 +90,10 @@ static void _DoCommandReturnBuildTunnel1(class ScriptInstance &instance) if (vehicle_type == ScriptVehicle::VT_RAIL) { /* For rail we do nothing special */ - return ScriptObject::Command::Do(start, TRANSPORT_RAIL, ScriptRail::GetCurrentRailType()); + return ScriptObject::Command::Do(start, TRANSPORT_RAIL, ScriptRail::GetCurrentRailType()); } else { ScriptObject::SetCallbackVariable(0, start.base()); - return ScriptObject::Command::Do(&::_DoCommandReturnBuildTunnel1, start, TRANSPORT_ROAD, ScriptRoad::GetCurrentRoadType()); + return ScriptObject::Command::Do(&::_DoCommandReturnBuildTunnel1, start, TRANSPORT_ROAD, ScriptRoad::GetCurrentRoadType()); } } @@ -108,7 +108,7 @@ static void _DoCommandReturnBuildTunnel1(class ScriptInstance &instance) DiagDirection dir_1 = ::DiagdirBetweenTiles(end, start); DiagDirection dir_2 = ::ReverseDiagDir(dir_1); - return ScriptObject::Command::Do(&::_DoCommandReturnBuildTunnel2, start + ::TileOffsByDiagDir(dir_1), ::DiagDirToRoadBits(dir_2), ScriptRoad::GetRoadType(), DRD_NONE, TownID::Invalid()); + return ScriptObject::Command::Do(&::_DoCommandReturnBuildTunnel2, start + ::TileOffsByDiagDir(dir_1), ::DiagDirToRoadBits(dir_2), ScriptRoad::GetRoadType(), DRD_NONE, TownID::Invalid()); } /* static */ bool ScriptTunnel::_BuildTunnelRoad2() @@ -122,7 +122,7 @@ static void _DoCommandReturnBuildTunnel1(class ScriptInstance &instance) DiagDirection dir_1 = ::DiagdirBetweenTiles(end, start); DiagDirection dir_2 = ::ReverseDiagDir(dir_1); - return ScriptObject::Command::Do(end + ::TileOffsByDiagDir(dir_2), ::DiagDirToRoadBits(dir_1), ScriptRoad::GetRoadType(), DRD_NONE, TownID::Invalid()); + return ScriptObject::Command::Do(end + ::TileOffsByDiagDir(dir_2), ::DiagDirToRoadBits(dir_1), ScriptRoad::GetRoadType(), DRD_NONE, TownID::Invalid()); } /* static */ bool ScriptTunnel::RemoveTunnel(TileIndex tile) @@ -130,5 +130,5 @@ static void _DoCommandReturnBuildTunnel1(class ScriptInstance &instance) EnforceCompanyModeValid(false); EnforcePrecondition(false, IsTunnelTile(tile)); - return ScriptObject::Command::Do(tile); + return ScriptObject::Command::Do(tile); } diff --git a/src/script/api/script_vehicle.cpp b/src/script/api/script_vehicle.cpp index 0bec1959e1..d4436c18dc 100644 --- a/src/script/api/script_vehicle.cpp +++ b/src/script/api/script_vehicle.cpp @@ -82,7 +82,7 @@ EnforcePreconditionCustomError(VEHICLE_INVALID, !ScriptGameSettings::IsDisabledVehicleType((ScriptVehicle::VehicleType)type), ScriptVehicle::ERR_VEHICLE_BUILD_DISABLED); - if (!ScriptObject::Command::Do(&ScriptInstance::DoCommandReturnVehicleID, depot, engine_id, true, cargo, INVALID_CLIENT_ID)) return VEHICLE_INVALID; + if (!ScriptObject::Command::Do(&ScriptInstance::DoCommandReturnVehicleID, depot, engine_id, true, cargo, INVALID_CLIENT_ID)) return VEHICLE_INVALID; /* In case of test-mode, we return VehicleID 0 */ return VehicleID::Begin(); @@ -104,7 +104,7 @@ if (!ScriptEngine::IsBuildable(engine_id)) return -1; if (!ScriptCargo::IsValidCargo(cargo)) return -1; - auto [res, veh_id, refit_capacity, refit_mail, cargo_capacities] = ::Command::Do(DoCommandFlag::QueryCost, depot, engine_id, true, cargo, INVALID_CLIENT_ID); + auto [res, veh_id, refit_capacity, refit_mail, cargo_capacities] = ::Command::Do(DoCommandFlag::QueryCost, depot, engine_id, true, cargo, INVALID_CLIENT_ID); return res.Succeeded() ? refit_capacity : -1; } @@ -113,7 +113,7 @@ EnforceCompanyModeValid(VEHICLE_INVALID); EnforcePrecondition(VEHICLE_INVALID, IsPrimaryVehicle(vehicle_id)); - if (!ScriptObject::Command::Do(&ScriptInstance::DoCommandReturnVehicleID, depot, vehicle_id, share_orders)) return VEHICLE_INVALID; + if (!ScriptObject::Command::Do(&ScriptInstance::DoCommandReturnVehicleID, depot, vehicle_id, share_orders)) return VEHICLE_INVALID; /* In case of test-mode, we return VehicleID 0 */ return VehicleID::Begin(); @@ -135,7 +135,7 @@ while (dest_wagon-- > 0) w = w->GetNextUnit(); } - return ScriptObject::Command::Do(v->index, w == nullptr ? VehicleID::Invalid() : w->index, move_attached_wagons); + return ScriptObject::Command::Do(v->index, w == nullptr ? VehicleID::Invalid() : w->index, move_attached_wagons); } /* static */ bool ScriptVehicle::MoveWagon(VehicleID source_vehicle_id, SQInteger source_wagon, SQInteger dest_vehicle_id, SQInteger dest_wagon) @@ -153,7 +153,7 @@ if (!IsValidVehicle(vehicle_id)) return -1; if (!ScriptCargo::IsValidCargo(cargo)) return -1; - auto [res, refit_capacity, refit_mail, cargo_capacities] = ::Command::Do(DoCommandFlag::QueryCost, vehicle_id, cargo, 0, false, false, 0); + auto [res, refit_capacity, refit_mail, cargo_capacities] = ::Command::Do(DoCommandFlag::QueryCost, vehicle_id, cargo, 0, false, false, 0); return res.Succeeded() ? refit_capacity : -1; } @@ -162,7 +162,7 @@ EnforceCompanyModeValid(false); EnforcePrecondition(false, IsValidVehicle(vehicle_id) && ScriptCargo::IsValidCargo(cargo)); - return ScriptObject::Command::Do(vehicle_id, cargo, 0, false, false, 0); + return ScriptObject::Command::Do(vehicle_id, cargo, 0, false, false, 0); } @@ -172,7 +172,7 @@ EnforcePrecondition(false, IsValidVehicle(vehicle_id)); const Vehicle *v = ::Vehicle::Get(vehicle_id); - return ScriptObject::Command::Do(vehicle_id, v->type == VEH_TRAIN, false, INVALID_CLIENT_ID); + return ScriptObject::Command::Do(vehicle_id, v->type == VEH_TRAIN, false, INVALID_CLIENT_ID); } /* static */ bool ScriptVehicle::_SellWagonInternal(VehicleID vehicle_id, SQInteger wagon, bool sell_attached_wagons) @@ -184,7 +184,7 @@ const Train *v = ::Train::Get(vehicle_id); while (wagon-- > 0) v = v->GetNextUnit(); - return ScriptObject::Command::Do(v->index, sell_attached_wagons, false, INVALID_CLIENT_ID); + return ScriptObject::Command::Do(v->index, sell_attached_wagons, false, INVALID_CLIENT_ID); } /* static */ bool ScriptVehicle::SellWagon(VehicleID vehicle_id, SQInteger wagon) @@ -202,7 +202,7 @@ EnforceCompanyModeValid(false); EnforcePrecondition(false, IsPrimaryVehicle(vehicle_id)); - return ScriptObject::Command::Do(vehicle_id, DepotCommandFlags{}, {}); + return ScriptObject::Command::Do(vehicle_id, DepotCommandFlags{}, {}); } /* static */ bool ScriptVehicle::SendVehicleToDepotForServicing(VehicleID vehicle_id) @@ -210,7 +210,7 @@ EnforceCompanyModeValid(false); EnforcePrecondition(false, IsPrimaryVehicle(vehicle_id)); - return ScriptObject::Command::Do(vehicle_id, DepotCommandFlag::Service, {}); + return ScriptObject::Command::Do(vehicle_id, DepotCommandFlag::Service, {}); } /* static */ bool ScriptVehicle::IsInDepot(VehicleID vehicle_id) @@ -230,7 +230,7 @@ EnforceCompanyModeValid(false); EnforcePrecondition(false, IsPrimaryVehicle(vehicle_id)); - return ScriptObject::Command::Do(vehicle_id, false); + return ScriptObject::Command::Do(vehicle_id, false); } /* static */ bool ScriptVehicle::ReverseVehicle(VehicleID vehicle_id) @@ -240,8 +240,8 @@ EnforcePrecondition(false, ::Vehicle::Get(vehicle_id)->type == VEH_ROAD || ::Vehicle::Get(vehicle_id)->type == VEH_TRAIN); switch (::Vehicle::Get(vehicle_id)->type) { - case VEH_ROAD: return ScriptObject::Command::Do(vehicle_id); - case VEH_TRAIN: return ScriptObject::Command::Do(vehicle_id, false); + case VEH_ROAD: return ScriptObject::Command::Do(vehicle_id); + case VEH_TRAIN: return ScriptObject::Command::Do(vehicle_id, false); default: NOT_REACHED(); } } @@ -257,7 +257,7 @@ EnforcePreconditionEncodedText(false, text); EnforcePreconditionCustomError(false, ::Utf8StringLength(text) < MAX_LENGTH_VEHICLE_NAME_CHARS, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG); - return ScriptObject::Command::Do(vehicle_id, text); + return ScriptObject::Command::Do(vehicle_id, text); } /* static */ TileIndex ScriptVehicle::GetLocation(VehicleID vehicle_id) diff --git a/src/script/api/script_viewport.cpp b/src/script/api/script_viewport.cpp index 6eb7e4b07b..853e46415e 100644 --- a/src/script/api/script_viewport.cpp +++ b/src/script/api/script_viewport.cpp @@ -31,7 +31,7 @@ EnforceDeityMode(false); EnforcePrecondition(false, ScriptMap::IsValidTile(tile)); - return ScriptObject::Command::Do(tile, VST_EVERYONE, 0); + return ScriptObject::Command::Do(tile, VST_EVERYONE, 0); } /* static */ bool ScriptViewport::ScrollCompanyClientsTo(ScriptCompany::CompanyID company, TileIndex tile) @@ -42,7 +42,7 @@ company = ScriptCompany::ResolveCompanyID(company); EnforcePrecondition(false, company != ScriptCompany::COMPANY_INVALID); - return ScriptObject::Command::Do(tile, VST_COMPANY, ScriptCompany::FromScriptCompanyID(company).base()); + return ScriptObject::Command::Do(tile, VST_COMPANY, ScriptCompany::FromScriptCompanyID(company).base()); } /* static */ bool ScriptViewport::ScrollClientTo(ScriptClient::ClientID client, TileIndex tile) @@ -54,5 +54,5 @@ client = ScriptClient::ResolveClientID(client); EnforcePrecondition(false, client != ScriptClient::CLIENT_INVALID); - return ScriptObject::Command::Do(tile, VST_CLIENT, client); + return ScriptObject::Command::Do(tile, VST_CLIENT, client); } diff --git a/src/script/script_gui.cpp b/src/script/script_gui.cpp index d84a904fd5..d6e2aed82f 100644 --- a/src/script/script_gui.cpp +++ b/src/script/script_gui.cpp @@ -1014,8 +1014,8 @@ struct ScriptDebugWindow : public Window { case WID_SCRD_RELOAD_TOGGLE: if (this->filter.script_debug_company == OWNER_DEITY) break; /* First kill the company of the AI, then start a new one. This should start the current AI again */ - Command::Post(CCA_DELETE, this->filter.script_debug_company, CRR_MANUAL, INVALID_CLIENT_ID); - Command::Post(CCA_NEW_AI, this->filter.script_debug_company, CRR_NONE, INVALID_CLIENT_ID); + Command::Post(CCA_DELETE, this->filter.script_debug_company, CRR_MANUAL, INVALID_CLIENT_ID); + Command::Post(CCA_NEW_AI, this->filter.script_debug_company, CRR_NONE, INVALID_CLIENT_ID); break; case WID_SCRD_SETTINGS: @@ -1054,7 +1054,7 @@ struct ScriptDebugWindow : public Window { } if (all_unpaused) { /* All scripts have been unpaused => unpause the game. */ - Command::Post(PauseMode::Normal, false); + Command::Post(PauseMode::Normal, false); } } } @@ -1107,7 +1107,7 @@ struct ScriptDebugWindow : public Window { /* Pause the game. */ if (!_pause_mode.Test(PauseMode::Normal)) { - Command::Post(PauseMode::Normal, true); + Command::Post(PauseMode::Normal, true); } /* Highlight row that matched */ diff --git a/src/script/script_instance.cpp b/src/script/script_instance.cpp index 31a72c21e9..86db2e634f 100644 --- a/src/script/script_instance.cpp +++ b/src/script/script_instance.cpp @@ -829,7 +829,7 @@ bool ScriptInstance::DoCommandCallback(const CommandCost &result, const CommandD ScriptObject::SetLastCost(result.GetCost()); } - ScriptObject::SetLastCommand({}, CMD_END); + ScriptObject::SetLastCommand({}, Commands::End); return true; } diff --git a/src/script/script_storage.hpp b/src/script/script_storage.hpp index 73a4d5fe83..6079039fb0 100644 --- a/src/script/script_storage.hpp +++ b/src/script/script_storage.hpp @@ -59,7 +59,7 @@ private: bool last_command_res = true; ///< The last result of the command. CommandDataBuffer last_data; ///< The last data passed to a command. - Commands last_cmd = CMD_END; ///< The last cmd passed to a command. + Commands last_cmd = Commands::End; ///< The last cmd passed to a command. CommandDataBuffer last_cmd_ret; ///< The extra data returned by the last command. std::vector callback_value; ///< The values which need to survive a callback. diff --git a/src/settings.cpp b/src/settings.cpp index 2e24977359..d9bf815547 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -1820,7 +1820,7 @@ bool SetSettingValue(const IntSettingDesc *sd, int32_t value, bool force_newgame const IntSettingDesc *setting = sd->AsIntSetting(); if (setting->flags.Test(SettingFlag::PerCompany)) { if (Company::IsValidID(_local_company) && _game_mode != GM_MENU) { - return Command::Post(setting->GetName(), value); + return Command::Post(setting->GetName(), value); } setting->ChangeValue(&_settings_client.company, value); @@ -1846,7 +1846,7 @@ bool SetSettingValue(const IntSettingDesc *sd, int32_t value, bool force_newgame /* send non-company-based settings over the network */ if (!_networking || (_networking && _network_server)) { - return Command::Post(setting->GetName(), value); + return Command::Post(setting->GetName(), value); } return false; } @@ -1880,7 +1880,7 @@ void SyncCompanySettings() * that the rest of the clients do not know about, we need to circumvent the normal ::Post * local command validation and immediately send the command to the server. */ - if (old_value != new_value) Command::SendNet(STR_NULL, _local_company, sd->GetName(), new_value); + if (old_value != new_value) Command::SendNet(STR_NULL, _local_company, sd->GetName(), new_value); } } diff --git a/src/settings_cmd.h b/src/settings_cmd.h index 2332b6aca3..f937f05f40 100644 --- a/src/settings_cmd.h +++ b/src/settings_cmd.h @@ -15,7 +15,7 @@ CommandCost CmdChangeSetting(DoCommandFlags flags, const std::string &name, int32_t value); CommandCost CmdChangeCompanySetting(DoCommandFlags flags, const std::string &name, int32_t value); -DEF_CMD_TRAIT(CMD_CHANGE_SETTING, CmdChangeSetting, CommandFlags({CommandFlag::Server, CommandFlag::NoEst}), CommandType::ServerSetting) -DEF_CMD_TRAIT(CMD_CHANGE_COMPANY_SETTING, CmdChangeCompanySetting, CommandFlag::NoEst, CommandType::CompanySetting) +DEF_CMD_TRAIT(Commands::ChangeSetting, CmdChangeSetting, CommandFlags({CommandFlag::Server, CommandFlag::NoEst}), CommandType::ServerSetting) +DEF_CMD_TRAIT(Commands::ChangeCompanySetting, CmdChangeCompanySetting, CommandFlag::NoEst, CommandType::CompanySetting) #endif /* SETTINGS_CMD_H */ diff --git a/src/signs_cmd.cpp b/src/signs_cmd.cpp index fb5e58bb13..795eab6754 100644 --- a/src/signs_cmd.cpp +++ b/src/signs_cmd.cpp @@ -148,5 +148,5 @@ void CcPlaceSign(Commands, const CommandCost &result, SignID new_sign) */ void PlaceProc_Sign(TileIndex tile) { - Command::Post(STR_ERROR_CAN_T_PLACE_SIGN_HERE, CcPlaceSign, tile, {}); + Command::Post(STR_ERROR_CAN_T_PLACE_SIGN_HERE, CcPlaceSign, tile, {}); } diff --git a/src/signs_cmd.h b/src/signs_cmd.h index 4faa7e5b31..1d0f00227b 100644 --- a/src/signs_cmd.h +++ b/src/signs_cmd.h @@ -18,9 +18,9 @@ std::tuple CmdPlaceSign(DoCommandFlags flags, TileIndex til CommandCost CmdRenameSign(DoCommandFlags flags, SignID sign_id, const std::string &text, Colours text_colour); CommandCost CmdMoveSign(DoCommandFlags flags, SignID sign_id, TileIndex tile); -DEF_CMD_TRAIT(CMD_PLACE_SIGN, CmdPlaceSign, CommandFlag::Deity, CommandType::OtherManagement) -DEF_CMD_TRAIT(CMD_RENAME_SIGN, CmdRenameSign, CommandFlag::Deity, CommandType::OtherManagement) -DEF_CMD_TRAIT(CMD_MOVE_SIGN, CmdMoveSign, CommandFlag::Deity, CommandType::OtherManagement) +DEF_CMD_TRAIT(Commands::PlaceSign, CmdPlaceSign, CommandFlag::Deity, CommandType::OtherManagement) +DEF_CMD_TRAIT(Commands::RenameSign, CmdRenameSign, CommandFlag::Deity, CommandType::OtherManagement) +DEF_CMD_TRAIT(Commands::MoveSign, CmdMoveSign, CommandFlag::Deity, CommandType::OtherManagement) void CcPlaceSign(Commands cmd, const CommandCost &result, SignID new_sign); diff --git a/src/signs_gui.cpp b/src/signs_gui.cpp index b675bf72aa..576fb88b6e 100644 --- a/src/signs_gui.cpp +++ b/src/signs_gui.cpp @@ -387,7 +387,7 @@ Window *ShowSignList() static bool RenameSign(SignID index, std::string_view text, Colours text_colour) { bool remove = text.empty(); - Command::Post(remove ? STR_ERROR_CAN_T_DELETE_SIGN : STR_ERROR_CAN_T_CHANGE_SIGN_NAME, index, std::string{text}, text_colour); + Command::Post(remove ? STR_ERROR_CAN_T_DELETE_SIGN : STR_ERROR_CAN_T_CHANGE_SIGN_NAME, index, std::string{text}, text_colour); return remove; } @@ -398,7 +398,7 @@ static bool RenameSign(SignID index, std::string_view text, Colours text_colour) */ void MoveSign(SignID index, TileIndex tile) { - Command::Post(STR_ERROR_CAN_T_PLACE_SIGN_HERE, index, tile); + Command::Post(STR_ERROR_CAN_T_PLACE_SIGN_HERE, index, tile); } struct SignWindow : Window, SignList { diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index 4627c2f5b8..a2c71cbc02 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -845,7 +845,7 @@ static CommandCost CheckFlatLandAirport(AirportTileTableIterator tile_iter, DoCo if (ret.Failed()) return ret; cost.AddCost(ret.GetCost()); - ret = Command::Do(flags, tile_iter); + ret = Command::Do(flags, tile_iter); if (ret.Failed()) return ret; cost.AddCost(ret.GetCost()); } @@ -891,7 +891,7 @@ static CommandCost IsStationBridgeAboveOk(TileIndex tile, std::span::Do(DoCommandFlag::Auto, tile); + return Command::Do(DoCommandFlag::Auto, tile); } if (GetTileMaxZ(tile) + height > bridge_height) { int height_diff = (GetTileMaxZ(tile) + height - bridge_height) * TILE_HEIGHT_STEP; @@ -1043,7 +1043,7 @@ static CommandCost CheckFlatLandRailStation(TileIndex tile_cur, TileIndex north_ affected_vehicles.push_back(v); } } - ret = Command::Do(flags, tile_cur, track); + ret = Command::Do(flags, tile_cur, track); if (ret.Failed()) return ret; cost.AddCost(ret.GetCost()); /* With DoCommandFlags{flags}.Reset(DoCommandFlag::Execute) CmdLandscapeClear would fail since the rail still exists */ @@ -1051,7 +1051,7 @@ static CommandCost CheckFlatLandRailStation(TileIndex tile_cur, TileIndex north_ } } } - ret = Command::Do(flags, tile_cur); + ret = Command::Do(flags, tile_cur); if (ret.Failed()) return ret; cost.AddCost(ret.GetCost()); } @@ -1173,7 +1173,7 @@ static CommandCost CheckFlatLandRoadStop(TileIndex cur_tile, int &allowed_z, con } else if (rt == INVALID_ROADTYPE) { return CommandCost(STR_ERROR_THERE_IS_NO_ROAD); } else { - ret = Command::Do(flags, cur_tile); + ret = Command::Do(flags, cur_tile); if (ret.Failed()) return ret; cost.AddCost(ret.GetCost()); cost.AddCost(RoadBuildCost(rt) * 2); @@ -1944,7 +1944,7 @@ static CommandCost RemoveRailStation(TileIndex tile, DoCommandFlags flags) { /* if there is flooding, remove platforms tile by tile */ if (_current_company == OWNER_WATER) { - return Command::Do(DoCommandFlag::Execute, tile, TileIndex{}, false); + return Command::Do(DoCommandFlag::Execute, tile, TileIndex{}, false); } Station *st = Station::GetByTile(tile); @@ -1965,7 +1965,7 @@ static CommandCost RemoveRailWaypoint(TileIndex tile, DoCommandFlags flags) { /* if there is flooding, remove waypoints tile by tile */ if (_current_company == OWNER_WATER) { - return Command::Do(DoCommandFlag::Execute, tile, TileIndex{}, false); + return Command::Do(DoCommandFlag::Execute, tile, TileIndex{}, false); } return RemoveRailStation(Waypoint::GetByTile(tile), flags, _price[Price::ClearWaypointRail]); @@ -2911,7 +2911,7 @@ CommandCost CmdBuildDock(DoCommandFlags flags, TileIndex tile, StationID station if (ret.Failed()) return ret; CommandCost cost(EXPENSES_CONSTRUCTION, _price[Price::BuildStationDock]); - ret = Command::Do(flags, tile); + ret = Command::Do(flags, tile); if (ret.Failed()) return ret; cost.AddCost(ret.GetCost()); @@ -2928,7 +2928,7 @@ CommandCost CmdBuildDock(DoCommandFlags flags, TileIndex tile, StationID station WaterClass wc = GetWaterClass(tile_cur); bool add_cost = !IsWaterTile(tile_cur); - ret = Command::Do(flags, tile_cur); + ret = Command::Do(flags, tile_cur); if (ret.Failed()) return ret; if (add_cost) cost.AddCost(ret.GetCost()); @@ -4841,15 +4841,15 @@ static void ChangeTileOwner_Station(TileIndex tile, Owner old_owner, Owner new_o if (IsDriveThroughStopTile(tile)) { /* Remove the drive-through road stop */ if (IsRoadWaypoint(tile)) { - Command::Do({DoCommandFlag::Execute, DoCommandFlag::Bankrupt}, tile, tile); + Command::Do({DoCommandFlag::Execute, DoCommandFlag::Bankrupt}, tile, tile); } else { - Command::Do({DoCommandFlag::Execute, DoCommandFlag::Bankrupt}, tile, 1, 1, (GetStationType(tile) == StationType::Truck) ? RoadStopType::Truck : RoadStopType::Bus, false); + Command::Do({DoCommandFlag::Execute, DoCommandFlag::Bankrupt}, tile, 1, 1, (GetStationType(tile) == StationType::Truck) ? RoadStopType::Truck : RoadStopType::Bus, false); } assert(IsTileType(tile, TileType::Road)); /* Change owner of tile and all roadtypes */ ChangeTileOwner(tile, old_owner, new_owner); } else { - Command::Do({DoCommandFlag::Execute, DoCommandFlag::Bankrupt}, tile); + Command::Do({DoCommandFlag::Execute, DoCommandFlag::Bankrupt}, tile); /* Set tile owner of water under (now removed) buoy and dock to OWNER_NONE. * Update owner of buoy if it was not removed (was in orders). * Do not update when owned by OWNER_WATER (sea and rivers). */ @@ -4975,7 +4975,7 @@ static CommandCost TerraformTile_Station(TileIndex tile, DoCommandFlags flags, i } } } - return Command::Do(flags, tile); + return Command::Do(flags, tile); } /** diff --git a/src/station_cmd.h b/src/station_cmd.h index 25cb6211b9..b44a83ea39 100644 --- a/src/station_cmd.h +++ b/src/station_cmd.h @@ -33,15 +33,15 @@ CommandCost CmdRenameStation(DoCommandFlags flags, StationID station_id, const s std::tuple CmdMoveStationName(DoCommandFlags flags, StationID station_id, TileIndex tile); CommandCost CmdOpenCloseAirport(DoCommandFlags flags, StationID station_id); -DEF_CMD_TRAIT(CMD_BUILD_AIRPORT, CmdBuildAirport, CommandFlags({CommandFlag::Auto, CommandFlag::NoWater}), CommandType::LandscapeConstruction) -DEF_CMD_TRAIT(CMD_BUILD_DOCK, CmdBuildDock, CommandFlag::Auto, CommandType::LandscapeConstruction) -DEF_CMD_TRAIT(CMD_BUILD_RAIL_STATION, CmdBuildRailStation, CommandFlags({CommandFlag::Auto, CommandFlag::NoWater}), CommandType::LandscapeConstruction) -DEF_CMD_TRAIT(CMD_REMOVE_FROM_RAIL_STATION, CmdRemoveFromRailStation, {}, CommandType::LandscapeConstruction) -DEF_CMD_TRAIT(CMD_BUILD_ROAD_STOP, CmdBuildRoadStop, CommandFlags({CommandFlag::Auto, CommandFlag::NoWater}), CommandType::LandscapeConstruction) -DEF_CMD_TRAIT(CMD_REMOVE_ROAD_STOP, CmdRemoveRoadStop, {}, CommandType::LandscapeConstruction) -DEF_CMD_TRAIT(CMD_RENAME_STATION, CmdRenameStation, {}, CommandType::OtherManagement) -DEF_CMD_TRAIT(CMD_MOVE_STATION_NAME, CmdMoveStationName, {}, CommandType::OtherManagement) -DEF_CMD_TRAIT(CMD_OPEN_CLOSE_AIRPORT, CmdOpenCloseAirport, {}, CommandType::RouteManagement) +DEF_CMD_TRAIT(Commands::BuildAirport, CmdBuildAirport, CommandFlags({CommandFlag::Auto, CommandFlag::NoWater}), CommandType::LandscapeConstruction) +DEF_CMD_TRAIT(Commands::BuildDock, CmdBuildDock, CommandFlag::Auto, CommandType::LandscapeConstruction) +DEF_CMD_TRAIT(Commands::BuildRailStation, CmdBuildRailStation, CommandFlags({CommandFlag::Auto, CommandFlag::NoWater}), CommandType::LandscapeConstruction) +DEF_CMD_TRAIT(Commands::RemoveFromRailStation, CmdRemoveFromRailStation, {}, CommandType::LandscapeConstruction) +DEF_CMD_TRAIT(Commands::BuildRoadStop, CmdBuildRoadStop, CommandFlags({CommandFlag::Auto, CommandFlag::NoWater}), CommandType::LandscapeConstruction) +DEF_CMD_TRAIT(Commands::RemoveRoadStop, CmdRemoveRoadStop, {}, CommandType::LandscapeConstruction) +DEF_CMD_TRAIT(Commands::RenameStation, CmdRenameStation, {}, CommandType::OtherManagement) +DEF_CMD_TRAIT(Commands::MoveStationName, CmdMoveStationName, {}, CommandType::OtherManagement) +DEF_CMD_TRAIT(Commands::OpenCloseAirport, CmdOpenCloseAirport, {}, CommandType::RouteManagement) void CcMoveStationName(Commands cmd, const CommandCost &result, StationID station_id); diff --git a/src/station_gui.cpp b/src/station_gui.cpp index 9a275a82cd..4bf77ff3a0 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -1998,7 +1998,7 @@ struct StationViewWindow : public Window { break; case WID_SV_CLOSE_AIRPORT: - Command::Post(this->window_number); + Command::Post(this->window_number); break; case WID_SV_TRAINS: // Show list of scheduled trains to this station @@ -2135,7 +2135,7 @@ struct StationViewWindow : public Window { { if (!str.has_value()) return; - Command::Post(STR_ERROR_CAN_T_RENAME_STATION, this->window_number, *str); + Command::Post(STR_ERROR_CAN_T_RENAME_STATION, this->window_number, *str); } void OnResize() override diff --git a/src/story_cmd.h b/src/story_cmd.h index 75574f092c..7345c149cf 100644 --- a/src/story_cmd.h +++ b/src/story_cmd.h @@ -25,14 +25,14 @@ CommandCost CmdRemoveStoryPage(DoCommandFlags flags, StoryPageID page_id); CommandCost CmdRemoveStoryPageElement(DoCommandFlags flags, StoryPageElementID page_element_id); CommandCost CmdStoryPageButton(DoCommandFlags flags, TileIndex tile, StoryPageElementID page_element_id, VehicleID reference); -DEF_CMD_TRAIT(CMD_CREATE_STORY_PAGE, CmdCreateStoryPage, CommandFlags({CommandFlag::Deity, CommandFlag::StrCtrl}), CommandType::OtherManagement) -DEF_CMD_TRAIT(CMD_CREATE_STORY_PAGE_ELEMENT, CmdCreateStoryPageElement, CommandFlags({CommandFlag::Deity, CommandFlag::StrCtrl}), CommandType::OtherManagement) -DEF_CMD_TRAIT(CMD_UPDATE_STORY_PAGE_ELEMENT, CmdUpdateStoryPageElement, CommandFlags({CommandFlag::Deity, CommandFlag::StrCtrl}), CommandType::OtherManagement) -DEF_CMD_TRAIT(CMD_SET_STORY_PAGE_TITLE, CmdSetStoryPageTitle, CommandFlags({CommandFlag::Deity, CommandFlag::StrCtrl}), CommandType::OtherManagement) -DEF_CMD_TRAIT(CMD_SET_STORY_PAGE_DATE, CmdSetStoryPageDate, CommandFlag::Deity, CommandType::OtherManagement) -DEF_CMD_TRAIT(CMD_SHOW_STORY_PAGE, CmdShowStoryPage, CommandFlag::Deity, CommandType::OtherManagement) -DEF_CMD_TRAIT(CMD_REMOVE_STORY_PAGE, CmdRemoveStoryPage, CommandFlag::Deity, CommandType::OtherManagement) -DEF_CMD_TRAIT(CMD_REMOVE_STORY_PAGE_ELEMENT, CmdRemoveStoryPageElement, CommandFlag::Deity, CommandType::OtherManagement) -DEF_CMD_TRAIT(CMD_STORY_PAGE_BUTTON, CmdStoryPageButton, CommandFlag::Deity, CommandType::OtherManagement) +DEF_CMD_TRAIT(Commands::CreateStoryPage, CmdCreateStoryPage, CommandFlags({CommandFlag::Deity, CommandFlag::StrCtrl}), CommandType::OtherManagement) +DEF_CMD_TRAIT(Commands::CreateStoryPageElement, CmdCreateStoryPageElement, CommandFlags({CommandFlag::Deity, CommandFlag::StrCtrl}), CommandType::OtherManagement) +DEF_CMD_TRAIT(Commands::UpdateStoryPageElement, CmdUpdateStoryPageElement, CommandFlags({CommandFlag::Deity, CommandFlag::StrCtrl}), CommandType::OtherManagement) +DEF_CMD_TRAIT(Commands::SetStoryPageTitle, CmdSetStoryPageTitle, CommandFlags({CommandFlag::Deity, CommandFlag::StrCtrl}), CommandType::OtherManagement) +DEF_CMD_TRAIT(Commands::SetStoryPageDate, CmdSetStoryPageDate, CommandFlag::Deity, CommandType::OtherManagement) +DEF_CMD_TRAIT(Commands::ShowStoryPage, CmdShowStoryPage, CommandFlag::Deity, CommandType::OtherManagement) +DEF_CMD_TRAIT(Commands::RemoveStoryPage, CmdRemoveStoryPage, CommandFlag::Deity, CommandType::OtherManagement) +DEF_CMD_TRAIT(Commands::RemoveStoryPageElement, CmdRemoveStoryPageElement, CommandFlag::Deity, CommandType::OtherManagement) +DEF_CMD_TRAIT(Commands::StoryPageButton, CmdStoryPageButton, CommandFlag::Deity, CommandType::OtherManagement) #endif /* STORY_CMD_H */ diff --git a/src/story_gui.cpp b/src/story_gui.cpp index f6c43318f3..f69ae83a36 100644 --- a/src/story_gui.cpp +++ b/src/story_gui.cpp @@ -553,7 +553,7 @@ protected: this->SetTimeout(); this->SetWidgetDirty(WID_SB_PAGE_PANEL); - Command::Post(TileIndex{}, pe.index, VehicleID::Invalid()); + Command::Post(TileIndex{}, pe.index, VehicleID::Invalid()); break; case SPET_BUTTON_TILE: @@ -898,7 +898,7 @@ public: return; } - Command::Post(tile, pe->index, VehicleID::Invalid()); + Command::Post(tile, pe->index, VehicleID::Invalid()); ResetObjectToPlace(); } @@ -917,7 +917,7 @@ public: VehicleType wanted_vehtype = data.GetVehicleType(); if (wanted_vehtype != VEH_INVALID && wanted_vehtype != v->type) return false; - Command::Post(TileIndex{}, pe->index, v->index); + Command::Post(TileIndex{}, pe->index, v->index); ResetObjectToPlace(); return true; } diff --git a/src/subsidy_cmd.h b/src/subsidy_cmd.h index 95ec30f833..1a0e439903 100644 --- a/src/subsidy_cmd.h +++ b/src/subsidy_cmd.h @@ -17,7 +17,7 @@ CommandCost CmdCreateSubsidy(DoCommandFlags flags, CargoType cargo_type, Source src, Source dst); -DEF_CMD_TRAIT(CMD_CREATE_SUBSIDY, CmdCreateSubsidy, CommandFlag::Deity, CommandType::OtherManagement) +DEF_CMD_TRAIT(Commands::CreateSubsidy, CmdCreateSubsidy, CommandFlag::Deity, CommandType::OtherManagement) template diff --git a/src/terraform_cmd.cpp b/src/terraform_cmd.cpp index 8769960b05..4e4bc7f126 100644 --- a/src/terraform_cmd.cpp +++ b/src/terraform_cmd.cpp @@ -263,7 +263,7 @@ std::tuple CmdTerraformLand(DoCommandFlags flags, } CommandCost cost; if (indirectly_cleared) { - cost = Command::Do(tile_flags, t); + cost = Command::Do(tile_flags, t); } else { cost = _tile_type_procs[GetTileType(t)]->terraform_tile_proc(t, tile_flags, z_min, tileh); } @@ -347,7 +347,7 @@ std::tuple CmdLevelLand(DoCommandFlags flags, Til uint curh = TileHeight(t); while (curh != h) { CommandCost ret; - std::tie(ret, std::ignore, error_tile) = Command::Do(DoCommandFlags{flags}.Reset(DoCommandFlag::Execute), t, SLOPE_N, curh <= h); + std::tie(ret, std::ignore, error_tile) = Command::Do(DoCommandFlags{flags}.Reset(DoCommandFlag::Execute), t, SLOPE_N, curh <= h); if (ret.Failed()) { last_error = std::move(ret); @@ -361,7 +361,7 @@ std::tuple CmdLevelLand(DoCommandFlags flags, Til if (money < 0) { return { cost, ret.GetCost(), error_tile }; } - Command::Do(flags, t, SLOPE_N, curh <= h); + Command::Do(flags, t, SLOPE_N, curh <= h); } else { /* When we're at the terraform limit we better bail (unneeded) testing as well. * This will probably cause the terraforming cost to be underestimated, but only diff --git a/src/terraform_cmd.h b/src/terraform_cmd.h index 3f672343e7..102ffc892d 100644 --- a/src/terraform_cmd.h +++ b/src/terraform_cmd.h @@ -17,8 +17,8 @@ std::tuple CmdTerraformLand(DoCommandFlags flags, TileIndex tile, Slope slope, bool dir_up); std::tuple CmdLevelLand(DoCommandFlags flags, TileIndex tile, TileIndex start_tile, bool diagonal, LevelMode lm); -DEF_CMD_TRAIT(CMD_TERRAFORM_LAND, CmdTerraformLand, CommandFlags({CommandFlag::AllTiles, CommandFlag::Auto}), CommandType::LandscapeConstruction) -DEF_CMD_TRAIT(CMD_LEVEL_LAND, CmdLevelLand, CommandFlags({CommandFlag::AllTiles, CommandFlag::Auto, CommandFlag::NoTest}), CommandType::LandscapeConstruction) // test run might clear tiles multiple times, in execution that only happens once +DEF_CMD_TRAIT(Commands::TerraformLand, CmdTerraformLand, CommandFlags({CommandFlag::AllTiles, CommandFlag::Auto}), CommandType::LandscapeConstruction) +DEF_CMD_TRAIT(Commands::LevelLand, CmdLevelLand, CommandFlags({CommandFlag::AllTiles, CommandFlag::Auto, CommandFlag::NoTest}), CommandType::LandscapeConstruction) // test run might clear tiles multiple times, in execution that only happens once CommandCallback CcPlaySound_EXPLOSION; void CcTerraform(Commands cmd, const CommandCost &result, Money, TileIndex tile); diff --git a/src/terraform_gui.cpp b/src/terraform_gui.cpp index a3220c5a21..37ababbb1d 100644 --- a/src/terraform_gui.cpp +++ b/src/terraform_gui.cpp @@ -65,7 +65,7 @@ static void GenerateDesertArea(TileIndex end, TileIndex start) TileArea ta(start, end); for (TileIndex tile : ta) { SetTropicZone(tile, (_ctrl_pressed) ? TROPICZONE_NORMAL : TROPICZONE_DESERT); - Command::Post(tile); + Command::Post(tile); MarkTileDirtyByTile(tile); } old_generating_world.Restore(); @@ -120,16 +120,16 @@ bool GUIPlaceProcDragXY(ViewportDragDropSelectionProcess proc, TileIndex start_t switch (proc) { case DDSP_DEMOLISH_AREA: - Command::Post(STR_ERROR_CAN_T_CLEAR_THIS_AREA, CcPlaySound_EXPLOSION, end_tile, start_tile, _ctrl_pressed); + Command::Post(STR_ERROR_CAN_T_CLEAR_THIS_AREA, CcPlaySound_EXPLOSION, end_tile, start_tile, _ctrl_pressed); break; case DDSP_RAISE_AND_LEVEL_AREA: - Command::Post(STR_ERROR_CAN_T_RAISE_LAND_HERE, CcTerraform, end_tile, start_tile, _ctrl_pressed, LM_RAISE); + Command::Post(STR_ERROR_CAN_T_RAISE_LAND_HERE, CcTerraform, end_tile, start_tile, _ctrl_pressed, LM_RAISE); break; case DDSP_LOWER_AND_LEVEL_AREA: - Command::Post(STR_ERROR_CAN_T_LOWER_LAND_HERE, CcTerraform, end_tile, start_tile, _ctrl_pressed, LM_LOWER); + Command::Post(STR_ERROR_CAN_T_LOWER_LAND_HERE, CcTerraform, end_tile, start_tile, _ctrl_pressed, LM_LOWER); break; case DDSP_LEVEL_AREA: - Command::Post(STR_ERROR_CAN_T_LEVEL_LAND_HERE, CcTerraform, end_tile, start_tile, _ctrl_pressed, LM_LEVEL); + Command::Post(STR_ERROR_CAN_T_LEVEL_LAND_HERE, CcTerraform, end_tile, start_tile, _ctrl_pressed, LM_LEVEL); break; case DDSP_CREATE_ROCKS: GenerateRockyArea(end_tile, start_tile); @@ -280,7 +280,7 @@ struct TerraformToolbarWindow : Window { if (TileX(end_tile) == Map::MaxX()) end_tile += TileDiffXY(-1, 0); if (TileY(end_tile) == Map::MaxY()) end_tile += TileDiffXY(0, -1); } - Command::Post(STR_ERROR_CAN_T_PURCHASE_THIS_LAND, CcPlaySound_CONSTRUCTION_RAIL, + Command::Post(STR_ERROR_CAN_T_PURCHASE_THIS_LAND, CcPlaySound_CONSTRUCTION_RAIL, end_tile, start_tile, OBJECT_OWNED_LAND, 0, _ctrl_pressed); break; } @@ -396,7 +396,7 @@ static void CommonRaiseLowerBigLand(TileIndex tile, bool mode) StringID msg = mode ? STR_ERROR_CAN_T_RAISE_LAND_HERE : STR_ERROR_CAN_T_LOWER_LAND_HERE; - Command::Post(msg, CcTerraform, tile, SLOPE_N, mode); + Command::Post(msg, CcTerraform, tile, SLOPE_N, mode); } else { assert(_terraform_size != 0); TileArea ta(tile, _terraform_size, _terraform_size); @@ -423,7 +423,7 @@ static void CommonRaiseLowerBigLand(TileIndex tile, bool mode) for (TileIndex tile2 : ta) { if (TileHeight(tile2) == h) { - Command::Post(tile2, SLOPE_N, mode); + Command::Post(tile2, SLOPE_N, mode); } } } @@ -511,7 +511,7 @@ static void ResetLandscapeConfirmationCallback(Window *, bool confirmed) /* Delete all station signs */ for (BaseStation *st : BaseStation::Iterate()) { /* There can be buoys, remove them */ - if (IsBuoyTile(st->xy)) Command::Do({DoCommandFlag::Execute, DoCommandFlag::Bankrupt}, st->xy); + if (IsBuoyTile(st->xy)) Command::Do({DoCommandFlag::Execute, DoCommandFlag::Bankrupt}, st->xy); if (!st->IsInUse()) delete st; } diff --git a/src/timetable_cmd.cpp b/src/timetable_cmd.cpp index 28f4758e6c..d6b9900868 100644 --- a/src/timetable_cmd.cpp +++ b/src/timetable_cmd.cpp @@ -242,7 +242,7 @@ CommandCost CmdBulkChangeTimetable(DoCommandFlags flags, VehicleID veh, ModifyTi Order *order = v->GetOrder(order_number); if (order == nullptr || order->IsType(OT_IMPLICIT)) continue; - Command::Do(DoCommandFlag::Execute, v->index, order_number, mtf, data); + Command::Do(DoCommandFlag::Execute, v->index, order_number, mtf, data); } } diff --git a/src/timetable_cmd.h b/src/timetable_cmd.h index 50e57c5e76..d20731e44d 100644 --- a/src/timetable_cmd.h +++ b/src/timetable_cmd.h @@ -21,10 +21,10 @@ CommandCost CmdSetVehicleOnTime(DoCommandFlags flags, VehicleID veh, bool apply_ CommandCost CmdAutofillTimetable(DoCommandFlags flags, VehicleID veh, bool autofill, bool preserve_wait_time); CommandCost CmdSetTimetableStart(DoCommandFlags flags, VehicleID veh_id, bool timetable_all, TimerGameTick::TickCounter start_tick); -DEF_CMD_TRAIT(CMD_CHANGE_TIMETABLE, CmdChangeTimetable, {}, CommandType::RouteManagement) -DEF_CMD_TRAIT(CMD_BULK_CHANGE_TIMETABLE, CmdBulkChangeTimetable, {}, CommandType::RouteManagement) -DEF_CMD_TRAIT(CMD_SET_VEHICLE_ON_TIME, CmdSetVehicleOnTime, {}, CommandType::RouteManagement) -DEF_CMD_TRAIT(CMD_AUTOFILL_TIMETABLE, CmdAutofillTimetable, {}, CommandType::RouteManagement) -DEF_CMD_TRAIT(CMD_SET_TIMETABLE_START, CmdSetTimetableStart, {}, CommandType::RouteManagement) +DEF_CMD_TRAIT(Commands::ChangeTimetable, CmdChangeTimetable, {}, CommandType::RouteManagement) +DEF_CMD_TRAIT(Commands::ChangeTimetableBulk, CmdBulkChangeTimetable, {}, CommandType::RouteManagement) +DEF_CMD_TRAIT(Commands::SetVehicleOnTime, CmdSetVehicleOnTime, {}, CommandType::RouteManagement) +DEF_CMD_TRAIT(Commands::AutofillTimetable, CmdAutofillTimetable, {}, CommandType::RouteManagement) +DEF_CMD_TRAIT(Commands::SetTimetableStart, CmdSetTimetableStart, {}, CommandType::RouteManagement) #endif /* TIMETABLE_CMD_H */ diff --git a/src/timetable_gui.cpp b/src/timetable_gui.cpp index 26d118c5d4..30f8cfba93 100644 --- a/src/timetable_gui.cpp +++ b/src/timetable_gui.cpp @@ -639,7 +639,7 @@ struct TimetableWindow : Window { } else { ShowSetDateWindow(this, v->index.base(), TimerGameEconomy::date, TimerGameEconomy::year, TimerGameEconomy::year + MAX_TIMETABLE_START_YEARS, [ctrl=_ctrl_pressed](const Window *w, TimerGameEconomy::Date date) { - Command::Post(STR_ERROR_CAN_T_TIMETABLE_VEHICLE, w->window_number, ctrl, GetStartTickFromDate(date)); + Command::Post(STR_ERROR_CAN_T_TIMETABLE_VEHICLE, w->window_number, ctrl, GetStartTickFromDate(date)); } ); } @@ -692,9 +692,9 @@ struct TimetableWindow : Window { case WID_VT_CLEAR_TIME: { // Clear waiting time. auto [order_id, mtf] = PackTimetableArgs(v, this->sel_index, false); if (_ctrl_pressed) { - Command::Post(STR_ERROR_CAN_T_TIMETABLE_VEHICLE, v->index, mtf, 0); + Command::Post(STR_ERROR_CAN_T_TIMETABLE_VEHICLE, v->index, mtf, 0); } else { - Command::Post(STR_ERROR_CAN_T_TIMETABLE_VEHICLE, v->index, order_id, mtf, 0); + Command::Post(STR_ERROR_CAN_T_TIMETABLE_VEHICLE, v->index, order_id, mtf, 0); } break; } @@ -702,19 +702,19 @@ struct TimetableWindow : Window { case WID_VT_CLEAR_SPEED: { // Clear max speed button. auto [order_id, mtf] = PackTimetableArgs(v, this->sel_index, true); if (_ctrl_pressed) { - Command::Post(STR_ERROR_CAN_T_TIMETABLE_VEHICLE, v->index, mtf, UINT16_MAX); + Command::Post(STR_ERROR_CAN_T_TIMETABLE_VEHICLE, v->index, mtf, UINT16_MAX); } else { - Command::Post(STR_ERROR_CAN_T_TIMETABLE_VEHICLE, v->index, order_id, mtf, UINT16_MAX); + Command::Post(STR_ERROR_CAN_T_TIMETABLE_VEHICLE, v->index, order_id, mtf, UINT16_MAX); } break; } case WID_VT_RESET_LATENESS: // Reset the vehicle's late counter. - Command::Post(STR_ERROR_CAN_T_TIMETABLE_VEHICLE, v->index, _ctrl_pressed); + Command::Post(STR_ERROR_CAN_T_TIMETABLE_VEHICLE, v->index, _ctrl_pressed); break; case WID_VT_AUTOFILL: { // Autofill the timetable. - Command::Post(STR_ERROR_CAN_T_TIMETABLE_VEHICLE, v->index, !v->vehicle_flags.Test(VehicleFlag::AutofillTimetable), _ctrl_pressed); + Command::Post(STR_ERROR_CAN_T_TIMETABLE_VEHICLE, v->index, !v->vehicle_flags.Test(VehicleFlag::AutofillTimetable), _ctrl_pressed); break; } @@ -743,9 +743,9 @@ struct TimetableWindow : Window { val = ConvertDisplaySpeedToKmhishSpeed(val, v->type); if (this->change_timetable_all) { - Command::Post(STR_ERROR_CAN_T_TIMETABLE_VEHICLE, v->index, mtf, ClampTo(val)); + Command::Post(STR_ERROR_CAN_T_TIMETABLE_VEHICLE, v->index, mtf, ClampTo(val)); } else { - Command::Post(STR_ERROR_CAN_T_TIMETABLE_VEHICLE, v->index, order_id, mtf, ClampTo(val)); + Command::Post(STR_ERROR_CAN_T_TIMETABLE_VEHICLE, v->index, order_id, mtf, ClampTo(val)); } break; } @@ -754,15 +754,15 @@ struct TimetableWindow : Window { val *= TicksPerTimetableUnit(); if (this->change_timetable_all) { - Command::Post(STR_ERROR_CAN_T_TIMETABLE_VEHICLE, v->index, mtf, ClampTo(val)); + Command::Post(STR_ERROR_CAN_T_TIMETABLE_VEHICLE, v->index, mtf, ClampTo(val)); } else { - Command::Post(STR_ERROR_CAN_T_TIMETABLE_VEHICLE, v->index, order_id, mtf, ClampTo(val)); + Command::Post(STR_ERROR_CAN_T_TIMETABLE_VEHICLE, v->index, order_id, mtf, ClampTo(val)); } break; case WID_VT_START_DATE: { TimerGameTick::TickCounter start_tick = TimerGameTick::counter + (val * Ticks::TICKS_PER_SECOND); - Command::Post(STR_ERROR_CAN_T_TIMETABLE_VEHICLE, v->index, this->change_timetable_all, start_tick); + Command::Post(STR_ERROR_CAN_T_TIMETABLE_VEHICLE, v->index, this->change_timetable_all, start_tick); break; } diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp index d66b323eb1..316823453a 100644 --- a/src/toolbar_gui.cpp +++ b/src/toolbar_gui.cpp @@ -209,7 +209,7 @@ static CallBackFunction ToolbarPauseClick(Window *) { if (_networking && !_network_server) return CBF_NONE; // only server can pause the game - if (Command::Post(PauseMode::Normal, _pause_mode.None())) { + if (Command::Post(PauseMode::Normal, _pause_mode.None())) { SndConfirmBeep(); } return CBF_NONE; diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index 5ea4ef3291..b01774d238 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -1087,8 +1087,8 @@ static bool IsRoadAllowedHere(Town *t, TileIndex tile, DiagDirection dir) * If that fails clear the land, and if that fails exit. * This is to make sure that we can build a road here later. */ RoadType rt = GetTownRoadType(); - if (Command::Do({DoCommandFlag::Auto, DoCommandFlag::NoWater}, tile, (dir == DIAGDIR_NW || dir == DIAGDIR_SE) ? ROAD_Y : ROAD_X, rt, DRD_NONE, t->index).Failed() && - Command::Do({DoCommandFlag::Auto, DoCommandFlag::NoWater}, tile).Failed()) { + if (Command::Do({DoCommandFlag::Auto, DoCommandFlag::NoWater}, tile, (dir == DIAGDIR_NW || dir == DIAGDIR_SE) ? ROAD_Y : ROAD_X, rt, DRD_NONE, t->index).Failed() && + Command::Do({DoCommandFlag::Auto, DoCommandFlag::NoWater}, tile).Failed()) { return false; } } @@ -1105,7 +1105,7 @@ static bool IsRoadAllowedHere(Town *t, TileIndex tile, DiagDirection dir) CommandCost res = CMD_ERROR; if (!_generating_world && Chance16(1, 10)) { /* Note: Do not replace "^ SLOPE_ELEVATED" with ComplementSlope(). The slope might be steep. */ - res = std::get<0>(Command::Do({DoCommandFlag::Execute, DoCommandFlag::Auto, DoCommandFlag::NoWater}, + res = std::get<0>(Command::Do({DoCommandFlag::Execute, DoCommandFlag::Auto, DoCommandFlag::NoWater}, tile, Chance16(1, 16) ? cur_slope : cur_slope ^ SLOPE_ELEVATED, false)); } if (res.Failed() && Chance16(1, 3)) { @@ -1122,9 +1122,9 @@ static bool TerraformTownTile(TileIndex tile, Slope edges, bool dir) { assert(tile < Map::Size()); - CommandCost r = std::get<0>(Command::Do({DoCommandFlag::Auto, DoCommandFlag::NoWater}, tile, edges, dir)); + CommandCost r = std::get<0>(Command::Do({DoCommandFlag::Auto, DoCommandFlag::NoWater}, tile, edges, dir)); if (r.Failed() || r.GetCost() >= (_price[Price::Terraform] + 2) * 8) return false; - Command::Do({DoCommandFlag::Auto, DoCommandFlag::NoWater, DoCommandFlag::Execute}, tile, edges, dir); + Command::Do({DoCommandFlag::Auto, DoCommandFlag::NoWater, DoCommandFlag::Execute}, tile, edges, dir); return true; } @@ -1251,7 +1251,7 @@ static bool GrowTownWithExtraHouse(Town *t, TileIndex tile, TownExpandModes mode static bool GrowTownWithRoad(const Town *t, TileIndex tile, RoadBits rcmd) { RoadType rt = GetTownRoadType(); - return Command::Do({DoCommandFlag::Execute, DoCommandFlag::Auto, DoCommandFlag::NoWater}, tile, rcmd, rt, DRD_NONE, t->index).Succeeded(); + return Command::Do({DoCommandFlag::Execute, DoCommandFlag::Auto, DoCommandFlag::NoWater}, tile, rcmd, rt, DRD_NONE, t->index).Succeeded(); } /** @@ -1296,7 +1296,7 @@ static bool CanRoadContinueIntoNextTile(const Town *t, const TileIndex tile, con if (IsTileType(next_tile, TileType::Railway) && !_settings_game.economy.allow_town_level_crossings) return false; /* If a road tile can be built, the construction is allowed. */ - return Command::Do({DoCommandFlag::Auto, DoCommandFlag::NoWater}, next_tile, rcmd, rt, DRD_NONE, t->index).Succeeded(); + return Command::Do({DoCommandFlag::Auto, DoCommandFlag::NoWater}, next_tile, rcmd, rt, DRD_NONE, t->index).Succeeded(); } /** @@ -1379,8 +1379,8 @@ static bool GrowTownWithBridge(const Town *t, const TileIndex tile, const DiagDi /* Can we actually build the bridge? */ RoadType rt = GetTownRoadType(); - if (Command::Do(CommandFlagsToDCFlags(GetCommandFlags()), tile, bridge_tile, TRANSPORT_ROAD, bridge_type, rt).Succeeded()) { - Command::Do(CommandFlagsToDCFlags(GetCommandFlags()).Set(DoCommandFlag::Execute), tile, bridge_tile, TRANSPORT_ROAD, bridge_type, rt); + if (Command::Do(CommandFlagsToDCFlags(GetCommandFlags()), tile, bridge_tile, TRANSPORT_ROAD, bridge_type, rt).Succeeded()) { + Command::Do(CommandFlagsToDCFlags(GetCommandFlags()).Set(DoCommandFlag::Execute), tile, bridge_tile, TRANSPORT_ROAD, bridge_type, rt); return true; } } @@ -1449,8 +1449,8 @@ static bool GrowTownWithTunnel(const Town *t, const TileIndex tile, const DiagDi /* Attempt to build the tunnel. Return false if it fails to let the town build a road instead. */ RoadType rt = GetTownRoadType(); - if (Command::Do(CommandFlagsToDCFlags(GetCommandFlags()), tile, TRANSPORT_ROAD, rt).Succeeded()) { - Command::Do(CommandFlagsToDCFlags(GetCommandFlags()).Set(DoCommandFlag::Execute), tile, TRANSPORT_ROAD, rt); + if (Command::Do(CommandFlagsToDCFlags(GetCommandFlags()), tile, TRANSPORT_ROAD, rt).Succeeded()) { + Command::Do(CommandFlagsToDCFlags(GetCommandFlags()).Set(DoCommandFlag::Execute), tile, TRANSPORT_ROAD, rt); return true; } @@ -1934,9 +1934,9 @@ static bool GrowTown(Town *t, TownExpandModes modes) for (const auto &ptr : _town_coord_mod) { /* Only work with plain land that not already has a house */ if (!IsTileType(tile, TileType::House) && IsTileFlat(tile)) { - if (Command::Do({DoCommandFlag::Auto, DoCommandFlag::NoWater}, tile).Succeeded()) { + if (Command::Do({DoCommandFlag::Auto, DoCommandFlag::NoWater}, tile).Succeeded()) { RoadType rt = GetTownRoadType(); - Command::Do({DoCommandFlag::Execute, DoCommandFlag::Auto}, tile, GenRandomRoadBits(), rt, DRD_NONE, t->index); + Command::Do({DoCommandFlag::Execute, DoCommandFlag::Auto}, tile, GenRandomRoadBits(), rt, DRD_NONE, t->index); cur_company.Restore(); return true; } @@ -2385,7 +2385,7 @@ HouseZones GetClimateMaskForLandscape() */ static Town *CreateRandomTown(uint attempts, uint32_t townnameparts, TownSize size, bool city, TownLayout layout) { - assert(_game_mode == GM_EDITOR || _generating_world); // These are the preconditions for CMD_DELETE_TOWN + assert(_game_mode == GM_EDITOR || _generating_world); // These are the preconditions for Commands::DeleteTown if (!Town::CanAllocateItem()) return nullptr; @@ -2410,7 +2410,7 @@ static Town *CreateRandomTown(uint attempts, uint32_t townnameparts, TownSize si if (t->cache.population > 0) return t; Backup cur_company(_current_company, OWNER_TOWN); - [[maybe_unused]] CommandCost rc = Command::Do(DoCommandFlag::Execute, t->index); + [[maybe_unused]] CommandCost rc = Command::Do(DoCommandFlag::Execute, t->index); cur_company.Restore(); assert(rc.Succeeded()); @@ -2540,7 +2540,7 @@ HouseZone GetTownRadiusGroup(const Town *t, TileIndex tile) */ static inline void ClearMakeHouseTile(TileIndex tile, Town *t, uint8_t counter, uint8_t stage, HouseID type, uint8_t random_bits, bool is_protected) { - [[maybe_unused]] CommandCost cc = Command::Do({DoCommandFlag::Execute, DoCommandFlag::Auto, DoCommandFlag::NoWater}, tile); + [[maybe_unused]] CommandCost cc = Command::Do({DoCommandFlag::Execute, DoCommandFlag::Auto, DoCommandFlag::NoWater}, tile); assert(cc.Succeeded()); IncreaseBuildingCount(t, type); @@ -2597,7 +2597,7 @@ static inline bool CanBuildHouseHere(TileIndex tile, bool noslope) if (IsBridgeAbove(tile)) return false; /* can we clear the land? */ - return Command::Do({DoCommandFlag::Auto, DoCommandFlag::NoWater}, tile).Succeeded(); + return Command::Do({DoCommandFlag::Auto, DoCommandFlag::NoWater}, tile).Succeeded(); } @@ -2979,7 +2979,7 @@ CommandCost CmdPlaceHouse(DoCommandFlags flags, TileIndex tile, HouseID house, b /* We might be replacing an existing house, otherwise check if we can clear land. */ if (!(replace && GetTileType(subtile) == TileType::House)) { - CommandCost cost = Command::Do({DoCommandFlag::Auto, DoCommandFlag::NoWater}, subtile); + CommandCost cost = Command::Do({DoCommandFlag::Auto, DoCommandFlag::NoWater}, subtile); if (!cost.Succeeded()) return cost; } } @@ -3036,7 +3036,7 @@ CommandCost CmdPlaceHouseArea(DoCommandFlags flags, TileIndex tile, TileIndex st std::unique_ptr iter = TileIterator::Create(tile, start_tile, diagonal); for (; *iter != INVALID_TILE; ++(*iter)) { TileIndex t = *iter; - CommandCost ret = Command::Do(DoCommandFlags{flags}.Reset(DoCommandFlag::Execute), t, house, is_protected, replace); + CommandCost ret = Command::Do(DoCommandFlags{flags}.Reset(DoCommandFlag::Execute), t, house, is_protected, replace); /* If we've reached the limit, stop building (or testing). */ if (c != nullptr && limit-- <= 0) break; @@ -3046,7 +3046,7 @@ CommandCost CmdPlaceHouseArea(DoCommandFlags flags, TileIndex tile, TileIndex st continue; } - if (flags.Test(DoCommandFlag::Execute)) Command::Do(flags, t, house, is_protected, replace); + if (flags.Test(DoCommandFlag::Execute)) Command::Do(flags, t, house, is_protected, replace); had_success = true; } @@ -3357,7 +3357,7 @@ CommandCost CmdDeleteTown(DoCommandFlags flags, TownID town_id) /* Non-oil rig stations are always a problem. */ if (!st->facilities.Test(StationFacility::Airport) || st->airport.type != AT_OILRIG) return CMD_ERROR; /* We can only automatically delete oil rigs *if* there's no vehicle on them. */ - CommandCost ret = Command::Do(flags, st->airport.tile); + CommandCost ret = Command::Do(flags, st->airport.tile); if (ret.Failed()) return ret; } } @@ -3378,7 +3378,7 @@ CommandCost CmdDeleteTown(DoCommandFlags flags, TownID town_id) * tile was already deleted earlier in the loop. */ for (const auto current_tile : Map::Iterate()) { if (IsTileType(current_tile, TileType::TunnelBridge) && TestTownOwnsBridge(current_tile, t)) { - CommandCost ret = Command::Do(flags, current_tile); + CommandCost ret = Command::Do(flags, current_tile); if (ret.Failed()) return ret; } } @@ -3421,7 +3421,7 @@ CommandCost CmdDeleteTown(DoCommandFlags flags, TownID town_id) break; } if (try_clear) { - CommandCost ret = Command::Do(flags, current_tile); + CommandCost ret = Command::Do(flags, current_tile); if (ret.Failed()) return ret; } } @@ -3531,7 +3531,7 @@ static CommandCost TownActionRoadRebuild(Town *t, DoCommandFlags flags) static bool CheckClearTile(TileIndex tile) { Backup cur_company(_current_company, OWNER_NONE); - CommandCost r = Command::Do({}, tile); + CommandCost r = Command::Do({}, tile); cur_company.Restore(); return r.Succeeded(); } @@ -3587,7 +3587,7 @@ static CommandCost TownActionBuildStatue(Town *t, DoCommandFlags flags) if (flags.Test(DoCommandFlag::Execute)) { Backup cur_company(_current_company, OWNER_NONE); - Command::Do(DoCommandFlag::Execute, best_position); + Command::Do(DoCommandFlag::Execute, best_position); cur_company.Restore(); BuildObject(OBJECT_STATUE, best_position, _current_company, t); t->statues.Set(_current_company); // Once found and built, "inform" the Town. @@ -4229,7 +4229,7 @@ static CommandCost TerraformTile_Town(TileIndex tile, DoCommandFlags flags, int } } - return Command::Do(flags, tile); + return Command::Do(flags, tile); } /** Tile callback functions for a town */ diff --git a/src/town_cmd.h b/src/town_cmd.h index f990f8385b..955841b6c8 100644 --- a/src/town_cmd.h +++ b/src/town_cmd.h @@ -30,17 +30,17 @@ CommandCost CmdDeleteTown(DoCommandFlags flags, TownID town_id); CommandCost CmdPlaceHouse(DoCommandFlags flags, TileIndex tile, HouseID house, bool house_protected, bool replace); CommandCost CmdPlaceHouseArea(DoCommandFlags flags, TileIndex tile, TileIndex start_tile, HouseID house, bool is_protected, bool replace, bool diagonal); -DEF_CMD_TRAIT(CMD_FOUND_TOWN, CmdFoundTown, CommandFlags({CommandFlag::Deity, CommandFlag::NoTest}), CommandType::LandscapeConstruction) // founding random town can fail only in exec run -DEF_CMD_TRAIT(CMD_RENAME_TOWN, CmdRenameTown, CommandFlags({CommandFlag::Deity, CommandFlag::Server}), CommandType::OtherManagement) -DEF_CMD_TRAIT(CMD_DO_TOWN_ACTION, CmdDoTownAction, CommandFlags({CommandFlag::Location}), CommandType::LandscapeConstruction) -DEF_CMD_TRAIT(CMD_TOWN_CARGO_GOAL, CmdTownCargoGoal, CommandFlags({CommandFlag::Deity}), CommandType::OtherManagement) -DEF_CMD_TRAIT(CMD_TOWN_GROWTH_RATE, CmdTownGrowthRate, CommandFlags({CommandFlag::Deity}), CommandType::OtherManagement) -DEF_CMD_TRAIT(CMD_TOWN_RATING, CmdTownRating, CommandFlags({CommandFlag::Deity}), CommandType::OtherManagement) -DEF_CMD_TRAIT(CMD_TOWN_SET_TEXT, CmdTownSetText, CommandFlags({CommandFlag::Deity, CommandFlag::StrCtrl}), CommandType::OtherManagement) -DEF_CMD_TRAIT(CMD_EXPAND_TOWN, CmdExpandTown, CommandFlags({CommandFlag::Deity}), CommandType::LandscapeConstruction) -DEF_CMD_TRAIT(CMD_DELETE_TOWN, CmdDeleteTown, CommandFlags({CommandFlag::Offline}), CommandType::LandscapeConstruction) -DEF_CMD_TRAIT(CMD_PLACE_HOUSE, CmdPlaceHouse, CommandFlags({CommandFlag::Deity}), CommandType::OtherManagement) -DEF_CMD_TRAIT(CMD_PLACE_HOUSE_AREA, CmdPlaceHouseArea, CommandFlags({ CommandFlag::Deity }), CommandType::OtherManagement) +DEF_CMD_TRAIT(Commands::FoundTown, CmdFoundTown, CommandFlags({CommandFlag::Deity, CommandFlag::NoTest}), CommandType::LandscapeConstruction) // founding random town can fail only in exec run +DEF_CMD_TRAIT(Commands::RenameTown, CmdRenameTown, CommandFlags({CommandFlag::Deity, CommandFlag::Server}), CommandType::OtherManagement) +DEF_CMD_TRAIT(Commands::TownAction, CmdDoTownAction, CommandFlags({CommandFlag::Location}), CommandType::LandscapeConstruction) +DEF_CMD_TRAIT(Commands::TownCargoGoal, CmdTownCargoGoal, CommandFlags({CommandFlag::Deity}), CommandType::OtherManagement) +DEF_CMD_TRAIT(Commands::TownGrowthRate, CmdTownGrowthRate, CommandFlags({CommandFlag::Deity}), CommandType::OtherManagement) +DEF_CMD_TRAIT(Commands::TownRating, CmdTownRating, CommandFlags({CommandFlag::Deity}), CommandType::OtherManagement) +DEF_CMD_TRAIT(Commands::TownSetText, CmdTownSetText, CommandFlags({CommandFlag::Deity, CommandFlag::StrCtrl}), CommandType::OtherManagement) +DEF_CMD_TRAIT(Commands::ExpandTown, CmdExpandTown, CommandFlags({CommandFlag::Deity}), CommandType::LandscapeConstruction) +DEF_CMD_TRAIT(Commands::DeleteTown, CmdDeleteTown, CommandFlags({CommandFlag::Offline}), CommandType::LandscapeConstruction) +DEF_CMD_TRAIT(Commands::PlaceHouse, CmdPlaceHouse, CommandFlags({CommandFlag::Deity}), CommandType::OtherManagement) +DEF_CMD_TRAIT(Commands::PlaceHouseArea, CmdPlaceHouseArea, CommandFlags({ CommandFlag::Deity }), CommandType::OtherManagement) CommandCallback CcFoundTown; diff --git a/src/town_gui.cpp b/src/town_gui.cpp index 9005e5191e..35e47dc9ab 100644 --- a/src/town_gui.cpp +++ b/src/town_gui.cpp @@ -309,7 +309,7 @@ public: } case WID_TA_EXECUTE: - Command::Post(STR_ERROR_CAN_T_DO_THIS, this->town->xy, static_cast(this->window_number), this->sel_action); + Command::Post(STR_ERROR_CAN_T_DO_THIS, this->town->xy, static_cast(this->window_number), this->sel_action); break; } } @@ -496,19 +496,19 @@ public: break; case WID_TV_EXPAND: // expand town - only available on Scenario editor - Command::Post(STR_ERROR_CAN_T_EXPAND_TOWN, static_cast(this->window_number), 0, {TownExpandMode::Buildings, TownExpandMode::Roads}); + Command::Post(STR_ERROR_CAN_T_EXPAND_TOWN, static_cast(this->window_number), 0, {TownExpandMode::Buildings, TownExpandMode::Roads}); break; case WID_TV_EXPAND_BUILDINGS: // expand buildings of town - only available on Scenario editor - Command::Post(STR_ERROR_CAN_T_EXPAND_TOWN, static_cast(this->window_number), 0, {TownExpandMode::Buildings}); + Command::Post(STR_ERROR_CAN_T_EXPAND_TOWN, static_cast(this->window_number), 0, {TownExpandMode::Buildings}); break; case WID_TV_EXPAND_ROADS: // expand roads of town - only available on Scenario editor - Command::Post(STR_ERROR_CAN_T_EXPAND_TOWN, static_cast(this->window_number), 0, {TownExpandMode::Roads}); + Command::Post(STR_ERROR_CAN_T_EXPAND_TOWN, static_cast(this->window_number), 0, {TownExpandMode::Roads}); break; case WID_TV_DELETE: // delete town - only available on Scenario editor - Command::Post(STR_ERROR_TOWN_CAN_T_DELETE, static_cast(this->window_number)); + Command::Post(STR_ERROR_TOWN_CAN_T_DELETE, static_cast(this->window_number)); break; case WID_TV_GRAPH: { @@ -602,7 +602,7 @@ public: { if (!str.has_value()) return; - Command::Post(STR_ERROR_CAN_T_RENAME_TOWN, static_cast(this->window_number), *str); + Command::Post(STR_ERROR_CAN_T_RENAME_TOWN, static_cast(this->window_number), *str); } const IntervalTimer daily_interval = {{TimerGameCalendar::DAY, TimerGameCalendar::Priority::NONE}, [this](auto) { @@ -1230,7 +1230,7 @@ public: if (original_name != this->townname_editbox.text.GetText()) name = this->townname_editbox.text.GetText(); } - bool success = Command::Post(errstr, cc, + bool success = Command::Post(errstr, cc, tile, this->town_size, this->city, this->town_layout, random, townnameparts, name); /* Rerandomise name, if success and no cost-estimation. */ @@ -1264,7 +1264,7 @@ public: case WID_TF_EXPAND_ALL_TOWNS: for (Town *t : Town::Iterate()) { - Command::Do(DoCommandFlag::Execute, t->index, 0, FoundTownWindow::expand_modes); + Command::Do(DoCommandFlag::Execute, t->index, 0, FoundTownWindow::expand_modes); } break; @@ -1810,7 +1810,7 @@ struct BuildHouseWindow : public PickerWindow { if (spec->building_flags.Test(BuildingFlag::Size1x1)) { VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_PLACE_HOUSE); } else { - Command::Post(STR_ERROR_CAN_T_BUILD_HOUSE, CcPlaySound_CONSTRUCTION_OTHER, tile, spec->Index(), BuildHouseWindow::house_protected, BuildHouseWindow::replace); + Command::Post(STR_ERROR_CAN_T_BUILD_HOUSE, CcPlaySound_CONSTRUCTION_OTHER, tile, spec->Index(), BuildHouseWindow::house_protected, BuildHouseWindow::replace); } } @@ -1826,7 +1826,7 @@ struct BuildHouseWindow : public PickerWindow { assert(select_proc == DDSP_PLACE_HOUSE); const HouseSpec *spec = HouseSpec::Get(HousePickerCallbacks::sel_type); - Command::Post(STR_ERROR_CAN_T_BUILD_HOUSE, CcPlaySound_CONSTRUCTION_OTHER, + Command::Post(STR_ERROR_CAN_T_BUILD_HOUSE, CcPlaySound_CONSTRUCTION_OTHER, end_tile, start_tile, spec->Index(), BuildHouseWindow::house_protected, BuildHouseWindow::replace, _ctrl_pressed); } diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index d24018228a..2701d4e585 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -87,7 +87,7 @@ void CheckTrainsLengths() if (!_networking && first) { first = false; - Command::Post(PauseMode::Error, true); + Command::Post(PauseMode::Error, true); } /* Break so we warn only once for each train. */ break; @@ -704,7 +704,7 @@ static CommandCost CmdBuildRailWagon(DoCommandFlags flags, TileIndex tile, const if (w->engine_type != v->engine_type) continue; ///< Must be same type if (w->First() == v) continue; ///< Don't connect to ourself - if (Command::Do(DoCommandFlag::Execute, v->index, w->Last()->index, true).Succeeded()) { + if (Command::Do(DoCommandFlag::Execute, v->index, w->Last()->index, true).Succeeded()) { break; } } @@ -718,7 +718,7 @@ void NormalizeTrainVehInDepot(const Train *u) { assert(u->IsEngine()); for (VehicleID vehicle : GetFreeWagonsInDepot(u->tile)) { - if (Command::Do(DoCommandFlag::Execute, vehicle, u->index, true).Failed()) { + if (Command::Do(DoCommandFlag::Execute, vehicle, u->index, true).Failed()) { break; } } diff --git a/src/train_cmd.h b/src/train_cmd.h index 341ddbcad5..b503d297c5 100644 --- a/src/train_cmd.h +++ b/src/train_cmd.h @@ -22,9 +22,9 @@ CommandCost CmdMoveRailVehicle(DoCommandFlags flags, VehicleID src_veh, VehicleI CommandCost CmdForceTrainProceed(DoCommandFlags flags, VehicleID veh_id); CommandCost CmdReverseTrainDirection(DoCommandFlags flags, VehicleID veh_id, bool reverse_single_veh); -DEF_CMD_TRAIT(CMD_MOVE_RAIL_VEHICLE, CmdMoveRailVehicle, CommandFlag::Location, CommandType::VehicleConstruction) -DEF_CMD_TRAIT(CMD_FORCE_TRAIN_PROCEED, CmdForceTrainProceed, CommandFlag::Location, CommandType::VehicleManagement) -DEF_CMD_TRAIT(CMD_REVERSE_TRAIN_DIRECTION, CmdReverseTrainDirection, CommandFlag::Location, CommandType::VehicleManagement) +DEF_CMD_TRAIT(Commands::MoveRailVehicle, CmdMoveRailVehicle, CommandFlag::Location, CommandType::VehicleConstruction) +DEF_CMD_TRAIT(Commands::ForceTrainProceed, CmdForceTrainProceed, CommandFlag::Location, CommandType::VehicleManagement) +DEF_CMD_TRAIT(Commands::ReverseTrainDirection, CmdReverseTrainDirection, CommandFlag::Location, CommandType::VehicleManagement) void CcBuildWagon(Commands cmd, const CommandCost &result, VehicleID new_veh_id, uint, uint16_t, CargoArray, TileIndex tile, EngineID, bool, CargoType, ClientID); diff --git a/src/train_gui.cpp b/src/train_gui.cpp index 83a27e2f3c..8ce192dcfa 100644 --- a/src/train_gui.cpp +++ b/src/train_gui.cpp @@ -48,7 +48,7 @@ void CcBuildWagon(Commands, const CommandCost &result, VehicleID new_veh_id, uin if (found != nullptr) { found = found->Last(); /* put the new wagon at the end of the loco. */ - Command::Post(found->tile, new_veh_id, found->index, false); + Command::Post(found->tile, new_veh_id, found->index, false); InvalidateWindowClassesData(WC_TRAINS_LIST, 0); } } diff --git a/src/tree_cmd.cpp b/src/tree_cmd.cpp index 818751bee5..8609edc002 100644 --- a/src/tree_cmd.cpp +++ b/src/tree_cmd.cpp @@ -576,7 +576,7 @@ CommandCost CmdPlantTree(DoCommandFlags flags, TileIndex tile, TileIndex start_t switch (GetClearGround(current_tile)) { case CLEAR_FIELDS: case CLEAR_ROCKS: { - CommandCost ret = Command::Do(flags, current_tile); + CommandCost ret = Command::Do(flags, current_tile); if (ret.Failed()) return ret; cost.AddCost(ret.GetCost()); break; @@ -1021,7 +1021,7 @@ void InitializeTrees() static CommandCost TerraformTile_Trees(TileIndex tile, DoCommandFlags flags, int, Slope) { - return Command::Do(flags, tile); + return Command::Do(flags, tile); } diff --git a/src/tree_cmd.h b/src/tree_cmd.h index a019c08579..563952878b 100644 --- a/src/tree_cmd.h +++ b/src/tree_cmd.h @@ -16,6 +16,6 @@ void PlaceTree(TileIndex tile, uint32_t r, bool keep_density = false); CommandCost CmdPlantTree(DoCommandFlags flags, TileIndex tile, TileIndex start_tile, uint8_t tree_to_plant, bool diagonal); -DEF_CMD_TRAIT(CMD_PLANT_TREE, CmdPlantTree, CommandFlag::Auto, CommandType::LandscapeConstruction) +DEF_CMD_TRAIT(Commands::PlantTree, CmdPlantTree, CommandFlag::Auto, CommandType::LandscapeConstruction) #endif /* TREE_CMD_H */ diff --git a/src/tree_gui.cpp b/src/tree_gui.cpp index 29dd6bd6a5..23f4d711ee 100644 --- a/src/tree_gui.cpp +++ b/src/tree_gui.cpp @@ -229,7 +229,7 @@ public: TileIndex tile = TileVirtXY(pt.x, pt.y); if (this->mode == PM_NORMAL) { - Command::Post(tile, tile, this->tree_to_plant, false); + Command::Post(tile, tile, this->tree_to_plant, false); } else { this->DoPlantForest(tile); } @@ -239,7 +239,7 @@ public: void OnPlaceMouseUp([[maybe_unused]] ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, [[maybe_unused]] Point pt, TileIndex start_tile, TileIndex end_tile) override { if (_game_mode != GM_EDITOR && this->mode == PM_NORMAL && pt.x != -1 && select_proc == DDSP_PLANT_TREES) { - Command::Post(STR_ERROR_CAN_T_PLANT_TREE_HERE, end_tile, start_tile, this->tree_to_plant, _ctrl_pressed); + Command::Post(STR_ERROR_CAN_T_PLANT_TREE_HERE, end_tile, start_tile, this->tree_to_plant, _ctrl_pressed); } } diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp index 03218e900d..10ef8d4295 100644 --- a/src/tunnelbridge_cmd.cpp +++ b/src/tunnelbridge_cmd.cpp @@ -293,7 +293,7 @@ static CommandCost CheckBuildAbove(TileIndex tile, DoCommandFlags flags, Axis ax return _tile_type_procs[GetTileType(tile)]->check_build_above_proc(tile, flags, axis, height); } /* A tile without a handler must be cleared. */ - return Command::Do(flags, tile); + return Command::Do(flags, tile); } /** @@ -471,7 +471,7 @@ CommandCost CmdBuildBridge(DoCommandFlags flags, TileIndex tile_end, TileIndex t bool allow_on_slopes = (_settings_game.construction.build_on_slopes && transport_type != TRANSPORT_WATER); /* Try and clear the start landscape */ - CommandCost ret = Command::Do(flags, tile_start); + CommandCost ret = Command::Do(flags, tile_start); if (ret.Failed()) return ret; cost = ret; @@ -479,7 +479,7 @@ CommandCost CmdBuildBridge(DoCommandFlags flags, TileIndex tile_end, TileIndex t cost.AddCost(terraform_cost_north.GetCost()); /* Try and clear the end landscape */ - ret = Command::Do(flags, tile_end); + ret = Command::Do(flags, tile_end); if (ret.Failed()) return ret; cost.AddCost(ret.GetCost()); @@ -682,7 +682,7 @@ CommandCost CmdBuildTunnel(DoCommandFlags flags, TileIndex start_tile, Transport if (HasTileWaterGround(start_tile)) return CommandCost(STR_ERROR_CAN_T_BUILD_ON_WATER); - CommandCost ret = Command::Do(flags, start_tile); + CommandCost ret = Command::Do(flags, start_tile); if (ret.Failed()) return ret; /* XXX - do NOT change 'ret' in the loop, as it is used as the price @@ -743,7 +743,7 @@ CommandCost CmdBuildTunnel(DoCommandFlags flags, TileIndex start_tile, Transport if (HasTileWaterGround(end_tile)) return CommandCost(STR_ERROR_CAN_T_BUILD_ON_WATER); /* Clear the tile in any case */ - ret = Command::Do(flags, end_tile); + ret = Command::Do(flags, end_tile); if (ret.Failed()) return CommandCost(STR_ERROR_UNABLE_TO_EXCAVATE_LAND); cost.AddCost(ret.GetCost()); @@ -760,12 +760,12 @@ CommandCost CmdBuildTunnel(DoCommandFlags flags, TileIndex start_tile, Transport TileIndex old_first_tile = coa->first_tile; coa->first_tile = INVALID_TILE; - /* CMD_TERRAFORM_LAND may append further items to _cleared_object_areas, + /* Commands::TerraformLand may append further items to _cleared_object_areas, * however it will never erase or re-order existing items. * _cleared_object_areas is a value-type self-resizing vector, therefore appending items * may result in a backing-store re-allocation, which would invalidate the coa pointer. * The index of the coa pointer into the _cleared_object_areas vector remains valid, - * and can be used safely after the CMD_TERRAFORM_LAND operation. + * and can be used safely after the Commands::TerraformLand operation. * Deliberately clear the coa pointer to avoid leaving dangling pointers which could * inadvertently be dereferenced. */ @@ -775,7 +775,7 @@ CommandCost CmdBuildTunnel(DoCommandFlags flags, TileIndex start_tile, Transport assert(coa_index < UINT_MAX); // more than 2**32 cleared areas would be a bug in itself coa = nullptr; - ret = std::get<0>(Command::Do(flags, end_tile, end_tileh & start_tileh, false)); + ret = std::get<0>(Command::Do(flags, end_tile, end_tileh & start_tileh, false)); _cleared_object_areas[(uint)coa_index].first_tile = old_first_tile; if (ret.Failed()) return CommandCost(STR_ERROR_UNABLE_TO_EXCAVATE_LAND); cost.AddCost(ret.GetCost()); @@ -1910,7 +1910,7 @@ static void ChangeTileOwner_TunnelBridge(TileIndex tile, Owner old_owner, Owner if (tt == TRANSPORT_RAIL) { /* Since all of our vehicles have been removed, it is safe to remove the rail * bridge / tunnel. */ - [[maybe_unused]] CommandCost ret = Command::Do({DoCommandFlag::Execute, DoCommandFlag::Bankrupt}, tile); + [[maybe_unused]] CommandCost ret = Command::Do({DoCommandFlag::Execute, DoCommandFlag::Bankrupt}, tile); assert(ret.Succeeded()); } else { /* In any other case, we can safely reassign the ownership to OWNER_NONE. */ @@ -2120,7 +2120,7 @@ static CommandCost TerraformTile_TunnelBridge(TileIndex tile, DoCommandFlags fla if (res.Succeeded() && (z_old == z_new) && (tileh_old == tileh_new)) return CommandCost(EXPENSES_CONSTRUCTION, _price[Price::BuildFoundation]); } - return Command::Do(flags, tile); + return Command::Do(flags, tile); } static CommandCost CheckBuildAbove_TunnelBridge(TileIndex tile, DoCommandFlags flags, Axis axis, int height) @@ -2131,7 +2131,7 @@ static CommandCost CheckBuildAbove_TunnelBridge(TileIndex tile, DoCommandFlags f return CommandCost(); } - return Command::Do(flags, tile); + return Command::Do(flags, tile); } extern const TileTypeProcs _tile_type_tunnelbridge_procs = { diff --git a/src/tunnelbridge_cmd.h b/src/tunnelbridge_cmd.h index 9f76184229..9793de9302 100644 --- a/src/tunnelbridge_cmd.h +++ b/src/tunnelbridge_cmd.h @@ -17,8 +17,8 @@ CommandCost CmdBuildBridge(DoCommandFlags flags, TileIndex tile_end, TileIndex tile_start, TransportType transport_type, BridgeType bridge_type, uint8_t road_rail_type); CommandCost CmdBuildTunnel(DoCommandFlags flags, TileIndex start_tile, TransportType transport_type, uint8_t road_rail_type); -DEF_CMD_TRAIT(CMD_BUILD_BRIDGE, CmdBuildBridge, CommandFlags({CommandFlag::Deity, CommandFlag::Auto, CommandFlag::NoWater}), CommandType::LandscapeConstruction) -DEF_CMD_TRAIT(CMD_BUILD_TUNNEL, CmdBuildTunnel, CommandFlags({CommandFlag::Deity, CommandFlag::Auto}), CommandType::LandscapeConstruction) +DEF_CMD_TRAIT(Commands::BuildBridge, CmdBuildBridge, CommandFlags({CommandFlag::Deity, CommandFlag::Auto, CommandFlag::NoWater}), CommandType::LandscapeConstruction) +DEF_CMD_TRAIT(Commands::BuildTunnel, CmdBuildTunnel, CommandFlags({CommandFlag::Deity, CommandFlag::Auto}), CommandType::LandscapeConstruction) void CcBuildBridge(Commands cmd, const CommandCost &result, TileIndex end_tile, TileIndex tile_start, TransportType transport_type, BridgeType, uint8_t); diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 661ac61445..6d51348257 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -337,7 +337,7 @@ void ShowNewGrfVehicleError(EngineID engine, StringID part1, StringID part2, GRF grfconfig->grf_bugs.Set(bug_type); ShowErrorMessage(GetEncodedString(part1, grfconfig->GetName()), GetEncodedString(part2, std::monostate{}, engine), WL_CRITICAL); - if (!_networking) Command::Do(DoCommandFlag::Execute, critical ? PauseMode::Error : PauseMode::Normal, true); + if (!_networking) Command::Do(DoCommandFlag::Execute, critical ? PauseMode::Error : PauseMode::Normal, true); } /* debug output */ @@ -1058,7 +1058,7 @@ void CallVehicleTicks() const Company *c = Company::Get(_current_company); SubtractMoneyFromCompany(_current_company, CommandCost(EXPENSES_NEW_VEHICLES, (Money)c->settings.engine_renew_money)); - CommandCost res = Command::Do(DoCommandFlag::Execute, v->index); + CommandCost res = Command::Do(DoCommandFlag::Execute, v->index); SubtractMoneyFromCompany(_current_company, CommandCost(EXPENSES_NEW_VEHICLES, -(Money)c->settings.engine_renew_money)); if (!IsLocalCompany()) continue; @@ -1609,7 +1609,7 @@ void VehicleEnterDepot(Vehicle *v) if (v->current_order.IsRefit()) { Backup cur_company(_current_company, v->owner); - CommandCost cost = std::get<0>(Command::Do(DoCommandFlag::Execute, v->index, v->current_order.GetRefitCargo(), 0xFF, false, false, 0)); + CommandCost cost = std::get<0>(Command::Do(DoCommandFlag::Execute, v->index, v->current_order.GetRefitCargo(), 0xFF, false, false, 0)); cur_company.Restore(); if (cost.Failed()) { @@ -2625,7 +2625,7 @@ CommandCost Vehicle::SendToDepot(DoCommandFlags flags, DepotCommandFlags command /* If there is no depot in front and the train is not already reversing, reverse automatically (trains only) */ if (this->type == VEH_TRAIN && (closest_depot.reverse ^ Train::From(this)->flags.Test(VehicleRailFlag::Reversing))) { - Command::Do(DoCommandFlag::Execute, this->index, false); + Command::Do(DoCommandFlag::Execute, this->index, false); } if (this->type == VEH_AIRCRAFT) { diff --git a/src/vehicle_cmd.cpp b/src/vehicle_cmd.cpp index 39bdf57ac4..f579ddcf35 100644 --- a/src/vehicle_cmd.cpp +++ b/src/vehicle_cmd.cpp @@ -214,7 +214,7 @@ std::tuple CmdBuildVehicle(D /* If we are not in DoCommandFlag::Execute undo everything */ if (flags != subflags) { - Command::Do(DoCommandFlag::Execute, v->index, false, false, INVALID_CLIENT_ID); + Command::Do(DoCommandFlag::Execute, v->index, false, false, INVALID_CLIENT_ID); } } @@ -684,7 +684,7 @@ CommandCost CmdMassStartStopVehicle(DoCommandFlags flags, TileIndex tile, bool d if (!vehicle_list_window && !v->IsChainInDepot()) continue; /* Just try and don't care if some vehicle's can't be stopped. */ - Command::Do(flags, v->index, false); + Command::Do(flags, v->index, false); } return CommandCost(); @@ -712,7 +712,7 @@ CommandCost CmdDepotSellAllVehicles(DoCommandFlags flags, TileIndex tile, Vehicl CommandCost last_error = CMD_ERROR; bool had_success = false; for (const Vehicle *v : list) { - CommandCost ret = Command::Do(flags, v->index, true, false, INVALID_CLIENT_ID); + CommandCost ret = Command::Do(flags, v->index, true, false, INVALID_CLIENT_ID); if (ret.Succeeded()) { cost.AddCost(ret.GetCost()); had_success = true; @@ -746,7 +746,7 @@ CommandCost CmdDepotMassAutoReplace(DoCommandFlags flags, TileIndex tile, Vehicl /* Ensure that the vehicle completely in the depot */ if (!v->IsChainInDepot()) continue; - CommandCost ret = Command::Do(flags, v->index); + CommandCost ret = Command::Do(flags, v->index); if (ret.Succeeded()) cost.AddCost(ret.GetCost()); } @@ -883,11 +883,11 @@ std::tuple CmdCloneVehicle(DoCommandFlags flags, TileInd if (flags.Test(DoCommandFlag::Execute) && !v->IsPrimaryVehicle()) build_flags.Set(DoCommandFlag::AutoReplace); CommandCost cost; - std::tie(cost, new_veh_id, std::ignore, std::ignore, std::ignore) = Command::Do(build_flags, tile, v->engine_type, false, INVALID_CARGO, INVALID_CLIENT_ID); + std::tie(cost, new_veh_id, std::ignore, std::ignore, std::ignore) = Command::Do(build_flags, tile, v->engine_type, false, INVALID_CARGO, INVALID_CLIENT_ID); if (cost.Failed()) { /* Can't build a part, then sell the stuff we already made; clear up the mess */ - if (w_front != nullptr) Command::Do(flags, w_front->index, true, false, INVALID_CLIENT_ID); + if (w_front != nullptr) Command::Do(flags, w_front->index, true, false, INVALID_CLIENT_ID); return { cost, VehicleID::Invalid() }; } @@ -907,13 +907,13 @@ std::tuple CmdCloneVehicle(DoCommandFlags flags, TileInd if (v->type == VEH_TRAIN && !v->IsFrontEngine()) { /* this s a train car * add this unit to the end of the train */ - CommandCost result = Command::Do(flags, w->index, w_rear->index, true); + CommandCost result = Command::Do(flags, w->index, w_rear->index, true); if (result.Failed()) { /* The train can't be joined to make the same consist as the original. * Sell what we already made (clean up) and return an error. */ - Command::Do(flags, w_front->index, true, false, INVALID_CLIENT_ID); - Command::Do(flags, w->index, true, false, INVALID_CLIENT_ID); - return { result, VehicleID::Invalid() }; // return error and the message returned from CMD_MOVE_RAIL_VEHICLE + Command::Do(flags, w_front->index, true, false, INVALID_CLIENT_ID); + Command::Do(flags, w->index, true, false, INVALID_CLIENT_ID); + return { result, VehicleID::Invalid() }; // return error and the message returned from Commands::MoveRailVehicle } } else { /* this is a front engine or not a train. */ @@ -933,7 +933,7 @@ std::tuple CmdCloneVehicle(DoCommandFlags flags, TileInd if (flags.Test(DoCommandFlag::Execute)) { /* Cloned vehicles belong to the same group */ - Command::Do(flags, v_front->group_id, w_front->index, false, VehicleListIdentifier{}); + Command::Do(flags, v_front->group_id, w_front->index, false, VehicleListIdentifier{}); } @@ -955,7 +955,7 @@ std::tuple CmdCloneVehicle(DoCommandFlags flags, TileInd /* Find out what's the best sub type */ uint8_t subtype = GetBestFittingSubType(v, w, v->cargo_type); if (w->cargo_type != v->cargo_type || w->cargo_subtype != subtype) { - CommandCost cost = std::get<0>(Command::Do(flags, w->index, v->cargo_type, subtype, false, true, 0)); + CommandCost cost = std::get<0>(Command::Do(flags, w->index, v->cargo_type, subtype, false, true, 0)); if (cost.Succeeded()) total_cost.AddCost(cost.GetCost()); } @@ -990,10 +990,10 @@ std::tuple CmdCloneVehicle(DoCommandFlags flags, TileInd * the vehicle refitted before doing this, otherwise the moved * cargo types might not match (passenger vs non-passenger) */ - CommandCost result = Command::Do(flags, (share_orders ? CO_SHARE : CO_COPY), w_front->index, v_front->index); + CommandCost result = Command::Do(flags, (share_orders ? CO_SHARE : CO_COPY), w_front->index, v_front->index); if (result.Failed()) { /* The vehicle has already been bought, so now it must be sold again. */ - Command::Do(flags, w_front->index, true, false, INVALID_CLIENT_ID); + Command::Do(flags, w_front->index, true, false, INVALID_CLIENT_ID); return { result, VehicleID::Invalid() }; } @@ -1004,7 +1004,7 @@ std::tuple CmdCloneVehicle(DoCommandFlags flags, TileInd * check whether the company has enough money manually. */ if (!CheckCompanyHasMoney(total_cost)) { /* The vehicle has already been bought, so now it must be sold again. */ - Command::Do(flags, w_front->index, true, false, INVALID_CLIENT_ID); + Command::Do(flags, w_front->index, true, false, INVALID_CLIENT_ID); return { total_cost, VehicleID::Invalid() }; } } @@ -1029,7 +1029,7 @@ static CommandCost SendAllVehiclesToDepot(DoCommandFlags flags, bool service, co bool had_success = false; for (uint i = 0; i < list.size(); i++) { const Vehicle *v = list[i]; - CommandCost ret = Command::Do(flags, v->index, (service ? DepotCommandFlag::Service : DepotCommandFlags{}) | DepotCommandFlag::DontCancel, {}); + CommandCost ret = Command::Do(flags, v->index, (service ? DepotCommandFlag::Service : DepotCommandFlags{}) | DepotCommandFlag::DontCancel, {}); if (ret.Succeeded()) { had_success = true; diff --git a/src/vehicle_cmd.h b/src/vehicle_cmd.h index f0d1e52d2f..406396168e 100644 --- a/src/vehicle_cmd.h +++ b/src/vehicle_cmd.h @@ -29,17 +29,17 @@ CommandCost CmdMassStartStopVehicle(DoCommandFlags flags, TileIndex tile, bool d CommandCost CmdDepotSellAllVehicles(DoCommandFlags flags, TileIndex tile, VehicleType vehicle_type); CommandCost CmdDepotMassAutoReplace(DoCommandFlags flags, TileIndex tile, VehicleType vehicle_type); -DEF_CMD_TRAIT(CMD_BUILD_VEHICLE, CmdBuildVehicle, CommandFlag::ClientID, CommandType::VehicleConstruction) -DEF_CMD_TRAIT(CMD_SELL_VEHICLE, CmdSellVehicle, CommandFlags({CommandFlag::ClientID, CommandFlag::Location}), CommandType::VehicleConstruction) -DEF_CMD_TRAIT(CMD_REFIT_VEHICLE, CmdRefitVehicle, CommandFlag::Location, CommandType::VehicleConstruction) -DEF_CMD_TRAIT(CMD_SEND_VEHICLE_TO_DEPOT, CmdSendVehicleToDepot, {}, CommandType::VehicleManagement) -DEF_CMD_TRAIT(CMD_CHANGE_SERVICE_INT, CmdChangeServiceInt, {}, CommandType::VehicleManagement) -DEF_CMD_TRAIT(CMD_RENAME_VEHICLE, CmdRenameVehicle, {}, CommandType::OtherManagement) -DEF_CMD_TRAIT(CMD_CLONE_VEHICLE, CmdCloneVehicle, CommandFlag::NoTest, CommandType::VehicleConstruction) // NewGRF callbacks influence building and refitting making it impossible to correctly estimate the cost -DEF_CMD_TRAIT(CMD_START_STOP_VEHICLE, CmdStartStopVehicle, CommandFlag::Location, CommandType::VehicleManagement) -DEF_CMD_TRAIT(CMD_MASS_START_STOP, CmdMassStartStopVehicle, {}, CommandType::VehicleManagement) -DEF_CMD_TRAIT(CMD_DEPOT_SELL_ALL_VEHICLES, CmdDepotSellAllVehicles, {}, CommandType::VehicleConstruction) -DEF_CMD_TRAIT(CMD_DEPOT_MASS_AUTOREPLACE, CmdDepotMassAutoReplace, {}, CommandType::VehicleConstruction) +DEF_CMD_TRAIT(Commands::BuildVehicle, CmdBuildVehicle, CommandFlag::ClientID, CommandType::VehicleConstruction) +DEF_CMD_TRAIT(Commands::SellVehicle, CmdSellVehicle, CommandFlags({CommandFlag::ClientID, CommandFlag::Location}), CommandType::VehicleConstruction) +DEF_CMD_TRAIT(Commands::RefitVehicle, CmdRefitVehicle, CommandFlag::Location, CommandType::VehicleConstruction) +DEF_CMD_TRAIT(Commands::SendVehicleToDepot, CmdSendVehicleToDepot, {}, CommandType::VehicleManagement) +DEF_CMD_TRAIT(Commands::ChangeServiceInterval, CmdChangeServiceInt, {}, CommandType::VehicleManagement) +DEF_CMD_TRAIT(Commands::RenameVehicle, CmdRenameVehicle, {}, CommandType::OtherManagement) +DEF_CMD_TRAIT(Commands::CloneVehicle, CmdCloneVehicle, CommandFlag::NoTest, CommandType::VehicleConstruction) // NewGRF callbacks influence building and refitting making it impossible to correctly estimate the cost +DEF_CMD_TRAIT(Commands::StartStopVehicle, CmdStartStopVehicle, CommandFlag::Location, CommandType::VehicleManagement) +DEF_CMD_TRAIT(Commands::MassStartStop, CmdMassStartStopVehicle, {}, CommandType::VehicleManagement) +DEF_CMD_TRAIT(Commands::DepotMassSell, CmdDepotSellAllVehicles, {}, CommandType::VehicleConstruction) +DEF_CMD_TRAIT(Commands::DepotMassAutoreplace, CmdDepotMassAutoReplace, {}, CommandType::VehicleConstruction) void CcBuildPrimaryVehicle(Commands cmd, const CommandCost &result, VehicleID new_veh_id, uint, uint16_t, CargoArray); void CcStartStopVehicle(Commands cmd, const CommandCost &result, VehicleID veh_id, bool); diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index c02e52ce12..20f4b018d3 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -1006,7 +1006,7 @@ struct RefitWindow : public Window { std::string GetCapacityString(const RefitOption &option) const { assert(_current_company == _local_company); - auto [cost, refit_capacity, mail_capacity, cargo_capacities] = Command::Do(DoCommandFlag::QueryCost, this->selected_vehicle, option.cargo, option.subtype, this->auto_refit, false, this->num_vehicles); + auto [cost, refit_capacity, mail_capacity, cargo_capacities] = Command::Do(DoCommandFlag::QueryCost, this->selected_vehicle, option.cargo, option.subtype, this->auto_refit, false, this->num_vehicles); if (cost.Failed()) return {}; @@ -1264,9 +1264,9 @@ struct RefitWindow : public Window { if (this->order == INVALID_VEH_ORDER_ID) { bool delete_window = this->selected_vehicle == v->index && this->num_vehicles == UINT8_MAX; - if (Command::Post(GetCmdRefitVehMsg(v), v->tile, this->selected_vehicle, this->selected_refit->cargo, this->selected_refit->subtype, false, false, this->num_vehicles) && delete_window) this->Close(); + if (Command::Post(GetCmdRefitVehMsg(v), v->tile, this->selected_vehicle, this->selected_refit->cargo, this->selected_refit->subtype, false, false, this->num_vehicles) && delete_window) this->Close(); } else { - if (Command::Post(v->tile, v->index, this->order, this->selected_refit->cargo)) this->Close(); + if (Command::Post(v->tile, v->index, this->order, this->selected_refit->cargo)) this->Close(); } } break; @@ -2166,7 +2166,7 @@ public: case WID_VL_STOP_ALL: case WID_VL_START_ALL: - Command::Post(TileIndex{}, widget == WID_VL_START_ALL, true, this->vli); + Command::Post(TileIndex{}, widget == WID_VL_START_ALL, true, this->vli); break; } } @@ -2195,11 +2195,11 @@ public: break; case ADI_SERVICE: // Send for servicing case ADI_DEPOT: // Send to Depots - Command::Post(GetCmdSendToDepotMsg(this->vli.vtype), VehicleID::Invalid(), (index == ADI_SERVICE ? DepotCommandFlag::Service : DepotCommandFlags{}) | DepotCommandFlag::MassSend, this->vli); + Command::Post(GetCmdSendToDepotMsg(this->vli.vtype), VehicleID::Invalid(), (index == ADI_SERVICE ? DepotCommandFlag::Service : DepotCommandFlags{}) | DepotCommandFlag::MassSend, this->vli); break; case ADI_CREATE_GROUP: // Create group - Command::Post(CcAddVehicleNewGroup, NEW_GROUP, VehicleID::Invalid(), false, this->vli); + Command::Post(CcAddVehicleNewGroup, NEW_GROUP, VehicleID::Invalid(), false, this->vli); break; default: NOT_REACHED(); @@ -2722,7 +2722,7 @@ struct VehicleDetailsWindow : Window { mod = GetServiceIntervalClamped(mod + v->GetServiceInterval(), v->ServiceIntervalIsPercent()); if (mod == v->GetServiceInterval()) return; - Command::Post(STR_ERROR_CAN_T_CHANGE_SERVICING, v->index, mod, true, v->ServiceIntervalIsPercent()); + Command::Post(STR_ERROR_CAN_T_CHANGE_SERVICING, v->index, mod, true, v->ServiceIntervalIsPercent()); break; } @@ -2777,7 +2777,7 @@ struct VehicleDetailsWindow : Window { bool iscustom = index != 0; bool ispercent = iscustom ? (index == 2) : Company::Get(v->owner)->settings.vehicle.servint_ispercent; uint16_t interval = GetServiceIntervalClamped(v->GetServiceInterval(), ispercent); - Command::Post(STR_ERROR_CAN_T_CHANGE_SERVICING, v->index, interval, iscustom, ispercent); + Command::Post(STR_ERROR_CAN_T_CHANGE_SERVICING, v->index, interval, iscustom, ispercent); break; } } @@ -2931,14 +2931,14 @@ void CcStartStopVehicle(Commands, const CommandCost &result, VehicleID veh_id, b } /** - * Executes #CMD_START_STOP_VEHICLE for given vehicle. + * Executes #Commands::StartStopVehicle for given vehicle. * @param v Vehicle to start/stop * @param texteffect Should a texteffect be shown? */ void StartStopVehicle(const Vehicle *v, bool texteffect) { assert(v->IsPrimaryVehicle()); - Command::Post(_vehicle_msg_translation_table[VCT_CMD_START_STOP][v->type], texteffect ? CcStartStopVehicle : nullptr, v->tile, v->index, false); + Command::Post(_vehicle_msg_translation_table[VCT_CMD_START_STOP][v->type], texteffect ? CcStartStopVehicle : nullptr, v->tile, v->index, false); } /** Checks whether the vehicle may be refitted at the moment.*/ @@ -3269,7 +3269,7 @@ public: break; case WID_VV_GOTO_DEPOT: // goto hangar - Command::Post(GetCmdSendToDepotMsg(v), v->index, _ctrl_pressed ? DepotCommandFlag::Service : DepotCommandFlags{}, {}); + Command::Post(GetCmdSendToDepotMsg(v), v->index, _ctrl_pressed ? DepotCommandFlag::Service : DepotCommandFlags{}, {}); break; case WID_VV_REFIT: // refit ShowVehicleRefitWindow(v, INVALID_VEH_ORDER_ID, this); @@ -3293,21 +3293,21 @@ public: * There is no point to it except for starting the vehicle. * For starting the vehicle the player has to open the depot GUI, which is * most likely already open, but is also visible in the vehicle viewport. */ - Command::Post(_vehicle_msg_translation_table[VCT_CMD_CLONE_VEH][v->type], + Command::Post(_vehicle_msg_translation_table[VCT_CMD_CLONE_VEH][v->type], _ctrl_pressed ? nullptr : CcCloneVehicle, v->tile, v->index, _ctrl_pressed); break; case WID_VV_TURN_AROUND: // turn around assert(v->IsGroundVehicle()); if (v->type == VEH_ROAD) { - Command::Post(_vehicle_msg_translation_table[VCT_CMD_TURN_AROUND][v->type], v->tile, v->index); + Command::Post(_vehicle_msg_translation_table[VCT_CMD_TURN_AROUND][v->type], v->tile, v->index); } else { - Command::Post(_vehicle_msg_translation_table[VCT_CMD_TURN_AROUND][v->type], v->tile, v->index, false); + Command::Post(_vehicle_msg_translation_table[VCT_CMD_TURN_AROUND][v->type], v->tile, v->index, false); } break; case WID_VV_FORCE_PROCEED: // force proceed assert(v->type == VEH_TRAIN); - Command::Post(STR_ERROR_CAN_T_MAKE_TRAIN_PASS_SIGNAL, v->tile, v->index); + Command::Post(STR_ERROR_CAN_T_MAKE_TRAIN_PASS_SIGNAL, v->tile, v->index); break; } } @@ -3330,7 +3330,7 @@ public: { if (!str.has_value()) return; - Command::Post(STR_ERROR_CAN_T_RENAME_TRAIN + Vehicle::Get(this->window_number)->type, static_cast(this->window_number), *str); + Command::Post(STR_ERROR_CAN_T_RENAME_TRAIN + Vehicle::Get(this->window_number)->type, static_cast(this->window_number), *str); } void OnMouseOver([[maybe_unused]] Point pt, WidgetID widget) override diff --git a/src/viewport_cmd.h b/src/viewport_cmd.h index 2f58b2e0b6..b71c476117 100644 --- a/src/viewport_cmd.h +++ b/src/viewport_cmd.h @@ -15,6 +15,6 @@ CommandCost CmdScrollViewport(DoCommandFlags flags, TileIndex tile, ViewportScrollTarget target, uint32_t ref); -DEF_CMD_TRAIT(CMD_SCROLL_VIEWPORT, CmdScrollViewport, CommandFlag::Deity, CommandType::OtherManagement) +DEF_CMD_TRAIT(Commands::ScrollViewport, CmdScrollViewport, CommandFlag::Deity, CommandType::OtherManagement) #endif /* VIEWPORT_CMD_H */ diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp index e8d7f35dab..90f962d376 100644 --- a/src/water_cmd.cpp +++ b/src/water_cmd.cpp @@ -132,13 +132,13 @@ CommandCost CmdBuildShipDepot(DoCommandFlags flags, TileIndex tile, Axis axis) CommandCost cost = CommandCost(EXPENSES_CONSTRUCTION, _price[Price::BuildDepotShip]); bool add_cost = !IsWaterTile(tile); - CommandCost ret = Command::Do(flags | DoCommandFlag::Auto, tile); + CommandCost ret = Command::Do(flags | DoCommandFlag::Auto, tile); if (ret.Failed()) return ret; if (add_cost) { cost.AddCost(ret.GetCost()); } add_cost = !IsWaterTile(tile2); - ret = Command::Do(flags | DoCommandFlag::Auto, tile2); + ret = Command::Do(flags | DoCommandFlag::Auto, tile2); if (ret.Failed()) return ret; if (add_cost) { cost.AddCost(ret.GetCost()); @@ -335,13 +335,13 @@ static CommandCost DoBuildLock(TileIndex tile, DiagDirection dir, DoCommandFlags /* middle tile */ WaterClass wc_middle = HasTileWaterGround(tile) ? GetWaterClass(tile) : WaterClass::Canal; - ret = Command::Do(flags, tile); + ret = Command::Do(flags, tile); if (ret.Failed()) return ret; cost.AddCost(ret.GetCost()); /* lower tile */ if (!IsWaterTile(tile - delta)) { - ret = Command::Do(flags, tile - delta); + ret = Command::Do(flags, tile - delta); if (ret.Failed()) return ret; cost.AddCost(ret.GetCost()); cost.AddCost(_price[Price::BuildCanal]); @@ -353,7 +353,7 @@ static CommandCost DoBuildLock(TileIndex tile, DiagDirection dir, DoCommandFlags /* upper tile */ if (!IsWaterTile(tile + delta)) { - ret = Command::Do(flags, tile + delta); + ret = Command::Do(flags, tile + delta); if (ret.Failed()) return ret; cost.AddCost(ret.GetCost()); cost.AddCost(_price[Price::BuildCanal]); @@ -513,7 +513,7 @@ CommandCost CmdBuildCanal(DoCommandFlags flags, TileIndex tile, TileIndex start_ /* Outside the editor, prevent building canals over your own or OWNER_NONE owned canals */ if (water && IsCanal(current_tile) && _game_mode != GM_EDITOR && (IsTileOwner(current_tile, _current_company) || IsTileOwner(current_tile, OWNER_NONE))) continue; - ret = Command::Do(flags, current_tile); + ret = Command::Do(flags, current_tile); if (ret.Failed()) return ret; if (!water) cost.AddCost(ret.GetCost()); @@ -1180,7 +1180,7 @@ static void DoFloodTile(TileIndex target) [[fallthrough]]; case TileType::Clear: - if (Command::Do(DoCommandFlag::Execute, target).Succeeded()) { + if (Command::Do(DoCommandFlag::Execute, target).Succeeded()) { MakeShore(target); MarkTileDirtyByTile(target); flooded = true; @@ -1195,7 +1195,7 @@ static void DoFloodTile(TileIndex target) FloodVehicles(target); /* flood flat tile */ - if (Command::Do(DoCommandFlag::Execute, target).Succeeded()) { + if (Command::Do(DoCommandFlag::Execute, target).Succeeded()) { MakeSea(target); MarkTileDirtyByTile(target); flooded = true; @@ -1248,7 +1248,7 @@ static void DoDryUp(TileIndex tile) case TileType::Water: assert(IsCoast(tile)); - if (Command::Do(DoCommandFlag::Execute, tile).Succeeded()) { + if (Command::Do(DoCommandFlag::Execute, tile).Succeeded()) { MakeClear(tile, CLEAR_GRASS, 3); MarkTileDirtyByTile(tile); } @@ -1418,7 +1418,7 @@ static void ChangeTileOwner_Water(TileIndex tile, Owner old_owner, Owner new_own } /* Remove depot */ - if (IsShipDepot(tile)) Command::Do({DoCommandFlag::Execute, DoCommandFlag::Bankrupt}, tile); + if (IsShipDepot(tile)) Command::Do({DoCommandFlag::Execute, DoCommandFlag::Bankrupt}, tile); /* Set owner of canals and locks ... and also canal under dock there was before. * Check if the new owner after removing depot isn't OWNER_WATER. */ @@ -1438,7 +1438,7 @@ static CommandCost TerraformTile_Water(TileIndex tile, DoCommandFlags flags, int /* Canals can't be terraformed */ if (IsWaterTile(tile) && IsCanal(tile)) return CommandCost(STR_ERROR_MUST_DEMOLISH_CANAL_FIRST); - return Command::Do(flags, tile); + return Command::Do(flags, tile); } static CommandCost CheckBuildAbove_Water(TileIndex tile, DoCommandFlags flags, Axis, int height) @@ -1449,7 +1449,7 @@ static CommandCost CheckBuildAbove_Water(TileIndex tile, DoCommandFlags flags, A int height_diff = (GetTileMaxZ(tile) + GetLockPartMinimalBridgeHeight(GetLockPart(tile)) - height) * TILE_HEIGHT_STEP; return CommandCostWithParam(STR_ERROR_BRIDGE_TOO_LOW_FOR_LOCK, height_diff); } - return Command::Do(flags, tile); + return Command::Do(flags, tile); } extern const TileTypeProcs _tile_type_water_procs = { diff --git a/src/water_cmd.h b/src/water_cmd.h index 1cf7dfb565..6660abfe4f 100644 --- a/src/water_cmd.h +++ b/src/water_cmd.h @@ -17,8 +17,8 @@ CommandCost CmdBuildShipDepot(DoCommandFlags flags, TileIndex tile, Axis axis); CommandCost CmdBuildCanal(DoCommandFlags flags, TileIndex tile, TileIndex start_tile, WaterClass wc, bool diagonal); CommandCost CmdBuildLock(DoCommandFlags flags, TileIndex tile); -DEF_CMD_TRAIT(CMD_BUILD_SHIP_DEPOT, CmdBuildShipDepot, CommandFlag::Auto, CommandType::LandscapeConstruction) -DEF_CMD_TRAIT(CMD_BUILD_CANAL, CmdBuildCanal, CommandFlag::Auto, CommandType::LandscapeConstruction) -DEF_CMD_TRAIT(CMD_BUILD_LOCK, CmdBuildLock, CommandFlag::Auto, CommandType::LandscapeConstruction) +DEF_CMD_TRAIT(Commands::BuildShipDepot, CmdBuildShipDepot, CommandFlag::Auto, CommandType::LandscapeConstruction) +DEF_CMD_TRAIT(Commands::BuildCanal, CmdBuildCanal, CommandFlag::Auto, CommandType::LandscapeConstruction) +DEF_CMD_TRAIT(Commands::BuildLock, CmdBuildLock, CommandFlag::Auto, CommandType::LandscapeConstruction) #endif /* WATER_CMD_H */ diff --git a/src/waypoint_cmd.cpp b/src/waypoint_cmd.cpp index cf8d960747..ac7ea7a5bb 100644 --- a/src/waypoint_cmd.cpp +++ b/src/waypoint_cmd.cpp @@ -485,7 +485,7 @@ CommandCost CmdBuildBuoy(DoCommandFlags flags, TileIndex tile) CommandCost cost(EXPENSES_CONSTRUCTION, _price[Price::BuildWaypointBuoy]); if (!IsWaterTile(tile)) { - CommandCost ret = Command::Do(flags | DoCommandFlag::Auto, tile); + CommandCost ret = Command::Do(flags | DoCommandFlag::Auto, tile); if (ret.Failed()) return ret; cost.AddCost(ret.GetCost()); } diff --git a/src/waypoint_cmd.h b/src/waypoint_cmd.h index c1ad764f2d..f7f89aeea2 100644 --- a/src/waypoint_cmd.h +++ b/src/waypoint_cmd.h @@ -24,13 +24,13 @@ CommandCost CmdBuildBuoy(DoCommandFlags flags, TileIndex tile); CommandCost CmdRenameWaypoint(DoCommandFlags flags, StationID waypoint_id, const std::string &text); std::tuple CmdMoveWaypointName(DoCommandFlags flags, StationID waypoint_id, TileIndex tile); -DEF_CMD_TRAIT(CMD_BUILD_RAIL_WAYPOINT, CmdBuildRailWaypoint, {}, CommandType::LandscapeConstruction) -DEF_CMD_TRAIT(CMD_REMOVE_FROM_RAIL_WAYPOINT, CmdRemoveFromRailWaypoint, {}, CommandType::LandscapeConstruction) -DEF_CMD_TRAIT(CMD_BUILD_ROAD_WAYPOINT, CmdBuildRoadWaypoint, {}, CommandType::LandscapeConstruction) -DEF_CMD_TRAIT(CMD_REMOVE_FROM_ROAD_WAYPOINT, CmdRemoveFromRoadWaypoint, {}, CommandType::LandscapeConstruction) -DEF_CMD_TRAIT(CMD_BUILD_BUOY, CmdBuildBuoy, CommandFlag::Auto, CommandType::LandscapeConstruction) -DEF_CMD_TRAIT(CMD_RENAME_WAYPOINT, CmdRenameWaypoint, {}, CommandType::OtherManagement) -DEF_CMD_TRAIT(CMD_MOVE_WAYPOINT_NAME, CmdMoveWaypointName, {}, CommandType::OtherManagement) +DEF_CMD_TRAIT(Commands::BuildRailWaypoint, CmdBuildRailWaypoint, {}, CommandType::LandscapeConstruction) +DEF_CMD_TRAIT(Commands::RemoveFromRailWaypoint, CmdRemoveFromRailWaypoint, {}, CommandType::LandscapeConstruction) +DEF_CMD_TRAIT(Commands::BuildRoadWaypoint, CmdBuildRoadWaypoint, {}, CommandType::LandscapeConstruction) +DEF_CMD_TRAIT(Commands::RemoveFromRoadWaypoint, CmdRemoveFromRoadWaypoint, {}, CommandType::LandscapeConstruction) +DEF_CMD_TRAIT(Commands::BuildBuoy, CmdBuildBuoy, CommandFlag::Auto, CommandType::LandscapeConstruction) +DEF_CMD_TRAIT(Commands::RenameWaypoint, CmdRenameWaypoint, {}, CommandType::OtherManagement) +DEF_CMD_TRAIT(Commands::MoveWaypointNAme, CmdMoveWaypointName, {}, CommandType::OtherManagement) void CcMoveWaypointName(Commands cmd, const CommandCost &result, StationID waypoint_id); diff --git a/src/waypoint_gui.cpp b/src/waypoint_gui.cpp index 2479abe4f5..4f523caca0 100644 --- a/src/waypoint_gui.cpp +++ b/src/waypoint_gui.cpp @@ -189,7 +189,7 @@ public: { if (!str.has_value()) return; - Command::Post(STR_ERROR_CAN_T_CHANGE_WAYPOINT_NAME, this->window_number, *str); + Command::Post(STR_ERROR_CAN_T_CHANGE_WAYPOINT_NAME, this->window_number, *str); } };