DiscIO: Add GetRegion function and Region enum

Instead of needing different switch cases for
converting countries to regions in multiple places,
we now only need a single country-to-region switch case
(in DiscIO/Enums.cpp), and we get a nice Region type.
This commit is contained in:
JosJuice
2016-12-23 18:41:21 +01:00
parent 6aef0630f7
commit 66ea9f5cc1
26 changed files with 218 additions and 158 deletions

View File

@ -61,13 +61,20 @@ std::string CVolumeGC::GetGameID() const
return DecodeString(ID);
}
Region CVolumeGC::GetRegion() const
{
u8 country_code;
if (!m_pReader->Read(3, 1, &country_code))
return Region::UNKNOWN_REGION;
return RegionSwitchGC(country_code);
}
Country CVolumeGC::GetCountry() const
{
if (!m_pReader)
return Country::COUNTRY_UNKNOWN;
u8 country_code;
m_pReader->Read(3, 1, &country_code);
if (!m_pReader->Read(3, 1, &country_code))
return Country::COUNTRY_UNKNOWN;
return CountrySwitch(country_code);
}
@ -247,7 +254,7 @@ void CVolumeGC::ExtractBannerInformation(const GCBanner& banner_file, bool is_bn
if (is_bnr1) // NTSC
{
bool is_japanese = GetCountry() == Country::COUNTRY_JAPAN;
bool is_japanese = GetRegion() == Region::NTSC_J;
number_of_languages = 1;
start_language = is_japanese ? Language::LANGUAGE_JAPANESE : Language::LANGUAGE_ENGLISH;
}