summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorPierre Bourdon <delroth@gmail.com>2016-07-17 02:19:43 +0200
committerGitHub <noreply@github.com>2016-07-17 02:19:43 +0200
commit92594e08d44c2a2da8acec4394829e2e3695e236 (patch)
tree69f8a1f428ce72dca5b9f7162398aaf0fbe9e647 /Source/Core
parentbb87bb73f45401213f1c7e15e21b1ce64132b1f8 (diff)
parent8b7bfe6cf985ace1de355907c4cc44e084811764 (diff)
Merge pull request #4016 from mimimi085181/sync-wiimote-netplay
Netplay: Fix synchronization for the Wiinote netplay
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Core/NetPlayClient.cpp79
-rw-r--r--Source/Core/Core/NetPlayClient.h3
2 files changed, 12 insertions, 70 deletions
diff --git a/Source/Core/Core/NetPlayClient.cpp b/Source/Core/Core/NetPlayClient.cpp
index 952fc60ae6..586ca0494c 100644
--- a/Source/Core/Core/NetPlayClient.cpp
+++ b/Source/Core/Core/NetPlayClient.cpp
@@ -768,7 +768,6 @@ bool NetPlayClient::StartGame(const std::string& path)
// Needed to prevent locking up at boot if (when) the wiimotes connect out of order.
NetWiimote nw;
nw.resize(4, 0);
- m_wiimote_current_data_size.fill(4);
for (unsigned int w = 0; w < 4; ++w)
{
@@ -973,46 +972,24 @@ bool NetPlayClient::WiimoteUpdate(int _number, u8* data, const u8 size)
{
std::lock_guard<std::recursive_mutex> lkp(m_crit.players);
- // in game mapping for this local Wiimote
- unsigned int in_game_num = LocalWiimoteToInGameWiimote(_number);
- // does this local Wiimote map in game?
- if (in_game_num < 4)
+ // Only send data, if this Wiimote is mapped to this player
+ if (m_wiimote_map[_number] == m_local_player->pid)
{
- if (m_wiimote_current_data_size[in_game_num] == size)
+ nw.assign(data, data + size);
+ do
{
- nw.assign(data, data + size);
- do
- {
- // add to buffer
- m_wiimote_buffer[in_game_num].Push(nw);
+ // add to buffer
+ m_wiimote_buffer[_number].Push(nw);
- SendWiimoteState(in_game_num, nw);
- } while (m_wiimote_buffer[in_game_num].Size() <=
- m_target_buffer_size * 200 /
- 120); // TODO: add a seperate setting for wiimote buffer?
- }
- else
- {
- while (m_wiimote_buffer[in_game_num].Size() > 0)
- {
- // Reporting mode changed, so previous buffer is no good.
- m_wiimote_buffer[in_game_num].Pop();
- }
- nw.resize(size, 0);
-
- m_wiimote_buffer[in_game_num].Push(nw);
- m_wiimote_buffer[in_game_num].Push(nw);
- m_wiimote_buffer[in_game_num].Push(nw);
- m_wiimote_buffer[in_game_num].Push(nw);
- m_wiimote_buffer[in_game_num].Push(nw);
- m_wiimote_buffer[in_game_num].Push(nw);
- m_wiimote_current_data_size[in_game_num] = size;
- }
+ SendWiimoteState(_number, nw);
+ } while (m_wiimote_buffer[_number].Size() <=
+ m_target_buffer_size * 200 /
+ 120); // TODO: add a seperate setting for wiimote buffer?
}
} // unlock players
- while (m_wiimote_current_data_size[_number] == size && !m_wiimote_buffer[_number].Pop(nw))
+ while (!m_wiimote_buffer[_number].Pop(nw))
{
// wait for receiving thread to push some data
Common::SleepCurrentThread(1);
@@ -1020,23 +997,11 @@ bool NetPlayClient::WiimoteUpdate(int _number, u8* data, const u8 size)
return false;
}
- // Use a blank input, since we may not have any valid input.
- if (m_wiimote_current_data_size[_number] != size)
- {
- nw.resize(size, 0);
- m_wiimote_buffer[_number].Push(nw);
- m_wiimote_buffer[_number].Push(nw);
- m_wiimote_buffer[_number].Push(nw);
- m_wiimote_buffer[_number].Push(nw);
- m_wiimote_buffer[_number].Push(nw);
- }
-
- // We should have used a blank input last time, so now we just need to pop through the old buffer,
+ // If the reporting mode has changed, we just need to pop through the buffer,
// until we reach a good input
if (nw.size() != size)
{
u32 tries = 0;
- // Clear the buffer and wait for new input, since we probably just changed reporting mode.
while (nw.size() != size)
{
while (!m_wiimote_buffer[_number].Pop(nw))
@@ -1058,7 +1023,6 @@ bool NetPlayClient::WiimoteUpdate(int _number, u8* data, const u8 size)
}
}
- m_wiimote_current_data_size[_number] = size;
memcpy(data, nw.data(), size);
return true;
}
@@ -1155,25 +1119,6 @@ u8 NetPlayClient::LocalPadToInGamePad(u8 local_pad)
return ingame_pad;
}
-u8 NetPlayClient::LocalWiimoteToInGameWiimote(u8 local_pad)
-{
- // Figure out which in-game pad maps to which local pad.
- // The logic we have here is that the local slots always
- // go in order.
- int local_pad_count = -1;
- int ingame_pad = 0;
- for (; ingame_pad < 4; ingame_pad++)
- {
- if (m_wiimote_map[ingame_pad] == m_local_player->pid)
- local_pad_count++;
-
- if (local_pad_count == local_pad)
- break;
- }
-
- return ingame_pad;
-}
-
void NetPlayClient::SendTimeBase()
{
std::lock_guard<std::mutex> lk(crit_netplay_client);
diff --git a/Source/Core/Core/NetPlayClient.h b/Source/Core/Core/NetPlayClient.h
index 8004d13d0e..907df2e89f 100644
--- a/Source/Core/Core/NetPlayClient.h
+++ b/Source/Core/Core/NetPlayClient.h
@@ -89,8 +89,6 @@ public:
u8 InGamePadToLocalPad(u8 ingame_pad);
u8 LocalPadToInGamePad(u8 localPad);
- u8 LocalWiimoteToInGameWiimote(u8 local_pad);
-
static void SendTimeBase();
bool DoAllPlayersHaveGame();
@@ -109,7 +107,6 @@ protected:
std::array<Common::FifoQueue<GCPadStatus>, 4> m_pad_buffer;
std::array<Common::FifoQueue<NetWiimote>, 4> m_wiimote_buffer;
- std::array<u32, 4> m_wiimote_current_data_size;
NetPlayUI* m_dialog = nullptr;