diff options
author | Michael Lutz <michi@icosahedron.de> | 2021-10-31 19:39:09 +0100 |
---|---|---|
committer | Michael Lutz <michi@icosahedron.de> | 2021-12-16 22:28:32 +0100 |
commit | 0f64ee5ce1548d9cda69917f27c5b1a3cb91823d (patch) | |
tree | 161f0e6ac300e604de61b8203b5a58279637f9eb /src/network | |
parent | e740c24eb7a90bc771f5976d64d80639ee7576e5 (diff) | |
download | openttd-0f64ee5ce1548d9cda69917f27c5b1a3cb91823d.tar.xz |
Codechange: Template DoCommandP to automagically reflect the parameters of the command proc.
When finished, this will allow each command handler to take individually
different parameters, obliviating the need for bit-packing.
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/network.cpp | 2 | ||||
-rw-r--r-- | src/network/network_command.cpp | 2 | ||||
-rw-r--r-- | src/network/network_gui.cpp | 5 | ||||
-rw-r--r-- | src/network/network_server.cpp | 5 |
4 files changed, 8 insertions, 6 deletions
diff --git a/src/network/network.cpp b/src/network/network.cpp index 8194f34d0..3bd287f85 100644 --- a/src/network/network.cpp +++ b/src/network/network.cpp @@ -395,7 +395,7 @@ static void CheckPauseHelper(bool pause, PauseMode pm) { if (pause == ((_pause_mode & pm) != PM_UNPAUSED)) return; - DoCommandP(CMD_PAUSE, 0, pm, pause ? 1 : 0); + Command<CMD_PAUSE>::Post(0, pm, pause ? 1 : 0, {}); } /** diff --git a/src/network/network_command.cpp b/src/network/network_command.cpp index 472d5e60e..983f4b565 100644 --- a/src/network/network_command.cpp +++ b/src/network/network_command.cpp @@ -451,5 +451,5 @@ template <Commands Tcmd> void UnpackNetworkCommand(const CommandPacket *cp) { auto args = EndianBufferReader::ToValue<typename CommandTraits<Tcmd>::Args>(cp->data); - std::apply(&InjectNetworkCommand, std::tuple_cat(std::make_tuple(Tcmd, cp->err_msg, cp->callback, cp->my_cmd), args)); + Command<Tcmd>::PostFromNet(cp->err_msg, cp->callback, cp->my_cmd, cp->tile, args); } diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index 82e01e81e..a2b34593e 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -36,6 +36,7 @@ #include "../zoom_func.h" #include "../sprite.h" #include "../settings_internal.h" +#include "../company_cmd.h" #include "../widgets/network_widget.h" @@ -1395,7 +1396,7 @@ static void AdminCompanyResetCallback(Window *w, bool confirmed) { if (confirmed) { if (NetworkCompanyHasClients(_admin_company_id)) return; - DoCommandP(CMD_COMPANY_CTRL, 0, CCA_DELETE | _admin_company_id << 16 | CRR_MANUAL << 24, 0); + Command<CMD_COMPANY_CTRL>::Post(0, CCA_DELETE | _admin_company_id << 16 | CRR_MANUAL << 24, 0, {}); } } @@ -1535,7 +1536,7 @@ private: static void OnClickCompanyNew(NetworkClientListWindow *w, Point pt, CompanyID company_id) { if (_network_server) { - DoCommandP(CMD_COMPANY_CTRL, 0, CCA_NEW, _network_own_client_id); + Command<CMD_COMPANY_CTRL>::Post(0, CCA_NEW, _network_own_client_id, {}); } else { NetworkSendCommand(CMD_COMPANY_CTRL, STR_NULL, nullptr, _local_company, 0, CCA_NEW, 0, {}); } diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp index 967ad40a8..65f3188de 100644 --- a/src/network/network_server.cpp +++ b/src/network/network_server.cpp @@ -29,6 +29,7 @@ #include "../order_backup.h" #include "../core/pool_func.hpp" #include "../core/random_func.hpp" +#include "../company_cmd.h" #include "../rev.h" #include <mutex> #include <condition_variable> @@ -1555,7 +1556,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(CMD_COMPANY_CTRL, 0, CCA_DELETE | c->index << 16 | CRR_AUTOCLEAN << 24, 0); + Command<CMD_COMPANY_CTRL>::Post(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? */ @@ -1569,7 +1570,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(CMD_COMPANY_CTRL, 0, CCA_DELETE | c->index << 16 | CRR_AUTOCLEAN << 24, 0); + Command<CMD_COMPANY_CTRL>::Post(0, CCA_DELETE | c->index << 16 | CRR_AUTOCLEAN << 24, 0, {}); IConsolePrint(CC_INFO, "Auto-cleaned company #{} with no vehicles.", c->index + 1); } } else { |