Fix crash on stop in netplay, and stop netplay when anyone with a pad mapped in game stops emulation.
This commit is contained in:
parent
6b1c8f9d17
commit
cea7737aef
|
@ -564,6 +564,23 @@ bool NetPlayClient::StopGame()
|
|||
return true;
|
||||
}
|
||||
|
||||
void NetPlayClient::Stop()
|
||||
{
|
||||
bool isPadMapped = false;
|
||||
for (unsigned int i = 0; i < 4; ++i)
|
||||
{
|
||||
if (m_pad_map[i] == m_local_player->pid)
|
||||
isPadMapped = true;
|
||||
}
|
||||
// tell the server to stop if we have a pad mapped in game.
|
||||
if (isPadMapped)
|
||||
{
|
||||
sf::Packet spac;
|
||||
spac << (MessageId)NP_MSG_STOP_GAME;
|
||||
m_socket.Send(spac);
|
||||
}
|
||||
}
|
||||
|
||||
// called from ---CPU--- thread
|
||||
u8 NetPlayClient::GetPadNum(u8 numPAD)
|
||||
{
|
||||
|
|
|
@ -74,6 +74,7 @@ public:
|
|||
|
||||
bool StartGame(const std::string &path);
|
||||
bool StopGame();
|
||||
void Stop();
|
||||
bool ChangeGame(const std::string& game);
|
||||
void SendChatMessage(const std::string& msg);
|
||||
|
||||
|
|
|
@ -376,6 +376,20 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, sf::SocketTCP& socket)
|
|||
}
|
||||
break;
|
||||
|
||||
case NP_MSG_STOP_GAME:
|
||||
{
|
||||
// tell clients to stop game
|
||||
sf::Packet spac;
|
||||
spac << (MessageId)NP_MSG_STOP_GAME;
|
||||
|
||||
std::lock_guard<std::recursive_mutex> lkp(m_crit.players);
|
||||
std::lock_guard<std::recursive_mutex> lks(m_crit.send);
|
||||
SendToClients(spac);
|
||||
|
||||
m_is_running = false;
|
||||
}
|
||||
break;
|
||||
|
||||
default :
|
||||
PanicAlertT("Unknown message with id:%d received from player:%d Kicking player!", mid, player.pid);
|
||||
// unknown message, kick the client
|
||||
|
|
|
@ -650,8 +650,6 @@ void PadMapDiag::OnAdjust(wxCommandEvent& event)
|
|||
|
||||
void NetPlay::StopGame()
|
||||
{
|
||||
if (netplay_server != NULL)
|
||||
netplay_server->StopGame();
|
||||
|
||||
// TODO: allow non-hosting clients to close the window
|
||||
if (netplay_client != NULL)
|
||||
netplay_client->Stop();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue