Fix segfault on NetPlay start with unknown region
This is accomplished by having SConfig::GetDirectoryForRegion no longer return nullptr, as doing that was kind silly, considering we never check for nullptr.
This commit is contained in:
parent
a21d536f99
commit
dee64a89e0
|
@ -806,6 +806,9 @@ DiscIO::Region SConfig::ToGameCubeRegion(DiscIO::Region region)
|
|||
|
||||
const char* SConfig::GetDirectoryForRegion(DiscIO::Region region)
|
||||
{
|
||||
if (region == DiscIO::Region::Unknown)
|
||||
region = ToGameCubeRegion(GetFallbackRegion());
|
||||
|
||||
switch (region)
|
||||
{
|
||||
case DiscIO::Region::NTSC_J:
|
||||
|
@ -819,10 +822,11 @@ const char* SConfig::GetDirectoryForRegion(DiscIO::Region region)
|
|||
|
||||
case DiscIO::Region::NTSC_K:
|
||||
ASSERT_MSG(BOOT, false, "NTSC-K is not a valid GameCube region");
|
||||
return nullptr;
|
||||
return JAP_DIR; // See ToGameCubeRegion
|
||||
|
||||
default:
|
||||
return nullptr;
|
||||
ASSERT_MSG(BOOT, false, "Default case should not be reached");
|
||||
return EUR_DIR;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -926,18 +930,8 @@ bool SConfig::SetPathsAndGameMetadata(const BootParameters& boot)
|
|||
if (!std::visit(SetGameMetadata(this, &m_region), boot.parameters))
|
||||
return false;
|
||||
|
||||
// Fall back to the system menu region, if possible.
|
||||
if (m_region == DiscIO::Region::Unknown)
|
||||
{
|
||||
IOS::HLE::Kernel ios;
|
||||
const IOS::ES::TMDReader system_menu_tmd = ios.GetES()->FindInstalledTMD(Titles::SYSTEM_MENU);
|
||||
if (system_menu_tmd.IsValid())
|
||||
m_region = system_menu_tmd.GetRegion();
|
||||
}
|
||||
|
||||
// Fall back to PAL.
|
||||
if (m_region == DiscIO::Region::Unknown)
|
||||
m_region = DiscIO::Region::PAL;
|
||||
m_region = GetFallbackRegion();
|
||||
|
||||
// Set up paths
|
||||
const std::string region_dir = GetDirectoryForRegion(ToGameCubeRegion(m_region));
|
||||
|
@ -947,6 +941,18 @@ bool SConfig::SetPathsAndGameMetadata(const BootParameters& boot)
|
|||
return true;
|
||||
}
|
||||
|
||||
DiscIO::Region SConfig::GetFallbackRegion()
|
||||
{
|
||||
// Fall back to the system menu region, if possible.
|
||||
IOS::HLE::Kernel ios;
|
||||
const IOS::ES::TMDReader system_menu_tmd = ios.GetES()->FindInstalledTMD(Titles::SYSTEM_MENU);
|
||||
if (system_menu_tmd.IsValid())
|
||||
return system_menu_tmd.GetRegion();
|
||||
|
||||
// Fall back to PAL.
|
||||
return DiscIO::Region::PAL;
|
||||
}
|
||||
|
||||
DiscIO::Language SConfig::GetCurrentLanguage(bool wii) const
|
||||
{
|
||||
int language_value;
|
||||
|
|
|
@ -211,6 +211,7 @@ struct SConfig
|
|||
static const char* GetDirectoryForRegion(DiscIO::Region region);
|
||||
std::string GetBootROMPath(const std::string& region_directory) const;
|
||||
bool SetPathsAndGameMetadata(const BootParameters& boot);
|
||||
static DiscIO::Region GetFallbackRegion();
|
||||
DiscIO::Language GetCurrentLanguage(bool wii) const;
|
||||
|
||||
IniFile LoadDefaultGameIni() const;
|
||||
|
|
Loading…
Reference in New Issue