Skip to content
Permalink
Browse files

Merge pull request #8256 from JosJuice/setrunninggamemetadata-channel…

…-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 29ba53f6c32313e551b4797a84a4edf477a4d54e
@@ -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();

// If we're launching a disc game, we want to read the revision from
// 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<u8>(tmd_title_id), DiscIO::Platform::WiiWAD,
tmd.GetRegion(), tmd.GetTitleVersion());
const DiscIO::Country country = DiscIO::CountryCodeToCountry(
static_cast<u8>(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;
@@ -20,6 +20,7 @@ namespace DiscIO
{
enum class Country;
enum class Language;
enum class Platform;
enum class Region;
struct Partition;
class Volume;
@@ -200,7 +201,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
@@ -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
@@ -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;

0 comments on commit 29ba53f

Please sign in to comment.
You can’t perform that action at this time.