From 34692ab826abc8f8faa61bdb2280b742424528f1 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Sat, 7 Dec 2013 15:14:29 -0500 Subject: Remove unnecessary Src/ folders --- Source/Core/Common/SysConf.cpp | 419 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 419 insertions(+) create mode 100644 Source/Core/Common/SysConf.cpp (limited to 'Source/Core/Common/SysConf.cpp') diff --git a/Source/Core/Common/SysConf.cpp b/Source/Core/Common/SysConf.cpp new file mode 100644 index 0000000000..acfb11b0ed --- /dev/null +++ b/Source/Core/Common/SysConf.cpp @@ -0,0 +1,419 @@ +// Copyright 2013 Dolphin Emulator Project +// Licensed under GPLv2 +// Refer to the license.txt file included. + +#include "FileUtil.h" +#include "SysConf.h" + +#include + +SysConf::SysConf() + : m_IsValid(false) +{ + m_FilenameDefault = File::GetUserPath(F_WIISYSCONF_IDX); + m_IsValid = LoadFromFile(m_FilenameDefault.c_str()); +} + +SysConf::~SysConf() +{ + if (!m_IsValid) + return; + + Save(); + Clear(); +} + +void SysConf::Clear() +{ + for (std::vector::const_iterator i = m_Entries.begin(); + i < m_Entries.end() - 1; i++) + delete [] i->data; + m_Entries.clear(); +} + +bool SysConf::LoadFromFile(const char *filename) +{ + // Basic check + if (!File::Exists(filename)) + { + File::CreateFullPath(filename); + GenerateSysConf(); + return true; + } + + u64 size = File::GetSize(filename); + if (size != SYSCONF_SIZE) + { + if (AskYesNoT("Your SYSCONF file is the wrong size.\nIt should be 0x%04x (but is 0x%04" PRIx64 ")\nDo you want to generate a new one?", + SYSCONF_SIZE, size)) + { + GenerateSysConf(); + return true; + } + else + return false; + } + + File::IOFile f(filename, "rb"); + if (f.IsOpen()) + { + if (LoadFromFileInternal(f.ReleaseHandle())) + { + m_Filename = filename; + return true; + } + } + + return false; +} + +bool SysConf::LoadFromFileInternal(FILE *fh) +{ + File::IOFile f(fh); + // Fill in infos + SSysConfHeader s_Header; + f.ReadArray(s_Header.version, 4); + f.ReadArray(&s_Header.numEntries, 1); + s_Header.numEntries = Common::swap16(s_Header.numEntries) + 1; + + for (u16 index = 0; index < s_Header.numEntries; index++) + { + SSysConfEntry tmpEntry; + f.ReadArray(&tmpEntry.offset, 1); + tmpEntry.offset = Common::swap16(tmpEntry.offset); + m_Entries.push_back(tmpEntry); + } + + // Last offset is an invalid entry. We ignore it throughout this class + for (std::vector::iterator i = m_Entries.begin(); + i < m_Entries.end() - 1; i++) + { + SSysConfEntry& curEntry = *i; + f.Seek(curEntry.offset, SEEK_SET); + + u8 description = 0; + f.ReadArray(&description, 1); + // Data type + curEntry.type = (SysconfType)((description & 0xe0) >> 5); + // Length of name in bytes - 1 + curEntry.nameLength = (description & 0x1f) + 1; + // Name + f.ReadArray(curEntry.name, curEntry.nameLength); + curEntry.name[curEntry.nameLength] = '\0'; + // Get length of data + curEntry.dataLength = 0; + switch (curEntry.type) + { + case Type_BigArray: + f.ReadArray(&curEntry.dataLength, 1); + curEntry.dataLength = Common::swap16(curEntry.dataLength); + break; + + case Type_SmallArray: + { + u8 dlength = 0; + f.ReadBytes(&dlength, 1); + curEntry.dataLength = dlength; + break; + } + + case Type_Byte: + case Type_Bool: + curEntry.dataLength = 1; + break; + + case Type_Short: + curEntry.dataLength = 2; + break; + + case Type_Long: + curEntry.dataLength = 4; + break; + + default: + PanicAlertT("Unknown entry type %i in SYSCONF (%s@%x)!", + curEntry.type, curEntry.name, curEntry.offset); + return false; + break; + } + // Fill in the actual data + if (curEntry.dataLength) + { + curEntry.data = new u8[curEntry.dataLength]; + f.ReadArray(curEntry.data, curEntry.dataLength); + } + } + + return f.IsGood(); +} + +// Returns the size of the item in file +unsigned int create_item(SSysConfEntry &item, SysconfType type, const std::string &name, + const int data_length, unsigned int offset) +{ + item.offset = offset; + item.type = type; + item.nameLength = (u8)(name.length()); + strncpy(item.name, name.c_str(), 32); + item.dataLength = data_length; + item.data = new u8[data_length]; + memset(item.data, 0, data_length); + switch (type) + { + case Type_BigArray: + // size of description + name length + size of dataLength + data length + null + return 1 + item.nameLength + 2 + item.dataLength + 1; + case Type_SmallArray: + // size of description + name length + size of dataLength + data length + null + return 1 + item.nameLength + 1 + item.dataLength + 1; + case Type_Byte: + case Type_Bool: + case Type_Short: + case Type_Long: + // size of description + name length + data length + return 1 + item.nameLength + item.dataLength; + default: + return 0; + } +} + +void SysConf::GenerateSysConf() +{ + SSysConfHeader s_Header; + strncpy(s_Header.version, "SCv0", 4); + s_Header.numEntries = Common::swap16(28 - 1); + + SSysConfEntry items[27]; + memset(items, 0, sizeof(SSysConfEntry) * 27); + + // version length + size of numEntries + 28 * size of offset + unsigned int current_offset = 4 + 2 + 28 * 2; + + // BT.DINF + current_offset += create_item(items[0], Type_BigArray, "BT.DINF", 0x460, current_offset); + items[0].data[0] = 4; + for (u8 i = 0; i < 4; ++i) + { + const u8 bt_addr[6] = {i, 0x00, 0x79, 0x19, 0x02, 0x11}; + memcpy(&items[0].data[1 + 70 * i], bt_addr, sizeof(bt_addr)); + memcpy(&items[0].data[7 + 70 * i], "Nintendo RVL-CNT-01", 19); + } + + // BT.SENS + current_offset += create_item(items[1], Type_Long, "BT.SENS", 4, current_offset); + items[1].data[3] = 0x03; + + // IPL.NIK + current_offset += create_item(items[2], Type_SmallArray, "IPL.NIK", 0x15, current_offset); + const u8 console_nick[14] = {0, 'd', 0, 'o', 0, 'l', 0, 'p', 0, 'h', 0, 'i', 0, 'n'}; + memcpy(items[2].data, console_nick, 14); + + // IPL.AR + current_offset += create_item(items[3], Type_Byte, "IPL.AR", 1, current_offset); + items[3].data[0] = 0x01; + + // BT.BAR + current_offset += create_item(items[4], Type_Byte, "BT.BAR", 1, current_offset); + items[4].data[0] = 0x01; + + // IPL.SSV + current_offset += create_item(items[5], Type_Byte, "IPL.SSV", 1, current_offset); + + // IPL.LNG + current_offset += create_item(items[6], Type_Byte, "IPL.LNG", 1, current_offset); + items[6].data[0] = 0x01; + + // IPL.SADR + current_offset += create_item(items[7], Type_BigArray, "IPL.SADR", 0x1007, current_offset); + items[7].data[0] = 0x6c; //(Switzerland) TODO should this default be changed? + + // IPL.CB + current_offset += create_item(items[8], Type_Long, "IPL.CB", 4, current_offset); + items[8].data[0] = 0x0f; items[8].data[1] = 0x11; + items[8].data[2] = 0x14; items[8].data[3] = 0xa6; + + // BT.SPKV + current_offset += create_item(items[9], Type_Byte, "BT.SPKV", 1, current_offset); + items[9].data[0] = 0x58; + + // IPL.PC + current_offset += create_item(items[10], Type_SmallArray, "IPL.PC", 0x49, current_offset); + items[10].data[1] = 0x04; items[10].data[2] = 0x14; + + // NET.CTPC + current_offset += create_item(items[11], Type_Long, "NET.CTPC", 4, current_offset); + + // WWW.RST + current_offset += create_item(items[12], Type_Bool, "WWW.RST", 1, current_offset); + + // BT.CDIF + current_offset += create_item(items[13], Type_BigArray, "BT.CDIF", 0x204, current_offset); + + // IPL.INC + current_offset += create_item(items[14], Type_Long, "IPL.INC", 4, current_offset); + items[14].data[3] = 0x08; + + // IPL.FRC + current_offset += create_item(items[15], Type_Long, "IPL.FRC", 4, current_offset); + items[15].data[3] = 0x28; + + // IPL.CD + current_offset += create_item(items[16], Type_Bool, "IPL.CD", 1, current_offset); + items[16].data[0] = 0x01; + + // IPL.CD2 + current_offset += create_item(items[17], Type_Bool, "IPL.CD2", 1, current_offset); + items[17].data[0] = 0x01; + + // IPL.UPT + current_offset += create_item(items[18], Type_Byte, "IPL.UPT", 1, current_offset); + items[18].data[0] = 0x02; + + // IPL.PGS + current_offset += create_item(items[19], Type_Byte, "IPL.PGS", 1, current_offset); + + // IPL.E60 + current_offset += create_item(items[20], Type_Byte, "IPL.E60", 1, current_offset); + items[20].data[0] = 0x01; + + // IPL.DH + current_offset += create_item(items[21], Type_Byte, "IPL.DH", 1, current_offset); + + // NET.WCFG + current_offset += create_item(items[22], Type_Long, "NET.WCFG", 4, current_offset); + items[22].data[3] = 0x01; + + // IPL.IDL + current_offset += create_item(items[23], Type_SmallArray, "IPL.IDL", 1, current_offset); + items[23].data[0] = 0x01; + + // IPL.EULA + current_offset += create_item(items[24], Type_Bool, "IPL.EULA", 1, current_offset); + items[24].data[0] = 0x01; + + // BT.MOT + current_offset += create_item(items[25], Type_Byte, "BT.MOT", 1, current_offset); + items[25].data[0] = 0x01; + + // MPLS.MOVIE + current_offset += create_item(items[26], Type_Bool, "MPLS.MOVIE", 1, current_offset); + items[26].data[0] = 0x01; + + + for (auto& item : items) + m_Entries.push_back(item); + + File::CreateFullPath(m_FilenameDefault); + File::IOFile g(m_FilenameDefault, "wb"); + + // Write the header and item offsets + g.WriteBytes(&s_Header.version, sizeof(s_Header.version)); + g.WriteBytes(&s_Header.numEntries, sizeof(u16)); + for (int i = 0; i != 27; ++i) + { + const u16 tmp_offset = Common::swap16(items[i].offset); + g.WriteBytes(&tmp_offset, 2); + } + const u16 end_data_offset = Common::swap16(current_offset); + g.WriteBytes(&end_data_offset, 2); + + // Write the items + const u8 null_byte = 0; + for (int i = 0; i != 27; ++i) + { + u8 description = (items[i].type << 5) | (items[i].nameLength - 1); + g.WriteBytes(&description, sizeof(description)); + g.WriteBytes(&items[i].name, items[i].nameLength); + switch (items[i].type) + { + case Type_BigArray: + { + const u16 tmpDataLength = Common::swap16(items[i].dataLength); + g.WriteBytes(&tmpDataLength, 2); + g.WriteBytes(items[i].data, items[i].dataLength); + g.WriteBytes(&null_byte, 1); + } + break; + + case Type_SmallArray: + g.WriteBytes(&items[i].dataLength, 1); + g.WriteBytes(items[i].data, items[i].dataLength); + g.WriteBytes(&null_byte, 1); + break; + + default: + g.WriteBytes(items[i].data, items[i].dataLength); + break; + } + } + + // Pad file to the correct size + const u64 cur_size = g.GetSize(); + for (unsigned int i = 0; i != 16380 - cur_size; ++i) + g.WriteBytes(&null_byte, 1); + + // Write the footer + g.WriteBytes("SCed", 4); + + m_Filename = m_FilenameDefault; +} + +bool SysConf::SaveToFile(const char *filename) +{ + File::IOFile f(filename, "r+b"); + + for (std::vector::iterator i = m_Entries.begin(); + i < m_Entries.end() - 1; i++) + { + // Seek to after the name of this entry + f.Seek(i->offset + i->nameLength + 1, SEEK_SET); + + // We may have to write array length value... + if (i->type == Type_BigArray) + { + const u16 tmpDataLength = Common::swap16(i->dataLength); + f.WriteArray(&tmpDataLength, 1); + } + else if (i->type == Type_SmallArray) + { + const u8 len = (u8)(i->dataLength); + f.WriteArray(&len, 1); + } + + // Now write the actual data + f.WriteBytes(i->data, i->dataLength); + } + + return f.IsGood(); +} + +bool SysConf::Save() +{ + if (!m_IsValid) + return false; + return SaveToFile(m_Filename.c_str()); +} + +void SysConf::UpdateLocation() +{ + // if the old Wii User dir had a sysconf file save any settings that have been changed to it + if (m_IsValid) + Save(); + + // 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); + Reload(); +} + +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; +} -- cgit v1.2.3 From 404624bf0b0125e5a408021c616ee9b9e2dde382 Mon Sep 17 00:00:00 2001 From: Tillmann Karras Date: Wed, 12 Feb 2014 16:00:34 +0100 Subject: Turn loops into range-based form and some things suggested by cppcheck and compiler warnings. --- Source/Core/Common/SysConf.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'Source/Core/Common/SysConf.cpp') diff --git a/Source/Core/Common/SysConf.cpp b/Source/Core/Common/SysConf.cpp index acfb11b0ed..6948e7db31 100644 --- a/Source/Core/Common/SysConf.cpp +++ b/Source/Core/Common/SysConf.cpp @@ -25,8 +25,7 @@ SysConf::~SysConf() void SysConf::Clear() { - for (std::vector::const_iterator i = m_Entries.begin(); - i < m_Entries.end() - 1; i++) + for (auto i = m_Entries.begin(); i < m_Entries.end() - 1; ++i) delete [] i->data; m_Entries.clear(); } @@ -85,8 +84,7 @@ bool SysConf::LoadFromFileInternal(FILE *fh) } // Last offset is an invalid entry. We ignore it throughout this class - for (std::vector::iterator i = m_Entries.begin(); - i < m_Entries.end() - 1; i++) + for (auto i = m_Entries.begin(); i < m_Entries.end() - 1; ++i) { SSysConfEntry& curEntry = *i; f.Seek(curEntry.offset, SEEK_SET); @@ -300,7 +298,7 @@ void SysConf::GenerateSysConf() items[26].data[0] = 0x01; - for (auto& item : items) + for (const SSysConfEntry& item : items) m_Entries.push_back(item); File::CreateFullPath(m_FilenameDefault); @@ -362,8 +360,7 @@ bool SysConf::SaveToFile(const char *filename) { File::IOFile f(filename, "r+b"); - for (std::vector::iterator i = m_Entries.begin(); - i < m_Entries.end() - 1; i++) + for (auto i = m_Entries.begin(); i < m_Entries.end() - 1; ++i) { // Seek to after the name of this entry f.Seek(i->offset + i->nameLength + 1, SEEK_SET); -- cgit v1.2.3 From 2afe2152712981e21d6bda6f029292ed2b1cf91e Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 17 Feb 2014 05:18:15 -0500 Subject: Convert all includes to relative paths. --- Source/Core/Common/SysConf.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Source/Core/Common/SysConf.cpp') diff --git a/Source/Core/Common/SysConf.cpp b/Source/Core/Common/SysConf.cpp index 6948e7db31..cb634b22b9 100644 --- a/Source/Core/Common/SysConf.cpp +++ b/Source/Core/Common/SysConf.cpp @@ -2,11 +2,11 @@ // Licensed under GPLv2 // Refer to the license.txt file included. -#include "FileUtil.h" -#include "SysConf.h" - #include +#include "Common/FileUtil.h" +#include "Common/SysConf.h" + SysConf::SysConf() : m_IsValid(false) { -- cgit v1.2.3 From 83b7bb64aa5e1ee6b18eaa5d08c17bb5b6c57048 Mon Sep 17 00:00:00 2001 From: Pierre Bourdon Date: Thu, 20 Feb 2014 04:11:52 +0100 Subject: Make Common/ mostly IWYU clean (and fix errors in rest of the project detected by this change). --- Source/Core/Common/SysConf.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'Source/Core/Common/SysConf.cpp') diff --git a/Source/Core/Common/SysConf.cpp b/Source/Core/Common/SysConf.cpp index cb634b22b9..a352b438ac 100644 --- a/Source/Core/Common/SysConf.cpp +++ b/Source/Core/Common/SysConf.cpp @@ -3,7 +3,12 @@ // Refer to the license.txt file included. #include +#include +#include +#include +#include +#include "Common/Common.h" #include "Common/FileUtil.h" #include "Common/SysConf.h" -- cgit v1.2.3 From a82675b7d581421fa80d5d5c53253cf1d5c1a26d Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 12 Mar 2014 15:33:41 -0400 Subject: Kill off some usages of c_str. Also changes some function params, but this is ok. Some simplifications were also able to be made (ie. killing off strcmps with ==, etc). --- Source/Core/Common/SysConf.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'Source/Core/Common/SysConf.cpp') diff --git a/Source/Core/Common/SysConf.cpp b/Source/Core/Common/SysConf.cpp index a352b438ac..6cd4f1bce2 100644 --- a/Source/Core/Common/SysConf.cpp +++ b/Source/Core/Common/SysConf.cpp @@ -16,7 +16,7 @@ SysConf::SysConf() : m_IsValid(false) { m_FilenameDefault = File::GetUserPath(F_WIISYSCONF_IDX); - m_IsValid = LoadFromFile(m_FilenameDefault.c_str()); + m_IsValid = LoadFromFile(m_FilenameDefault); } SysConf::~SysConf() @@ -32,10 +32,11 @@ void SysConf::Clear() { for (auto i = m_Entries.begin(); i < m_Entries.end() - 1; ++i) delete [] i->data; + m_Entries.clear(); } -bool SysConf::LoadFromFile(const char *filename) +bool SysConf::LoadFromFile(const std::string& filename) { // Basic check if (!File::Exists(filename)) @@ -55,7 +56,9 @@ bool SysConf::LoadFromFile(const char *filename) return true; } else + { return false; + } } File::IOFile f(filename, "rb"); @@ -361,7 +364,7 @@ void SysConf::GenerateSysConf() m_Filename = m_FilenameDefault; } -bool SysConf::SaveToFile(const char *filename) +bool SysConf::SaveToFile(const std::string& filename) { File::IOFile f(filename, "r+b"); @@ -393,7 +396,8 @@ bool SysConf::Save() { if (!m_IsValid) return false; - return SaveToFile(m_Filename.c_str()); + + return SaveToFile(m_Filename); } void SysConf::UpdateLocation() @@ -416,6 +420,6 @@ bool SysConf::Reload() std::string& filename = m_Filename.empty() ? m_FilenameDefault : m_Filename; - m_IsValid = LoadFromFile(filename.c_str()); + m_IsValid = LoadFromFile(filename); return m_IsValid; } -- cgit v1.2.3 From 22e1aa5bb4a159d6d66a321f978917614aa36331 Mon Sep 17 00:00:00 2001 From: degasus Date: Tue, 8 Jul 2014 14:29:26 +0200 Subject: mark all local functions as static --- Source/Core/Common/SysConf.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Source/Core/Common/SysConf.cpp') diff --git a/Source/Core/Common/SysConf.cpp b/Source/Core/Common/SysConf.cpp index 6cd4f1bce2..46ced20fc3 100644 --- a/Source/Core/Common/SysConf.cpp +++ b/Source/Core/Common/SysConf.cpp @@ -154,7 +154,7 @@ bool SysConf::LoadFromFileInternal(FILE *fh) } // Returns the size of the item in file -unsigned int create_item(SSysConfEntry &item, SysconfType type, const std::string &name, +static unsigned int create_item(SSysConfEntry &item, SysconfType type, const std::string &name, const int data_length, unsigned int offset) { item.offset = offset; -- cgit v1.2.3 From fbc64984ca7de7db10b1a8a4f49002f260c93569 Mon Sep 17 00:00:00 2001 From: Rohit Nirmal Date: Sun, 7 Sep 2014 20:06:58 -0500 Subject: Include CommonTypes.h instead of Common.h. --- Source/Core/Common/SysConf.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Source/Core/Common/SysConf.cpp') diff --git a/Source/Core/Common/SysConf.cpp b/Source/Core/Common/SysConf.cpp index 46ced20fc3..111a8846ca 100644 --- a/Source/Core/Common/SysConf.cpp +++ b/Source/Core/Common/SysConf.cpp @@ -8,7 +8,7 @@ #include #include -#include "Common/Common.h" +#include "Common/CommonTypes.h" #include "Common/FileUtil.h" #include "Common/SysConf.h" -- cgit v1.2.3 From cefcb0ace9d363b3679b4e93bcc9ec05f1e5f4f8 Mon Sep 17 00:00:00 2001 From: Tillmann Karras Date: Mon, 18 May 2015 01:08:10 +0200 Subject: Update license headers to GPLv2+ --- Source/Core/Common/SysConf.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Source/Core/Common/SysConf.cpp') diff --git a/Source/Core/Common/SysConf.cpp b/Source/Core/Common/SysConf.cpp index 111a8846ca..4611898967 100644 --- a/Source/Core/Common/SysConf.cpp +++ b/Source/Core/Common/SysConf.cpp @@ -1,5 +1,5 @@ // Copyright 2013 Dolphin Emulator Project -// Licensed under GPLv2 +// Licensed under GPLv2+ // Refer to the license.txt file included. #include -- cgit v1.2.3 From 30ebb2459eb97ba544547183854775df8460b475 Mon Sep 17 00:00:00 2001 From: Tillmann Karras Date: Sun, 24 May 2015 06:55:12 +0200 Subject: Set copyright year to when a file was created --- Source/Core/Common/SysConf.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Source/Core/Common/SysConf.cpp') diff --git a/Source/Core/Common/SysConf.cpp b/Source/Core/Common/SysConf.cpp index 4611898967..94124c4957 100644 --- a/Source/Core/Common/SysConf.cpp +++ b/Source/Core/Common/SysConf.cpp @@ -1,4 +1,4 @@ -// Copyright 2013 Dolphin Emulator Project +// Copyright 2009 Dolphin Emulator Project // Licensed under GPLv2+ // Refer to the license.txt file included. -- cgit v1.2.3 From dc91e8b60793276e83cc3c141dcdc551aa36d8ed Mon Sep 17 00:00:00 2001 From: comex Date: Mon, 17 Nov 2014 20:59:14 -0500 Subject: Add a mode to use a dummy Wii NAND. Eventually, netplay will be able to use the host's NAND, but this could still be useful in some cases; for TAS it definitely makes sense to have a way to avoid using any preexisting NAND. In terms of implementation: remove D_WIIUSER_IDX, which was just WIIROOT + "/", as well as some other indices which are pointless to have as separate variables rather than just using the actual path (fixed, since they're actual Wii NAND paths) at the call site. Then split off D_SESSION_WIIROOT_IDX, which can point to the dummy NAND directory, from D_WIIROOT_IDX, which always points to the "real" one the user configured. --- Source/Core/Common/SysConf.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'Source/Core/Common/SysConf.cpp') diff --git a/Source/Core/Common/SysConf.cpp b/Source/Core/Common/SysConf.cpp index 94124c4957..a0d3aa1f04 100644 --- a/Source/Core/Common/SysConf.cpp +++ b/Source/Core/Common/SysConf.cpp @@ -8,6 +8,7 @@ #include #include +#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() @@ -409,7 +409,10 @@ 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(); } -- cgit v1.2.3 From 45b07cbdcd97f2015dca5873c7949e9991ce23d4 Mon Sep 17 00:00:00 2001 From: comex Date: Mon, 20 Apr 2015 22:24:21 -0400 Subject: 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... --- Source/Core/Common/SysConf.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'Source/Core/Common/SysConf.cpp') 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; } -- cgit v1.2.3