From 66ea9f5cc18ca6beb87ddd7f7a291d96669ad653 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Fri, 23 Dec 2016 18:41:21 +0100 Subject: 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. --- Source/Core/DiscIO/VolumeGC.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'Source/Core/DiscIO/VolumeGC.cpp') diff --git a/Source/Core/DiscIO/VolumeGC.cpp b/Source/Core/DiscIO/VolumeGC.cpp index 58faed4fe8..fcba359931 100644 --- a/Source/Core/DiscIO/VolumeGC.cpp +++ b/Source/Core/DiscIO/VolumeGC.cpp @@ -61,13 +61,20 @@ std::string CVolumeGC::GetGameID() const return DecodeString(ID); } -Country CVolumeGC::GetCountry() const +Region CVolumeGC::GetRegion() const { - if (!m_pReader) - return Country::COUNTRY_UNKNOWN; + u8 country_code; + if (!m_pReader->Read(3, 1, &country_code)) + return Region::UNKNOWN_REGION; + return RegionSwitchGC(country_code); +} + +Country CVolumeGC::GetCountry() const +{ 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; } -- cgit v1.2.3