summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcomex <comexk@gmail.com>2015-04-20 22:24:21 -0400
committercomex <comexk@gmail.com>2015-05-28 19:19:00 -0400
commit45b07cbdcd97f2015dca5873c7949e9991ce23d4 (patch)
treeefc8338ec5b14e22ed0c7498abf88787a343ff74
parent0d257b9e88faf63b28b5f1a25bf86447e6d095ae (diff)
Fix determinism issues with Wiimote netplay.
- Change the Wiimote emulation SYSCONF R/W to use the temporary NAND if in use. - Fix up SysConf API so this actually works. Kind of a hack. Like I said, this can be cleaned up when configuration is synced...
-rw-r--r--Source/Core/Common/SysConf.cpp12
-rw-r--r--Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb.cpp19
2 files changed, 25 insertions, 6 deletions
diff --git a/Source/Core/Common/SysConf.cpp b/Source/Core/Common/SysConf.cpp
index a0d3aa1f04..047114774a 100644
--- a/Source/Core/Common/SysConf.cpp
+++ b/Source/Core/Common/SysConf.cpp
@@ -38,6 +38,10 @@ void SysConf::Clear()
bool SysConf::LoadFromFile(const std::string& filename)
{
+ if (m_IsValid)
+ Clear();
+ m_IsValid = false;
+
// Basic check
if (!File::Exists(filename))
{
@@ -67,6 +71,7 @@ bool SysConf::LoadFromFile(const std::string& filename)
if (LoadFromFileInternal(f.ReleaseHandle()))
{
m_Filename = filename;
+ m_IsValid = true;
return true;
}
}
@@ -107,6 +112,7 @@ bool SysConf::LoadFromFileInternal(FILE *fh)
f.ReadArray(curEntry.name, curEntry.nameLength);
curEntry.name[curEntry.nameLength] = '\0';
// Get length of data
+ curEntry.data = nullptr;
curEntry.dataLength = 0;
switch (curEntry.type)
{
@@ -362,6 +368,7 @@ void SysConf::GenerateSysConf()
g.WriteBytes("SCed", 4);
m_Filename = m_FilenameDefault;
+ m_IsValid = true;
}
bool SysConf::SaveToFile(const std::string& filename)
@@ -418,11 +425,8 @@ void SysConf::UpdateLocation()
bool SysConf::Reload()
{
- if (m_IsValid)
- Clear();
-
std::string& filename = m_Filename.empty() ? m_FilenameDefault : m_Filename;
- m_IsValid = LoadFromFile(filename);
+ LoadFromFile(filename);
return m_IsValid;
}
diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb.cpp b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb.cpp
index 243b121c9f..bfd90e4652 100644
--- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb.cpp
+++ b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb.cpp
@@ -2,6 +2,7 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
+#include "Common/CommonPaths.h"
#include "Core/ConfigManager.h"
#include "Core/Core.h"
#include "Core/CoreTiming.h"
@@ -35,11 +36,25 @@ CWII_IPC_HLE_Device_usb_oh1_57e_305::CWII_IPC_HLE_Device_usb_oh1_57e_305(u32 _De
, m_ACLEndpoint(0)
, m_last_ticks(0)
{
+ SysConf* sysconf;
+ std::unique_ptr<SysConf> owned_sysconf;
+ if (Core::g_want_determinism)
+ {
+ // See SysConf::UpdateLocation for comment about the Future.
+ owned_sysconf.reset(new SysConf());
+ sysconf = owned_sysconf.get();
+ sysconf->LoadFromFile(File::GetUserPath(D_SESSION_WIIROOT_IDX) + DIR_SEP WII_SYSCONF_DIR DIR_SEP WII_SYSCONF);
+ }
+ else
+ {
+ sysconf = SConfig::GetInstance().m_SYSCONF;
+ }
+
// Activate only first Wiimote by default
_conf_pads BT_DINF;
SetUsbPointer(this);
- if (!SConfig::GetInstance().m_SYSCONF->GetArrayData("BT.DINF", (u8*)&BT_DINF, sizeof(_conf_pads)))
+ if (!sysconf->GetArrayData("BT.DINF", (u8*)&BT_DINF, sizeof(_conf_pads)))
{
PanicAlertT("Trying to read from invalid SYSCONF\nWiimote bt ids are not available");
}
@@ -83,7 +98,7 @@ CWII_IPC_HLE_Device_usb_oh1_57e_305::CWII_IPC_HLE_Device_usb_oh1_57e_305(u32 _De
// save now so that when games load sysconf file it includes the new Wiimotes
// and the correct order for connected Wiimotes
- if (!SConfig::GetInstance().m_SYSCONF->SetArrayData("BT.DINF", (u8*)&BT_DINF, sizeof(_conf_pads)) || !SConfig::GetInstance().m_SYSCONF->Save())
+ if (!sysconf->SetArrayData("BT.DINF", (u8*)&BT_DINF, sizeof(_conf_pads)) || !sysconf->Save())
PanicAlertT("Failed to write BT.DINF to SYSCONF");
}