summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorRachel Bryk <RachelBryk@gmail.com>2013-10-16 21:44:49 -0400
committerRachel Bryk <RachelBryk@gmail.com>2013-10-16 21:44:49 -0400
commitf605ea9eeb3fc023937ee3d37696628208f20e23 (patch)
tree260418799f7983c493238b057747880a7cd01ebe /Source/Core
parent5a212a8fe0cc05b375a0d26aa62e9cd4d3f0977c (diff)
[Netplay] Allow a spectator to leave without affecting players.
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Core/Src/NetPlayServer.cpp29
1 files changed, 18 insertions, 11 deletions
diff --git a/Source/Core/Core/Src/NetPlayServer.cpp b/Source/Core/Core/Src/NetPlayServer.cpp
index 00fec793c7..8cd6f08a9a 100644
--- a/Source/Core/Core/Src/NetPlayServer.cpp
+++ b/Source/Core/Core/Src/NetPlayServer.cpp
@@ -228,20 +228,27 @@ unsigned int NetPlayServer::OnConnect(sf::SocketTCP& socket)
// called from ---NETPLAY--- thread
unsigned int NetPlayServer::OnDisconnect(sf::SocketTCP& socket)
{
+ PlayerId pid = m_players[socket].pid;
+
if (m_is_running)
{
- PanicAlertT("Client disconnect while game is running!! NetPlay is disabled. You must manually stop the game.");
- std::lock_guard<std::recursive_mutex> lkg(m_crit.game);
- m_is_running = false;
-
- sf::Packet spac;
- spac << (MessageId)NP_MSG_DISABLE_GAME;
- // this thread doesn't need players lock
- std::lock_guard<std::recursive_mutex> lks(m_crit.send);
- SendToClients(spac);
- }
+ for (int i = 0; i < 4; i++)
+ {
+ if (m_pad_map[i] == pid)
+ {
+ PanicAlertT("Client disconnect while game is running!! NetPlay is disabled. You must manually stop the game.");
+ std::lock_guard<std::recursive_mutex> lkg(m_crit.game);
+ m_is_running = false;
- PlayerId pid = m_players[socket].pid;
+ sf::Packet spac;
+ spac << (MessageId)NP_MSG_DISABLE_GAME;
+ // this thread doesn't need players lock
+ std::lock_guard<std::recursive_mutex> lks(m_crit.send);
+ SendToClients(spac);
+ break;
+ }
+ }
+ }
sf::Packet spac;
spac << (MessageId)NP_MSG_PLAYER_LEAVE;