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/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<std::recursive_mutex> 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<std::recursive_mutex> 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<PowerPC::CPUCore> 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;

View File

@ -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