NetPlay: Supply every player's ping data to the client

This means that we now have feature parity with the combined server
before.
This commit is contained in:
Jasper St. Pierre 2013-08-05 05:50:26 -04:00
parent a3a222bf5b
commit 59ab60f37f
5 changed files with 28 additions and 3 deletions

View File

@ -35,7 +35,7 @@ std::string NetPlayClient::Player::ToString() const
ss << name << '[' << (char)(pid+'0') << "] : " << revision << " |";
for (unsigned int i=0; i<4; ++i)
ss << (pad_map[i]>=0 ? (char)(pad_map[i]+'1') : '-');
ss << '|';
ss << " | " << ping << "ms";
return ss.str();
}
@ -293,6 +293,21 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet)
}
break;
case NP_MSG_PLAYER_PING_DATA:
{
PlayerId pid;
packet >> pid;
{
std::lock_guard<std::recursive_mutex> lkp(m_crit.players);
Player& player = m_players[pid];
packet >> player.ping;
}
m_dialog->Update();
}
break;
default :
PanicAlertT("Unknown message received with id : %d", mid);
break;

View File

@ -94,6 +94,7 @@ protected:
std::string name;
PadMapping pad_map[4];
std::string revision;
u32 ping;
};
Common::FifoQueue<NetPad> m_pad_buffer[4];

View File

@ -23,7 +23,7 @@ struct Rpt : public std::vector<u8>
typedef std::vector<Rpt> NetWiimote;
#define NETPLAY_VERSION "Dolphin NetPlay 2013-07-19"
#define NETPLAY_VERSION "Dolphin NetPlay 2013-08-05"
// messages
enum
@ -50,6 +50,7 @@ enum
NP_MSG_PING = 0xE0,
NP_MSG_PONG = 0xE1,
NP_MSG_PLAYER_PING_DATA = 0xE2,
};
typedef u8 MessageId;

View File

@ -456,6 +456,14 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, sf::SocketTCP& socket)
if (m_ping_key == ping_key)
player.ping = ping;
sf::Packet spac;
spac << (MessageId)NP_MSG_PLAYER_PING_DATA;
spac << player.pid;
spac << player.ping;
std::lock_guard<std::recursive_mutex> lks(m_crit.send);
SendToClients(spac);
}
break;

View File

@ -61,7 +61,7 @@ private:
std::string revision;
sf::SocketTCP socket;
u64 ping;
u32 ping;
u32 current_game;
};