Add warning comments to RegionSwitch and code that uses it

This commit is contained in:
JosJuice 2017-07-16 14:49:28 +02:00
parent cd60810d9d
commit db1c534b3e
6 changed files with 19 additions and 9 deletions

View File

@ -44,6 +44,7 @@ int GCMemcardDirectory::LoadGCI(const std::string& file_name, DiscIO::Region car
return NO_INDEX; 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]); 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: // 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.) // - Datel Action Replay uses C as the fourth character. (Can be on any region's card.)

View File

@ -232,14 +232,6 @@ u64 TMDReader::GetIOSId() const
return Common::swap64(m_bytes.data() + offsetof(TMDHeader, ios_id)); 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<u8>(GetTitleId() & 0xff));
}
u64 TMDReader::GetTitleId() const u64 TMDReader::GetTitleId() const
{ {
return Common::swap64(m_bytes.data() + offsetof(TMDHeader, title_id)); 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)); 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<u8>(GetTitleId() & 0xff));
}
std::string TMDReader::GetGameID() const std::string TMDReader::GetGameID() const
{ {
char game_id[6]; char game_id[6];

View File

@ -185,12 +185,14 @@ public:
u16 GetBootIndex() const; u16 GetBootIndex() const;
u64 GetIOSId() const; u64 GetIOSId() const;
DiscIO::Region GetRegion() const;
u64 GetTitleId() const; u64 GetTitleId() const;
u32 GetTitleFlags() const; u32 GetTitleFlags() const;
u16 GetTitleVersion() const; u16 GetTitleVersion() const;
u16 GetGroupId() 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. // Constructs a 6-character game ID in the format typically used by Dolphin.
// If the 6-character game ID would contain unprintable characters, // If the 6-character game ID would contain unprintable characters,
// the title ID converted to hexadecimal is returned instead. // the title ID converted to hexadecimal is returned instead.

View File

@ -71,11 +71,16 @@ enum class Language
bool IsDisc(Platform volume_type); bool IsDisc(Platform volume_type);
bool IsWii(Platform volume_type); bool IsWii(Platform volume_type);
bool IsNTSC(Region region); bool IsNTSC(Region region);
Country TypicalCountryForRegion(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); 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); Region RegionSwitchWii(u8 country_code);
Country CountrySwitch(u8 country_code); Country CountrySwitch(u8 country_code);
Region GetSysMenuRegion(u16 title_version); Region GetSysMenuRegion(u16 title_version);
std::string GetSysMenuVersionString(u16 title_version); std::string GetSysMenuVersionString(u16 title_version);
std::string GetCompanyFromID(const std::string& company_id); std::string GetCompanyFromID(const std::string& company_id);
} }

View File

@ -83,6 +83,7 @@ public:
virtual Platform GetVolumeType() const = 0; virtual Platform GetVolumeType() const = 0;
virtual bool SupportsIntegrityCheck() const { return false; } virtual bool SupportsIntegrityCheck() const { return false; }
virtual bool CheckIntegrity(const Partition& partition) const { return false; } virtual bool CheckIntegrity(const Partition& partition) const { return false; }
// May be inaccurate for WADs
virtual Region GetRegion() const = 0; virtual Region GetRegion() const = 0;
Country GetCountry() const { return GetCountry(GetGamePartition()); } Country GetCountry() const { return GetCountry(GetGamePartition()); }
virtual Country GetCountry(const Partition& partition) const = 0; virtual Country GetCountry(const Partition& partition) const = 0;

View File

@ -50,6 +50,7 @@ public:
return ""; return "";
} }
Platform GetVolumeType() const override; Platform GetVolumeType() const override;
// Provides a best guess for the region. Might be inaccurate or UNKNOWN_REGION.
Region GetRegion() const override; Region GetRegion() const override;
Country GetCountry(const Partition& partition = PARTITION_NONE) const override; Country GetCountry(const Partition& partition = PARTITION_NONE) const override;