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:
@@ -15,6 +15,8 @@
|
||||
#include "core/tcp_game.h"
|
||||
|
||||
#include "../command_type.h"
|
||||
#include "../command_func.h"
|
||||
#include "../misc/endian_buffer.hpp"
|
||||
|
||||
#ifdef RANDOM_DEBUG
|
||||
/**
|
||||
@@ -104,19 +106,26 @@ void UpdateNetworkGameWindow();
|
||||
/**
|
||||
* Everything we need to know about a command to be able to execute it.
|
||||
*/
|
||||
struct CommandPacket : CommandContainer {
|
||||
struct CommandPacket {
|
||||
/** Make sure the pointer is nullptr. */
|
||||
CommandPacket() : next(nullptr), company(INVALID_COMPANY), frame(0), my_cmd(false) {}
|
||||
CommandPacket() : next(nullptr), company(INVALID_COMPANY), frame(0), my_cmd(false), tile(0) {}
|
||||
CommandPacket *next; ///< the next command packet (if in queue)
|
||||
CompanyID company; ///< company that is executing the command
|
||||
uint32 frame; ///< the frame in which this packet is executed
|
||||
bool my_cmd; ///< did the command originate from "me"
|
||||
|
||||
Commands cmd; ///< command being executed.
|
||||
StringID err_msg; ///< string ID of error message to use.
|
||||
CommandCallback *callback; ///< any callback function executed upon successful completion of the command.
|
||||
TileIndex tile; ///< location of the command (for e.g. error message or effect display).
|
||||
CommandDataBuffer data; ///< command parameters.
|
||||
};
|
||||
|
||||
void NetworkDistributeCommands();
|
||||
void NetworkExecuteLocalCommandQueue();
|
||||
void NetworkFreeLocalCommandQueue();
|
||||
void NetworkSyncCommandQueue(NetworkClientSocket *cs);
|
||||
void NetworkReplaceCommandClientId(CommandPacket &cp, ClientID client_id);
|
||||
|
||||
void ShowNetworkError(StringID error_string);
|
||||
void NetworkTextMessage(NetworkAction action, TextColour colour, bool self_send, const std::string &name, const std::string &str = "", int64 data = 0, const std::string &data_str = "");
|
||||
|
||||
Reference in New Issue
Block a user