NetPlayClient: Extract control mapping checking to its own function
This commit is contained in:
parent
8588c8fd31
commit
e6ad76fa70
|
@ -2,6 +2,7 @@
|
|||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include "Common/Common.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
|
@ -1017,25 +1018,20 @@ 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 (LocalPlayerHasControllerMapped())
|
||||
SendStopGamePacket();
|
||||
}
|
||||
|
||||
// Tell the server to stop if we have a pad mapped in game.
|
||||
if (isPadMapped)
|
||||
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)
|
||||
|
|
|
@ -129,6 +129,8 @@ private:
|
|||
Failure
|
||||
};
|
||||
|
||||
bool LocalPlayerHasControllerMapped() const;
|
||||
|
||||
void SendStartGamePacket();
|
||||
void SendStopGamePacket();
|
||||
|
||||
|
|
Loading…
Reference in New Issue