NetPlayClient: Consolidate stopping code to function.

This commit is contained in:
Admiral H. Curtiss 2022-09-13 01:22:51 +02:00
parent c4b3f2302a
commit 35f6d12acc
No known key found for this signature in database
GPG Key ID: F051B4C4044F33FB
2 changed files with 9 additions and 9 deletions

View File

@ -2244,8 +2244,7 @@ void NetPlayClient::SendPadHostPoll(const PadIndex pad_num)
SendAsync(std::move(packet)); SendAsync(std::move(packet));
} }
// called from ---GUI--- thread and ---NETPLAY--- thread (client side) void NetPlayClient::InvokeStop()
bool NetPlayClient::StopGame()
{ {
m_is_running.Clear(); m_is_running.Clear();
@ -2254,6 +2253,12 @@ bool NetPlayClient::StopGame()
m_wii_pad_event.Set(); m_wii_pad_event.Set();
m_first_pad_status_received_event.Set(); m_first_pad_status_received_event.Set();
m_wait_on_input_event.Set(); m_wait_on_input_event.Set();
}
// called from ---GUI--- thread and ---NETPLAY--- thread (client side)
bool NetPlayClient::StopGame()
{
InvokeStop();
NetPlay_Disable(); NetPlay_Disable();
@ -2269,13 +2274,7 @@ void NetPlayClient::Stop()
if (!m_is_running.IsSet()) if (!m_is_running.IsSet())
return; return;
m_is_running.Clear(); InvokeStop();
// stop waiting for input
m_gc_pad_event.Set();
m_wii_pad_event.Set();
m_first_pad_status_received_event.Set();
m_wait_on_input_event.Set();
// Tell the server to stop if we have a pad mapped in game. // Tell the server to stop if we have a pad mapped in game.
if (LocalPlayerHasControllerMapped()) if (LocalPlayerHasControllerMapped())

View File

@ -117,6 +117,7 @@ public:
// Called from the GUI thread. // Called from the GUI thread.
bool IsConnected() const { return m_is_connected; } bool IsConnected() const { return m_is_connected; }
bool StartGame(const std::string& path); bool StartGame(const std::string& path);
void InvokeStop();
bool StopGame(); bool StopGame();
void Stop(); void Stop();
bool ChangeGame(const std::string& game); bool ChangeGame(const std::string& game);