diff --git a/Source/Core/Common/CMakeLists.txt b/Source/Core/Common/CMakeLists.txt
index 92d2bec668..122f681085 100644
--- a/Source/Core/Common/CMakeLists.txt
+++ b/Source/Core/Common/CMakeLists.txt
@@ -15,6 +15,7 @@ set(SRCS Src/ABI.cpp
Src/Misc.cpp
Src/MsgHandler.cpp
Src/NandPaths.cpp
+ Src/SettingsHandler.cpp
Src/SDCardUtil.cpp
Src/StringUtil.cpp
Src/SymbolDB.cpp
diff --git a/Source/Core/Common/Common.vcxproj b/Source/Core/Common/Common.vcxproj
index 732fc7258c..a67da7fcf9 100644
--- a/Source/Core/Common/Common.vcxproj
+++ b/Source/Core/Common/Common.vcxproj
@@ -195,6 +195,7 @@
+
Create
Create
@@ -251,6 +252,7 @@
+
diff --git a/Source/Core/Common/Common.vcxproj.filters b/Source/Core/Common/Common.vcxproj.filters
index 0922d00196..852ce5e6ad 100644
--- a/Source/Core/Common/Common.vcxproj.filters
+++ b/Source/Core/Common/Common.vcxproj.filters
@@ -53,6 +53,7 @@
Crypto
+
@@ -121,6 +122,7 @@
+
diff --git a/Source/Core/Core/Src/Boot/SettingsHandler.cpp b/Source/Core/Common/Src/SettingsHandler.cpp
similarity index 67%
rename from Source/Core/Core/Src/Boot/SettingsHandler.cpp
rename to Source/Core/Common/Src/SettingsHandler.cpp
index 619957632c..7eba971087 100644
--- a/Source/Core/Core/Src/Boot/SettingsHandler.cpp
+++ b/Source/Core/Common/Src/SettingsHandler.cpp
@@ -42,42 +42,46 @@ const u8* SettingsHandler::GetData() const
return m_buffer;
}
-const std::string SettingsHandler::GetValue(std::string key)
+const std::string SettingsHandler::GetValue(const std::string key)
{
std::string delim = std::string("\r\n");
std::string toFind = delim + key + "=";
size_t found = decoded.find(toFind);
- if (found!=std::string::npos){
- size_t delimFound = decoded.find(delim, found+toFind.length());
- if (delimFound == std::string::npos)
- delimFound = decoded.length()-1;
- return decoded.substr(found+toFind.length(), delimFound - (found+toFind.length()));
- }else{
+
+ if (found != decoded.npos)
+ {
+ size_t delimFound = decoded.find(delim, found + toFind.length());
+ if (delimFound == decoded.npos)
+ delimFound = decoded.length() - 1;
+ return decoded.substr(found + toFind.length(), delimFound - (found + toFind.length()));
+ }
+ else
+ {
toFind = key + "=";
size_t found = decoded.find(toFind);
- if (found==0){
- size_t delimFound = decoded.find(delim, found+toFind.length());
- if (delimFound == std::string::npos)
- delimFound = decoded.length()-1;
- return decoded.substr(found+toFind.length(), delimFound - (found+toFind.length()));
+ if (found == 0)
+ {
+ size_t delimFound = decoded.find(delim, found + toFind.length());
+ if (delimFound == decoded.npos)
+ delimFound = decoded.length() - 1;
+ return decoded.substr(found + toFind.length(), delimFound - (found + toFind.length()));
}
}
return "";
}
-
void SettingsHandler::Decrypt()
{
const u8 *str = m_buffer;
- while(*str != 0){
-
+ while (*str != 0)
+ {
if (m_position >= SETTINGS_SIZE)
return;
decoded.push_back((u8)(m_buffer[m_position] ^ m_key));
m_position++;
str++;
- m_key = ((m_key >> 31) | (m_key << 1));
+ m_key = (m_key >> 31) | (m_key << 1);
}
}
@@ -116,21 +120,21 @@ void SettingsHandler::WriteByte(u8 b)
m_buffer[m_position] = b ^ m_key;
m_position++;
- m_key = ((m_key >> 31) | (m_key << 1));
+ m_key = (m_key >> 31) | (m_key << 1);
}
-std::string SettingsHandler::generateSerialNumber()
+const std::string SettingsHandler::generateSerialNumber()
{
time_t rawtime;
- struct tm * timeinfo;
- char buffer [12];
- char serialNumber [12];
+ tm *timeinfo;
+ char buffer[12];
+ char serialNumber[12];
- time ( &rawtime );
- timeinfo = localtime ( &rawtime );
- strftime (buffer,11,"%j%H%M%S",timeinfo);
+ time(&rawtime);
+ timeinfo = localtime(&rawtime);
+ strftime(buffer, 11, "%j%H%M%S", timeinfo);
- snprintf(serialNumber,11, "%s%i", buffer, (Common::Timer::GetTimeMs()>>1)&0xF);
+ snprintf(serialNumber, 11, "%s%i", buffer, (Common::Timer::GetTimeMs() >> 1) & 0xF);
serialNumber[10] = 0;
return std::string(serialNumber);
-}
\ No newline at end of file
+}
diff --git a/Source/Core/Core/Src/Boot/SettingsHandler.h b/Source/Core/Common/Src/SettingsHandler.h
similarity index 81%
rename from Source/Core/Core/Src/Boot/SettingsHandler.h
rename to Source/Core/Common/Src/SettingsHandler.h
index 55295ece17..cda17b0b58 100644
--- a/Source/Core/Core/Src/Boot/SettingsHandler.h
+++ b/Source/Core/Common/Src/SettingsHandler.h
@@ -1,50 +1,51 @@
-// Copyright (C) 2003 Dolphin Project.
-
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, version 2.0.
-
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License 2.0 for more details.
-
-// A copy of the GPL 2.0 should have been included with the program.
-// If not, see http://www.gnu.org/licenses/
-
-// Official SVN repository and contact information can be found at
-// http://code.google.com/p/dolphin-emu/
-
-// Thanks to Treeki for writing the original class - 29/01/2012
-
-#ifndef _SETTINGS_HANDLER_H
-#define _SETTINGS_HANDLER_H
-
-#include
-
-#include "Common.h"
-#include "../CoreParameter.h"
-#define SETTINGS_SIZE 0x100
-
-class SettingsHandler
-{
-public:
- SettingsHandler();
-
- void AddSetting(const char *key, const char *value);
-
- const u8 *GetData() const;
- const std::string GetValue(std::string key);
-
- void Decrypt();
- void Reset();
- std::string generateSerialNumber();
-private:
- void WriteByte(u8 b);
-
- u8 m_buffer[SETTINGS_SIZE];
- u32 m_position, m_key;
- std::string decoded;
-};
-
-#endif
+// Copyright (C) 2003 Dolphin Project.
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, version 2.0.
+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License 2.0 for more details.
+
+// A copy of the GPL 2.0 should have been included with the program.
+// If not, see http://www.gnu.org/licenses/
+
+// Official SVN repository and contact information can be found at
+// http://code.google.com/p/dolphin-emu/
+
+// Thanks to Treeki for writing the original class - 29/01/2012
+
+#pragma once
+
+#include
+
+#include "Common.h"
+
+class SettingsHandler
+{
+public:
+ SettingsHandler();
+
+ enum
+ {
+ SETTINGS_SIZE = 0x100
+ };
+
+ void AddSetting(const char *key, const char *value);
+
+ const u8 *GetData() const;
+ const std::string GetValue(const std::string key);
+
+ void Decrypt();
+ void Reset();
+ const std::string generateSerialNumber();
+
+private:
+ void WriteByte(u8 b);
+
+ u8 m_buffer[SETTINGS_SIZE];
+ u32 m_position, m_key;
+ std::string decoded;
+};
diff --git a/Source/Core/Core/Core.vcxproj b/Source/Core/Core/Core.vcxproj
index 141b797be7..df209f43ce 100644
--- a/Source/Core/Core/Core.vcxproj
+++ b/Source/Core/Core/Core.vcxproj
@@ -203,7 +203,6 @@
-
@@ -408,7 +407,6 @@
-
diff --git a/Source/Core/Core/Core.vcxproj.filters b/Source/Core/Core/Core.vcxproj.filters
index 7d498e2f03..017c32f865 100644
--- a/Source/Core/Core/Core.vcxproj.filters
+++ b/Source/Core/Core/Core.vcxproj.filters
@@ -559,9 +559,6 @@
HW %28Flipper/Hollywood%29\GCMemcard
-
- Boot
-
@@ -1045,9 +1042,6 @@
IPC HLE %28IOS/Starlet%29\Net
-
- Boot
-
diff --git a/Source/Core/Core/Src/Boot/Boot_BS2Emu.cpp b/Source/Core/Core/Src/Boot/Boot_BS2Emu.cpp
index 45a010d13a..53c5fdbb63 100644
--- a/Source/Core/Core/Src/Boot/Boot_BS2Emu.cpp
+++ b/Source/Core/Core/Src/Boot/Boot_BS2Emu.cpp
@@ -177,11 +177,7 @@ bool CBoot::SetupWiiMemory(unsigned int _CountryCode)
{
INFO_LOG(BOOT, "Setup Wii Memory...");
- // Write the 256 byte setting.txt to memory. This may not be needed as
- // most or all games read the setting.txt file from
- // \title\00000001\00000002\data\setting.txt directly after the read the
- // SYSCONF file. The games also read it to 0x3800, what is a little strange
- // however is that it only reads the first 100 bytes of it.
+ // Write the 256 byte setting.txt to memory.
std::string settings_Filename(Common::GetTitleDataPath(TITLEID_SYSMENU) + WII_SETTING);
std::string area, model, code, video, game;
@@ -217,13 +213,13 @@ bool CBoot::SetupWiiMemory(unsigned int _CountryCode)
code = "L" + area.substr(0,1);
game = area.substr(0,2);
-
SettingsHandler gen;
std::string serno = "";
if (File::Exists(settings_Filename))
{
File::IOFile settingsFileHandle(settings_Filename, "rb");
- if(settingsFileHandle.ReadBytes((void*)gen.GetData(), SETTINGS_SIZE)){
+ if (settingsFileHandle.ReadBytes((void*)gen.GetData(), SettingsHandler::SETTINGS_SIZE))
+ {
gen.Decrypt();
serno = gen.GetValue("SERNO");
gen.Reset();
@@ -231,10 +227,13 @@ bool CBoot::SetupWiiMemory(unsigned int _CountryCode)
File::Delete(settings_Filename);
}
- if(serno.empty() || serno == "000000000"){
+ if (serno.empty() || serno == "000000000")
+ {
serno = gen.generateSerialNumber();
INFO_LOG(BOOT, "No previous serial number found, generated one instead: %s", serno.c_str());
- }else{
+ }
+ else
+ {
INFO_LOG(BOOT, "Using serial number: %s", serno.c_str());
}
@@ -253,12 +252,12 @@ bool CBoot::SetupWiiMemory(unsigned int _CountryCode)
{
File::IOFile settingsFileHandle(settings_Filename, "wb");
- if (!settingsFileHandle.WriteBytes(gen.GetData(), SETTINGS_SIZE))
+ if (!settingsFileHandle.WriteBytes(gen.GetData(), SettingsHandler::SETTINGS_SIZE))
{
PanicAlertT("SetupWiiMem: Cant create setting file");
return false;
}
- Memory::WriteBigEData(gen.GetData(), 0x3800, SETTINGS_SIZE);
+ Memory::WriteBigEData(gen.GetData(), 0x3800, SettingsHandler::SETTINGS_SIZE);
}
/*
diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net.h b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net.h
index 1a3b2c2659..0b427cb7ed 100644
--- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net.h
+++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net.h
@@ -201,8 +201,6 @@ public:
// TODO Writes stuff to /shared2/nwc24/misc.bin
u32 update_misc = 0;
- static bool init = false;
-
switch (Parameter)
{
case IOCTL_NW24_GET_UNIVERSAL_TIME: