From b367cd03312c6dfe1a108e1b35137dbaaa537831 Mon Sep 17 00:00:00 2001 From: spycrab Date: Tue, 10 Jul 2018 17:46:13 +0200 Subject: [PATCH] Core/NetPlay: Add debugging messages --- Source/Core/Core/NetPlayClient.cpp | 19 +++++++++++++++++++ Source/Core/Core/NetPlayServer.cpp | 2 ++ 2 files changed, 21 insertions(+) diff --git a/Source/Core/Core/NetPlayClient.cpp b/Source/Core/Core/NetPlayClient.cpp index 99863ce273..60a40bfa83 100644 --- a/Source/Core/Core/NetPlayClient.cpp +++ b/Source/Core/Core/NetPlayClient.cpp @@ -20,6 +20,7 @@ #include "Common/CommonTypes.h" #include "Common/ENetUtil.h" #include "Common/FileUtil.h" +#include "Common/Logging/Log.h" #include "Common/MD5.h" #include "Common/MsgHandler.h" #include "Common/QoSSession.h" @@ -258,6 +259,8 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet) MessageId mid; packet >> mid; + INFO_LOG(NETPLAY, "Got server message: %x", mid); + switch (mid) { case NP_MSG_PLAYER_JOIN: @@ -267,6 +270,9 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet) packet >> player.name; packet >> player.revision; + INFO_LOG(NETPLAY, "Player %s (%d) using %s joined", player.name.c_str(), player.pid, + player.revision.c_str()); + { std::lock_guard lkp(m_crit.players); m_players[player.pid] = player; @@ -281,6 +287,8 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet) PlayerId pid; packet >> pid; + INFO_LOG(NETPLAY, "Player %s (%d) left", m_players.find(pid)->second.name.c_str(), pid); + { std::lock_guard lkp(m_crit.players); m_players.erase(m_players.find(pid)); @@ -300,6 +308,8 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet) // don't need lock to read in this thread const Player& player = m_players[pid]; + INFO_LOG(NETPLAY, "Player %s (%d) wrote: %s", player.name.c_str(), player.pid, msg.c_str()); + // add to gui std::ostringstream ss; ss << player.name << '[' << (char)(pid + '0') << "]: " << msg; @@ -382,6 +392,8 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet) packet >> m_selected_game; } + INFO_LOG(NETPLAY, "Game changed to %s", m_selected_game.c_str()); + // update gui m_dialog->OnMsgChangeGame(m_selected_game); @@ -421,6 +433,8 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet) packet >> m_current_game; packet >> g_NetPlaySettings.m_CPUthread; + INFO_LOG(NETPLAY, "Start of game %s", m_selected_game.c_str()); + { std::underlying_type_t core; if (packet >> core) @@ -461,6 +475,8 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet) case NP_MSG_STOP_GAME: case NP_MSG_DISABLE_GAME: { + INFO_LOG(NETPLAY, "Game stopped"); + StopGame(); m_dialog->OnMsgStopGame(); } @@ -509,6 +525,9 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet) if (it != m_players.end()) player = it->second.name; } + + INFO_LOG(NETPLAY, "Player %s (%d) desynced!", player.c_str(), pid_to_blame); + m_dialog->OnDesync(frame, player); } break; diff --git a/Source/Core/Core/NetPlayServer.cpp b/Source/Core/Core/NetPlayServer.cpp index 78ad81364c..bb903b5323 100644 --- a/Source/Core/Core/NetPlayServer.cpp +++ b/Source/Core/Core/NetPlayServer.cpp @@ -500,6 +500,8 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player) MessageId mid; packet >> mid; + INFO_LOG(NETPLAY, "Got client message: %x", mid); + // don't need lock because this is the only thread that modifies the players // only need locks for writes to m_players in this thread