Skip to content

Commit

Permalink
Core/NetPlay: Add debugging messages
Browse files Browse the repository at this point in the history
  • Loading branch information
spycrab committed Jul 10, 2018
1 parent b996077 commit b367cd0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Source/Core/Core/NetPlayClient.cpp
Expand Up @@ -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"
Expand Down Expand Up @@ -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:
Expand All @@ -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;
Expand All @@ -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));
Expand All @@ -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;
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions Source/Core/Core/NetPlayServer.cpp
Expand Up @@ -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

Expand Down

0 comments on commit b367cd0

Please sign in to comment.