WII_IPC_HLE: Fix Reinit

Init cannot be called more than once because it registers the
CoreTiming callbacks, that trips the assertions and will cause
anyone with PanicAlerts disabled to crash.
This commit is contained in:
EmptyChaos 2016-09-06 02:59:22 +00:00
parent 5932ded806
commit 014714d515
3 changed files with 11 additions and 3 deletions

View File

@ -119,9 +119,9 @@ std::shared_ptr<T> AddDevice(const char* deviceName)
return device;
}
void Init()
void Reinit()
{
_dbg_assert_msg_(WII_IPC_HLE, g_DeviceMap.empty(), "DeviceMap isn't empty on init");
_assert_msg_(WII_IPC_HLE, g_DeviceMap.empty(), "Reinit called while already initialized");
CWII_IPC_HLE_Device_es::m_ContentFile = "";
num_devices = 0;
@ -156,6 +156,11 @@ void Init()
#endif
AddDevice<CWII_IPC_HLE_Device_stub>("/dev/usb/oh1");
AddDevice<IWII_IPC_HLE_Device>("_Unimplemented_Device_");
}
void Init()
{
Reinit();
event_enqueue = CoreTiming::RegisterEvent("IPCEvent", EnqueueEvent);
event_sdio_notify = CoreTiming::RegisterEvent("SDIO_EventNotify", SDIO_EventNotify_CPUThread);

View File

@ -45,6 +45,9 @@ namespace WII_IPC_HLE_Interface
// Init
void Init();
// Needs to be called after Reset(true) to recreate the device tree
void Reinit();
// Shutdown
void Shutdown();

View File

@ -1000,7 +1000,7 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(u32 _CommandAddress)
wiiMoteConnected[i] = s_Usb->m_WiiMotes[i].IsConnected();
WII_IPC_HLE_Interface::Reset(true);
WII_IPC_HLE_Interface::Init();
WII_IPC_HLE_Interface::Reinit();
s_Usb = GetUsbPointer();
for (unsigned int i = 0; i < s_Usb->m_WiiMotes.size(); i++)
{