mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-25 07:21:14 +01:00
Ensure that Volume::GetRegion doesn't return invalid enum values
This commit is contained in:
parent
db1c534b3e
commit
be8e93f472
@ -61,7 +61,10 @@ std::string VolumeGC::GetGameID(const Partition& partition) const
|
||||
Region VolumeGC::GetRegion() const
|
||||
{
|
||||
const std::optional<u32> region_code = ReadSwapped<u32>(0x458, PARTITION_NONE);
|
||||
return region_code ? static_cast<Region>(*region_code) : Region::UNKNOWN_REGION;
|
||||
if (!region_code)
|
||||
return Region::UNKNOWN_REGION;
|
||||
const Region region = static_cast<Region>(*region_code);
|
||||
return region <= Region::PAL ? region : Region::UNKNOWN_REGION;
|
||||
}
|
||||
|
||||
Country VolumeGC::GetCountry(const Partition& partition) const
|
||||
|
@ -233,7 +233,10 @@ std::string VolumeWii::GetGameID(const Partition& partition) const
|
||||
Region VolumeWii::GetRegion() const
|
||||
{
|
||||
const std::optional<u32> region_code = m_pReader->ReadSwapped<u32>(0x4E000);
|
||||
return region_code ? static_cast<Region>(*region_code) : Region::UNKNOWN_REGION;
|
||||
if (!region_code)
|
||||
return Region::UNKNOWN_REGION;
|
||||
const Region region = static_cast<Region>(*region_code);
|
||||
return region <= Region::NTSC_K ? region : Region::UNKNOWN_REGION;
|
||||
}
|
||||
|
||||
Country VolumeWii::GetCountry(const Partition& partition) const
|
||||
|
Loading…
x
Reference in New Issue
Block a user