summaryrefslogtreecommitdiff
path: root/Source/Core/Common/SysConf.cpp
diff options
context:
space:
mode:
authorcomex <comexk@gmail.com>2015-06-02 18:38:19 -0400
committercomex <comexk@gmail.com>2015-06-02 18:38:19 -0400
commita3b3f0522bce40ed6613ab97c1a64fe825b4ed66 (patch)
treef46f75d4960816c8c8905e2294130ac36d5bb11b /Source/Core/Common/SysConf.cpp
parent2b5945ae07dbbf46e6e38d2524bf2112ef2b6324 (diff)
parent45b07cbdcd97f2015dca5873c7949e9991ce23d4 (diff)
Merge pull request #1556 from comex/project-moration
Rudimentary version of Wii IPC determinism. Ported from my old udpnet branch.
Diffstat (limited to 'Source/Core/Common/SysConf.cpp')
-rw-r--r--Source/Core/Common/SysConf.cpp21
1 files changed, 14 insertions, 7 deletions
diff --git a/Source/Core/Common/SysConf.cpp b/Source/Core/Common/SysConf.cpp
index 94124c4957..047114774a 100644
--- a/Source/Core/Common/SysConf.cpp
+++ b/Source/Core/Common/SysConf.cpp
@@ -8,6 +8,7 @@
#include <string>
#include <vector>
+#include "Common/CommonPaths.h"
#include "Common/CommonTypes.h"
#include "Common/FileUtil.h"
#include "Common/SysConf.h"
@@ -15,8 +16,7 @@
SysConf::SysConf()
: m_IsValid(false)
{
- m_FilenameDefault = File::GetUserPath(F_WIISYSCONF_IDX);
- m_IsValid = LoadFromFile(m_FilenameDefault);
+ UpdateLocation();
}
SysConf::~SysConf()
@@ -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)
@@ -409,17 +416,17 @@ void SysConf::UpdateLocation()
// Clear the old filename and set the default filename to the new user path
// So that it can be generated if the file does not exist in the new location
m_Filename.clear();
- m_FilenameDefault = File::GetUserPath(F_WIISYSCONF_IDX);
+ // Note: We don't use the dummy Wii root here (if in use) because this is
+ // all tied up with the configuration code. In the future this should
+ // probably just be synced with the other settings.
+ m_FilenameDefault = File::GetUserPath(D_WIIROOT_IDX) + DIR_SEP WII_SYSCONF_DIR DIR_SEP WII_SYSCONF;
Reload();
}
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;
}