diff --git a/src/Engine/Network/Client.cpp b/src/Engine/Network/Client.cpp index fd6825b5..83e0d886 100644 --- a/src/Engine/Network/Client.cpp +++ b/src/Engine/Network/Client.cpp @@ -238,8 +238,7 @@ void Client::connect() void Client::disconnect() { - Packet packet(MessageType::Connect, m_SendPacketID); - packet.WriteString("+Disconnect"); + Packet packet(MessageType::Disconnect, m_SendPacketID); send(packet); } @@ -254,9 +253,16 @@ void Client::ping() bool Client::OnInputCommand(const Events::InputCommand & e) { if (e.Command == "ConnectToServer") { // Connect for now - connect(); + if (e.Value > 0) { + connect(); + } //LOG_DEBUG("Client::OnInputCommand: Command is %s. Value is %f. PlayerID is %i.", e.Command.c_str(), e.Value, e.PlayerID); return true; + } else if (e.Command == "DisconnectFromServer") { + if (e.Value > 0) { + disconnect(); + } + return true; } else { m_InputCommandBuffer.push_back(e); //LOG_DEBUG("Client::OnInputCommand: Command is %s. Value is %f. PlayerID is %i.", e.Command.c_str(), e.Value, e.PlayerID); @@ -280,7 +286,7 @@ void Client::identifyPacketLoss() // if no packets lost, difference should be equal to 1 int difference = m_PacketID - m_PreviousPacketID; if (difference != 1) { - LOG_INFO("%i Packet(s) were lost...", difference -1); + LOG_INFO("%i Packet(s) were lost...", difference - 1); } }