diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_es.cpp b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_es.cpp index 039be8fe39..b14dae1ad0 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_es.cpp +++ b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_es.cpp @@ -64,7 +64,6 @@ std::string CWII_IPC_HLE_Device_es::m_ContentFile; CWII_IPC_HLE_Device_es::CWII_IPC_HLE_Device_es(u32 _DeviceID, const std::string& _rDeviceName) : IWII_IPC_HLE_Device(_DeviceID, _rDeviceName) - , m_pContentLoader(nullptr) , m_TitleID(-1) , m_AccessIdentID(0x6000000) { @@ -99,12 +98,12 @@ void CWII_IPC_HLE_Device_es::LoadWAD(const std::string& _rContentFile) void CWII_IPC_HLE_Device_es::OpenInternal() { - m_pContentLoader = &DiscIO::CNANDContentManager::Access().GetNANDLoader(m_ContentFile); + auto& contentLoader = DiscIO::CNANDContentManager::Access().GetNANDLoader(m_ContentFile); // check for cd ... - if (m_pContentLoader->IsValid()) + if (contentLoader.IsValid()) { - m_TitleID = m_pContentLoader->GetTitleID(); + m_TitleID = contentLoader.GetTitleID(); m_TitleIDs.clear(); DiscIO::cUIDsys::AccessInstance().GetTitleIDs(m_TitleIDs); @@ -186,14 +185,11 @@ IPCCommandResult CWII_IPC_HLE_Device_es::Open(u32 _CommandAddress, u32 _Mode) IPCCommandResult CWII_IPC_HLE_Device_es::Close(u32 _CommandAddress, bool _bForce) { - // Leave deletion of the CNANDContentLoader objects to CNANDContentManager, don't do it here! - m_NANDContent.clear(); for (auto& pair : m_ContentAccessMap) { delete pair.second.m_pFile; } m_ContentAccessMap.clear(); - m_pContentLoader = nullptr; m_TitleIDs.clear(); m_TitleID = -1; m_AccessIdentID = 0x6000000; @@ -1077,31 +1073,17 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(u32 _CommandAddress) return GetDefaultReply(); } -// TODO: This cache is redundant with the one in CNANDContentManager.h const DiscIO::CNANDContentLoader& CWII_IPC_HLE_Device_es::AccessContentDevice(u64 title_id) { - if (m_pContentLoader->IsValid() && m_pContentLoader->GetTitleID() == title_id) - return *m_pContentLoader; + // for WADs, the passed title id and the stored title id match; along with m_ContentFile being set to the + // actual WAD file name. We cannot simply get a NAND Loader for the title id in those cases, since the WAD + // need not be installed in the NAND, but it could be opened directly from a WAD file anywhere on disk. + if (m_TitleID == title_id && !m_ContentFile.empty()) + return DiscIO::CNANDContentManager::Access().GetNANDLoader(m_ContentFile); - CTitleToContentMap::iterator itr = m_NANDContent.find(title_id); - if (itr != m_NANDContent.end()) - return *itr->second; - - m_NANDContent[title_id] = &DiscIO::CNANDContentManager::Access().GetNANDLoader(title_id, Common::FROM_SESSION_ROOT); - - _dbg_assert_msg_(WII_IPC_ES, ((u32)(title_id >> 32) == 0x00010000) || m_NANDContent[title_id]->IsValid(), "NandContent not valid for TitleID %08x/%08x", (u32)(title_id >> 32), (u32)title_id); - return *m_NANDContent[title_id]; + return DiscIO::CNANDContentManager::Access().GetNANDLoader(title_id, Common::FROM_SESSION_ROOT); } -bool CWII_IPC_HLE_Device_es::IsValid(u64 _TitleID) const -{ - if (m_pContentLoader->IsValid() && m_pContentLoader->GetTitleID() == _TitleID) - return true; - - return false; -} - - u32 CWII_IPC_HLE_Device_es::ES_DIVerify(const std::vector& tmd) { u64 title_id = 0xDEADBEEFDEADBEEFull; diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_es.h b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_es.h index 89988f1ecf..42836735be 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_es.h +++ b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_es.h @@ -133,11 +133,6 @@ private: typedef std::map CContentAccessMap; CContentAccessMap m_ContentAccessMap; - typedef std::map CTitleToContentMap; - CTitleToContentMap m_NANDContent; - - const DiscIO::CNANDContentLoader* m_pContentLoader; - std::vector m_TitleIDs; u64 m_TitleID; u32 m_AccessIdentID; @@ -147,8 +142,6 @@ private: const DiscIO::CNANDContentLoader& AccessContentDevice(u64 title_id); u32 OpenTitleContent(u32 CFD, u64 TitleID, u16 Index); - bool IsValid(u64 _TitleID) const; - struct ecc_cert_t { u32 sig_type ;