From f834ef1dfede5b1f010314810845c97715eabae7 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Mon, 8 Oct 2018 13:51:21 +0200 Subject: [PATCH] DiscIO: Rename RegionSwitch/CountrySwitch Callers don't need to know that these functions are implemented with a switch statement. --- Source/Core/Core/IOS/ES/Formats.cpp | 3 ++- Source/Core/Core/TitleDatabase.cpp | 14 ++++++++++---- Source/Core/DiscIO/Enums.cpp | 4 ++-- Source/Core/DiscIO/Enums.h | 5 +++-- Source/Core/DiscIO/VolumeGC.cpp | 4 ++-- Source/Core/DiscIO/VolumeWad.cpp | 2 +- Source/Core/DiscIO/VolumeWii.cpp | 4 ++-- 7 files changed, 22 insertions(+), 14 deletions(-) diff --git a/Source/Core/Core/IOS/ES/Formats.cpp b/Source/Core/Core/IOS/ES/Formats.cpp index 44e648603f..9086e8270c 100644 --- a/Source/Core/Core/IOS/ES/Formats.cpp +++ b/Source/Core/Core/IOS/ES/Formats.cpp @@ -298,7 +298,8 @@ DiscIO::Region TMDReader::GetRegion() const if (GetTitleId() == Titles::SYSTEM_MENU) return DiscIO::GetSysMenuRegion(GetTitleVersion()); - return DiscIO::RegionSwitch(static_cast(GetTitleId() & 0xff), DiscIO::Platform::WiiWAD); + return DiscIO::CountryCodeToRegion(static_cast(GetTitleId() & 0xff), + DiscIO::Platform::WiiWAD); } std::string TMDReader::GetGameID() const diff --git a/Source/Core/Core/TitleDatabase.cpp b/Source/Core/Core/TitleDatabase.cpp index cd7449b139..7000fe723d 100644 --- a/Source/Core/Core/TitleDatabase.cpp +++ b/Source/Core/Core/TitleDatabase.cpp @@ -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 diff --git a/Source/Core/DiscIO/Enums.cpp b/Source/Core/DiscIO/Enums.cpp index 167b5eb145..723525ec48 100644 --- a/Source/Core/DiscIO/Enums.cpp +++ b/Source/Core/DiscIO/Enums.cpp @@ -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) { diff --git a/Source/Core/DiscIO/Enums.h b/Source/Core/DiscIO/Enums.h index 6acbee9960..fc6f0543db 100644 --- a/Source/Core/DiscIO/Enums.h +++ b/Source/Core/DiscIO/Enums.h @@ -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); diff --git a/Source/Core/DiscIO/VolumeGC.cpp b/Source/Core/DiscIO/VolumeGC.cpp index c984d60f9d..1275fcfb78 100644 --- a/Source/Core/DiscIO/VolumeGC.cpp +++ b/Source/Core/DiscIO/VolumeGC.cpp @@ -87,10 +87,10 @@ Country VolumeGC::GetCountry(const Partition& partition) const const u8 country = ReadSwapped(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 diff --git a/Source/Core/DiscIO/VolumeWad.cpp b/Source/Core/DiscIO/VolumeWad.cpp index ef102df9c1..c274181695 100644 --- a/Source/Core/DiscIO/VolumeWad.cpp +++ b/Source/Core/DiscIO/VolumeWad.cpp @@ -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 diff --git a/Source/Core/DiscIO/VolumeWii.cpp b/Source/Core/DiscIO/VolumeWii.cpp index c64dc3ec05..29d822fca9 100644 --- a/Source/Core/DiscIO/VolumeWii.cpp +++ b/Source/Core/DiscIO/VolumeWii.cpp @@ -293,10 +293,10 @@ Country VolumeWii::GetCountry(const Partition& partition) const const u8 country_byte = ReadSwapped(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