1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-18 04:23:20 +01:00

Add deep copy to GameCommand

This commit is contained in:
duncanspumpkin
2017-04-18 20:22:50 +01:00
committed by Michał Janiszewski
parent 4b1a27bb4f
commit a7d1cbee9e
2 changed files with 28 additions and 4 deletions

View File

@@ -1363,7 +1363,6 @@ void Network::ProcessGameCommandQueue()
IGameAction * action = GameActions::Create(gc.actionType);
uint32 flags = gc.parameters->ReadValue<uint32>();
action->Deserialise(gc.parameters);
delete gc.parameters;
GameActionResult result = GameActions::Execute(action, flags | GAME_COMMAND_FLAG_NETWORKED);
if (result.Error != GA_ERROR::OK)
{
@@ -2056,7 +2055,7 @@ void Network::Client_Handle_GAMECMD(NetworkConnection& connection, NetworkPacket
uint8 callback;
packet >> tick >> args[0] >> args[1] >> args[2] >> args[3] >> args[4] >> args[5] >> args[6] >> playerid >> callback;
GameCommand gc = GameCommand(tick, args, playerid, callback);
GameCommand gc(tick, args, playerid, callback);
game_command_queue.insert(gc);
}
void Network::Client_Handle_GAME_ACTION(NetworkConnection& connection, NetworkPacket& packet)
@@ -2069,7 +2068,7 @@ void Network::Client_Handle_GAME_ACTION(NetworkConnection& connection, NetworkPa
size_t size = packet.Size - packet.BytesRead;
stream.WriteArray(packet.Read(size), size);
stream.SetPosition(0);
GameCommand gc = GameCommand(tick, type, stream, playerid);
GameCommand gc(tick, type, stream, playerid);
game_command_queue.insert(gc);
}

View File

@@ -175,7 +175,6 @@ public:
std::string ServerProviderWebsite;
private:
<<<<<<< 8f169e5ce2dfbca82427a8ee4023704f0ea31e2c
bool ProcessConnection(NetworkConnection& connection);
void ProcessPacket(NetworkConnection& connection, NetworkPacket& packet);
void AddClient(ITcpSocket * socket);
@@ -205,6 +204,32 @@ private:
parameters = new MemoryStream(stream);
}
GameCommand(const GameCommand &source) {
tick = source.tick;
playerid = source.playerid;
actionType = source.actionType;
callback = source.callback;
if (actionType != 0xFFFFFFFF)
{
parameters = new MemoryStream(*source.parameters);
}
else
{
eax = source.eax;
ebx = source.ebx;
ecx = source.ecx;
edx = source.edx;
esi = source.esi;
edi = source.edi;
ebp = source.ebp;
}
}
~GameCommand()
{
delete parameters;
}
uint32 tick;
uint32 eax, ebx, ecx, edx, esi, edi, ebp;
uint32 actionType = 0xFFFFFFFF;