DiscIO: Rename RegionSwitch/CountrySwitch

Callers don't need to know that these functions are implemented
with a switch statement.
This commit is contained in:
JosJuice 2018-10-08 13:51:21 +02:00
parent 7fd1784b9a
commit f834ef1dfe
7 changed files with 22 additions and 14 deletions

View File

@ -298,7 +298,8 @@ DiscIO::Region TMDReader::GetRegion() const
if (GetTitleId() == Titles::SYSTEM_MENU)
return DiscIO::GetSysMenuRegion(GetTitleVersion());
return DiscIO::RegionSwitch(static_cast<u8>(GetTitleId() & 0xff), DiscIO::Platform::WiiWAD);
return DiscIO::CountryCodeToRegion(static_cast<u8>(GetTitleId() & 0xff),
DiscIO::Platform::WiiWAD);
}
std::string TMDReader::GetGameID() const

View File

@ -97,14 +97,20 @@ static bool IsWiiTitle(const std::string& game_id)
static bool IsJapaneseGCTitle(const std::string& game_id)
{
return IsGCTitle(game_id) && DiscIO::CountrySwitch(game_id[3], DiscIO::Platform::GameCubeDisc) ==
DiscIO::Country::Japan;
if (!IsGCTitle(game_id))
return false;
return DiscIO::CountryCodeToCountry(game_id[3], DiscIO::Platform::GameCubeDisc) ==
DiscIO::Country::Japan;
}
static bool IsNonJapaneseGCTitle(const std::string& game_id)
{
return IsGCTitle(game_id) && DiscIO::CountrySwitch(game_id[3], DiscIO::Platform::GameCubeDisc) !=
DiscIO::Country::Japan;
if (!IsGCTitle(game_id))
return false;
return DiscIO::CountryCodeToCountry(game_id[3], DiscIO::Platform::GameCubeDisc) !=
DiscIO::Country::Japan;
}
// Note that this function will not overwrite entries that already are in the maps

View File

@ -145,7 +145,7 @@ Country TypicalCountryForRegion(Region region)
}
}
Region RegionSwitch(u8 country_code, Platform platform, Region expected_region)
Region CountryCodeToRegion(u8 country_code, Platform platform, Region expected_region)
{
switch (country_code)
{
@ -198,7 +198,7 @@ Region RegionSwitch(u8 country_code, Platform platform, Region expected_region)
}
}
Country CountrySwitch(u8 country_code, Platform platform, Region region)
Country CountryCodeToCountry(u8 country_code, Platform platform, Region region)
{
switch (country_code)
{

View File

@ -77,8 +77,9 @@ bool IsNTSC(Region region);
Country TypicalCountryForRegion(Region region);
// Avoid using this function if you can. Country codes aren't always reliable region indicators.
Region RegionSwitch(u8 country_code, Platform platform, Region expected_region = Region::Unknown);
Country CountrySwitch(u8 country_code, Platform platform, Region region = Region::Unknown);
Region CountryCodeToRegion(u8 country_code, Platform platform,
Region expected_region = Region::Unknown);
Country CountryCodeToCountry(u8 country_code, Platform platform, Region region = Region::Unknown);
Region GetSysMenuRegion(u16 title_version);
std::string GetSysMenuVersionString(u16 title_version);

View File

@ -87,10 +87,10 @@ Country VolumeGC::GetCountry(const Partition& partition) const
const u8 country = ReadSwapped<u8>(3, partition).value_or(0);
const Region region = GetRegion();
if (RegionSwitch(country, Platform::GameCubeDisc, region) != region)
if (CountryCodeToRegion(country, Platform::GameCubeDisc, region) != region)
return TypicalCountryForRegion(region);
return CountrySwitch(country, Platform::GameCubeDisc, region);
return CountryCodeToCountry(country, Platform::GameCubeDisc, region);
}
std::string VolumeGC::GetMakerID(const Partition& partition) const

View File

@ -88,7 +88,7 @@ Country VolumeWAD::GetCountry(const Partition& partition) const
if (country_code == 2) // SYSMENU
return TypicalCountryForRegion(GetSysMenuRegion(m_tmd.GetTitleVersion()));
return CountrySwitch(country_code, Platform::WiiWAD);
return CountryCodeToCountry(country_code, Platform::WiiWAD);
}
const IOS::ES::TMDReader& VolumeWAD::GetTMD(const Partition& partition) const

View File

@ -293,10 +293,10 @@ Country VolumeWii::GetCountry(const Partition& partition) const
const u8 country_byte = ReadSwapped<u8>(3, partition).value_or(0);
const Region region = GetRegion();
if (RegionSwitch(country_byte, Platform::WiiDisc, region) != region)
if (CountryCodeToRegion(country_byte, Platform::WiiDisc, region) != region)
return TypicalCountryForRegion(region);
return CountrySwitch(country_byte, Platform::WiiDisc, region);
return CountryCodeToCountry(country_byte, Platform::WiiDisc, region);
}
std::string VolumeWii::GetMakerID(const Partition& partition) const