Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix changing wiimotes when starting netplay.
AccessWiiMote() crashed for some users. Not sure why...
  • Loading branch information
RachelBryk committed Sep 25, 2013
1 parent ebe4448 commit 93f7622
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions Source/Core/Core/Src/NetPlayClient.cpp
Expand Up @@ -19,6 +19,7 @@
#include "ConfigManager.h"
#include "Movie.h"
#include "HW/WiimoteEmu/WiimoteEmu.h"
#include "HW/WiimoteReal/WiimoteReal.h"

std::mutex crit_netplay_client;
static NetPlayClient * netplay_client = NULL;
Expand Down Expand Up @@ -498,29 +499,27 @@ bool NetPlayClient::StartGame(const std::string &path)
}

// boot game

m_dialog->BootGame(path);

UpdateDevices();

if (SConfig::GetInstance().m_LocalCoreStartupParameter.bWii)
{
for (unsigned int i = 0; i < 4; ++i)
{
g_wiimote_sources[i] = m_wiimote_map[i] > 0 ? WIIMOTE_SRC_EMU : WIIMOTE_SRC_NONE;
GetUsbPointer()->AccessWiiMote(i | 0x100)->Activate(m_wiimote_map[i] > 0);
}
}
WiimoteReal::ChangeWiimoteSource(i, m_wiimote_map[i] > 0 ? WIIMOTE_SRC_EMU : WIIMOTE_SRC_NONE);

// Needed to prevent locking up at boot if (when) the wiimotes connect out of order.
NetWiimote nw;
nw.resize(4, 0);
// Needed to prevent locking up at boot if (when) the wiimotes connect out of order.
NetWiimote nw;
nw.resize(4, 0);

for (unsigned int w = 0; w < 4; ++w)
{
if (m_wiimote_map[w] != -1)
// probably overkill, but whatever
for (unsigned int i = 0; i < 7; ++i)
m_wiimote_buffer[w].Push(nw);
for (unsigned int w = 0; w < 4; ++w)
{
if (m_wiimote_map[w] != -1)
// probably overkill, but whatever
for (unsigned int i = 0; i < 7; ++i)
m_wiimote_buffer[w].Push(nw);
}
}

return true;
Expand Down

0 comments on commit 93f7622

Please sign in to comment.