mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
DiscIO: Make Korean GC checks in Enums.cpp less fragile
This commit is contained in:
parent
c028a84531
commit
c885fed9da
@ -145,7 +145,8 @@ Country TypicalCountryForRegion(Region region)
|
||||
}
|
||||
}
|
||||
|
||||
Region CountryCodeToRegion(u8 country_code, Platform platform, Region expected_region)
|
||||
Region CountryCodeToRegion(u8 country_code, Platform platform, Region expected_region,
|
||||
std::optional<u16> revision)
|
||||
{
|
||||
switch (country_code)
|
||||
{
|
||||
@ -159,11 +160,24 @@ Region CountryCodeToRegion(u8 country_code, Platform platform, Region expected_r
|
||||
return Region::NTSC_J; // Korean GC games in English or Taiwanese Wii games
|
||||
|
||||
case 'E':
|
||||
if (expected_region == Region::NTSC_J)
|
||||
return Region::NTSC_J; // Korean GC games in English
|
||||
else
|
||||
if (platform != Platform::GameCubeDisc)
|
||||
return Region::NTSC_U; // The most common country code for NTSC-U
|
||||
|
||||
if (revision)
|
||||
{
|
||||
if (*revision >= 0x30)
|
||||
return Region::NTSC_J; // Korean GC games in English
|
||||
else
|
||||
return Region::NTSC_U; // The most common country code for NTSC-U
|
||||
}
|
||||
else
|
||||
{
|
||||
if (expected_region == Region::NTSC_J)
|
||||
return Region::NTSC_J; // Korean GC games in English
|
||||
else
|
||||
return Region::NTSC_U; // The most common country code for NTSC-U
|
||||
}
|
||||
|
||||
case 'B':
|
||||
case 'N':
|
||||
return Region::NTSC_U;
|
||||
@ -198,7 +212,8 @@ Region CountryCodeToRegion(u8 country_code, Platform platform, Region expected_r
|
||||
}
|
||||
}
|
||||
|
||||
Country CountryCodeToCountry(u8 country_code, Platform platform, Region region)
|
||||
Country CountryCodeToCountry(u8 country_code, Platform platform, Region region,
|
||||
std::optional<u16> revision)
|
||||
{
|
||||
switch (country_code)
|
||||
{
|
||||
@ -214,10 +229,10 @@ Country CountryCodeToCountry(u8 country_code, Platform platform, Region region)
|
||||
return region == Region::NTSC_U ? Country::USA : Country::Europe;
|
||||
|
||||
case 'W':
|
||||
if (region == Region::PAL)
|
||||
return Country::Europe; // Only the Nordic version of Ratatouille (Wii)
|
||||
else if (platform == Platform::GameCubeDisc)
|
||||
if (platform == Platform::GameCubeDisc)
|
||||
return Country::Korea; // GC games in English released in Korea
|
||||
else if (region == Region::PAL)
|
||||
return Country::Europe; // Only the Nordic version of Ratatouille (Wii)
|
||||
else
|
||||
return Country::Taiwan; // Wii games in traditional Chinese released in Taiwan
|
||||
|
||||
@ -251,11 +266,24 @@ Country CountryCodeToCountry(u8 country_code, Platform platform, Region region)
|
||||
|
||||
// NTSC
|
||||
case 'E':
|
||||
if (region == Region::NTSC_J)
|
||||
return Country::Korea; // GC games in English released in Korea
|
||||
else
|
||||
if (platform != Platform::GameCubeDisc)
|
||||
return Country::USA; // The most common country code for NTSC-U
|
||||
|
||||
if (revision)
|
||||
{
|
||||
if (*revision >= 0x30)
|
||||
return Country::Korea; // GC games in English released in Korea
|
||||
else
|
||||
return Country::USA; // The most common country code for NTSC-U
|
||||
}
|
||||
else
|
||||
{
|
||||
if (region == Region::NTSC_J)
|
||||
return Country::Korea; // GC games in English released in Korea
|
||||
else
|
||||
return Country::USA; // The most common country code for NTSC-U
|
||||
}
|
||||
|
||||
case 'B': // PAL games released on NTSC-U VC
|
||||
case 'N': // NTSC-J games released on NTSC-U VC
|
||||
return Country::USA;
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
@ -78,8 +79,10 @@ bool IsNTSC(Region region);
|
||||
Country TypicalCountryForRegion(Region region);
|
||||
// Avoid using this function if you can. Country codes aren't always reliable region indicators.
|
||||
Region CountryCodeToRegion(u8 country_code, Platform platform,
|
||||
Region expected_region = Region::Unknown);
|
||||
Country CountryCodeToCountry(u8 country_code, Platform platform, Region region = Region::Unknown);
|
||||
Region expected_region = Region::Unknown,
|
||||
std::optional<u16> revision = {});
|
||||
Country CountryCodeToCountry(u8 country_code, Platform platform, Region region = Region::Unknown,
|
||||
std::optional<u16> revision = {});
|
||||
|
||||
Region GetSysMenuRegion(u16 title_version);
|
||||
std::string GetSysMenuVersionString(u16 title_version);
|
||||
|
@ -97,11 +97,12 @@ Country VolumeGC::GetCountry(const Partition& partition) const
|
||||
// The 0 that we use as a default value is mapped to Country::Unknown and Region::Unknown
|
||||
const u8 country = ReadSwapped<u8>(3, partition).value_or(0);
|
||||
const Region region = GetRegion();
|
||||
const std::optional<u16> revision = GetRevision();
|
||||
|
||||
if (CountryCodeToRegion(country, Platform::GameCubeDisc, region) != region)
|
||||
if (CountryCodeToRegion(country, Platform::GameCubeDisc, region, revision) != region)
|
||||
return TypicalCountryForRegion(region);
|
||||
|
||||
return CountryCodeToCountry(country, Platform::GameCubeDisc, region);
|
||||
return CountryCodeToCountry(country, Platform::GameCubeDisc, region, revision);
|
||||
}
|
||||
|
||||
std::string VolumeGC::GetMakerID(const Partition& partition) const
|
||||
|
@ -96,10 +96,11 @@ Country VolumeWAD::GetCountry(const Partition& partition) const
|
||||
return TypicalCountryForRegion(GetSysMenuRegion(m_tmd.GetTitleVersion()));
|
||||
|
||||
const Region region = GetRegion();
|
||||
if (CountryCodeToRegion(country_byte, Platform::WiiWAD, region) != region)
|
||||
const std::optional<u16> revision = GetRevision();
|
||||
if (CountryCodeToRegion(country_byte, Platform::WiiWAD, region, revision) != region)
|
||||
return TypicalCountryForRegion(region);
|
||||
|
||||
return CountryCodeToCountry(country_byte, Platform::WiiWAD, region);
|
||||
return CountryCodeToCountry(country_byte, Platform::WiiWAD, region, revision);
|
||||
}
|
||||
|
||||
const IOS::ES::TicketReader& VolumeWAD::GetTicket(const Partition& partition) const
|
||||
|
@ -316,11 +316,12 @@ Country VolumeWii::GetCountry(const Partition& partition) const
|
||||
// The 0 that we use as a default value is mapped to Country::Unknown and Region::Unknown
|
||||
const u8 country_byte = ReadSwapped<u8>(3, partition).value_or(0);
|
||||
const Region region = GetRegion();
|
||||
const std::optional<u16> revision = GetRevision();
|
||||
|
||||
if (CountryCodeToRegion(country_byte, Platform::WiiDisc, region) != region)
|
||||
if (CountryCodeToRegion(country_byte, Platform::WiiDisc, region, revision) != region)
|
||||
return TypicalCountryForRegion(region);
|
||||
|
||||
return CountryCodeToCountry(country_byte, Platform::WiiDisc, region);
|
||||
return CountryCodeToCountry(country_byte, Platform::WiiDisc, region, revision);
|
||||
}
|
||||
|
||||
std::string VolumeWii::GetMakerID(const Partition& partition) const
|
||||
|
@ -45,22 +45,22 @@ public:
|
||||
static u64 EncryptedPartitionOffsetToRawOffset(u64 offset, const Partition& partition,
|
||||
u64 partition_data_offset);
|
||||
u64 PartitionOffsetToRawOffset(u64 offset, const Partition& partition) const override;
|
||||
std::string GetGameID(const Partition& partition) const override;
|
||||
std::string GetGameTDBID(const Partition& partition) const override;
|
||||
std::string GetMakerID(const Partition& partition) const override;
|
||||
std::optional<u16> GetRevision(const Partition& partition) const override;
|
||||
std::string GetInternalName(const Partition& partition) const override;
|
||||
std::string GetGameID(const Partition& partition = PARTITION_NONE) const override;
|
||||
std::string GetGameTDBID(const Partition& partition = PARTITION_NONE) const override;
|
||||
std::string GetMakerID(const Partition& partition = PARTITION_NONE) const override;
|
||||
std::optional<u16> GetRevision(const Partition& partition = PARTITION_NONE) const override;
|
||||
std::string GetInternalName(const Partition& partition = PARTITION_NONE) const override;
|
||||
std::map<Language, std::string> GetLongNames() const override;
|
||||
std::vector<u32> GetBanner(u32* width, u32* height) const override;
|
||||
std::string GetApploaderDate(const Partition& partition) const override;
|
||||
std::optional<u8> GetDiscNumber(const Partition& partition) const override;
|
||||
std::optional<u8> GetDiscNumber(const Partition& partition = PARTITION_NONE) const override;
|
||||
|
||||
Platform GetVolumeType() const override;
|
||||
bool SupportsIntegrityCheck() const override { return true; }
|
||||
bool CheckIntegrity(const Partition& partition) const override;
|
||||
|
||||
Region GetRegion() const override;
|
||||
Country GetCountry(const Partition& partition) const override;
|
||||
Country GetCountry(const Partition& partition = PARTITION_NONE) const override;
|
||||
BlobType GetBlobType() const override;
|
||||
u64 GetSize() const override;
|
||||
bool IsSizeAccurate() const override;
|
||||
|
Loading…
Reference in New Issue
Block a user