Skip to content

Commit

Permalink
Merge pull request #8256 from JosJuice/setrunninggamemetadata-channel…
Browse files Browse the repository at this point in the history
…-disc

Never set disc as active title when launching channel with same ID
  • Loading branch information
leoetlino committed Jul 23, 2019
2 parents c8c1a0d + 2fda104 commit 29ba53f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
14 changes: 7 additions & 7 deletions Source/Core/Core/ConfigManager.cpp
Expand Up @@ -670,20 +670,20 @@ 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(); const u64 tmd_title_id = tmd.GetTitleId();


// If we're launching a disc game, we want to read the revision from // If we're launching a disc game, we want to read the revision from
// the disc header instead of the TMD. They can differ. // the disc header instead of the TMD. They can differ.
// (IOS HLE ES calls us with a TMDReader rather than a volume when launching // (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.) // 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. // If not launching a disc game, just read everything from the TMD.
const DiscIO::Country country = const DiscIO::Country country = DiscIO::CountryCodeToCountry(
DiscIO::CountryCodeToCountry(static_cast<u8>(tmd_title_id), DiscIO::Platform::WiiWAD, static_cast<u8>(tmd_title_id), platform, tmd.GetRegion(), tmd.GetTitleVersion());
tmd.GetRegion(), tmd.GetTitleVersion());
SetRunningGameMetadata(tmd.GetGameID(), tmd.GetGameTDBID(), tmd_title_id, tmd.GetTitleVersion(), SetRunningGameMetadata(tmd.GetGameID(), tmd.GetGameTDBID(), tmd_title_id, tmd.GetTitleVersion(),
country); country);
} }
Expand Down Expand Up @@ -902,7 +902,7 @@ struct SetGameMetadata
} }


const IOS::ES::TMDReader& tmd = wad.GetTMD(); const IOS::ES::TMDReader& tmd = wad.GetTMD();
config->SetRunningGameMetadata(tmd); config->SetRunningGameMetadata(tmd, DiscIO::Platform::WiiWAD);
config->bWii = true; config->bWii = true;
*region = tmd.GetRegion(); *region = tmd.GetRegion();
return true; return true;
Expand All @@ -917,7 +917,7 @@ struct SetGameMetadata
PanicAlertT("This title cannot be booted."); PanicAlertT("This title cannot be booted.");
return false; return false;
} }
config->SetRunningGameMetadata(tmd); config->SetRunningGameMetadata(tmd, DiscIO::Platform::WiiWAD);
config->bWii = true; config->bWii = true;
*region = tmd.GetRegion(); *region = tmd.GetRegion();
return true; return true;
Expand Down
3 changes: 2 additions & 1 deletion Source/Core/Core/ConfigManager.h
Expand Up @@ -20,6 +20,7 @@ namespace DiscIO
{ {
enum class Country; enum class Country;
enum class Language; enum class Language;
enum class Platform;
enum class Region; enum class Region;
struct Partition; struct Partition;
class Volume; class Volume;
Expand Down Expand Up @@ -200,7 +201,7 @@ struct SConfig
u16 GetRevision() const { return m_revision; } u16 GetRevision() const { return m_revision; }
void ResetRunningGameMetadata(); void ResetRunningGameMetadata();
void SetRunningGameMetadata(const DiscIO::Volume& volume, const DiscIO::Partition& partition); 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(); void LoadDefaults();
// Replaces NTSC-K with some other region, and doesn't replace non-NTSC-K regions // Replaces NTSC-K with some other region, and doesn't replace non-NTSC-K regions
Expand Down
10 changes: 6 additions & 4 deletions Source/Core/Core/IOS/ES/ES.cpp
Expand Up @@ -25,6 +25,7 @@
#include "Core/IOS/IOSC.h" #include "Core/IOS/IOSC.h"
#include "Core/IOS/Uids.h" #include "Core/IOS/Uids.h"
#include "Core/IOS/VersionInfo.h" #include "Core/IOS/VersionInfo.h"
#include "DiscIO/Enums.h"


namespace IOS::HLE::Device namespace IOS::HLE::Device
{ {
Expand Down Expand Up @@ -93,7 +94,8 @@ void TitleContext::DoState(PointerWrap& p)
p.Do(active); 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()) if (!tmd_.IsValid() || !ticket_.IsValid())
{ {
Expand All @@ -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. // Interesting title changes (channel or disc game launch) always happen after an IOS reload.
if (first_change) if (first_change)
{ {
SConfig::GetInstance().SetRunningGameMetadata(tmd); SConfig::GetInstance().SetRunningGameMetadata(tmd, platform);
first_change = false; first_change = false;
} }
} }
Expand Down Expand Up @@ -298,7 +300,7 @@ bool ES::LaunchPPCTitle(u64 title_id, bool skip_reload)
return LaunchTitle(required_ios); 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()); 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 // Note: the UID/GID is also updated for IOS titles, but since we have no guarantee IOS titles
Expand Down Expand Up @@ -648,7 +650,7 @@ ReturnCode ES::DIVerify(const IOS::ES::TMDReader& tmd, const IOS::ES::TicketRead
if (tmd.GetTitleId() != ticket.GetTitleId()) if (tmd.GetTitleId() != ticket.GetTitleId())
return ES_EINVAL; 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()); 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 // XXX: We are supposed to verify the TMD and ticket here, but cannot because
Expand Down
8 changes: 7 additions & 1 deletion Source/Core/Core/IOS/ES/ES.h
Expand Up @@ -18,13 +18,19 @@


class PointerWrap; class PointerWrap;


namespace DiscIO
{
enum class Platform;
}

namespace IOS::HLE::Device namespace IOS::HLE::Device
{ {
struct TitleContext struct TitleContext
{ {
void Clear(); void Clear();
void DoState(PointerWrap& p); 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::TicketReader ticket;
IOS::ES::TMDReader tmd; IOS::ES::TMDReader tmd;
Expand Down

0 comments on commit 29ba53f

Please sign in to comment.