diff --git a/Source/Core/Core/HW/GCMemcard/GCMemcardDirectory.cpp b/Source/Core/Core/HW/GCMemcard/GCMemcardDirectory.cpp index 23c0e4b467..344b9a56f7 100644 --- a/Source/Core/Core/HW/GCMemcard/GCMemcardDirectory.cpp +++ b/Source/Core/Core/HW/GCMemcard/GCMemcardDirectory.cpp @@ -44,6 +44,7 @@ int GCMemcardDirectory::LoadGCI(const std::string& file_name, DiscIO::Region car return NO_INDEX; } + // This isn't a reliable way to detect regions. TODO: Get rid of this? DiscIO::Region gci_region = DiscIO::RegionSwitchGC(gci.m_gci_header.Gamecode[3]); // Some special save files have game IDs that we parse as UNKNOWN_REGION. For instance: // - Datel Action Replay uses C as the fourth character. (Can be on any region's card.) diff --git a/Source/Core/Core/IOS/ES/Formats.cpp b/Source/Core/Core/IOS/ES/Formats.cpp index b7e1e9c106..9ac65e8373 100644 --- a/Source/Core/Core/IOS/ES/Formats.cpp +++ b/Source/Core/Core/IOS/ES/Formats.cpp @@ -232,14 +232,6 @@ u64 TMDReader::GetIOSId() const return Common::swap64(m_bytes.data() + offsetof(TMDHeader, ios_id)); } -DiscIO::Region TMDReader::GetRegion() const -{ - if (GetTitleId() == Titles::SYSTEM_MENU) - return DiscIO::GetSysMenuRegion(GetTitleVersion()); - - return DiscIO::RegionSwitchWii(static_cast(GetTitleId() & 0xff)); -} - u64 TMDReader::GetTitleId() const { return Common::swap64(m_bytes.data() + offsetof(TMDHeader, title_id)); @@ -260,6 +252,14 @@ u16 TMDReader::GetGroupId() const return Common::swap16(m_bytes.data() + offsetof(TMDHeader, group_id)); } +DiscIO::Region TMDReader::GetRegion() const +{ + if (GetTitleId() == Titles::SYSTEM_MENU) + return DiscIO::GetSysMenuRegion(GetTitleVersion()); + + return DiscIO::RegionSwitchWii(static_cast(GetTitleId() & 0xff)); +} + std::string TMDReader::GetGameID() const { char game_id[6]; diff --git a/Source/Core/Core/IOS/ES/Formats.h b/Source/Core/Core/IOS/ES/Formats.h index 3998076cbe..5f01e7eef6 100644 --- a/Source/Core/Core/IOS/ES/Formats.h +++ b/Source/Core/Core/IOS/ES/Formats.h @@ -185,12 +185,14 @@ public: u16 GetBootIndex() const; u64 GetIOSId() const; - DiscIO::Region GetRegion() const; u64 GetTitleId() const; u32 GetTitleFlags() const; u16 GetTitleVersion() const; u16 GetGroupId() const; + // Provides a best guess for the region. Might be inaccurate or UNKNOWN_REGION. + DiscIO::Region GetRegion() const; + // Constructs a 6-character game ID in the format typically used by Dolphin. // If the 6-character game ID would contain unprintable characters, // the title ID converted to hexadecimal is returned instead. diff --git a/Source/Core/DiscIO/Enums.h b/Source/Core/DiscIO/Enums.h index 7aa06ef4a1..fda94c43be 100644 --- a/Source/Core/DiscIO/Enums.h +++ b/Source/Core/DiscIO/Enums.h @@ -71,11 +71,16 @@ enum class Language bool IsDisc(Platform volume_type); bool IsWii(Platform volume_type); bool IsNTSC(Region region); + Country TypicalCountryForRegion(Region region); +// Avoid using this function if you can. Country codes aren't always reliable region indicators. Region RegionSwitchGC(u8 country_code); +// Avoid using this function if you can. Country codes aren't always reliable region indicators. Region RegionSwitchWii(u8 country_code); Country CountrySwitch(u8 country_code); + Region GetSysMenuRegion(u16 title_version); std::string GetSysMenuVersionString(u16 title_version); + std::string GetCompanyFromID(const std::string& company_id); } diff --git a/Source/Core/DiscIO/Volume.h b/Source/Core/DiscIO/Volume.h index e0978048ab..209a0d09a9 100644 --- a/Source/Core/DiscIO/Volume.h +++ b/Source/Core/DiscIO/Volume.h @@ -83,6 +83,7 @@ public: virtual Platform GetVolumeType() const = 0; virtual bool SupportsIntegrityCheck() const { return false; } virtual bool CheckIntegrity(const Partition& partition) const { return false; } + // May be inaccurate for WADs virtual Region GetRegion() const = 0; Country GetCountry() const { return GetCountry(GetGamePartition()); } virtual Country GetCountry(const Partition& partition) const = 0; diff --git a/Source/Core/DiscIO/VolumeWad.h b/Source/Core/DiscIO/VolumeWad.h index d8b45d3585..d1964bcfa1 100644 --- a/Source/Core/DiscIO/VolumeWad.h +++ b/Source/Core/DiscIO/VolumeWad.h @@ -50,6 +50,7 @@ public: return ""; } Platform GetVolumeType() const override; + // Provides a best guess for the region. Might be inaccurate or UNKNOWN_REGION. Region GetRegion() const override; Country GetCountry(const Partition& partition = PARTITION_NONE) const override;