Merge pull request #8673 from JosJuice/preserve-setting-txt

Boot: Do a better job of preserving certain parts of settings.txt
This commit is contained in:
Léo Lam 2020-03-24 10:16:17 +01:00 committed by GitHub
commit 5b10f4b71e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 46 additions and 1 deletions

View File

@ -242,6 +242,30 @@ bool CBoot::EmulatedBS2_GC(const DiscIO::VolumeDisc& volume)
return RunApploader(/*is_wii*/ false, volume);
}
static DiscIO::Region CodeRegion(char c)
{
switch (c)
{
case 'J': // Japan
case 'T': // Taiwan
return DiscIO::Region::NTSC_J;
case 'B': // Brazil
case 'M': // Middle East
case 'R': // Argentina
case 'S': // ???
case 'U': // USA
case 'W': // ???
return DiscIO::Region::NTSC_U;
case 'A': // Australia
case 'E': // Europe
return DiscIO::Region::PAL;
case 'K': // Korea
return DiscIO::Region::NTSC_K;
default:
return DiscIO::Region::Unknown;
}
}
bool CBoot::SetupWiiMemory(IOS::HLE::IOSC::ConsoleType console_type)
{
static const std::map<DiscIO::Region, const RegionSetting> region_settings = {
@ -254,6 +278,7 @@ bool CBoot::SetupWiiMemory(IOS::HLE::IOSC::ConsoleType console_type)
Common::SettingsHandler gen;
std::string serno;
std::string model = "RVL-001(" + region_setting.area + ")";
CreateSystemMenuTitleDirs();
const std::string settings_file_path(Common::GetTitleDataPath(Titles::SYSTEM_MENU) +
"/" WII_SETTING);
@ -267,11 +292,32 @@ bool CBoot::SetupWiiMemory(IOS::HLE::IOSC::ConsoleType console_type)
{
gen.SetBytes(std::move(data));
serno = gen.GetValue("SERNO");
model = gen.GetValue("MODEL");
bool region_matches = false;
if (SConfig::GetInstance().bOverrideRegionSettings)
{
region_matches = true;
}
else
{
const std::string code = gen.GetValue("CODE");
if (code.size() >= 2 && CodeRegion(code[1]) == SConfig::GetInstance().m_region)
region_matches = true;
}
if (region_matches)
{
region_setting = RegionSetting{gen.GetValue("AREA"), gen.GetValue("VIDEO"),
gen.GetValue("GAME"), gen.GetValue("CODE")};
}
else
{
const size_t parenthesis_pos = model.find('(');
if (parenthesis_pos != std::string::npos)
model = model.substr(0, parenthesis_pos) + '(' + region_setting.area + ')';
}
gen.Reset();
}
}
@ -290,7 +336,6 @@ bool CBoot::SetupWiiMemory(IOS::HLE::IOSC::ConsoleType console_type)
INFO_LOG(BOOT, "Using serial number: %s", serno.c_str());
}
std::string model = "RVL-001(" + region_setting.area + ")";
gen.AddSetting("AREA", region_setting.area);
gen.AddSetting("MODEL", model);
gen.AddSetting("DVD", "0");