From 549caca39cebc8c988f4e51d79d353cab4646d58 Mon Sep 17 00:00:00 2001 From: Michael Lutz Date: Sun, 3 Oct 2021 17:15:48 +0200 Subject: Codechange: Move command arguments to the back of the networked command function calls. --- src/ai/ai_gui.cpp | 8 ++-- src/autoreplace_gui.cpp | 10 ++--- src/bridge_gui.cpp | 6 +-- src/build_vehicle_gui.cpp | 6 +-- src/cheat_gui.cpp | 2 +- src/command.cpp | 74 ++++++++++++++++++++++++++----------- src/command_func.h | 7 ++-- src/company_cmd.cpp | 2 +- src/company_gui.cpp | 24 ++++++------ src/console_cmds.cpp | 14 +++---- src/depot_gui.cpp | 20 +++++----- src/dock_gui.cpp | 12 +++--- src/economy.cpp | 2 +- src/engine_gui.cpp | 2 +- src/fios_gui.cpp | 4 +- src/goal_gui.cpp | 6 +-- src/group_gui.cpp | 24 ++++++------ src/highscore_gui.cpp | 8 ++-- src/industry_gui.cpp | 7 ++-- src/linkgraph/linkgraphschedule.cpp | 4 +- src/main_gui.cpp | 2 +- src/misc_cmd.cpp | 2 +- src/network/network.cpp | 4 +- src/network/network_client.cpp | 2 +- src/network/network_command.cpp | 8 ++-- src/network/network_gui.cpp | 6 +-- src/network/network_server.cpp | 6 +-- src/object_gui.cpp | 4 +- src/openttd.cpp | 8 ++-- src/order_backup.cpp | 4 +- src/order_gui.cpp | 46 +++++++++++------------ src/rail_gui.cpp | 42 ++++++++++----------- src/road_gui.cpp | 22 +++++------ src/script/api/script_object.cpp | 2 +- src/settings.cpp | 6 +-- src/signs_cmd.cpp | 2 +- src/signs_gui.cpp | 2 +- src/station_gui.cpp | 4 +- src/story_gui.cpp | 6 +-- src/terraform_gui.cpp | 16 ++++---- src/timetable_gui.cpp | 12 +++--- src/toolbar_gui.cpp | 2 +- src/town_gui.cpp | 12 +++--- src/train_cmd.cpp | 2 +- src/train_gui.cpp | 2 +- src/tree_gui.cpp | 4 +- src/vehicle_gui.cpp | 29 +++++++-------- src/waypoint_gui.cpp | 2 +- 48 files changed, 265 insertions(+), 236 deletions(-) (limited to 'src') diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp index c7ae4740e..340b6db95 100644 --- a/src/ai/ai_gui.cpp +++ b/src/ai/ai_gui.cpp @@ -1290,8 +1290,8 @@ struct AIDebugWindow : public Window { case WID_AID_RELOAD_TOGGLE: if (ai_debug_company == OWNER_DEITY) break; /* First kill the company of the AI, then start a new one. This should start the current AI again */ - DoCommandP(0, CCA_DELETE | ai_debug_company << 16 | CRR_MANUAL << 24, 0, CMD_COMPANY_CTRL); - DoCommandP(0, CCA_NEW_AI | ai_debug_company << 16, 0, CMD_COMPANY_CTRL); + DoCommandP(CMD_COMPANY_CTRL, 0, CCA_DELETE | ai_debug_company << 16 | CRR_MANUAL << 24, 0); + DoCommandP(CMD_COMPANY_CTRL, 0, CCA_NEW_AI | ai_debug_company << 16, 0); break; case WID_AID_SETTINGS: @@ -1330,7 +1330,7 @@ struct AIDebugWindow : public Window { } if (all_unpaused) { /* All scripts have been unpaused => unpause the game. */ - DoCommandP(0, PM_PAUSED_NORMAL, 0, CMD_PAUSE); + DoCommandP(CMD_PAUSE, 0, PM_PAUSED_NORMAL, 0); } } } @@ -1379,7 +1379,7 @@ struct AIDebugWindow : public Window { /* Pause the game. */ if ((_pause_mode & PM_PAUSED_NORMAL) == PM_UNPAUSED) { - DoCommandP(0, PM_PAUSED_NORMAL, 1, CMD_PAUSE); + DoCommandP(CMD_PAUSE, 0, PM_PAUSED_NORMAL, 1); } /* Highlight row that matched */ diff --git a/src/autoreplace_gui.cpp b/src/autoreplace_gui.cpp index 898b4e750..d4e392c97 100644 --- a/src/autoreplace_gui.cpp +++ b/src/autoreplace_gui.cpp @@ -217,7 +217,7 @@ class ReplaceVehicleWindow : public Window { { EngineID veh_from = this->sel_engine[0]; EngineID veh_to = this->sel_engine[1]; - DoCommandP(0, (replace_when_old ? 1 : 0) | (this->sel_group << 16), veh_from + (veh_to << 16), CMD_SET_AUTOREPLACE); + DoCommandP(CMD_SET_AUTOREPLACE, 0, (replace_when_old ? 1 : 0) | (this->sel_group << 16), veh_from + (veh_to << 16)); } public: @@ -541,10 +541,10 @@ public: case WID_RV_TRAIN_WAGONREMOVE_TOGGLE: { const Group *g = Group::GetIfValid(this->sel_group); if (g != nullptr) { - DoCommandP(0, this->sel_group | (GroupFlags::GF_REPLACE_WAGON_REMOVAL << 16), (HasBit(g->flags, GroupFlags::GF_REPLACE_WAGON_REMOVAL) ? 0 : 1) | (_ctrl_pressed << 1), CMD_SET_GROUP_FLAG); + DoCommandP(CMD_SET_GROUP_FLAG, 0, this->sel_group | (GroupFlags::GF_REPLACE_WAGON_REMOVAL << 16), (HasBit(g->flags, GroupFlags::GF_REPLACE_WAGON_REMOVAL) ? 0 : 1) | (_ctrl_pressed << 1)); } else { // toggle renew_keep_length - DoCommandP(0, 0, Company::Get(_local_company)->settings.renew_keep_length ? 0 : 1, CMD_CHANGE_COMPANY_SETTING, nullptr, "company.renew_keep_length"); + DoCommandP(CMD_CHANGE_COMPANY_SETTING, 0, 0, Company::Get(_local_company)->settings.renew_keep_length ? 0 : 1, "company.renew_keep_length"); } break; } @@ -562,7 +562,7 @@ public: case WID_RV_STOP_REPLACE: { // Stop replacing EngineID veh_from = this->sel_engine[0]; - DoCommandP(0, this->sel_group << 16, veh_from + (INVALID_ENGINE << 16), CMD_SET_AUTOREPLACE); + DoCommandP(CMD_SET_AUTOREPLACE, 0, this->sel_group << 16, veh_from + (INVALID_ENGINE << 16)); break; } @@ -584,7 +584,7 @@ public: if (click_side == 0 && _ctrl_pressed && e != INVALID_ENGINE && (GetGroupNumEngines(_local_company, sel_group, e) == 0 || GetGroupNumEngines(_local_company, ALL_GROUP, e) == 0)) { EngineID veh_from = e; - DoCommandP(0, this->sel_group << 16, veh_from + (INVALID_ENGINE << 16), CMD_SET_AUTOREPLACE); + DoCommandP(CMD_SET_AUTOREPLACE, 0, this->sel_group << 16, veh_from + (INVALID_ENGINE << 16)); break; } diff --git a/src/bridge_gui.cpp b/src/bridge_gui.cpp index 9e6fc4eee..2aef088e3 100644 --- a/src/bridge_gui.cpp +++ b/src/bridge_gui.cpp @@ -117,8 +117,8 @@ private: case TRANSPORT_ROAD: _last_roadbridge_type = this->bridges->at(i).index; break; default: break; } - DoCommandP(this->end_tile, this->start_tile, this->type | this->bridges->at(i).index, - CMD_BUILD_BRIDGE | CMD_MSG(STR_ERROR_CAN_T_BUILD_BRIDGE_HERE), CcBuildBridge); + DoCommandP(CMD_BUILD_BRIDGE | CMD_MSG(STR_ERROR_CAN_T_BUILD_BRIDGE_HERE), CcBuildBridge, + this->end_tile, this->start_tile, this->type | this->bridges->at(i).index); } /** Sort the builable bridges */ @@ -383,7 +383,7 @@ 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()) { - DoCommandP(end, start, type | last_bridge_type, CMD_BUILD_BRIDGE | CMD_MSG(STR_ERROR_CAN_T_BUILD_BRIDGE_HERE), CcBuildBridge); + DoCommandP(CMD_BUILD_BRIDGE | CMD_MSG(STR_ERROR_CAN_T_BUILD_BRIDGE_HERE), CcBuildBridge, end, start, type | last_bridge_type); return; } diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp index 6bee767b0..aafc0a950 100644 --- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -1458,7 +1458,7 @@ struct BuildVehicleWindow : Window { case WID_BV_SHOW_HIDE: { const Engine *e = (this->sel_engine == INVALID_ENGINE) ? nullptr : Engine::Get(this->sel_engine); if (e != nullptr) { - DoCommandP(0, 0, this->sel_engine | (e->IsHidden(_current_company) ? 0 : (1u << 31)), CMD_SET_VEHICLE_VISIBILITY); + DoCommandP(CMD_SET_VEHICLE_VISIBILITY, 0, 0, this->sel_engine | (e->IsHidden(_current_company) ? 0 : (1u << 31))); } break; } @@ -1469,7 +1469,7 @@ struct BuildVehicleWindow : Window { CommandCallback *callback = (this->vehicle_type == VEH_TRAIN && RailVehInfo(sel_eng)->railveh_type == RAILVEH_WAGON) ? CcBuildWagon : CcBuildPrimaryVehicle; CargoID cargo = this->cargo_filter[this->cargo_filter_criteria]; if (cargo == CF_ANY || cargo == CF_ENGINES) cargo = CF_NONE; - DoCommandP(this->window_number, sel_eng | (cargo << 24), 0, GetCmdBuildVeh(this->vehicle_type), callback); + DoCommandP(GetCmdBuildVeh(this->vehicle_type), callback, this->window_number, sel_eng | (cargo << 24), 0); } break; } @@ -1634,7 +1634,7 @@ struct BuildVehicleWindow : Window { { if (str == nullptr) return; - DoCommandP(0, this->rename_engine, 0, CMD_RENAME_ENGINE | CMD_MSG(STR_ERROR_CAN_T_RENAME_TRAIN_TYPE + this->vehicle_type), nullptr, str); + DoCommandP(CMD_RENAME_ENGINE | CMD_MSG(STR_ERROR_CAN_T_RENAME_TRAIN_TYPE + this->vehicle_type), 0, this->rename_engine, 0, str); } void OnDropdownSelect(int widget, int index) override diff --git a/src/cheat_gui.cpp b/src/cheat_gui.cpp index a0ac5fab8..84884b3de 100644 --- a/src/cheat_gui.cpp +++ b/src/cheat_gui.cpp @@ -54,7 +54,7 @@ static int32 _money_cheat_amount = 10000000; */ static int32 ClickMoneyCheat(int32 p1, int32 p2) { - DoCommandP(0, (uint32)(p2 * _money_cheat_amount), 0, CMD_MONEY_CHEAT); + DoCommandP(CMD_MONEY_CHEAT, 0, (uint32)(p2 * _money_cheat_amount), 0); return _money_cheat_amount; } diff --git a/src/command.cpp b/src/command.cpp index b971ccb6b..d397d3fe6 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -532,16 +532,6 @@ Money GetAvailableMoneyForCommand() return Company::Get(company)->money; } -/** - * Shortcut for the long DoCommandP when having a container with the data. - * @param container the container with information. - * @param my_cmd indicator if the command is from a company or server (to display error messages for a user) - * @return true if the command succeeded, else false - */ -bool DoCommandP(const CommandContainer *container, bool my_cmd) -{ - return DoCommandP(container->tile, container->p1, container->p2, container->cmd, container->callback, container->text, my_cmd); -} /*! * Toplevel network safe docommand function for the current company. Must not be called recursively. @@ -549,16 +539,16 @@ bool DoCommandP(const CommandContainer *container, bool my_cmd) * \a tile, \a p1, and \a p2 are from the #CommandProc function. The parameter \a cmd is the command to execute. * The parameter \a my_cmd is used to indicate if the command is from a company or the server. * + * @param cmd The command to execute (a CMD_* value) + * @param callback A callback function to call after the command is finished + * @param my_cmd indicator if the command is from a company or server (to display error messages for a user) * @param tile The tile to perform a command on (see #CommandProc) * @param p1 Additional data for the command (see #CommandProc) * @param p2 Additional data for the command (see #CommandProc) - * @param cmd The command to execute (a CMD_* value) - * @param callback A callback function to call after the command is finished * @param text The text to pass - * @param my_cmd indicator if the command is from a company or server (to display error messages for a user) * @return \c true if the command succeeded, else \c false. */ -bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const std::string &text, bool my_cmd) +static bool DoCommandP(uint32 cmd, CommandCallback *callback, bool my_cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text) { /* Cost estimation is generally only done when the * local user presses shift while doing something. @@ -586,7 +576,7 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallbac /* Only set p2 when the command does not come from the network. */ if (!(cmd & CMD_NETWORK_COMMAND) && GetCommandFlags(cmd) & CMD_CLIENT_ID && p2 == 0) p2 = CLIENT_ID_SERVER; - CommandCost res = DoCommandPInternal(tile, p1, p2, cmd, callback, text, my_cmd, estimate_only); + CommandCost res = DoCommandPInternal(cmd, callback, my_cmd, estimate_only, tile, p1, p2, text); if (res.Failed()) { /* Only show the error when it's for us. */ StringID error_part1 = GB(cmd, 16, 16); @@ -611,6 +601,48 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallbac return res.Succeeded(); } +/** + * Shortcut for the long DoCommandP when having a container with the data. + * @param container the container with information. + * @param my_cmd indicator if the command is from a company or server (to display error messages for a user) + * @return true if the command succeeded, else false + */ +bool DoCommandP(const CommandContainer *container, bool my_cmd) +{ + return DoCommandP(container->cmd, container->callback, my_cmd, container->tile, container->p1, container->p2, container->text); +} + +/** + * Shortcut for the long DoCommandP when not using a callback. + * @param cmd The command to execute (a CMD_* value) + * @param tile The tile to perform a command on (see #CommandProc) + * @param p1 Additional data for the command (see #CommandProc) + * @param p2 Additional data for the command (see #CommandProc) + * @param text The text to pass + * @return \c true if the command succeeded, else \c false. + */ +bool DoCommandP(uint32 cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text) +{ + return DoCommandP(cmd, nullptr, true, tile, p1, p2, text); +} + +/*! + * Toplevel network safe docommand function for the current company. Must not be called recursively. + * The callback is called when the command succeeded or failed. The parameters + * \a tile, \a p1, and \a p2 are from the #CommandProc function. The parameter \a cmd is the command to execute. + * + * @param cmd The command to execute (a CMD_* value) + * @param callback A callback function to call after the command is finished + * @param tile The tile to perform a command on (see #CommandProc) + * @param p1 Additional data for the command (see #CommandProc) + * @param p2 Additional data for the command (see #CommandProc) + * @param text The text to pass + * @return \c true if the command succeeded, else \c false. + */ +bool DoCommandP(uint32 cmd, CommandCallback *callback, TileIndex tile, uint32 p1, uint32 p2, const std::string &text) +{ + return DoCommandP(cmd, callback, true, tile, p1, p2, text); +} /** * Helper to deduplicate the code for returning. @@ -621,17 +653,17 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallbac /*! * Helper function for the toplevel network safe docommand function for the current company. * - * @param tile The tile to perform a command on (see #CommandProc) - * @param p1 Additional data for the command (see #CommandProc) - * @param p2 Additional data for the command (see #CommandProc) * @param cmd The command to execute (a CMD_* value) * @param callback A callback function to call after the command is finished - * @param text The text to pass * @param my_cmd indicator if the command is from a company or server (to display error messages for a user) * @param estimate_only whether to give only the estimate or also execute the command + * @param tile The tile to perform a command on (see #CommandProc) + * @param p1 Additional data for the command (see #CommandProc) + * @param p2 Additional data for the command (see #CommandProc) + * @param text The text to pass * @return the command cost of this function. */ -CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const std::string &text, bool my_cmd, bool estimate_only) +CommandCost DoCommandPInternal(uint32 cmd, CommandCallback *callback, bool my_cmd, bool estimate_only, TileIndex tile, uint32 p1, uint32 p2, const std::string &text) { /* Prevent recursion; it gives a mess over the network */ assert(_docommand_recursive == 0); @@ -707,7 +739,7 @@ CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, * send it to the command-queue and abort execution */ if (_networking && !_generating_world && !(cmd & CMD_NETWORK_COMMAND)) { - NetworkSendCommand(tile, p1, p2, cmd & ~CMD_FLAGS_MASK, callback, text, _current_company); + NetworkSendCommand(cmd & ~CMD_FLAGS_MASK, callback, _current_company, tile, p1, p2, text); cur_company.Restore(); /* Don't return anything special here; no error, no costs. diff --git a/src/command_func.h b/src/command_func.h index 07de8de9c..eefaadd9b 100644 --- a/src/command_func.h +++ b/src/command_func.h @@ -35,12 +35,13 @@ static const CommandCost CMD_ERROR = CommandCost(INVALID_STRING_ID); CommandCost DoCommand(DoCommandFlag flags, uint32 cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text = {}); CommandCost DoCommand(const CommandContainer *container, DoCommandFlag flags); -bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback = nullptr, const std::string &text = {}, bool my_cmd = true); +bool DoCommandP(uint32 cmd, CommandCallback *callback, TileIndex tile, uint32 p1, uint32 p2, const std::string &text = {}); +bool DoCommandP(uint32 cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text = {}); bool DoCommandP(const CommandContainer *container, bool my_cmd = true); -CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const std::string &text, bool my_cmd, bool estimate_only); +CommandCost DoCommandPInternal(uint32 cmd, CommandCallback *callback, bool my_cmd, bool estimate_only, TileIndex tile, uint32 p1, uint32 p2, const std::string &text); -void NetworkSendCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const std::string &text, CompanyID company); +void NetworkSendCommand(uint32 cmd, CommandCallback *callback, CompanyID company, TileIndex tile, uint32 p1, uint32 p2, const std::string &text); extern Money _additional_cash_required; diff --git a/src/company_cmd.cpp b/src/company_cmd.cpp index ce7488f03..792dd624b 100644 --- a/src/company_cmd.cpp +++ b/src/company_cmd.cpp @@ -603,7 +603,7 @@ static bool MaybeStartNewCompany() if (n < (uint)_settings_game.difficulty.max_no_competitors) { /* Send a command to all clients to start up a new AI. * Works fine for Multiplayer and Singleplayer */ - return DoCommandP(0, CCA_NEW_AI | INVALID_COMPANY << 16, 0, CMD_COMPANY_CTRL); + return DoCommandP(CMD_COMPANY_CTRL, 0, CCA_NEW_AI | INVALID_COMPANY << 16, 0); } return false; diff --git a/src/company_gui.cpp b/src/company_gui.cpp index fe8c2326c..d8b468ad9 100644 --- a/src/company_gui.cpp +++ b/src/company_gui.cpp @@ -435,11 +435,11 @@ struct CompanyFinancesWindow : Window { break; case WID_CF_INCREASE_LOAN: // increase loan - DoCommandP(0, 0, _ctrl_pressed, CMD_INCREASE_LOAN | CMD_MSG(STR_ERROR_CAN_T_BORROW_ANY_MORE_MONEY)); + DoCommandP(CMD_INCREASE_LOAN | CMD_MSG(STR_ERROR_CAN_T_BORROW_ANY_MORE_MONEY), 0, 0, _ctrl_pressed); break; case WID_CF_REPAY_LOAN: // repay loan - DoCommandP(0, 0, _ctrl_pressed, CMD_DECREASE_LOAN | CMD_MSG(STR_ERROR_CAN_T_REPAY_LOAN)); + DoCommandP(CMD_DECREASE_LOAN | CMD_MSG(STR_ERROR_CAN_T_REPAY_LOAN), 0, 0, _ctrl_pressed); break; case WID_CF_INFRASTRUCTURE: // show infrastructure details @@ -995,12 +995,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))) { - DoCommandP(0, scheme | (widget == WID_SCL_PRI_COL_DROPDOWN ? 0 : 256), index, CMD_SET_COMPANY_COLOUR); + DoCommandP(CMD_SET_COMPANY_COLOUR, 0, scheme | (widget == WID_SCL_PRI_COL_DROPDOWN ? 0 : 256), index); } } } else { /* Setting group livery */ - DoCommandP(0, this->sel, (widget == WID_SCL_PRI_COL_DROPDOWN ? 0 : 256) | (index << 16), CMD_SET_GROUP_LIVERY); + DoCommandP(CMD_SET_GROUP_LIVERY, 0, this->sel, (widget == WID_SCL_PRI_COL_DROPDOWN ? 0 : 256) | (index << 16)); } } @@ -1581,7 +1581,7 @@ public: /* OK button */ case WID_SCMF_ACCEPT: - DoCommandP(0, 0, this->face, CMD_SET_COMPANY_MANAGER_FACE); + DoCommandP(CMD_SET_COMPANY_MANAGER_FACE, 0, 0, this->face); FALLTHROUGH; /* Cancel button */ @@ -2576,11 +2576,11 @@ struct CompanyWindow : Window break; case WID_C_BUY_SHARE: - DoCommandP(0, this->window_number, 0, CMD_BUY_SHARE_IN_COMPANY | CMD_MSG(STR_ERROR_CAN_T_BUY_25_SHARE_IN_THIS)); + DoCommandP(CMD_BUY_SHARE_IN_COMPANY | CMD_MSG(STR_ERROR_CAN_T_BUY_25_SHARE_IN_THIS), 0, this->window_number, 0); break; case WID_C_SELL_SHARE: - DoCommandP(0, this->window_number, 0, CMD_SELL_SHARE_IN_COMPANY | CMD_MSG(STR_ERROR_CAN_T_SELL_25_SHARE_IN)); + DoCommandP(CMD_SELL_SHARE_IN_COMPANY | CMD_MSG(STR_ERROR_CAN_T_SELL_25_SHARE_IN), 0, this->window_number, 0); break; case WID_C_COMPANY_PASSWORD: @@ -2613,7 +2613,7 @@ struct CompanyWindow : Window void OnPlaceObject(Point pt, TileIndex tile) override { - if (DoCommandP(tile, OBJECT_HQ, 0, CMD_BUILD_OBJECT | CMD_MSG(STR_ERROR_CAN_T_BUILD_COMPANY_HEADQUARTERS)) && !_shift_pressed) { + if (DoCommandP(CMD_BUILD_OBJECT | CMD_MSG(STR_ERROR_CAN_T_BUILD_COMPANY_HEADQUARTERS), tile, OBJECT_HQ, 0) && !_shift_pressed) { ResetObjectToPlace(); this->RaiseButtons(); } @@ -2635,16 +2635,16 @@ struct CompanyWindow : Window Money money = (Money)(strtoull(str, nullptr, 10) / _currency->rate); uint32 money_c = Clamp(ClampToI32(money), 0, 20000000); // Clamp between 20 million and 0 - DoCommandP(0, money_c, this->window_number, CMD_GIVE_MONEY | CMD_MSG(STR_ERROR_CAN_T_GIVE_MONEY)); + DoCommandP(CMD_GIVE_MONEY | CMD_MSG(STR_ERROR_CAN_T_GIVE_MONEY), 0, money_c, this->window_number); break; } case WID_C_PRESIDENT_NAME: - DoCommandP(0, 0, 0, CMD_RENAME_PRESIDENT | CMD_MSG(STR_ERROR_CAN_T_CHANGE_PRESIDENT), nullptr, str); + DoCommandP(CMD_RENAME_PRESIDENT | CMD_MSG(STR_ERROR_CAN_T_CHANGE_PRESIDENT), 0, 0, 0, str); break; case WID_C_COMPANY_NAME: - DoCommandP(0, 0, 0, CMD_RENAME_COMPANY | CMD_MSG(STR_ERROR_CAN_T_CHANGE_COMPANY_NAME), nullptr, str); + DoCommandP(CMD_RENAME_COMPANY | CMD_MSG(STR_ERROR_CAN_T_CHANGE_COMPANY_NAME), 0, 0, 0, str); break; case WID_C_COMPANY_JOIN: @@ -2771,7 +2771,7 @@ struct BuyCompanyWindow : Window { break; case WID_BC_YES: - DoCommandP(0, this->window_number, 0, CMD_BUY_COMPANY | CMD_MSG(STR_ERROR_CAN_T_BUY_COMPANY)); + DoCommandP(CMD_BUY_COMPANY | CMD_MSG(STR_ERROR_CAN_T_BUY_COMPANY), 0, this->window_number, 0); break; } } diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp index 5cdb744ab..040b938fe 100644 --- a/src/console_cmds.cpp +++ b/src/console_cmds.cpp @@ -630,7 +630,7 @@ DEF_CONSOLE_CMD(ConPauseGame) } if ((_pause_mode & PM_PAUSED_NORMAL) == PM_UNPAUSED) { - DoCommandP(0, PM_PAUSED_NORMAL, 1, CMD_PAUSE); + DoCommandP(CMD_PAUSE, 0, PM_PAUSED_NORMAL, 1); if (!_networking) IConsolePrint(CC_DEFAULT, "Game paused."); } else { IConsolePrint(CC_DEFAULT, "Game is already paused."); @@ -652,7 +652,7 @@ DEF_CONSOLE_CMD(ConUnpauseGame) } if ((_pause_mode & PM_PAUSED_NORMAL) != PM_UNPAUSED) { - DoCommandP(0, PM_PAUSED_NORMAL, 0, CMD_PAUSE); + DoCommandP(CMD_PAUSE, 0, PM_PAUSED_NORMAL, 0); if (!_networking) IConsolePrint(CC_DEFAULT, "Game unpaused."); } else if ((_pause_mode & PM_PAUSED_ERROR) != PM_UNPAUSED) { IConsolePrint(CC_DEFAULT, "Game is in error state and cannot be unpaused via console."); @@ -863,7 +863,7 @@ DEF_CONSOLE_CMD(ConResetCompany) } /* It is safe to remove this company */ - DoCommandP(0, CCA_DELETE | index << 16 | CRR_MANUAL << 24, 0, CMD_COMPANY_CTRL); + DoCommandP(CMD_COMPANY_CTRL, 0, CCA_DELETE | index << 16 | CRR_MANUAL << 24, 0); IConsolePrint(CC_DEFAULT, "Company deleted."); return true; @@ -1220,7 +1220,7 @@ DEF_CONSOLE_CMD(ConStartAI) } /* Start a new AI company */ - DoCommandP(0, CCA_NEW_AI | INVALID_COMPANY << 16, 0, CMD_COMPANY_CTRL); + DoCommandP(CMD_COMPANY_CTRL, 0, CCA_NEW_AI | INVALID_COMPANY << 16, 0); return true; } @@ -1256,8 +1256,8 @@ DEF_CONSOLE_CMD(ConReloadAI) } /* First kill the company of the AI, then start a new one. This should start the current AI again */ - DoCommandP(0, CCA_DELETE | company_id << 16 | CRR_MANUAL << 24, 0, CMD_COMPANY_CTRL); - DoCommandP(0, CCA_NEW_AI | company_id << 16, 0, CMD_COMPANY_CTRL); + DoCommandP(CMD_COMPANY_CTRL, 0, CCA_DELETE | company_id << 16 | CRR_MANUAL << 24, 0); + DoCommandP(CMD_COMPANY_CTRL, 0, CCA_NEW_AI | company_id << 16, 0); IConsolePrint(CC_DEFAULT, "AI reloaded."); return true; @@ -1294,7 +1294,7 @@ DEF_CONSOLE_CMD(ConStopAI) } /* Now kill the company of the AI. */ - DoCommandP(0, CCA_DELETE | company_id << 16 | CRR_MANUAL << 24, 0, CMD_COMPANY_CTRL); + DoCommandP(CMD_COMPANY_CTRL, 0, CCA_DELETE | company_id << 16 | CRR_MANUAL << 24, 0); IConsolePrint(CC_DEFAULT, "AI stopped, company deleted."); return true; diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp index d6f4d900c..7ff812c23 100644 --- a/src/depot_gui.cpp +++ b/src/depot_gui.cpp @@ -141,7 +141,7 @@ static void TrainDepotMoveVehicle(const Vehicle *wagon, VehicleID sel, const Veh if (wagon == v) return; - DoCommandP(v->tile, v->index | (_ctrl_pressed ? 1 : 0) << 20, wagon == nullptr ? INVALID_VEHICLE : wagon->index, CMD_MOVE_RAIL_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_MOVE_VEHICLE)); + DoCommandP(CMD_MOVE_RAIL_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_MOVE_VEHICLE), v->tile, v->index | (_ctrl_pressed ? 1 : 0) << 20, wagon == nullptr ? INVALID_VEHICLE : wagon->index); } static VehicleCellSize _base_block_sizes_depot[VEH_COMPANY_END]; ///< Cell size for vehicle images in the depot view. @@ -802,7 +802,7 @@ struct DepotWindow : Window { case WID_D_STOP_ALL: case WID_D_START_ALL: { VehicleListIdentifier vli(VL_DEPOT_LIST, this->type, this->owner); - DoCommandP(this->window_number, (widget == WID_D_START_ALL ? (1 << 0) : 0), vli.Pack(), CMD_MASS_START_STOP); + DoCommandP(CMD_MASS_START_STOP, this->window_number, (widget == WID_D_START_ALL ? (1 << 0) : 0), vli.Pack()); break; } @@ -825,7 +825,7 @@ struct DepotWindow : Window { break; case WID_D_AUTOREPLACE: - DoCommandP(this->window_number, this->type, 0, CMD_DEPOT_MASS_AUTOREPLACE); + DoCommandP(CMD_DEPOT_MASS_AUTOREPLACE, this->window_number, this->type, 0); break; } @@ -836,7 +836,7 @@ struct DepotWindow : Window { if (str == nullptr) return; /* Do depot renaming */ - DoCommandP(0, this->GetDepotIndex(), 0, CMD_RENAME_DEPOT | CMD_MSG(STR_ERROR_CAN_T_RENAME_DEPOT), nullptr, str); + DoCommandP(CMD_RENAME_DEPOT | CMD_MSG(STR_ERROR_CAN_T_RENAME_DEPOT), 0, this->GetDepotIndex(), 0, str); } bool OnRightClick(Point pt, int widget) override @@ -904,10 +904,10 @@ struct DepotWindow : Window { { if (_ctrl_pressed) { /* Share-clone, do not open new viewport, and keep tool active */ - DoCommandP(this->window_number, v->index, 1, CMD_CLONE_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_BUY_TRAIN + v->type), nullptr); + DoCommandP(CMD_CLONE_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_BUY_TRAIN + v->type), this->window_number, v->index, 1); } else { /* Copy-clone, open viewport for new vehicle, and deselect the tool (assume player wants to changs things on new vehicle) */ - if (DoCommandP(this->window_number, v->index, 0, CMD_CLONE_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_BUY_TRAIN + v->type), CcCloneVehicle)) { + if (DoCommandP(CMD_CLONE_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_BUY_TRAIN + v->type), CcCloneVehicle, this->window_number, v->index, 0)) { ResetObjectToPlace(); } } @@ -1001,8 +1001,8 @@ struct DepotWindow : Window { if (this->GetVehicleFromDepotWndPt(pt.x - nwi->pos_x, pt.y - nwi->pos_y, &v, &gdvp) == MODE_DRAG_VEHICLE && sel != INVALID_VEHICLE) { if (gdvp.wagon != nullptr && gdvp.wagon->index == sel && _ctrl_pressed) { - DoCommandP(Vehicle::Get(sel)->tile, Vehicle::Get(sel)->index, true, - CMD_REVERSE_TRAIN_DIRECTION | CMD_MSG(STR_ERROR_CAN_T_REVERSE_DIRECTION_RAIL_VEHICLE)); + DoCommandP(CMD_REVERSE_TRAIN_DIRECTION | CMD_MSG(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 = INVALID_VEHICLE; TrainDepotMoveVehicle(gdvp.wagon, sel, gdvp.head); @@ -1027,7 +1027,7 @@ struct DepotWindow : Window { this->SetDirty(); int sell_cmd = (v->type == VEH_TRAIN && (widget == WID_D_SELL_CHAIN || _ctrl_pressed)) ? 1 : 0; - DoCommandP(v->tile, v->index | sell_cmd << 20 | MAKE_ORDER_BACKUP_FLAG, 0, GetCmdSellVeh(v->type)); + DoCommandP(GetCmdSellVeh(v->type), v->tile, v->index | sell_cmd << 20 | MAKE_ORDER_BACKUP_FLAG, 0); break; } @@ -1091,7 +1091,7 @@ static void DepotSellAllConfirmationCallback(Window *win, bool confirmed) DepotWindow *w = (DepotWindow*)win; TileIndex tile = w->window_number; byte vehtype = w->type; - DoCommandP(tile, vehtype, 0, CMD_DEPOT_SELL_ALL_VEHICLES); + DoCommandP(CMD_DEPOT_SELL_ALL_VEHICLES, tile, vehtype, 0); } } diff --git a/src/dock_gui.cpp b/src/dock_gui.cpp index 77ebe1be7..0911555a4 100644 --- a/src/dock_gui.cpp +++ b/src/dock_gui.cpp @@ -191,7 +191,7 @@ struct BuildDocksToolbarWindow : Window { break; case WID_DT_LOCK: // Build lock button - DoCommandP(tile, 0, 0, CMD_BUILD_LOCK | CMD_MSG(STR_ERROR_CAN_T_BUILD_LOCKS), CcBuildDocks); + DoCommandP(CMD_BUILD_LOCK | CMD_MSG(STR_ERROR_CAN_T_BUILD_LOCKS), CcBuildDocks, tile, 0, 0); break; case WID_DT_DEMOLISH: // Demolish aka dynamite button @@ -199,7 +199,7 @@ struct BuildDocksToolbarWindow : Window { break; case WID_DT_DEPOT: // Build depot button - DoCommandP(tile, _ship_depot_direction, 0, CMD_BUILD_SHIP_DEPOT | CMD_MSG(STR_ERROR_CAN_T_BUILD_SHIP_DEPOT), CcBuildDocks); + DoCommandP(CMD_BUILD_SHIP_DEPOT | CMD_MSG(STR_ERROR_CAN_T_BUILD_SHIP_DEPOT), CcBuildDocks, tile, _ship_depot_direction, 0); break; case WID_DT_STATION: { // Build station button @@ -217,7 +217,7 @@ struct BuildDocksToolbarWindow : Window { } case WID_DT_BUOY: // Build buoy button - DoCommandP(tile, 0, 0, CMD_BUILD_BUOY | CMD_MSG(STR_ERROR_CAN_T_POSITION_BUOY_HERE), CcBuildDocks); + DoCommandP(CMD_BUILD_BUOY | CMD_MSG(STR_ERROR_CAN_T_POSITION_BUOY_HERE), CcBuildDocks, tile, 0, 0); break; case WID_DT_RIVER: // Build river button (in scenario editor) @@ -225,7 +225,7 @@ struct BuildDocksToolbarWindow : Window { break; case WID_DT_BUILD_AQUEDUCT: // Build aqueduct button - DoCommandP(tile, GetOtherAqueductEnd(tile), TRANSPORT_WATER << 15, CMD_BUILD_BRIDGE | CMD_MSG(STR_ERROR_CAN_T_BUILD_AQUEDUCT_HERE), CcBuildBridge); + DoCommandP(CMD_BUILD_BRIDGE | CMD_MSG(STR_ERROR_CAN_T_BUILD_AQUEDUCT_HERE), CcBuildBridge, tile, GetOtherAqueductEnd(tile), TRANSPORT_WATER << 15); break; default: NOT_REACHED(); @@ -245,10 +245,10 @@ struct BuildDocksToolbarWindow : Window { GUIPlaceProcDragXY(select_proc, start_tile, end_tile); break; case DDSP_CREATE_WATER: - DoCommandP(end_tile, start_tile, (_game_mode == GM_EDITOR && _ctrl_pressed) ? WATER_CLASS_SEA : WATER_CLASS_CANAL, CMD_BUILD_CANAL | CMD_MSG(STR_ERROR_CAN_T_BUILD_CANALS), CcPlaySound_CONSTRUCTION_WATER); + DoCommandP(CMD_BUILD_CANAL | CMD_MSG(STR_ERROR_CAN_T_BUILD_CANALS), CcPlaySound_CONSTRUCTION_WATER, end_tile, start_tile, (_game_mode == GM_EDITOR && _ctrl_pressed) ? WATER_CLASS_SEA : WATER_CLASS_CANAL); break; case DDSP_CREATE_RIVER: - DoCommandP(end_tile, start_tile, WATER_CLASS_RIVER | (_ctrl_pressed ? 1 << 2 : 0), CMD_BUILD_CANAL | CMD_MSG(STR_ERROR_CAN_T_PLACE_RIVERS), CcPlaySound_CONSTRUCTION_WATER); + DoCommandP(CMD_BUILD_CANAL | CMD_MSG(STR_ERROR_CAN_T_PLACE_RIVERS), CcPlaySound_CONSTRUCTION_WATER, end_tile, start_tile, WATER_CLASS_RIVER | (_ctrl_pressed ? 1 << 2 : 0)); break; default: break; diff --git a/src/economy.cpp b/src/economy.cpp index 5c2563645..b7100257a 100644 --- a/src/economy.cpp +++ b/src/economy.cpp @@ -627,7 +627,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) { - DoCommandP(0, CCA_DELETE | (c->index << 16) | (CRR_BANKRUPT << 24), 0, CMD_COMPANY_CTRL); + DoCommandP(CMD_COMPANY_CTRL, 0, CCA_DELETE | (c->index << 16) | (CRR_BANKRUPT << 24), 0); return; } break; diff --git a/src/engine_gui.cpp b/src/engine_gui.cpp index bc0143be1..6710967f4 100644 --- a/src/engine_gui.cpp +++ b/src/engine_gui.cpp @@ -125,7 +125,7 @@ struct EnginePreviewWindow : Window { { switch (widget) { case WID_EP_YES: - DoCommandP(0, this->window_number, 0, CMD_WANT_ENGINE_PREVIEW); + DoCommandP(CMD_WANT_ENGINE_PREVIEW, 0, this->window_number, 0); FALLTHROUGH; case WID_EP_NO: if (!_shift_pressed) this->Close(); diff --git a/src/fios_gui.cpp b/src/fios_gui.cpp index c0551701e..9d7ab70d8 100644 --- a/src/fios_gui.cpp +++ b/src/fios_gui.cpp @@ -358,7 +358,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) { - DoCommandP(0, PM_PAUSED_SAVELOAD, 1, CMD_PAUSE); + DoCommandP(CMD_PAUSE, 0, PM_PAUSED_SAVELOAD, 1); } SetObjectToPlace(SPR_CURSOR_ZZZ, PAL_NONE, HT_NONE, WC_MAIN_WINDOW, 0); @@ -402,7 +402,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) { - DoCommandP(0, PM_PAUSED_SAVELOAD, 0, CMD_PAUSE); + DoCommandP(CMD_PAUSE, 0, PM_PAUSED_SAVELOAD, 0); } this->Window::Close(); } diff --git a/src/goal_gui.cpp b/src/goal_gui.cpp index 65ed9003b..d6180b0df 100644 --- a/src/goal_gui.cpp +++ b/src/goal_gui.cpp @@ -382,17 +382,17 @@ struct GoalQuestionWindow : public Window { { switch (widget) { case WID_GQ_BUTTON_1: - DoCommandP(0, this->window_number, this->button[0], CMD_GOAL_QUESTION_ANSWER); + DoCommandP(CMD_GOAL_QUESTION_ANSWER, 0, this->window_number, this->button[0]); this->Close(); break; case WID_GQ_BUTTON_2: - DoCommandP(0, this->window_number, this->button[1], CMD_GOAL_QUESTION_ANSWER); + DoCommandP(CMD_GOAL_QUESTION_ANSWER, 0, this->window_number, this->button[1]); this->Close(); break; case WID_GQ_BUTTON_3: - DoCommandP(0, this->window_number, this->button[2], CMD_GOAL_QUESTION_ANSWER); + DoCommandP(CMD_GOAL_QUESTION_ANSWER, 0, this->window_number, this->button[2]); this->Close(); break; } diff --git a/src/group_gui.cpp b/src/group_gui.cpp index 374ed5700..ee8e60474 100644 --- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -640,7 +640,7 @@ public: if (confirmed) { VehicleGroupWindow *w = (VehicleGroupWindow*)win; w->vli.index = ALL_GROUP; - DoCommandP(0, w->group_confirm, 0, CMD_DELETE_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_DELETE)); + DoCommandP(CMD_DELETE_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_DELETE), 0, w->group_confirm, 0); } } @@ -771,7 +771,7 @@ public: } case WID_GL_CREATE_GROUP: { // Create a new group - DoCommandP(0, this->vli.vtype, this->vli.index, CMD_CREATE_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_CREATE), CcCreateGroup); + DoCommandP(CMD_CREATE_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_CREATE), CcCreateGroup, 0, this->vli.vtype, this->vli.index); break; } @@ -800,14 +800,14 @@ public: case WID_GL_START_ALL: case WID_GL_STOP_ALL: { // Start/stop all vehicles of the list - DoCommandP(0, (1 << 1) | (widget == WID_GL_START_ALL ? (1 << 0) : 0), this->vli.Pack(), CMD_MASS_START_STOP); + DoCommandP(CMD_MASS_START_STOP, 0, (1 << 1) | (widget == WID_GL_START_ALL ? (1 << 0) : 0), this->vli.Pack()); break; } case WID_GL_REPLACE_PROTECTION: { const Group *g = Group::GetIfValid(this->vli.index); if (g != nullptr) { - DoCommandP(0, this->vli.index | (GroupFlags::GF_REPLACE_PROTECTION << 16), (HasBit(g->flags, GroupFlags::GF_REPLACE_PROTECTION) ? 0 : 1) | (_ctrl_pressed << 1), CMD_SET_GROUP_FLAG); + DoCommandP(CMD_SET_GROUP_FLAG, 0, this->vli.index | (GroupFlags::GF_REPLACE_PROTECTION << 16), (HasBit(g->flags, GroupFlags::GF_REPLACE_PROTECTION) ? 0 : 1) | (_ctrl_pressed << 1)); } break; } @@ -822,7 +822,7 @@ public: case WID_GL_ALL_VEHICLES: // All vehicles case WID_GL_DEFAULT_VEHICLES: // Ungrouped vehicles if (g->parent != INVALID_GROUP) { - DoCommandP(0, this->group_sel | (1 << 16), INVALID_GROUP, CMD_ALTER_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_SET_PARENT)); + DoCommandP(CMD_ALTER_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_SET_PARENT), 0, this->group_sel | (1 << 16), INVALID_GROUP); } this->group_sel = INVALID_GROUP; @@ -835,7 +835,7 @@ public: GroupID new_g = id_g >= this->groups.size() ? INVALID_GROUP : this->groups[id_g]->index; if (this->group_sel != new_g && g->parent != new_g) { - DoCommandP(0, this->group_sel | (1 << 16), new_g, CMD_ALTER_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_SET_PARENT)); + DoCommandP(CMD_ALTER_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_SET_PARENT), 0, this->group_sel | (1 << 16), new_g); } this->group_sel = INVALID_GROUP; @@ -850,7 +850,7 @@ public: { switch (widget) { case WID_GL_DEFAULT_VEHICLES: // Ungrouped vehicles - DoCommandP(0, DEFAULT_GROUP, this->vehicle_sel | (_ctrl_pressed || this->grouping == GB_SHARED_ORDERS ? 1 << 31 : 0), CMD_ADD_VEHICLE_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_ADD_VEHICLE)); + DoCommandP(CMD_ADD_VEHICLE_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_ADD_VEHICLE), 0, DEFAULT_GROUP, this->vehicle_sel | (_ctrl_pressed || this->grouping == GB_SHARED_ORDERS ? 1 << 31 : 0)); this->vehicle_sel = INVALID_VEHICLE; this->group_over = INVALID_GROUP; @@ -867,7 +867,7 @@ public: uint id_g = this->group_sb->GetScrolledRowFromWidget(pt.y, this, WID_GL_LIST_GROUP); GroupID new_g = id_g >= this->groups.size() ? NEW_GROUP : this->groups[id_g]->index; - DoCommandP(0, new_g, vindex | (_ctrl_pressed || this->grouping == GB_SHARED_ORDERS ? 1 << 31 : 0), CMD_ADD_VEHICLE_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_ADD_VEHICLE), new_g == NEW_GROUP ? CcAddVehicleNewGroup : nullptr); + DoCommandP(CMD_ADD_VEHICLE_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_ADD_VEHICLE), new_g == NEW_GROUP ? CcAddVehicleNewGroup : nullptr, 0, new_g, vindex | (_ctrl_pressed || this->grouping == GB_SHARED_ORDERS ? 1 << 31 : 0)); break; } @@ -922,7 +922,7 @@ public: void OnQueryTextFinished(char *str) override { - if (str != nullptr) DoCommandP(0, this->group_rename, 0, CMD_ALTER_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_RENAME), nullptr, str); + if (str != nullptr) DoCommandP(CMD_ALTER_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_RENAME), 0, this->group_rename, 0, str); this->group_rename = INVALID_GROUP; } @@ -952,19 +952,19 @@ public: break; case ADI_SERVICE: // Send for servicing case ADI_DEPOT: { // Send to Depots - DoCommandP(0, DEPOT_MASS_SEND | (index == ADI_SERVICE ? DEPOT_SERVICE : 0U), this->vli.Pack(), GetCmdSendToDepot(this->vli.vtype)); + DoCommandP(GetCmdSendToDepot(this->vli.vtype), 0, DEPOT_MASS_SEND | (index == ADI_SERVICE ? DEPOT_SERVICE : 0U), this->vli.Pack()); break; } case ADI_ADD_SHARED: // Add shared Vehicles assert(Group::IsValidID(this->vli.index)); - DoCommandP(0, this->vli.index, this->vli.vtype, CMD_ADD_SHARED_VEHICLE_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_ADD_SHARED_VEHICLE)); + DoCommandP(CMD_ADD_SHARED_VEHICLE_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_ADD_SHARED_VEHICLE), 0, this->vli.index, this->vli.vtype); break; case ADI_REMOVE_ALL: // Remove all Vehicles from the selected group assert(Group::IsValidID(this->vli.index)); - DoCommandP(0, this->vli.index, 0, CMD_REMOVE_ALL_VEHICLES_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_REMOVE_ALL_VEHICLES)); + DoCommandP(CMD_REMOVE_ALL_VEHICLES_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_REMOVE_ALL_VEHICLES), 0, this->vli.index, 0); break; default: NOT_REACHED(); } diff --git a/src/highscore_gui.cpp b/src/highscore_gui.cpp index 768b9c9c1..0dfaebc3b 100644 --- a/src/highscore_gui.cpp +++ b/src/highscore_gui.cpp @@ -96,7 +96,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) DoCommandP(0, PM_PAUSED_NORMAL, 1, CMD_PAUSE); + if (!_networking) DoCommandP(CMD_PAUSE, 0, PM_PAUSED_NORMAL, 1); this->background_img = SPR_TYCOON_IMG1_BEGIN; @@ -124,7 +124,7 @@ struct EndGameWindow : EndGameHighScoreBaseWindow { void Close() override { - if (!_networking) DoCommandP(0, PM_PAUSED_NORMAL, 0, CMD_PAUSE); // unpause + if (!_networking) DoCommandP(CMD_PAUSE, 0, PM_PAUSED_NORMAL, 0); // unpause ShowHighscoreTable(this->window_number, this->rank); this->EndGameHighScoreBaseWindow::Close(); } @@ -159,7 +159,7 @@ struct HighScoreWindow : EndGameHighScoreBaseWindow { { /* pause game to show the chart */ this->game_paused_by_player = _pause_mode == PM_PAUSED_NORMAL; - if (!_networking && !this->game_paused_by_player) DoCommandP(0, PM_PAUSED_NORMAL, 1, CMD_PAUSE); + if (!_networking && !this->game_paused_by_player) DoCommandP(CMD_PAUSE, 0, PM_PAUSED_NORMAL, 1); /* Close all always on-top windows to get a clean screen */ if (_game_mode != GM_MENU) HideVitalWindows(); @@ -174,7 +174,7 @@ struct HighScoreWindow : EndGameHighScoreBaseWindow { { if (_game_mode != GM_MENU) ShowVitalWindows(); - if (!_networking && !this->game_paused_by_player) DoCommandP(0, PM_PAUSED_NORMAL, 0, CMD_PAUSE); // unpause + if (!_networking && !this->game_paused_by_player) DoCommandP(CMD_PAUSE, 0, PM_PAUSED_NORMAL, 0); // unpause this->EndGameHighScoreBaseWindow::Close(); } diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp index bfdb308b6..e78b6853d 100644 --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -678,7 +678,7 @@ public: case WID_DPI_FUND_WIDGET: { if (this->selected_type != INVALID_INDUSTRYTYPE) { if (_game_mode != GM_EDITOR && _settings_game.construction.raw_industry_construction == 2 && GetIndustrySpec(this->selected_type)->IsRawIndustry()) { - DoCommandP(0, this->selected_type, InteractiveRandom(), CMD_BUILD_INDUSTRY | CMD_MSG(STR_ERROR_CAN_T_CONSTRUCT_THIS_INDUSTRY)); + DoCommandP(CMD_BUILD_INDUSTRY | CMD_MSG(STR_ERROR_CAN_T_CONSTRUCT_THIS_INDUSTRY), 0, this->selected_type, InteractiveRandom()); this->HandleButtonClick(WID_DPI_FUND_WIDGET); } else { HandlePlacePushButton(this, WID_DPI_FUND_WIDGET, SPR_CURSOR_INDUSTRY, HT_RECT); @@ -715,14 +715,13 @@ public: Backup old_generating_world(_generating_world, true, FILE_LINE); _ignore_restrictions = true; - DoCommandP(tile, (layout_index << 8) | this->selected_type, seed, - CMD_BUILD_INDUSTRY | CMD_MSG(STR_ERROR_CAN_T_CONSTRUCT_THIS_INDUSTRY), &CcBuildIndustry); + DoCommandP(CMD_BUILD_INDUSTRY | CMD_MSG(STR_ERROR_CAN_T_CONSTRUCT_THIS_INDUSTRY), &CcBuildIndustry, tile, (layout_index << 8) | this->selected_type, seed); cur_company.Restore(); old_generating_world.Restore(); _ignore_restrictions = false; } else { - success = DoCommandP(tile, (layout_index << 8) | this->selected_type, seed, CMD_BUILD_INDUSTRY | CMD_MSG(STR_ERROR_CAN_T_CONSTRUCT_THIS_INDUSTRY)); + success = DoCommandP(CMD_BUILD_INDUSTRY | CMD_MSG(STR_ERROR_CAN_T_CONSTRUCT_THIS_INDUSTRY), tile, (layout_index << 8) | this->selected_type, seed); } /* If an industry has been built, just reset the cursor and the system */ diff --git a/src/linkgraph/linkgraphschedule.cpp b/src/linkgraph/linkgraphschedule.cpp index ce28ec3d8..c4fc2d5f9 100644 --- a/src/linkgraph/linkgraphschedule.cpp +++ b/src/linkgraph/linkgraphschedule.cpp @@ -173,7 +173,7 @@ void StateGameLoop_LinkGraphPauseControl() if (_pause_mode & PM_PAUSED_LINK_GRAPH) { /* We are paused waiting on a job, check the job every tick. */ if (!LinkGraphSchedule::instance.IsJoinWithUnfinishedJobDue()) { - DoCommandP(0, PM_PAUSED_LINK_GRAPH, 0, CMD_PAUSE); + DoCommandP(CMD_PAUSE, 0, PM_PAUSED_LINK_GRAPH, 0); } } else if (_pause_mode == PM_UNPAUSED && _date_fract == LinkGraphSchedule::SPAWN_JOIN_TICK - 2 && @@ -181,7 +181,7 @@ void StateGameLoop_LinkGraphPauseControl() LinkGraphSchedule::instance.IsJoinWithUnfinishedJobDue()) { /* Perform check two _date_fract ticks before we would join, to make * sure it also works in multiplayer. */ - DoCommandP(0, PM_PAUSED_LINK_GRAPH, 1, CMD_PAUSE); + DoCommandP(CMD_PAUSE, 0, PM_PAUSED_LINK_GRAPH, 1); } } diff --git a/src/main_gui.cpp b/src/main_gui.cpp index 6131050cf..46fff1a51 100644 --- a/src/main_gui.cpp +++ b/src/main_gui.cpp @@ -326,7 +326,7 @@ struct MainWindow : Window case GHK_MONEY: // Gimme money /* You can only cheat for money in singleplayer mode. */ - if (!_networking) DoCommandP(0, 10000000, 0, CMD_MONEY_CHEAT); + if (!_networking) DoCommandP(CMD_MONEY_CHEAT, 0, 10000000, 0); 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 e60717cf8..c461d36dc 100644 --- a/src/misc_cmd.cpp +++ b/src/misc_cmd.cpp @@ -134,7 +134,7 @@ CommandCost CmdDecreaseLoan(TileIndex tile, DoCommandFlag flags, uint32 p1, uint static void AskUnsafeUnpauseCallback(Window *w, bool confirmed) { if (confirmed) { - DoCommandP(0, PM_PAUSED_ERROR, 0, CMD_PAUSE); + DoCommandP(CMD_PAUSE, 0, PM_PAUSED_ERROR, 0); } } diff --git a/src/network/network.cpp b/src/network/network.cpp index dd0a91594..6e111926e 100644 --- a/src/network/network.cpp +++ b/src/network/network.cpp @@ -394,7 +394,7 @@ static void CheckPauseHelper(bool pause, PauseMode pm) { if (pause == ((_pause_mode & pm) != PM_UNPAUSED)) return; - DoCommandP(0, pm, pause ? 1 : 0, CMD_PAUSE); + DoCommandP(CMD_PAUSE, 0, pm, pause ? 1 : 0); } /** @@ -1064,7 +1064,7 @@ void NetworkGameLoop() while (f != nullptr && !feof(f)) { if (_date == next_date && _date_fract == next_date_fract) { if (cp != nullptr) { - NetworkSendCommand(cp->tile, cp->p1, cp->p2, cp->cmd & ~CMD_FLAGS_MASK, nullptr, cp->text, cp->company); + NetworkSendCommand(cp->cmd & ~CMD_FLAGS_MASK, nullptr, cp->company, cp->tile, cp->p1, cp->p2, cp->text); Debug(desync, 0, "Injecting: {:08x}; {:02x}; {:02x}; {:06x}; {:08x}; {:08x}; {:08x}; \"{}\" ({})", _date, _date_fract, (int)_current_company, cp->tile, cp->p1, cp->p2, cp->cmd, cp->text, GetCommandName(cp->cmd)); delete cp; cp = nullptr; diff --git a/src/network/network_client.cpp b/src/network/network_client.cpp index f03601b39..e638df005 100644 --- a/src/network/network_client.cpp +++ b/src/network/network_client.cpp @@ -839,7 +839,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_MAP_DONE(Packet * the server will give us a client-id and let us in */ _network_join_status = NETWORK_JOIN_STATUS_REGISTERING; ShowJoinStatusWindow(); - NetworkSendCommand(0, CCA_NEW, 0, CMD_COMPANY_CTRL, nullptr, {}, _local_company); + NetworkSendCommand(CMD_COMPANY_CTRL, nullptr, _local_company, 0, CCA_NEW, 0, {}); } } else { /* take control over an existing company */ diff --git a/src/network/network_command.cpp b/src/network/network_command.cpp index 6d03aaaa1..f1a0f682d 100644 --- a/src/network/network_command.cpp +++ b/src/network/network_command.cpp @@ -125,15 +125,15 @@ static CommandQueue _local_execution_queue; /** * Prepare a DoCommand to be send over the network + * @param cmd The command to execute (a CMD_* value) + * @param callback A callback function to call after the command is finished + * @param company The company that wants to send the command * @param tile The tile to perform a command on (see #CommandProc) * @param p1 Additional data for the command (see #CommandProc) * @param p2 Additional data for the command (see #CommandProc) - * @param cmd The command to execute (a CMD_* value) - * @param callback A callback function to call after the command is finished * @param text The text to pass - * @param company The company that wants to send the command */ -void NetworkSendCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const std::string &text, CompanyID company) +void NetworkSendCommand(uint32 cmd, CommandCallback *callback, CompanyID company, TileIndex tile, uint32 p1, uint32 p2, const std::string &text) { assert((cmd & CMD_FLAGS_MASK) == 0); diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index 76385a087..c795e1550 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -1395,7 +1395,7 @@ static void AdminCompanyResetCallback(Window *w, bool confirmed) { if (confirmed) { if (NetworkCompanyHasClients(_admin_company_id)) return; - DoCommandP(0, CCA_DELETE | _admin_company_id << 16 | CRR_MANUAL << 24, 0, CMD_COMPANY_CTRL); + DoCommandP(CMD_COMPANY_CTRL, 0, CCA_DELETE | _admin_company_id << 16 | CRR_MANUAL << 24, 0); } } @@ -1535,9 +1535,9 @@ private: static void OnClickCompanyNew(NetworkClientListWindow *w, Point pt, CompanyID company_id) { if (_network_server) { - DoCommandP(0, CCA_NEW, _network_own_client_id, CMD_COMPANY_CTRL); + DoCommandP(CMD_COMPANY_CTRL, 0, CCA_NEW, _network_own_client_id); } else { - NetworkSendCommand(0, CCA_NEW, 0, CMD_COMPANY_CTRL, nullptr, {}, _local_company); + NetworkSendCommand(CMD_COMPANY_CTRL, nullptr, _local_company, 0, CCA_NEW, 0, {}); } } diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp index 9deaa5522..65e801073 100644 --- a/src/network/network_server.cpp +++ b/src/network/network_server.cpp @@ -1553,7 +1553,7 @@ static void NetworkAutoCleanCompanies() /* Is the company empty for autoclean_unprotected-months, and is there no protection? */ if (_settings_client.network.autoclean_unprotected != 0 && _network_company_states[c->index].months_empty > _settings_client.network.autoclean_unprotected && _network_company_states[c->index].password.empty()) { /* Shut the company down */ - DoCommandP(0, CCA_DELETE | c->index << 16 | CRR_AUTOCLEAN << 24, 0, CMD_COMPANY_CTRL); + DoCommandP(CMD_COMPANY_CTRL, 0, CCA_DELETE | c->index << 16 | CRR_AUTOCLEAN << 24, 0); IConsolePrint(CC_INFO, "Auto-cleaned company #{} with no password.", c->index + 1); } /* Is the company empty for autoclean_protected-months, and there is a protection? */ @@ -1567,7 +1567,7 @@ static void NetworkAutoCleanCompanies() /* Is the company empty for autoclean_novehicles-months, and has no vehicles? */ if (_settings_client.network.autoclean_novehicles != 0 && _network_company_states[c->index].months_empty > _settings_client.network.autoclean_novehicles && vehicles_in_company[c->index] == 0) { /* Shut the company down */ - DoCommandP(0, CCA_DELETE | c->index << 16 | CRR_AUTOCLEAN << 24, 0, CMD_COMPANY_CTRL); + DoCommandP(CMD_COMPANY_CTRL, 0, CCA_DELETE | c->index << 16 | CRR_AUTOCLEAN << 24, 0); IConsolePrint(CC_INFO, "Auto-cleaned company #{} with no vehicles.", c->index + 1); } } else { @@ -2078,7 +2078,7 @@ void NetworkServerNewCompany(const Company *c, NetworkClientInfo *ci) /* ci is nullptr when replaying, or for AIs. In neither case there is a client. */ ci->client_playas = c->index; NetworkUpdateClientInfo(ci->client_id); - NetworkSendCommand(0, 0, 0, CMD_RENAME_PRESIDENT, nullptr, ci->client_name, c->index); + NetworkSendCommand(CMD_RENAME_PRESIDENT, nullptr, c->index, 0, 0, 0, ci->client_name); } /* Announce new company on network. */ diff --git a/src/object_gui.cpp b/src/object_gui.cpp index 4ab961533..b05d46831 100644 --- a/src/object_gui.cpp +++ b/src/object_gui.cpp @@ -541,8 +541,8 @@ public: void OnPlaceObject(Point pt, TileIndex tile) override { ObjectClass *objclass = ObjectClass::Get(_selected_object_class); - DoCommandP(tile, objclass->GetSpec(_selected_object_index)->Index(), - _selected_object_view, CMD_BUILD_OBJECT | CMD_MSG(STR_ERROR_CAN_T_BUILD_OBJECT), CcTerraform); + DoCommandP(CMD_BUILD_OBJECT | CMD_MSG(STR_ERROR_CAN_T_BUILD_OBJECT), CcTerraform, + tile, objclass->GetSpec(_selected_object_index)->Index(), _selected_object_view); } void OnPlaceObjectAbort() override diff --git a/src/openttd.cpp b/src/openttd.cpp index 189010aad..abd5d99df 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -851,7 +851,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) DoCommandP(0, PM_PAUSED_NORMAL, 1, CMD_PAUSE); + if (_settings_client.gui.pause_on_newgame) DoCommandP(CMD_PAUSE, 0, PM_PAUSED_NORMAL, 1); return; } @@ -880,7 +880,7 @@ static void MakeNewGameDone() NetworkChangeCompanyPassword(_local_company, _settings_client.network.default_company_pass); } - if (_settings_client.gui.pause_on_newgame) DoCommandP(0, PM_PAUSED_NORMAL, 1, CMD_PAUSE); + if (_settings_client.gui.pause_on_newgame) DoCommandP(CMD_PAUSE, 0, PM_PAUSED_NORMAL, 1); CheckEngines(); CheckIndustries(); @@ -1045,7 +1045,7 @@ void SwitchToMode(SwitchMode new_mode) } OnStartGame(_network_dedicated); /* Decrease pause counter (was increased from opening load dialog) */ - DoCommandP(0, PM_PAUSED_SAVELOAD, 0, CMD_PAUSE); + DoCommandP(CMD_PAUSE, 0, PM_PAUSED_SAVELOAD, 0); } break; } @@ -1067,7 +1067,7 @@ void SwitchToMode(SwitchMode new_mode) SetLocalCompany(OWNER_NONE); _settings_newgame.game_creation.starting_year = _cur_year; /* Cancel the saveload pausing */ - DoCommandP(0, PM_PAUSED_SAVELOAD, 0, CMD_PAUSE); + DoCommandP(CMD_PAUSE, 0, PM_PAUSED_SAVELOAD, 0); } else { SetDParamStr(0, GetSaveLoadErrorString()); ShowErrorMessage(STR_JUST_RAW_STRING, INVALID_STRING_ID, WL_ERROR); diff --git a/src/order_backup.cpp b/src/order_backup.cpp index 8b8c2685f..e3bcb30eb 100644 --- a/src/order_backup.cpp +++ b/src/order_backup.cpp @@ -169,7 +169,7 @@ CommandCost CmdClearOrderBackup(TileIndex tile, DoCommandFlag flags, uint32 p1, /* If it's not a backup of us, ignore it. */ if (ob->user != user) continue; - DoCommandP(0, 0, user, CMD_CLEAR_ORDER_BACKUP); + DoCommandP(CMD_CLEAR_ORDER_BACKUP, 0, 0, user); return; } } @@ -198,7 +198,7 @@ CommandCost CmdClearOrderBackup(TileIndex tile, DoCommandFlag flags, uint32 p1, /* 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. */ - DoCommandPInternal(ob->tile, 0, user, CMD_CLEAR_ORDER_BACKUP, nullptr, {}, true, false); + DoCommandPInternal(CMD_CLEAR_ORDER_BACKUP, nullptr, true, false, ob->tile, 0, 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_gui.cpp b/src/order_gui.cpp index 3205be166..8ec4e7e98 100644 --- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -591,7 +591,7 @@ private: } if (order->GetLoadType() == load_type) return; // If we still match, do nothing - DoCommandP(this->vehicle->tile, this->vehicle->index + (sel_ord << 20), MOF_LOAD | (load_type << 4), CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER)); + DoCommandP(CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER), this->vehicle->tile, this->vehicle->index + (sel_ord << 20), MOF_LOAD | (load_type << 4)); } /** @@ -606,7 +606,7 @@ private: if (order == nullptr) return; i = (order->GetDepotOrderType() & ODTFB_SERVICE) ? DA_ALWAYS_GO : DA_SERVICE; } - DoCommandP(this->vehicle->tile, this->vehicle->index + (sel_ord << 20), MOF_DEPOT_ACTION | (i << 4), CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER)); + DoCommandP(CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER), this->vehicle->tile, this->vehicle->index + (sel_ord << 20), MOF_DEPOT_ACTION | (i << 4)); } /** @@ -621,7 +621,7 @@ private: _settings_client.gui.new_nonstop && this->vehicle->IsGroundVehicle() ? ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS : ONSF_STOP_EVERYWHERE); order.SetDepotActionType(ODATFB_NEAREST_DEPOT); - DoCommandP(this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 20), order.Pack(), CMD_INSERT_ORDER | CMD_MSG(STR_ERROR_CAN_T_INSERT_NEW_ORDER)); + DoCommandP(CMD_INSERT_ORDER | CMD_MSG(STR_ERROR_CAN_T_INSERT_NEW_ORDER), this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 20), order.Pack()); } /** @@ -641,11 +641,11 @@ private: } if (order->GetUnloadType() == unload_type) return; // If we still match, do nothing - DoCommandP(this->vehicle->tile, this->vehicle->index + (sel_ord << 20), MOF_UNLOAD | (unload_type << 4), CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER)); + DoCommandP(CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER), this->vehicle->tile, this->vehicle->index + (sel_ord << 20), MOF_UNLOAD | (unload_type << 4)); /* Transfer and unload orders with leave empty as default */ if (unload_type == OUFB_TRANSFER || unload_type == OUFB_UNLOAD) { - DoCommandP(this->vehicle->tile, this->vehicle->index + (sel_ord << 20), MOF_LOAD | (OLFB_NO_LOAD << 4), CMD_MODIFY_ORDER); + DoCommandP(CMD_MODIFY_ORDER, this->vehicle->tile, this->vehicle->index + (sel_ord << 20), MOF_LOAD | (OLFB_NO_LOAD << 4)); this->SetWidgetDirty(WID_O_FULL_LOAD); } } @@ -669,7 +669,7 @@ private: } this->SetWidgetDirty(WID_O_NON_STOP); - DoCommandP(this->vehicle->tile, this->vehicle->index + (sel_ord << 20), MOF_NON_STOP | non_stop << 4, CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER)); + DoCommandP(CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER), this->vehicle->tile, this->vehicle->index + (sel_ord << 20), MOF_NON_STOP | non_stop << 4); } /** @@ -682,8 +682,8 @@ private: if (_ctrl_pressed && this->vehicle->cur_implicit_order_index == this->OrderGetSel()) return; if (this->vehicle->GetNumOrders() <= 1) return; - DoCommandP(this->vehicle->tile, this->vehicle->index, _ctrl_pressed ? this->OrderGetSel() : ((this->vehicle->cur_implicit_order_index + 1) % this->vehicle->GetNumOrders()), - CMD_SKIP_TO_ORDER | CMD_MSG(_ctrl_pressed ? STR_ERROR_CAN_T_SKIP_TO_ORDER : STR_ERROR_CAN_T_SKIP_ORDER)); + DoCommandP(CMD_SKIP_TO_ORDER | CMD_MSG(_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())); } /** @@ -694,7 +694,7 @@ private: /* When networking, move one order lower */ int selected = this->selected_order + (int)_networking; - if (DoCommandP(this->vehicle->tile, this->vehicle->index, this->OrderGetSel(), CMD_DELETE_ORDER | CMD_MSG(STR_ERROR_CAN_T_DELETE_THIS_ORDER))) { + if (DoCommandP(CMD_DELETE_ORDER | CMD_MSG(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(); } @@ -719,7 +719,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 (DoCommandP(this->vehicle->tile, this->vehicle->index | CO_COPY << 30, other_shared->index, CMD_CLONE_ORDER | CMD_MSG(STR_ERROR_CAN_T_STOP_SHARING_ORDER_LIST))) { + if (DoCommandP(CMD_CLONE_ORDER | CMD_MSG(STR_ERROR_CAN_T_STOP_SHARING_ORDER_LIST), this->vehicle->tile, this->vehicle->index | CO_COPY << 30, other_shared->index)) { this->UpdateButtonState(); } } @@ -734,10 +734,10 @@ private: { if (_ctrl_pressed) { /* Cancel refitting */ - DoCommandP(this->vehicle->tile, this->vehicle->index, (this->OrderGetSel() << 16) | (CT_NO_REFIT << 8) | CT_NO_REFIT, CMD_ORDER_REFIT); + DoCommandP(CMD_ORDER_REFIT, this->vehicle->tile, this->vehicle->index, (this->OrderGetSel() << 16) | (CT_NO_REFIT << 8) | CT_NO_REFIT); } else { if (i == 1) { // Auto-refit to available cargo type. - DoCommandP(this->vehicle->tile, this->vehicle->index, (this->OrderGetSel() << 16) | CT_AUTO_REFIT, CMD_ORDER_REFIT); + DoCommandP(CMD_ORDER_REFIT, this->vehicle->tile, this->vehicle->index, (this->OrderGetSel() << 16) | CT_AUTO_REFIT); } else { ShowVehicleRefitWindow(this->vehicle, this->OrderGetSel(), this, auto_refit); } @@ -1159,7 +1159,7 @@ public: order.index = 0; order.MakeConditional(order_id); - DoCommandP(this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 20), order.Pack(), CMD_INSERT_ORDER | CMD_MSG(STR_ERROR_CAN_T_INSERT_NEW_ORDER)); + DoCommandP(CMD_INSERT_ORDER | CMD_MSG(STR_ERROR_CAN_T_INSERT_NEW_ORDER), this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 20), order.Pack()); } ResetObjectToPlace(); break; @@ -1182,9 +1182,9 @@ public: this->selected_order = -1; } else if (sel == this->selected_order) { if (this->vehicle->type == VEH_TRAIN && sel < this->vehicle->GetNumOrders()) { - DoCommandP(this->vehicle->tile, this->vehicle->index + (sel << 20), - MOF_STOP_LOCATION | ((this->vehicle->GetOrder(sel)->GetStopLocation() + 1) % OSL_END) << 4, - CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER)); + DoCommandP(CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER), + this->vehicle->tile, this->vehicle->index + (sel << 20), + MOF_STOP_LOCATION | ((this->vehicle->GetOrder(sel)->GetStopLocation() + 1) % OSL_END) << 4); } } else { /* Select clicked order */ @@ -1331,7 +1331,7 @@ public: default: break; } - DoCommandP(this->vehicle->tile, this->vehicle->index + (sel << 20), MOF_COND_VALUE | Clamp(value, 0, 2047) << 4, CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER)); + DoCommandP(CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER), this->vehicle->tile, this->vehicle->index + (sel << 20), MOF_COND_VALUE | Clamp(value, 0, 2047) << 4); } } @@ -1369,11 +1369,11 @@ public: break; case WID_O_COND_VARIABLE: - DoCommandP(this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 20), MOF_COND_VARIABLE | index << 4, CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER)); + DoCommandP(CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER), this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 20), MOF_COND_VARIABLE | index << 4); break; case WID_O_COND_COMPARATOR: - DoCommandP(this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 20), MOF_COND_COMPARATOR | index << 4, CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER)); + DoCommandP(CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER), this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 20), MOF_COND_COMPARATOR | index << 4); break; } } @@ -1386,7 +1386,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()) && - DoCommandP(this->vehicle->tile, this->vehicle->index, from_order | (to_order << 16), CMD_MOVE_ORDER | CMD_MSG(STR_ERROR_CAN_T_MOVE_THIS_ORDER))) { + DoCommandP(CMD_MOVE_ORDER | CMD_MSG(STR_ERROR_CAN_T_MOVE_THIS_ORDER), this->vehicle->tile, this->vehicle->index, from_order | (to_order << 16))) { this->selected_order = -1; this->UpdateButtonState(); } @@ -1438,7 +1438,7 @@ public: const Order cmd = GetOrderCmdFromTile(this->vehicle, tile); if (cmd.IsType(OT_NOTHING)) return; - if (DoCommandP(this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 20), cmd.Pack(), CMD_INSERT_ORDER | CMD_MSG(STR_ERROR_CAN_T_INSERT_NEW_ORDER))) { + if (DoCommandP(CMD_INSERT_ORDER | CMD_MSG(STR_ERROR_CAN_T_INSERT_NEW_ORDER), this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 20), cmd.Pack())) { /* With quick goto the Go To button stays active */ if (!_settings_client.gui.quick_goto) ResetObjectToPlace(); } @@ -1455,8 +1455,8 @@ public: bool share_order = _ctrl_pressed || this->goto_type == OPOS_SHARE; if (this->vehicle->GetNumOrders() != 0 && !share_order) return false; - if (DoCommandP(this->vehicle->tile, this->vehicle->index | (share_order ? CO_SHARE : CO_COPY) << 30, v->index, - share_order ? CMD_CLONE_ORDER | CMD_MSG(STR_ERROR_CAN_T_SHARE_ORDER_LIST) : CMD_CLONE_ORDER | CMD_MSG(STR_ERROR_CAN_T_COPY_ORDER_LIST))) { + if (DoCommandP(share_order ? CMD_CLONE_ORDER | CMD_MSG(STR_ERROR_CAN_T_SHARE_ORDER_LIST) : CMD_CLONE_ORDER | CMD_MSG(STR_ERROR_CAN_T_COPY_ORDER_LIST), + this->vehicle->tile, this->vehicle->index | (share_order ? CO_SHARE : CO_COPY) << 30, v->index)) { this->selected_order = -1; ResetObjectToPlace(); } diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index 9ed9032c4..17254ccfb 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -92,11 +92,11 @@ void CcPlaySound_CONSTRUCTION_RAIL(const CommandCost &result, TileIndex tile, ui static void GenericPlaceRail(TileIndex tile, int cmd) { - DoCommandP(tile, _cur_railtype, cmd | (_settings_client.gui.auto_remove_signals << 3), - _remove_button_clicked ? + DoCommandP(_remove_button_clicked ? CMD_REMOVE_SINGLE_RAIL | CMD_MSG(STR_ERROR_CAN_T_REMOVE_RAILROAD_TRACK) : CMD_BUILD_SINGLE_RAIL | CMD_MSG(STR_ERROR_CAN_T_BUILD_RAILROAD_TRACK), - CcPlaySound_CONSTRUCTION_RAIL); + CcPlaySound_CONSTRUCTION_RAIL, + tile, _cur_railtype, cmd | (_settings_client.gui.auto_remove_signals << 3)); } /** @@ -112,7 +112,7 @@ static void PlaceExtraDepotRail(TileIndex tile, DiagDirection dir, Track track) if (GetRailTileType(tile) == RAIL_TILE_SIGNALS && !_settings_client.gui.auto_remove_signals) return; if ((GetTrackBits(tile) & DiagdirReachesTracks(dir)) == 0) return; - DoCommandP(tile, _cur_railtype, track | (_settings_client.gui.auto_remove_signals << 3), CMD_BUILD_SINGLE_RAIL); + DoCommandP(CMD_BUILD_SINGLE_RAIL, tile, _cur_railtype, track | (_settings_client.gui.auto_remove_signals << 3)); } /** Additional pieces of track to add at the entrance of a depot. */ @@ -166,7 +166,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. */ - DoCommandP(tile, 1 << 8 | 1 << 16, STAT_CLASS_WAYP | INVALID_STATION << 16, CMD_BUILD_RAIL_WAYPOINT | CMD_MSG(STR_ERROR_CAN_T_BUILD_TRAIN_WAYPOINT)); + DoCommandP(CMD_BUILD_RAIL_WAYPOINT | CMD_MSG(STR_ERROR_CAN_T_BUILD_TRAIN_WAYPOINT), tile, 1 << 8 | 1 << 16, STAT_CLASS_WAYP | INVALID_STATION << 16); } } @@ -224,7 +224,7 @@ static void GenericPlaceSignals(TileIndex tile) Track track = FindFirstTrack(trackbits); if (_remove_button_clicked) { - DoCommandP(tile, track, 0, CMD_REMOVE_SIGNALS | CMD_MSG(STR_ERROR_CAN_T_REMOVE_SIGNALS_FROM), CcPlaySound_CONSTRUCTION_RAIL); + DoCommandP(CMD_REMOVE_SIGNALS | CMD_MSG(STR_ERROR_CAN_T_REMOVE_SIGNALS_FROM), CcPlaySound_CONSTRUCTION_RAIL, tile, track, 0); } else { const Window *w = FindWindowById(WC_BUILD_SIGNAL, 0); @@ -255,9 +255,8 @@ static void GenericPlaceSignals(TileIndex tile) SB(p1, 9, 6, cycle_types); } - DoCommandP(tile, p1, 0, CMD_BUILD_SIGNALS | - CMD_MSG((w != nullptr && _convert_signal_button) ? STR_ERROR_SIGNAL_CAN_T_CONVERT_SIGNALS_HERE : STR_ERROR_CAN_T_BUILD_SIGNALS_HERE), - CcPlaySound_CONSTRUCTION_RAIL); + DoCommandP(CMD_BUILD_SIGNALS | CMD_MSG((w != nullptr && _convert_signal_button) ? STR_ERROR_SIGNAL_CAN_T_CONVERT_SIGNALS_HERE : STR_ERROR_CAN_T_BUILD_SIGNALS_HERE), + CcPlaySound_CONSTRUCTION_RAIL, tile, p1, 0); } } @@ -359,11 +358,11 @@ static void BuildRailClick_Remove(Window *w) static void DoRailroadTrack(int mode) { uint32 p2 = _cur_railtype | (mode << 6) | (_settings_client.gui.auto_remove_signals << 11); - DoCommandP(TileVirtXY(_thd.selstart.x, _thd.selstart.y), TileVirtXY(_thd.selend.x, _thd.selend.y), p2, - _remove_button_clicked ? + DoCommandP(_remove_button_clicked ? CMD_REMOVE_RAILROAD_TRACK | CMD_MSG(STR_ERROR_CAN_T_REMOVE_RAILROAD_TRACK) : CMD_BUILD_RAILROAD_TRACK | CMD_MSG(STR_ERROR_CAN_T_BUILD_RAILROAD_TRACK), - CcPlaySound_CONSTRUCTION_RAIL); + CcPlaySound_CONSTRUCTION_RAIL, + TileVirtXY(_thd.selstart.x, _thd.selstart.y), TileVirtXY(_thd.selend.x, _thd.selend.y), p2); } static void HandleAutodirPlacement() @@ -414,11 +413,11 @@ 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 */ - DoCommandP(TileVirtXY(_thd.selstart.x, _thd.selstart.y), TileVirtXY(_thd.selend.x, _thd.selend.y), p2, - _remove_button_clicked ? + DoCommandP(_remove_button_clicked ? CMD_REMOVE_SIGNAL_TRACK | CMD_MSG(STR_ERROR_CAN_T_REMOVE_SIGNALS_FROM) : CMD_BUILD_SIGNAL_TRACK | CMD_MSG(STR_ERROR_CAN_T_BUILD_SIGNALS_HERE), - CcPlaySound_CONSTRUCTION_RAIL); + CcPlaySound_CONSTRUCTION_RAIL, + TileVirtXY(_thd.selstart.x, _thd.selstart.y), TileVirtXY(_thd.selend.x, _thd.selend.y), p2); } @@ -644,9 +643,8 @@ struct BuildRailToolbarWindow : Window { break; case WID_RAT_BUILD_DEPOT: - DoCommandP(tile, _cur_railtype, _build_depot_direction, - CMD_BUILD_TRAIN_DEPOT | CMD_MSG(STR_ERROR_CAN_T_BUILD_TRAIN_DEPOT), - CcRailDepot); + DoCommandP(CMD_BUILD_TRAIN_DEPOT | CMD_MSG(STR_ERROR_CAN_T_BUILD_TRAIN_DEPOT), + CcRailDepot, tile, _cur_railtype, _build_depot_direction); break; case WID_RAT_BUILD_WAYPOINT: @@ -666,7 +664,7 @@ struct BuildRailToolbarWindow : Window { break; case WID_RAT_BUILD_TUNNEL: - DoCommandP(tile, _cur_railtype | (TRANSPORT_RAIL << 8), 0, CMD_BUILD_TUNNEL | CMD_MSG(STR_ERROR_CAN_T_BUILD_TUNNEL_HERE), CcBuildRailTunnel); + DoCommandP(CMD_BUILD_TUNNEL | CMD_MSG(STR_ERROR_CAN_T_BUILD_TUNNEL_HERE), CcBuildRailTunnel, tile, _cur_railtype | (TRANSPORT_RAIL << 8), 0); break; case WID_RAT_CONVERT_RAIL: @@ -708,7 +706,7 @@ struct BuildRailToolbarWindow : Window { break; case DDSP_CONVERT_RAIL: - DoCommandP(end_tile, start_tile, _cur_railtype | (_ctrl_pressed ? 1 << 6 : 0), CMD_CONVERT_RAIL | CMD_MSG(STR_ERROR_CAN_T_CONVERT_RAIL), CcPlaySound_CONSTRUCTION_RAIL); + DoCommandP(CMD_CONVERT_RAIL | CMD_MSG(STR_ERROR_CAN_T_CONVERT_RAIL), CcPlaySound_CONSTRUCTION_RAIL, end_tile, start_tile, _cur_railtype | (_ctrl_pressed ? 1 << 6 : 0)); break; case DDSP_REMOVE_STATION: @@ -716,14 +714,14 @@ struct BuildRailToolbarWindow : Window { if (this->IsWidgetLowered(WID_RAT_BUILD_STATION)) { /* Station */ if (_remove_button_clicked) { - DoCommandP(end_tile, start_tile, _ctrl_pressed ? 0 : 1, CMD_REMOVE_FROM_RAIL_STATION | CMD_MSG(STR_ERROR_CAN_T_REMOVE_PART_OF_STATION), CcPlaySound_CONSTRUCTION_RAIL); + DoCommandP(CMD_REMOVE_FROM_RAIL_STATION | CMD_MSG(STR_ERROR_CAN_T_REMOVE_PART_OF_STATION), CcPlaySound_CONSTRUCTION_RAIL, end_tile, start_tile, _ctrl_pressed ? 0 : 1); } else { HandleStationPlacement(start_tile, end_tile); } } else { /* Waypoint */ if (_remove_button_clicked) { - DoCommandP(end_tile, start_tile, _ctrl_pressed ? 0 : 1, CMD_REMOVE_FROM_RAIL_WAYPOINT | CMD_MSG(STR_ERROR_CAN_T_REMOVE_TRAIN_WAYPOINT), CcPlaySound_CONSTRUCTION_RAIL); + DoCommandP(CMD_REMOVE_FROM_RAIL_WAYPOINT | CMD_MSG(STR_ERROR_CAN_T_REMOVE_TRAIN_WAYPOINT), CcPlaySound_CONSTRUCTION_RAIL, end_tile, start_tile, _ctrl_pressed ? 0 : 1); } else { TileArea ta(start_tile, end_tile); uint32 p1 = _cur_railtype | (select_method == VPM_X_LIMITED ? AXIS_X : AXIS_Y) << 6 | ta.w << 8 | ta.h << 16 | _ctrl_pressed << 24; diff --git a/src/road_gui.cpp b/src/road_gui.cpp index 30d9301aa..84ec74206 100644 --- a/src/road_gui.cpp +++ b/src/road_gui.cpp @@ -124,7 +124,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) { - DoCommandP(tile, _cur_roadtype << 4 | DiagDirToRoadBits(ReverseDiagDir(direction)), 0, CMD_BUILD_ROAD); + DoCommandP(CMD_BUILD_ROAD, tile, _cur_roadtype << 4 | DiagDirToRoadBits(ReverseDiagDir(direction)), 0); } } } @@ -550,8 +550,8 @@ struct BuildRoadToolbarWindow : Window { break; case WID_ROT_DEPOT: - DoCommandP(tile, _cur_roadtype << 2 | _road_depot_orientation, 0, - CMD_BUILD_ROAD_DEPOT | CMD_MSG(this->rti->strings.err_depot), CcRoadDepot); + DoCommandP(CMD_BUILD_ROAD_DEPOT | CMD_MSG(this->rti->strings.err_depot), CcRoadDepot, + tile, _cur_roadtype << 2 | _road_depot_orientation, 0); break; case WID_ROT_BUS_STATION: @@ -567,8 +567,8 @@ struct BuildRoadToolbarWindow : Window { break; case WID_ROT_BUILD_TUNNEL: - DoCommandP(tile, _cur_roadtype | (TRANSPORT_ROAD << 8), 0, - CMD_BUILD_TUNNEL | CMD_MSG(STR_ERROR_CAN_T_BUILD_TUNNEL_HERE), CcBuildRoadTunnel); + DoCommandP(CMD_BUILD_TUNNEL | CMD_MSG(STR_ERROR_CAN_T_BUILD_TUNNEL_HERE), CcBuildRoadTunnel, + tile, _cur_roadtype | (TRANSPORT_ROAD << 8), 0); break; case WID_ROT_CONVERT_ROAD: @@ -669,10 +669,10 @@ struct BuildRoadToolbarWindow : Window { * flags */ _place_road_flag = (RoadFlags)((_place_road_flag & RF_DIR_Y) ? (_place_road_flag & 0x07) : (_place_road_flag >> 3)); - DoCommandP(start_tile, end_tile, _place_road_flag | (_cur_roadtype << 3) | (_one_way_button_clicked << 10), - _remove_button_clicked ? + DoCommandP(_remove_button_clicked ? CMD_REMOVE_LONG_ROAD | CMD_MSG(this->rti->strings.err_remove_road) : - CMD_BUILD_LONG_ROAD | CMD_MSG(this->rti->strings.err_build_road), CcPlaySound_CONSTRUCTION_OTHER); + CMD_BUILD_LONG_ROAD | CMD_MSG(this->rti->strings.err_build_road), CcPlaySound_CONSTRUCTION_OTHER, + start_tile, end_tile, _place_road_flag | (_cur_roadtype << 3) | (_one_way_button_clicked << 10)); break; case DDSP_BUILD_BUSSTOP: @@ -680,7 +680,7 @@ struct BuildRoadToolbarWindow : Window { if (this->IsWidgetLowered(WID_ROT_BUS_STATION)) { if (_remove_button_clicked) { TileArea ta(start_tile, end_tile); - DoCommandP(ta.tile, ta.w | ta.h << 8, (_ctrl_pressed << 1) | ROADSTOP_BUS, CMD_REMOVE_ROAD_STOP | CMD_MSG(this->rti->strings.err_remove_station[ROADSTOP_BUS]), CcPlaySound_CONSTRUCTION_OTHER); + DoCommandP(CMD_REMOVE_ROAD_STOP | CMD_MSG(this->rti->strings.err_remove_station[ROADSTOP_BUS]), CcPlaySound_CONSTRUCTION_OTHER, ta.tile, ta.w | ta.h << 8, (_ctrl_pressed << 1) | ROADSTOP_BUS); } else { PlaceRoadStop(start_tile, end_tile, _cur_roadtype << 5 | (_ctrl_pressed << 2) | ROADSTOP_BUS, CMD_BUILD_ROAD_STOP | CMD_MSG(this->rti->strings.err_build_station[ROADSTOP_BUS])); } @@ -692,7 +692,7 @@ struct BuildRoadToolbarWindow : Window { if (this->IsWidgetLowered(WID_ROT_TRUCK_STATION)) { if (_remove_button_clicked) { TileArea ta(start_tile, end_tile); - DoCommandP(ta.tile, ta.w | ta.h << 8, (_ctrl_pressed << 1) | ROADSTOP_TRUCK, CMD_REMOVE_ROAD_STOP | CMD_MSG(this->rti->strings.err_remove_station[ROADSTOP_TRUCK]), CcPlaySound_CONSTRUCTION_OTHER); + DoCommandP(CMD_REMOVE_ROAD_STOP | CMD_MSG(this->rti->strings.err_remove_station[ROADSTOP_TRUCK]), CcPlaySound_CONSTRUCTION_OTHER, ta.tile, ta.w | ta.h << 8, (_ctrl_pressed << 1) | ROADSTOP_TRUCK); } else { PlaceRoadStop(start_tile, end_tile, _cur_roadtype << 5 | (_ctrl_pressed << 2) | ROADSTOP_TRUCK, CMD_BUILD_ROAD_STOP | CMD_MSG(this->rti->strings.err_build_station[ROADSTOP_TRUCK])); } @@ -700,7 +700,7 @@ struct BuildRoadToolbarWindow : Window { break; case DDSP_CONVERT_ROAD: - DoCommandP(end_tile, start_tile, _cur_roadtype, CMD_CONVERT_ROAD | CMD_MSG(rti->strings.err_convert_road), CcPlaySound_CONSTRUCTION_OTHER); + DoCommandP(CMD_CONVERT_ROAD | CMD_MSG(rti->strings.err_convert_road), CcPlaySound_CONSTRUCTION_OTHER, end_tile, start_tile, _cur_roadtype); break; } } diff --git a/src/script/api/script_object.cpp b/src/script/api/script_object.cpp index 1e20b55ed..bb7260d9c 100644 --- a/src/script/api/script_object.cpp +++ b/src/script/api/script_object.cpp @@ -329,7 +329,7 @@ ScriptObject::ActiveInstance::~ActiveInstance() if (!estimate_only && _networking && !_generating_world) SetLastCommand(tile, p1, p2, cmd); /* Try to perform the command. */ - CommandCost res = ::DoCommandPInternal(tile, p1, p2, cmd, (_networking && !_generating_world) ? ScriptObject::GetActiveInstance()->GetDoCommandCallback() : nullptr, command_text, false, estimate_only); + CommandCost res = ::DoCommandPInternal(cmd, (_networking && !_generating_world) ? ScriptObject::GetActiveInstance()->GetDoCommandCallback() : nullptr, false, estimate_only, tile, p1, p2, command_text); /* We failed; set the error and bail out */ if (res.Failed()) { diff --git a/src/settings.cpp b/src/settings.cpp index 52f30be08..d821239fb 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -1549,7 +1549,7 @@ bool SetSettingValue(const IntSettingDesc *sd, int32 value, bool force_newgame) const IntSettingDesc *setting = sd->AsIntSetting(); if ((setting->flags & SF_PER_COMPANY) != 0) { if (Company::IsValidID(_local_company) && _game_mode != GM_MENU) { - return DoCommandP(0, 0, value, CMD_CHANGE_COMPANY_SETTING, nullptr, setting->GetName()); + return DoCommandP(CMD_CHANGE_COMPANY_SETTING, 0, 0, value, setting->GetName()); } setting->ChangeValue(&_settings_client.company, value); @@ -1575,7 +1575,7 @@ bool SetSettingValue(const IntSettingDesc *sd, int32 value, bool force_newgame) /* send non-company-based settings over the network */ if (!_networking || (_networking && _network_server)) { - return DoCommandP(0, 0, value, CMD_CHANGE_SETTING, nullptr, setting->GetName()); + return DoCommandP(CMD_CHANGE_SETTING, 0, 0, value, setting->GetName()); } return false; } @@ -1603,7 +1603,7 @@ void SyncCompanySettings() const SettingDesc *sd = GetSettingDesc(desc); uint32 old_value = (uint32)sd->AsIntSetting()->Read(new_object); uint32 new_value = (uint32)sd->AsIntSetting()->Read(old_object); - if (old_value != new_value) NetworkSendCommand(0, 0, new_value, CMD_CHANGE_COMPANY_SETTING, nullptr, sd->GetName(), _local_company); + if (old_value != new_value) NetworkSendCommand(CMD_CHANGE_COMPANY_SETTING, nullptr, _local_company, 0, 0, new_value, sd->GetName()); } } diff --git a/src/signs_cmd.cpp b/src/signs_cmd.cpp index 78bbb8b4b..77c5ce456 100644 --- a/src/signs_cmd.cpp +++ b/src/signs_cmd.cpp @@ -130,5 +130,5 @@ void CcPlaceSign(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2 */ void PlaceProc_Sign(TileIndex tile) { - DoCommandP(tile, 0, 0, CMD_PLACE_SIGN | CMD_MSG(STR_ERROR_CAN_T_PLACE_SIGN_HERE), CcPlaceSign); + DoCommandP(CMD_PLACE_SIGN | CMD_MSG(STR_ERROR_CAN_T_PLACE_SIGN_HERE), CcPlaceSign, tile, 0, 0); } diff --git a/src/signs_gui.cpp b/src/signs_gui.cpp index 516906462..368b57b43 100644 --- a/src/signs_gui.cpp +++ b/src/signs_gui.cpp @@ -413,7 +413,7 @@ Window *ShowSignList() static bool RenameSign(SignID index, const char *text) { bool remove = StrEmpty(text); - DoCommandP(0, index, 0, CMD_RENAME_SIGN | (StrEmpty(text) ? CMD_MSG(STR_ERROR_CAN_T_DELETE_SIGN) : CMD_MSG(STR_ERROR_CAN_T_CHANGE_SIGN_NAME)), nullptr, text); + DoCommandP(CMD_RENAME_SIGN | (StrEmpty(text) ? CMD_MSG(STR_ERROR_CAN_T_DELETE_SIGN) : CMD_MSG(STR_ERROR_CAN_T_CHANGE_SIGN_NAME)), 0, index, 0, text); return remove; } diff --git a/src/station_gui.cpp b/src/station_gui.cpp index ecc7ea77c..1992a2c56 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -1947,7 +1947,7 @@ struct StationViewWindow : public Window { break; case WID_SV_CLOSE_AIRPORT: - DoCommandP(0, this->window_number, 0, CMD_OPEN_CLOSE_AIRPORT); + DoCommandP(CMD_OPEN_CLOSE_AIRPORT, 0, this->window_number, 0); break; case WID_SV_TRAINS: // Show list of scheduled trains to this station @@ -2084,7 +2084,7 @@ struct StationViewWindow : public Window { { if (str == nullptr) return; - DoCommandP(0, this->window_number, 0, CMD_RENAME_STATION | CMD_MSG(STR_ERROR_CAN_T_RENAME_STATION), nullptr, str); + DoCommandP(CMD_RENAME_STATION | CMD_MSG(STR_ERROR_CAN_T_RENAME_STATION), 0, this->window_number, 0, str); } void OnResize() override diff --git a/src/story_gui.cpp b/src/story_gui.cpp index ccb9ccf7b..5330b8a30 100644 --- a/src/story_gui.cpp +++ b/src/story_gui.cpp @@ -566,7 +566,7 @@ protected: this->SetTimeout(); this->SetWidgetDirty(WID_SB_PAGE_PANEL); - DoCommandP(0, pe.index, 0, CMD_STORY_PAGE_BUTTON); + DoCommandP(CMD_STORY_PAGE_BUTTON, 0, pe.index, 0); break; case SPET_BUTTON_TILE: @@ -921,7 +921,7 @@ public: return; } - DoCommandP(tile, pe->index, 0, CMD_STORY_PAGE_BUTTON); + DoCommandP(CMD_STORY_PAGE_BUTTON, tile, pe->index, 0); ResetObjectToPlace(); } @@ -940,7 +940,7 @@ public: VehicleType wanted_vehtype = data.GetVehicleType(); if (wanted_vehtype != VEH_INVALID && wanted_vehtype != v->type) return false; - DoCommandP(0, pe->index, v->index, CMD_STORY_PAGE_BUTTON); + DoCommandP(CMD_STORY_PAGE_BUTTON, 0, pe->index, v->index); ResetObjectToPlace(); return true; } diff --git a/src/terraform_gui.cpp b/src/terraform_gui.cpp index 820287e9c..5e25df78c 100644 --- a/src/terraform_gui.cpp +++ b/src/terraform_gui.cpp @@ -60,7 +60,7 @@ static void GenerateDesertArea(TileIndex end, TileIndex start) TileArea ta(start, end); for (TileIndex tile : ta) { SetTropicZone(tile, (_ctrl_pressed) ? TROPICZONE_NORMAL : TROPICZONE_DESERT); - DoCommandP(tile, 0, 0, CMD_LANDSCAPE_CLEAR); + DoCommandP(CMD_LANDSCAPE_CLEAR, tile, 0, 0); MarkTileDirtyByTile(tile); } old_generating_world.Restore(); @@ -115,16 +115,16 @@ bool GUIPlaceProcDragXY(ViewportDragDropSelectionProcess proc, TileIndex start_t switch (proc) { case DDSP_DEMOLISH_AREA: - DoCommandP(end_tile, start_tile, _ctrl_pressed ? 1 : 0, CMD_CLEAR_AREA | CMD_MSG(STR_ERROR_CAN_T_CLEAR_THIS_AREA), CcPlaySound_EXPLOSION); + DoCommandP(CMD_CLEAR_AREA | CMD_MSG(STR_ERROR_CAN_T_CLEAR_THIS_AREA), CcPlaySound_EXPLOSION, end_tile, start_tile, _ctrl_pressed ? 1 : 0); break; case DDSP_RAISE_AND_LEVEL_AREA: - DoCommandP(end_tile, start_tile, LM_RAISE << 1 | (_ctrl_pressed ? 1 : 0), CMD_LEVEL_LAND | CMD_MSG(STR_ERROR_CAN_T_RAISE_LAND_HERE), CcTerraform); + DoCommandP(CMD_LEVEL_LAND | CMD_MSG(STR_ERROR_CAN_T_RAISE_LAND_HERE), CcTerraform, end_tile, start_tile, LM_RAISE << 1 | (_ctrl_pressed ? 1 : 0)); break; case DDSP_LOWER_AND_LEVEL_AREA: - DoCommandP(end_tile, start_tile, LM_LOWER << 1 | (_ctrl_pressed ? 1 : 0), CMD_LEVEL_LAND | CMD_MSG(STR_ERROR_CAN_T_LOWER_LAND_HERE), CcTerraform); + DoCommandP(CMD_LEVEL_LAND | CMD_MSG(STR_ERROR_CAN_T_LOWER_LAND_HERE), CcTerraform, end_tile, start_tile, LM_LOWER << 1 | (_ctrl_pressed ? 1 : 0)); break; case DDSP_LEVEL_AREA: - DoCommandP(end_tile, start_tile, LM_LEVEL << 1 | (_ctrl_pressed ? 1 : 0), CMD_LEVEL_LAND | CMD_MSG(STR_ERROR_CAN_T_LEVEL_LAND_HERE), CcTerraform); + DoCommandP(CMD_LEVEL_LAND | CMD_MSG(STR_ERROR_CAN_T_LEVEL_LAND_HERE), CcTerraform, end_tile, start_tile, LM_LEVEL << 1 | (_ctrl_pressed ? 1 : 0)); break; case DDSP_CREATE_ROCKS: GenerateRockyArea(end_tile, start_tile); @@ -238,7 +238,7 @@ struct TerraformToolbarWindow : Window { break; case WID_TT_BUY_LAND: // Buy land button - DoCommandP(tile, OBJECT_OWNED_LAND, 0, CMD_BUILD_OBJECT | CMD_MSG(STR_ERROR_CAN_T_PURCHASE_THIS_LAND), CcPlaySound_CONSTRUCTION_RAIL); + DoCommandP(CMD_BUILD_OBJECT | CMD_MSG(STR_ERROR_CAN_T_PURCHASE_THIS_LAND), CcPlaySound_CONSTRUCTION_RAIL, tile, OBJECT_OWNED_LAND, 0); break; case WID_TT_PLACE_SIGN: // Place sign button @@ -395,7 +395,7 @@ static void CommonRaiseLowerBigLand(TileIndex tile, int mode) StringID msg = mode ? STR_ERROR_CAN_T_RAISE_LAND_HERE : STR_ERROR_CAN_T_LOWER_LAND_HERE; - DoCommandP(tile, SLOPE_N, (uint32)mode, CMD_TERRAFORM_LAND | CMD_MSG(msg), CcTerraform); + DoCommandP(CMD_TERRAFORM_LAND | CMD_MSG(msg), CcTerraform, tile, SLOPE_N, (uint32)mode); } else { assert(_terraform_size != 0); TileArea ta(tile, _terraform_size, _terraform_size); @@ -422,7 +422,7 @@ static void CommonRaiseLowerBigLand(TileIndex tile, int mode) for (TileIndex tile2 : ta) { if (TileHeight(tile2) == h) { - DoCommandP(tile2, SLOPE_N, (uint32)mode, CMD_TERRAFORM_LAND); + DoCommandP(CMD_TERRAFORM_LAND, tile2, SLOPE_N, (uint32)mode); } } } diff --git a/src/timetable_gui.cpp b/src/timetable_gui.cpp index 4853181b3..9f9bfad5a 100644 --- a/src/timetable_gui.cpp +++ b/src/timetable_gui.cpp @@ -142,7 +142,7 @@ static void FillTimetableArrivalDepartureTable(const Vehicle *v, VehicleOrderID */ static void ChangeTimetableStartCallback(const Window *w, Date date) { - DoCommandP(0, w->window_number, date, CMD_SET_TIMETABLE_START | CMD_MSG(STR_ERROR_CAN_T_TIMETABLE_VEHICLE)); + DoCommandP(CMD_SET_TIMETABLE_START | CMD_MSG(STR_ERROR_CAN_T_TIMETABLE_VEHICLE), 0, w->window_number, date); } @@ -578,25 +578,25 @@ struct TimetableWindow : Window { case WID_VT_CLEAR_TIME: { // Clear waiting time. uint32 p1 = PackTimetableArgs(v, this->sel_index, false); - DoCommandP(0, p1, 0, CMD_CHANGE_TIMETABLE | CMD_MSG(STR_ERROR_CAN_T_TIMETABLE_VEHICLE)); + DoCommandP(CMD_CHANGE_TIMETABLE | CMD_MSG(STR_ERROR_CAN_T_TIMETABLE_VEHICLE), 0, p1, 0); break; } case WID_VT_CLEAR_SPEED: { // Clear max speed button. uint32 p1 = PackTimetableArgs(v, this->sel_index, true); - DoCommandP(0, p1, UINT16_MAX, CMD_CHANGE_TIMETABLE | CMD_MSG(STR_ERROR_CAN_T_TIMETABLE_VEHICLE)); + DoCommandP(CMD_CHANGE_TIMETABLE | CMD_MSG(STR_ERROR_CAN_T_TIMETABLE_VEHICLE), 0, p1, UINT16_MAX); break; } case WID_VT_RESET_LATENESS: // Reset the vehicle's late counter. - DoCommandP(0, v->index, 0, CMD_SET_VEHICLE_ON_TIME | CMD_MSG(STR_ERROR_CAN_T_TIMETABLE_VEHICLE)); + DoCommandP(CMD_SET_VEHICLE_ON_TIME | CMD_MSG(STR_ERROR_CAN_T_TIMETABLE_VEHICLE), 0, v->index, 0); break; case WID_VT_AUTOFILL: { // Autofill the timetable. uint32 p2 = 0; if (!HasBit(v->vehicle_flags, VF_AUTOFILL_TIMETABLE)) SetBit(p2, 0); if (_ctrl_pressed) SetBit(p2, 1); - DoCommandP(0, v->index, p2, CMD_AUTOFILL_TIMETABLE | CMD_MSG(STR_ERROR_CAN_T_TIMETABLE_VEHICLE)); + DoCommandP(CMD_AUTOFILL_TIMETABLE | CMD_MSG(STR_ERROR_CAN_T_TIMETABLE_VEHICLE), 0, v->index, p2); break; } @@ -629,7 +629,7 @@ struct TimetableWindow : Window { uint32 p2 = std::min(val, UINT16_MAX); - DoCommandP(0, p1, p2, CMD_CHANGE_TIMETABLE | CMD_MSG(STR_ERROR_CAN_T_TIMETABLE_VEHICLE)); + DoCommandP(CMD_CHANGE_TIMETABLE | CMD_MSG(STR_ERROR_CAN_T_TIMETABLE_VEHICLE), 0, p1, p2); } void OnResize() override diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp index f5b3fa3b7..665556e8a 100644 --- a/src/toolbar_gui.cpp +++ b/src/toolbar_gui.cpp @@ -265,7 +265,7 @@ static CallBackFunction ToolbarPauseClick(Window *w) { if (_networking && !_network_server) return CBF_NONE; // only server can pause the game - if (DoCommandP(0, PM_PAUSED_NORMAL, _pause_mode == PM_UNPAUSED, CMD_PAUSE)) { + if (DoCommandP(CMD_PAUSE, 0, PM_PAUSED_NORMAL, _pause_mode == PM_UNPAUSED)) { if (_settings_client.sound.confirm) SndPlayFx(SND_15_BEEP); } return CBF_NONE; diff --git a/src/town_gui.cpp b/src/town_gui.cpp index a4bb24063..9082fc7b3 100644 --- a/src/town_gui.cpp +++ b/src/town_gui.cpp @@ -287,7 +287,7 @@ public: } case WID_TA_EXECUTE: - DoCommandP(this->town->xy, this->window_number, this->sel_index, CMD_DO_TOWN_ACTION | CMD_MSG(STR_ERROR_CAN_T_DO_THIS)); + DoCommandP(CMD_DO_TOWN_ACTION | CMD_MSG(STR_ERROR_CAN_T_DO_THIS), this->town->xy, this->window_number, this->sel_index); break; } } @@ -474,12 +474,12 @@ public: _warn_town_no_roads = true; } - DoCommandP(0, this->window_number, 0, CMD_EXPAND_TOWN | CMD_MSG(STR_ERROR_CAN_T_EXPAND_TOWN)); + DoCommandP(CMD_EXPAND_TOWN | CMD_MSG(STR_ERROR_CAN_T_EXPAND_TOWN), 0, this->window_number, 0); break; } case WID_TV_DELETE: // delete town - only available on Scenario editor - DoCommandP(0, this->window_number, 0, CMD_DELETE_TOWN | CMD_MSG(STR_ERROR_TOWN_CAN_T_DELETE)); + DoCommandP(CMD_DELETE_TOWN | CMD_MSG(STR_ERROR_TOWN_CAN_T_DELETE), 0, this->window_number, 0); break; } } @@ -561,7 +561,7 @@ public: { if (str == nullptr) return; - DoCommandP(0, this->window_number, 0, CMD_RENAME_TOWN | CMD_MSG(STR_ERROR_CAN_T_RENAME_TOWN), nullptr, str); + DoCommandP(CMD_RENAME_TOWN | CMD_MSG(STR_ERROR_CAN_T_RENAME_TOWN), 0, this->window_number, 0, str); } }; @@ -1162,8 +1162,8 @@ public: if (strcmp(buf, this->townname_editbox.text.buf) != 0) name = this->townname_editbox.text.buf; } - bool success = DoCommandP(tile, this->town_size | this->city << 2 | this->town_layout << 3 | random << 6, - townnameparts, CMD_FOUND_TOWN | CMD_MSG(errstr), cc, name); + bool success = DoCommandP(CMD_FOUND_TOWN | CMD_MSG(errstr), cc, + tile, this->town_size | this->city << 2 | this->town_layout << 3 | random << 6, townnameparts, name); /* Rerandomise name, if success and no cost-estimation. */ if (success && !_shift_pressed) this->RandomTownName(); diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 775b1f637..e0a70d14f 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -86,7 +86,7 @@ void CheckTrainsLengths() if (!_networking && first) { first = false; - DoCommandP(0, PM_PAUSED_ERROR, 1, CMD_PAUSE); + DoCommandP(CMD_PAUSE, 0, PM_PAUSED_ERROR, 1); } /* Break so we warn only once for each train. */ break; diff --git a/src/train_gui.cpp b/src/train_gui.cpp index c8995f9b7..9bb7d5947 100644 --- a/src/train_gui.cpp +++ b/src/train_gui.cpp @@ -44,7 +44,7 @@ void CcBuildWagon(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p if (found != nullptr) { found = found->Last(); /* put the new wagon at the end of the loco. */ - DoCommandP(0, _new_vehicle_id, found->index, CMD_MOVE_RAIL_VEHICLE); + DoCommandP(CMD_MOVE_RAIL_VEHICLE, 0, _new_vehicle_id, found->index); InvalidateWindowClassesData(WC_TRAINS_LIST, 0); } } diff --git a/src/tree_gui.cpp b/src/tree_gui.cpp index ccec4705d..005cebd46 100644 --- a/src/tree_gui.cpp +++ b/src/tree_gui.cpp @@ -230,7 +230,7 @@ public: TileIndex tile = TileVirtXY(pt.x, pt.y); if (this->mode == PM_NORMAL) { - DoCommandP(tile, this->tree_to_plant, tile, CMD_PLANT_TREE); + DoCommandP(CMD_PLANT_TREE, tile, this->tree_to_plant, tile); } else { this->DoPlantForest(tile); } @@ -240,7 +240,7 @@ public: void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, 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) { - DoCommandP(end_tile, this->tree_to_plant, start_tile, CMD_PLANT_TREE | CMD_MSG(STR_ERROR_CAN_T_PLANT_TREE_HERE)); + DoCommandP(CMD_PLANT_TREE | CMD_MSG(STR_ERROR_CAN_T_PLANT_TREE_HERE), end_tile, this->tree_to_plant, start_tile); } } diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index e11e340f5..56e1bb713 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -1033,9 +1033,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 (DoCommandP(v->tile, this->selected_vehicle, this->cargo->cargo | this->cargo->subtype << 8 | this->num_vehicles << 16, GetCmdRefitVeh(v)) && delete_window) this->Close(); + if (DoCommandP(GetCmdRefitVeh(v), v->tile, this->selected_vehicle, this->cargo->cargo | this->cargo->subtype << 8 | this->num_vehicles << 16) && delete_window) this->Close(); } else { - if (DoCommandP(v->tile, v->index, this->cargo->cargo | this->order << 16, CMD_ORDER_REFIT)) this->Close(); + if (DoCommandP(CMD_ORDER_REFIT, v->tile, v->index, this->cargo->cargo | this->order << 16)) this->Close(); } } break; @@ -1894,7 +1894,7 @@ public: case WID_VL_STOP_ALL: case WID_VL_START_ALL: - DoCommandP(0, (1 << 1) | (widget == WID_VL_START_ALL ? (1 << 0) : 0), this->window_number, CMD_MASS_START_STOP); + DoCommandP(CMD_MASS_START_STOP, 0, (1 << 1) | (widget == WID_VL_START_ALL ? (1 << 0) : 0), this->window_number); break; } } @@ -1919,7 +1919,7 @@ public: break; case ADI_SERVICE: // Send for servicing case ADI_DEPOT: // Send to Depots - DoCommandP(0, DEPOT_MASS_SEND | (index == ADI_SERVICE ? DEPOT_SERVICE : (DepotCommand)0), this->window_number, GetCmdSendToDepot(this->vli.vtype)); + DoCommandP(GetCmdSendToDepot(this->vli.vtype), 0, DEPOT_MASS_SEND | (index == ADI_SERVICE ? DEPOT_SERVICE : (DepotCommand)0), this->window_number); break; default: NOT_REACHED(); @@ -2422,7 +2422,7 @@ struct VehicleDetailsWindow : Window { mod = GetServiceIntervalClamped(mod + v->GetServiceInterval(), v->ServiceIntervalIsPercent()); if (mod == v->GetServiceInterval()) return; - DoCommandP(v->tile, v->index, mod | (1 << 16) | (v->ServiceIntervalIsPercent() << 17), CMD_CHANGE_SERVICE_INT | CMD_MSG(STR_ERROR_CAN_T_CHANGE_SERVICING)); + DoCommandP(CMD_CHANGE_SERVICE_INT | CMD_MSG(STR_ERROR_CAN_T_CHANGE_SERVICING), v->tile, v->index, mod | (1 << 16) | (v->ServiceIntervalIsPercent() << 17)); break; } @@ -2458,7 +2458,7 @@ struct VehicleDetailsWindow : Window { bool iscustom = index != 0; bool ispercent = iscustom ? (index == 2) : Company::Get(v->owner)->settings.vehicle.servint_ispercent; uint16 interval = GetServiceIntervalClamped(v->GetServiceInterval(), ispercent); - DoCommandP(v->tile, v->index, interval | (iscustom << 16) | (ispercent << 17), CMD_CHANGE_SERVICE_INT | CMD_MSG(STR_ERROR_CAN_T_CHANGE_SERVICING)); + DoCommandP(CMD_CHANGE_SERVICE_INT | CMD_MSG(STR_ERROR_CAN_T_CHANGE_SERVICING), v->tile, v->index, interval | (iscustom << 16) | (ispercent << 17)); break; } } @@ -2639,7 +2639,7 @@ void CcStartStopVehicle(const CommandCost &result, TileIndex tile, uint32 p1, ui void StartStopVehicle(const Vehicle *v, bool texteffect) { assert(v->IsPrimaryVehicle()); - DoCommandP(v->tile, v->index, 0, _vehicle_command_translation_table[VCT_CMD_START_STOP][v->type], texteffect ? CcStartStopVehicle : nullptr); + DoCommandP(_vehicle_command_translation_table[VCT_CMD_START_STOP][v->type], texteffect ? CcStartStopVehicle : nullptr, v->tile, v->index, 0); } /** Checks whether the vehicle may be refitted at the moment.*/ @@ -2963,7 +2963,7 @@ public: break; case WID_VV_GOTO_DEPOT: // goto hangar - DoCommandP(v->tile, v->index | (_ctrl_pressed ? DEPOT_SERVICE : 0U), 0, GetCmdSendToDepot(v)); + DoCommandP(GetCmdSendToDepot(v), v->tile, v->index | (_ctrl_pressed ? DEPOT_SERVICE : 0U), 0); break; case WID_VV_REFIT: // refit ShowVehicleRefitWindow(v, INVALID_VEH_ORDER_ID, this); @@ -2987,18 +2987,17 @@ 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. */ - DoCommandP(v->tile, v->index, _ctrl_pressed ? 1 : 0, - _vehicle_command_translation_table[VCT_CMD_CLONE_VEH][v->type], - _ctrl_pressed ? nullptr : CcCloneVehicle); + DoCommandP(_vehicle_command_translation_table[VCT_CMD_CLONE_VEH][v->type], + _ctrl_pressed ? nullptr : CcCloneVehicle, + v->tile, v->index, _ctrl_pressed ? 1 : 0); break; case WID_VV_TURN_AROUND: // turn around assert(v->IsGroundVehicle()); - DoCommandP(v->tile, v->index, 0, - _vehicle_command_translation_table[VCT_CMD_TURN_AROUND][v->type]); + DoCommandP(_vehicle_command_translation_table[VCT_CMD_TURN_AROUND][v->type], v->tile, v->index, 0); break; case WID_VV_FORCE_PROCEED: // force proceed assert(v->type == VEH_TRAIN); - DoCommandP(v->tile, v->index, 0, CMD_FORCE_TRAIN_PROCEED | CMD_MSG(STR_ERROR_CAN_T_MAKE_TRAIN_PASS_SIGNAL)); + DoCommandP(CMD_FORCE_TRAIN_PROCEED | CMD_MSG(STR_ERROR_CAN_T_MAKE_TRAIN_PASS_SIGNAL), v->tile, v->index, 0); break; } } @@ -3007,7 +3006,7 @@ public: { if (str == nullptr) return; - DoCommandP(0, this->window_number, 0, CMD_RENAME_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_RENAME_TRAIN + Vehicle::Get(this->window_number)->type), nullptr, str); + DoCommandP(CMD_RENAME_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_RENAME_TRAIN + Vehicle::Get(this->window_number)->type), 0, this->window_number, 0, str); } void OnMouseOver(Point pt, int widget) override diff --git a/src/waypoint_gui.cpp b/src/waypoint_gui.cpp index 4dd2397b7..8a4772ac0 100644 --- a/src/waypoint_gui.cpp +++ b/src/waypoint_gui.cpp @@ -138,7 +138,7 @@ public: { if (str == nullptr) return; - DoCommandP(0, this->window_number, 0, CMD_RENAME_WAYPOINT | CMD_MSG(STR_ERROR_CAN_T_CHANGE_WAYPOINT_NAME), nullptr, str); + DoCommandP(CMD_RENAME_WAYPOINT | CMD_MSG(STR_ERROR_CAN_T_CHANGE_WAYPOINT_NAME), 0, this->window_number, 0, str); } }; -- cgit v1.2.3-70-g09d2