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.
This commit is contained in:
Michael Lutz
2021-10-28 23:48:26 +02:00
parent b0990fcff7
commit a05fd7aa50
15 changed files with 455 additions and 35 deletions

View File

@@ -424,11 +424,19 @@ enum CommandPauseLevel {
typedef CommandCost CommandProc(DoCommandFlag flags, TileIndex tile, uint32 p1, uint32 p2, const std::string &text);
template <typename T> struct CommandFunctionTraitHelper;
template <typename... Targs>
struct CommandFunctionTraitHelper<CommandCost(*)(DoCommandFlag, Targs...)> {
using Args = std::tuple<std::decay_t<Targs>...>;
};
/** Defines the traits of a command. */
template <Commands Tcmd> struct CommandTraits;
#define DEF_CMD_TRAIT(cmd_, proc_, flags_, type_) \
template<> struct CommandTraits<cmd_> { \
using Args = typename CommandFunctionTraitHelper<decltype(&proc_)>::Args; \
static constexpr Commands cmd = cmd_; \
static constexpr auto &proc = proc_; \
static constexpr CommandFlags flags = (CommandFlags)(flags_); \
static constexpr CommandType type = type_; \