diff --git a/Source/Core/Common/Src/SysConf.cpp b/Source/Core/Common/Src/SysConf.cpp index 9c7cd6bad7..96f6b46167 100644 --- a/Source/Core/Common/Src/SysConf.cpp +++ b/Source/Core/Common/Src/SysConf.cpp @@ -19,10 +19,10 @@ #include "SysConf.h" SysConf::SysConf() -: m_IsValid(false) + : m_IsValid(false) { - if (LoadFromFile(File::GetUserPath(F_WIISYSCONF_IDX).c_str())) - m_IsValid = true; + m_FilenameDefault = File::GetUserPath(F_WIISYSCONF_IDX); + m_IsValid = LoadFromFile(m_FilenameDefault.c_str()); } SysConf::~SysConf() @@ -31,7 +31,11 @@ SysConf::~SysConf() return; Save(); + Clear(); +} +void SysConf::Clear() +{ for (size_t i = 0; i < m_Entries.size() - 1; i++) { delete [] m_Entries.at(i).data; @@ -167,3 +171,14 @@ bool SysConf::Save() return false; return SaveToFile(m_Filename.c_str()); } + +bool SysConf::Reload() +{ + if (m_IsValid) + Clear(); + + std::string& filename = m_Filename.empty() ? m_FilenameDefault : m_Filename; + + m_IsValid = LoadFromFile(filename.c_str()); + return m_IsValid; +} diff --git a/Source/Core/Common/Src/SysConf.h b/Source/Core/Common/Src/SysConf.h index c04434cf0c..13342b30ee 100644 --- a/Source/Core/Common/Src/SysConf.h +++ b/Source/Core/Common/Src/SysConf.h @@ -78,12 +78,6 @@ struct SSysConfEntry class SysConf { -private: - SSysConfHeader m_Header; - std::string m_Filename; - std::vector m_Entries; - bool m_IsValid; - public: SysConf(); ~SysConf(); @@ -182,8 +176,17 @@ public: bool Save(); bool SaveToFile(const char* filename); bool LoadFromFile(const char* filename); + bool Reload(); + private: bool LoadFromFileInternal(FILE *f); + void Clear(); + + SSysConfHeader m_Header; + std::string m_Filename; + std::string m_FilenameDefault; + std::vector m_Entries; + bool m_IsValid; }; #endif // __SYSCONF_MANAGER_h__ diff --git a/Source/Core/Core/Src/Core.cpp b/Source/Core/Core/Src/Core.cpp index 57398aee64..8bd7616857 100644 --- a/Source/Core/Core/Src/Core.cpp +++ b/Source/Core/Core/Src/Core.cpp @@ -323,6 +323,10 @@ void Stop() // - Hammertime! Pad::Shutdown(); Wiimote::Shutdown(); g_video_backend->Shutdown(); + + // Reload sysconf file in order to see changes committed during emulation + if (_CoreParameter.bWii) + SConfig::GetInstance().m_SYSCONF->Reload(); INFO_LOG(CONSOLE, "Stop [Main Thread]\t\t---- Shutdown complete ----"); }