summaryrefslogtreecommitdiff
path: root/src/command_func.h
diff options
context:
space:
mode:
authorMichael Lutz <michi@icosahedron.de>2021-10-28 23:48:26 +0200
committerMichael Lutz <michi@icosahedron.de>2021-12-16 22:28:32 +0100
commita05fd7aa50ecbee425df2d6f9015ec3ea359232f (patch)
tree9b9208d39813670789635b638592a903a2aafaa4 /src/command_func.h
parentb0990fcff7358e839468e5cf811ffddc8b9d73e2 (diff)
downloadopenttd-a05fd7aa50ecbee425df2d6f9015ec3ea359232f.tar.xz
Change: [Network] Transfer command data as serialized byte stream without fixed structure.
The data will be transmitted as the length followed by the serialized data. This allows the command data to be different for every command type in the future.
Diffstat (limited to 'src/command_func.h')
-rw-r--r--src/command_func.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/command_func.h b/src/command_func.h
index 03bfc73f1..0d000755c 100644
--- a/src/command_func.h
+++ b/src/command_func.h
@@ -12,6 +12,7 @@
#include "command_type.h"
#include "company_type.h"
+#include <vector>
/**
* Define a default return value for a failed command.
@@ -32,6 +33,9 @@ static const CommandCost CMD_ERROR = CommandCost(INVALID_STRING_ID);
*/
#define return_cmd_error(errcode) return CommandCost(errcode);
+/** Storage buffer for serialized command data. */
+typedef std::vector<byte> CommandDataBuffer;
+
CommandCost DoCommand(DoCommandFlag flags, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text = {});
CommandCost DoCommand(const CommandContainer *container, DoCommandFlag flags);
@@ -41,9 +45,12 @@ bool DoCommandP(Commands cmd, CommandCallback *callback, TileIndex tile, uint32
bool DoCommandP(Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text = {});
bool DoCommandP(const CommandContainer *container, bool my_cmd = true, bool network_command = false);
+bool InjectNetworkCommand(Commands cmd, StringID err_message, CommandCallback *callback, bool my_cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text);
+
CommandCost DoCommandPInternal(Commands cmd, StringID err_message, CommandCallback *callback, bool my_cmd, bool estimate_only, bool network_command, TileIndex tile, uint32 p1, uint32 p2, const std::string &text);
void NetworkSendCommand(Commands cmd, StringID err_message, CommandCallback *callback, CompanyID company, TileIndex tile, uint32 p1, uint32 p2, const std::string &text);
+void NetworkSendCommand(Commands cmd, StringID err_message, CommandCallback *callback, CompanyID company, TileIndex location, const CommandDataBuffer &cmd_data);
extern Money _additional_cash_required;