Core/NetPlay: Add debugging messages

This commit is contained in:
spycrab 2018-07-10 17:46:13 +02:00
parent b9960777a7
commit b367cd0331
2 changed files with 21 additions and 0 deletions

View File

@ -20,6 +20,7 @@
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
#include "Common/ENetUtil.h" #include "Common/ENetUtil.h"
#include "Common/FileUtil.h" #include "Common/FileUtil.h"
#include "Common/Logging/Log.h"
#include "Common/MD5.h" #include "Common/MD5.h"
#include "Common/MsgHandler.h" #include "Common/MsgHandler.h"
#include "Common/QoSSession.h" #include "Common/QoSSession.h"
@ -258,6 +259,8 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet)
MessageId mid; MessageId mid;
packet >> mid; packet >> mid;
INFO_LOG(NETPLAY, "Got server message: %x", mid);
switch (mid) switch (mid)
{ {
case NP_MSG_PLAYER_JOIN: case NP_MSG_PLAYER_JOIN:
@ -267,6 +270,9 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet)
packet >> player.name; packet >> player.name;
packet >> player.revision; 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<std::recursive_mutex> lkp(m_crit.players); std::lock_guard<std::recursive_mutex> lkp(m_crit.players);
m_players[player.pid] = player; m_players[player.pid] = player;
@ -281,6 +287,8 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet)
PlayerId pid; PlayerId pid;
packet >> pid; packet >> pid;
INFO_LOG(NETPLAY, "Player %s (%d) left", m_players.find(pid)->second.name.c_str(), pid);
{ {
std::lock_guard<std::recursive_mutex> lkp(m_crit.players); std::lock_guard<std::recursive_mutex> lkp(m_crit.players);
m_players.erase(m_players.find(pid)); 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 // don't need lock to read in this thread
const Player& player = m_players[pid]; 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 // add to gui
std::ostringstream ss; std::ostringstream ss;
ss << player.name << '[' << (char)(pid + '0') << "]: " << msg; ss << player.name << '[' << (char)(pid + '0') << "]: " << msg;
@ -382,6 +392,8 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet)
packet >> m_selected_game; packet >> m_selected_game;
} }
INFO_LOG(NETPLAY, "Game changed to %s", m_selected_game.c_str());
// update gui // update gui
m_dialog->OnMsgChangeGame(m_selected_game); m_dialog->OnMsgChangeGame(m_selected_game);
@ -421,6 +433,8 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet)
packet >> m_current_game; packet >> m_current_game;
packet >> g_NetPlaySettings.m_CPUthread; packet >> g_NetPlaySettings.m_CPUthread;
INFO_LOG(NETPLAY, "Start of game %s", m_selected_game.c_str());
{ {
std::underlying_type_t<PowerPC::CPUCore> core; std::underlying_type_t<PowerPC::CPUCore> core;
if (packet >> core) if (packet >> core)
@ -461,6 +475,8 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet)
case NP_MSG_STOP_GAME: case NP_MSG_STOP_GAME:
case NP_MSG_DISABLE_GAME: case NP_MSG_DISABLE_GAME:
{ {
INFO_LOG(NETPLAY, "Game stopped");
StopGame(); StopGame();
m_dialog->OnMsgStopGame(); m_dialog->OnMsgStopGame();
} }
@ -509,6 +525,9 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet)
if (it != m_players.end()) if (it != m_players.end())
player = it->second.name; player = it->second.name;
} }
INFO_LOG(NETPLAY, "Player %s (%d) desynced!", player.c_str(), pid_to_blame);
m_dialog->OnDesync(frame, player); m_dialog->OnDesync(frame, player);
} }
break; break;

View File

@ -500,6 +500,8 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
MessageId mid; MessageId mid;
packet >> 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 // 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 // only need locks for writes to m_players in this thread