From 2fda104d5aadd3daf3f8a422746321723b03d6ca Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sat, 20 Jul 2019 08:37:14 +0200 Subject: [PATCH] Never set disc as active title when launching channel with same ID https://bugs.dolphin-emu.org/issues/11804 --- Source/Core/Core/ConfigManager.cpp | 14 +++++++------- Source/Core/Core/ConfigManager.h | 3 ++- Source/Core/Core/IOS/ES/ES.cpp | 10 ++++++---- Source/Core/Core/IOS/ES/ES.h | 8 +++++++- 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/Source/Core/Core/ConfigManager.cpp b/Source/Core/Core/ConfigManager.cpp index 68cf1457a1..e1a1eb6ef9 100644 --- a/Source/Core/Core/ConfigManager.cpp +++ b/Source/Core/Core/ConfigManager.cpp @@ -670,7 +670,7 @@ void SConfig::SetRunningGameMetadata(const DiscIO::Volume& volume, } } -void SConfig::SetRunningGameMetadata(const IOS::ES::TMDReader& tmd) +void SConfig::SetRunningGameMetadata(const IOS::ES::TMDReader& tmd, DiscIO::Platform platform) { const u64 tmd_title_id = tmd.GetTitleId(); @@ -678,12 +678,12 @@ void SConfig::SetRunningGameMetadata(const IOS::ES::TMDReader& tmd) // the disc header instead of the TMD. They can differ. // (IOS HLE ES calls us with a TMDReader rather than a volume when launching // a disc game, because ES has no reason to be accessing the disc directly.) - if (!DVDInterface::UpdateRunningGameMetadata(tmd_title_id)) + if (platform == DiscIO::Platform::WiiWAD || + !DVDInterface::UpdateRunningGameMetadata(tmd_title_id)) { // If not launching a disc game, just read everything from the TMD. - const DiscIO::Country country = - DiscIO::CountryCodeToCountry(static_cast(tmd_title_id), DiscIO::Platform::WiiWAD, - tmd.GetRegion(), tmd.GetTitleVersion()); + const DiscIO::Country country = DiscIO::CountryCodeToCountry( + static_cast(tmd_title_id), platform, tmd.GetRegion(), tmd.GetTitleVersion()); SetRunningGameMetadata(tmd.GetGameID(), tmd.GetGameTDBID(), tmd_title_id, tmd.GetTitleVersion(), country); } @@ -902,7 +902,7 @@ struct SetGameMetadata } const IOS::ES::TMDReader& tmd = wad.GetTMD(); - config->SetRunningGameMetadata(tmd); + config->SetRunningGameMetadata(tmd, DiscIO::Platform::WiiWAD); config->bWii = true; *region = tmd.GetRegion(); return true; @@ -917,7 +917,7 @@ struct SetGameMetadata PanicAlertT("This title cannot be booted."); return false; } - config->SetRunningGameMetadata(tmd); + config->SetRunningGameMetadata(tmd, DiscIO::Platform::WiiWAD); config->bWii = true; *region = tmd.GetRegion(); return true; diff --git a/Source/Core/Core/ConfigManager.h b/Source/Core/Core/ConfigManager.h index 11c27f2f1a..d5a61a4b44 100644 --- a/Source/Core/Core/ConfigManager.h +++ b/Source/Core/Core/ConfigManager.h @@ -19,6 +19,7 @@ namespace DiscIO { enum class Country; enum class Language; +enum class Platform; enum class Region; struct Partition; class Volume; @@ -199,7 +200,7 @@ struct SConfig u16 GetRevision() const { return m_revision; } void ResetRunningGameMetadata(); void SetRunningGameMetadata(const DiscIO::Volume& volume, const DiscIO::Partition& partition); - void SetRunningGameMetadata(const IOS::ES::TMDReader& tmd); + void SetRunningGameMetadata(const IOS::ES::TMDReader& tmd, DiscIO::Platform platform); void LoadDefaults(); // Replaces NTSC-K with some other region, and doesn't replace non-NTSC-K regions diff --git a/Source/Core/Core/IOS/ES/ES.cpp b/Source/Core/Core/IOS/ES/ES.cpp index 8d1f9a9898..9f39112654 100644 --- a/Source/Core/Core/IOS/ES/ES.cpp +++ b/Source/Core/Core/IOS/ES/ES.cpp @@ -25,6 +25,7 @@ #include "Core/IOS/IOSC.h" #include "Core/IOS/Uids.h" #include "Core/IOS/VersionInfo.h" +#include "DiscIO/Enums.h" namespace IOS::HLE::Device { @@ -93,7 +94,8 @@ void TitleContext::DoState(PointerWrap& p) p.Do(active); } -void TitleContext::Update(const IOS::ES::TMDReader& tmd_, const IOS::ES::TicketReader& ticket_) +void TitleContext::Update(const IOS::ES::TMDReader& tmd_, const IOS::ES::TicketReader& ticket_, + DiscIO::Platform platform) { if (!tmd_.IsValid() || !ticket_.IsValid()) { @@ -108,7 +110,7 @@ void TitleContext::Update(const IOS::ES::TMDReader& tmd_, const IOS::ES::TicketR // Interesting title changes (channel or disc game launch) always happen after an IOS reload. if (first_change) { - SConfig::GetInstance().SetRunningGameMetadata(tmd); + SConfig::GetInstance().SetRunningGameMetadata(tmd, platform); first_change = false; } } @@ -298,7 +300,7 @@ bool ES::LaunchPPCTitle(u64 title_id, bool skip_reload) return LaunchTitle(required_ios); } - m_title_context.Update(tmd, ticket); + m_title_context.Update(tmd, ticket, DiscIO::Platform::WiiWAD); INFO_LOG(IOS_ES, "LaunchPPCTitle: Title context changed: %016" PRIx64, tmd.GetTitleId()); // Note: the UID/GID is also updated for IOS titles, but since we have no guarantee IOS titles @@ -648,7 +650,7 @@ ReturnCode ES::DIVerify(const IOS::ES::TMDReader& tmd, const IOS::ES::TicketRead if (tmd.GetTitleId() != ticket.GetTitleId()) return ES_EINVAL; - m_title_context.Update(tmd, ticket); + m_title_context.Update(tmd, ticket, DiscIO::Platform::WiiDisc); INFO_LOG(IOS_ES, "ES_DIVerify: Title context changed: %016" PRIx64, tmd.GetTitleId()); // XXX: We are supposed to verify the TMD and ticket here, but cannot because diff --git a/Source/Core/Core/IOS/ES/ES.h b/Source/Core/Core/IOS/ES/ES.h index 89c47a90c7..184fed3fa4 100644 --- a/Source/Core/Core/IOS/ES/ES.h +++ b/Source/Core/Core/IOS/ES/ES.h @@ -18,13 +18,19 @@ class PointerWrap; +namespace DiscIO +{ +enum class Platform; +} + namespace IOS::HLE::Device { struct TitleContext { void Clear(); void DoState(PointerWrap& p); - void Update(const IOS::ES::TMDReader& tmd_, const IOS::ES::TicketReader& ticket_); + void Update(const IOS::ES::TMDReader& tmd_, const IOS::ES::TicketReader& ticket_, + DiscIO::Platform platform); IOS::ES::TicketReader ticket; IOS::ES::TMDReader tmd;