From 295cc65dce7e81f79d65b2627d00bc5c2ee2fd16 Mon Sep 17 00:00:00 2001 From: Max-Wilhelm Bruker Date: Wed, 9 May 2012 23:25:29 +0200 Subject: [PATCH] minor fix wrt issue #42 --- cockatrice/src/abstractclient.cpp | 2 +- cockatrice/src/abstractclient.h | 1 + cockatrice/src/remoteclient.cpp | 3 ++- common/server_protocolhandler.cpp | 4 ++-- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/cockatrice/src/abstractclient.cpp b/cockatrice/src/abstractclient.cpp index 45c67864..de823716 100644 --- a/cockatrice/src/abstractclient.cpp +++ b/cockatrice/src/abstractclient.cpp @@ -119,7 +119,7 @@ void AbstractClient::sendCommand(PendingCommand *pend) void AbstractClient::queuePendingCommand(PendingCommand *pend) { // This function is always called from the client thread via signal/slot. - const int cmdId = nextCmdId++; + const int cmdId = getNewCmdId(); pend->getCommandContainer().set_cmd_id(cmdId); pendingCommands.insert(cmdId, pend); diff --git a/cockatrice/src/abstractclient.h b/cockatrice/src/abstractclient.h index 7853deb3..92b49826 100644 --- a/cockatrice/src/abstractclient.h +++ b/cockatrice/src/abstractclient.h @@ -73,6 +73,7 @@ protected: QMap pendingCommands; QString userName, password; void setStatus(ClientStatus _status); + int getNewCmdId() { return nextCmdId++; } virtual void sendCommandContainer(const CommandContainer &cont) = 0; public: AbstractClient(QObject *parent = 0); diff --git a/cockatrice/src/remoteclient.cpp b/cockatrice/src/remoteclient.cpp index 4f48c474..42fb602e 100644 --- a/cockatrice/src/remoteclient.cpp +++ b/cockatrice/src/remoteclient.cpp @@ -9,7 +9,7 @@ #include "pb/server_message.pb.h" #include "pb/event_server_identification.pb.h" -static const unsigned int protocolVersion = 14; +static const unsigned int protocolVersion = 13; RemoteClient::RemoteClient(QObject *parent) : AbstractClient(parent), timeRunning(0), lastDataReceived(0), messageInProgress(false), handshakeStarted(false), messageLength(0) @@ -50,6 +50,7 @@ void RemoteClient::slotConnected() // dirty hack to be compatible with v14 server sendCommandContainer(CommandContainer()); + getNewCmdId(); // end of hack setStatus(StatusAwaitingWelcome); diff --git a/common/server_protocolhandler.cpp b/common/server_protocolhandler.cpp index 242c5220..5c5efb05 100644 --- a/common/server_protocolhandler.cpp +++ b/common/server_protocolhandler.cpp @@ -260,7 +260,7 @@ void Server_ProtocolHandler::processCommandContainer(const CommandContainer &con { lastDataReceived = timeRunning; - ResponseContainer responseContainer(cont.cmd_id()); + ResponseContainer responseContainer(cont.has_cmd_id() ? cont.cmd_id() : -1); Response::ResponseCode finalResponseCode; if (cont.game_command_size()) @@ -276,7 +276,7 @@ void Server_ProtocolHandler::processCommandContainer(const CommandContainer &con else finalResponseCode = Response::RespInvalidCommand; - if (finalResponseCode != Response::RespNothing) + if ((finalResponseCode != Response::RespNothing)) sendResponseContainer(responseContainer, finalResponseCode); }