diff --git a/Source/Core/Core/NetPlayClient.cpp b/Source/Core/Core/NetPlayClient.cpp index b59845c97b..a498803ce2 100644 --- a/Source/Core/Core/NetPlayClient.cpp +++ b/Source/Core/Core/NetPlayClient.cpp @@ -2,6 +2,7 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. +#include #include #include "Common/Common.h" #include "Common/CommonTypes.h" @@ -1017,27 +1018,22 @@ void NetPlayClient::Stop() if (!m_is_running.load()) return; - bool isPadMapped = false; - for (PadMapping mapping : m_pad_map) - { - if (mapping == m_local_player->pid) - { - isPadMapped = true; - } - } - for (PadMapping mapping : m_wiimote_map) - { - if (mapping == m_local_player->pid) - { - isPadMapped = true; - } - } - // Tell the server to stop if we have a pad mapped in game. - if (isPadMapped) + if (LocalPlayerHasControllerMapped()) SendStopGamePacket(); } +// called from ---GUI--- thread +bool NetPlayClient::LocalPlayerHasControllerMapped() const +{ + const auto mapping_matches_player_id = [this](const PadMapping& mapping) { + return mapping == m_local_player->pid; + }; + + return std::any_of(m_pad_map.begin(), m_pad_map.end(), mapping_matches_player_id) || + std::any_of(m_wiimote_map.begin(), m_wiimote_map.end(), mapping_matches_player_id); +} + u8 NetPlayClient::InGamePadToLocalPad(u8 ingame_pad) { // not our pad diff --git a/Source/Core/Core/NetPlayClient.h b/Source/Core/Core/NetPlayClient.h index 0e1c2ec70e..f55af047cd 100644 --- a/Source/Core/Core/NetPlayClient.h +++ b/Source/Core/Core/NetPlayClient.h @@ -129,6 +129,8 @@ private: Failure }; + bool LocalPlayerHasControllerMapped() const; + void SendStartGamePacket(); void SendStopGamePacket();