From f03e3668097ca637bf347fbbe3712df9a80ab5b6 Mon Sep 17 00:00:00 2001 From: hilnius Date: Thu, 11 Jul 2013 13:39:36 +0000 Subject: [PATCH] adding debug logging to see why when two players are connected, only one gets all the kart update messages git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/hilnius@13183 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/network/game_setup.cpp | 8 +++++++- src/network/protocols/client_lobby_room_protocol.cpp | 4 +++- src/network/protocols/server_lobby_room_protocol.cpp | 8 ++++---- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/network/game_setup.cpp b/src/network/game_setup.cpp index 9a19ab0db..37bcb9a5a 100644 --- a/src/network/game_setup.cpp +++ b/src/network/game_setup.cpp @@ -76,14 +76,20 @@ bool GameSetup::removePlayer(uint8_t id) void GameSetup::setPlayerKart(uint8_t id, std::string kart_name) { + bool found = false; for (unsigned int i = 0; i < m_players.size(); i++) { if (m_players[i]->race_id == id) { m_players[i]->kart_name = kart_name; - Log::info("GameSetup", "Player %d took kart %s", id, kart_name.c_str()); + Log::info("GameSetup::setPlayerKart", "Player %d took kart %s", id, kart_name.c_str()); + found = true; } } + if (!found) + { + Log::info("GameSetup::setPlayerKart", "The player %d was unknown.", id); + } } //----------------------------------------------------------------------------- diff --git a/src/network/protocols/client_lobby_room_protocol.cpp b/src/network/protocols/client_lobby_room_protocol.cpp index b9d48115e..427668163 100644 --- a/src/network/protocols/client_lobby_room_protocol.cpp +++ b/src/network/protocols/client_lobby_room_protocol.cpp @@ -62,9 +62,9 @@ void ClientLobbyRoomProtocol::notifyEvent(Event* event) if (event->type == EVENT_TYPE_MESSAGE) { assert(event->data.size()); // assert that data isn't empty - Log::verbose("ClientLobbyRoomProtocol", "Message from %u : \"%s\"", peer->getAddress(), event->data.c_str()); uint8_t message_type = event->data.getAndRemoveUInt8(); + Log::debug("ClientLobbyRoomProtocol", "Message of type %d", message_type); if (message_type == 0x01) // new player connected newPlayer(event); else if (message_type == 0x02) // player disconnected @@ -220,6 +220,8 @@ void ClientLobbyRoomProtocol::connectionAccepted(Event* event) m_server = *(event->peer); m_state = CONNECTED; } + else + Log::info("ClientLobbyRoomProtocol", "Failure during the connection acceptation process."); } //----------------------------------------------------------------------------- diff --git a/src/network/protocols/server_lobby_room_protocol.cpp b/src/network/protocols/server_lobby_room_protocol.cpp index 70d61146c..4cd906784 100644 --- a/src/network/protocols/server_lobby_room_protocol.cpp +++ b/src/network/protocols/server_lobby_room_protocol.cpp @@ -58,7 +58,6 @@ void ServerLobbyRoomProtocol::setup() void ServerLobbyRoomProtocol::notifyEvent(Event* event) { assert(m_setup); // assert that the setup exists - Log::debug("ServerLobbyRoomProtocol", "Event received"); if (event->type == EVENT_TYPE_MESSAGE) { assert(event->data.size()); // message not empty @@ -165,15 +164,15 @@ void ServerLobbyRoomProtocol::update() void ServerLobbyRoomProtocol::kartDisconnected(Event* event) { STKPeer* peer = *(event->peer); - Log::info("ServerLobbyRoomProtocol", "Player disconnected."); if (peer->getPlayerProfile() != NULL) // others knew him { NetworkString msg; msg.ai8(0x02).ai8(1).ai8(peer->getPlayerProfile()->race_id); m_listener->sendMessage(this, msg); + Log::info("ServerLobbyRoomProtocol", "Player disconnected."); } else - Log::info("ServerLobbyRoomProtocol", "Peer not registered"); + Log::info("ServerLobbyRoomProtocol", "The DC peer wasn't registered."); } //----------------------------------------------------------------------------- @@ -196,7 +195,6 @@ void ServerLobbyRoomProtocol::connectionRequested(Event* event) Log::warn("ServerLobbyRoomProtocol", "The server is sending a badly formated message. Size is %d and first byte %d", event->data.size(), event->data[0]); return; } - Log::verbose("ServerLobbyRoomProtocol", "New player."); int player_id = 0; player_id = event->data.getUInt32(1); // can we add the player ? @@ -231,6 +229,7 @@ void ServerLobbyRoomProtocol::connectionRequested(Event* event) profile->user_profile = new OnlineUser("Unnamed Player"); m_setup->addPlayer(profile); peer->setPlayerProfile(profile); + Log::verbose("ServerLobbyRoomProtocol", "New player."); } // accept player else // refuse the connection with code 0 (too much players) { @@ -240,6 +239,7 @@ void ServerLobbyRoomProtocol::connectionRequested(Event* event) message.ai8(0); // 0 = too much players // send only to the peer that made the request m_listener->sendMessage(this, peer, message); + Log::verbose("ServerLobbyRoomProtocol", "Player refused"); } }