Skip to content

Commit

Permalink
Merge pull request #3139 from JosJuice/fix-wii-root
Browse files Browse the repository at this point in the history
Mark which Wii root to use in the NAND path code
  • Loading branch information
Tilka committed Oct 16, 2015
2 parents d12b026 + c22d1d6 commit 05e339a
Show file tree
Hide file tree
Showing 17 changed files with 174 additions and 191 deletions.
30 changes: 18 additions & 12 deletions Source/Core/Common/NandPaths.cpp
Expand Up @@ -56,34 +56,40 @@ void ShutdownWiiRoot()
}
}

std::string GetTicketFileName(u64 _titleID)
static std::string RootUserPath(FromWhichRoot from)
{
int idx = from == FROM_CONFIGURED_ROOT ? D_WIIROOT_IDX : D_SESSION_WIIROOT_IDX;
return File::GetUserPath(idx);
}

std::string GetTicketFileName(u64 _titleID, FromWhichRoot from)
{
return StringFromFormat("%s/ticket/%08x/%08x.tik",
File::GetUserPath(D_SESSION_WIIROOT_IDX).c_str(),
RootUserPath(from).c_str(),
(u32)(_titleID >> 32), (u32)_titleID);
}

std::string GetTitleDataPath(u64 _titleID)
std::string GetTitleDataPath(u64 _titleID, FromWhichRoot from)
{
return StringFromFormat("%s/title/%08x/%08x/data/",
File::GetUserPath(D_SESSION_WIIROOT_IDX).c_str(),
RootUserPath(from).c_str(),
(u32)(_titleID >> 32), (u32)_titleID);
}

std::string GetTMDFileName(u64 _titleID)
std::string GetTMDFileName(u64 _titleID, FromWhichRoot from)
{
return GetTitleContentPath(_titleID) + "title.tmd";
return GetTitleContentPath(_titleID, from) + "title.tmd";
}
std::string GetTitleContentPath(u64 _titleID)
std::string GetTitleContentPath(u64 _titleID, FromWhichRoot from)
{
return StringFromFormat("%s/title/%08x/%08x/content/",
File::GetUserPath(D_SESSION_WIIROOT_IDX).c_str(),
RootUserPath(from).c_str(),
(u32)(_titleID >> 32), (u32)_titleID);
}

bool CheckTitleTMD(u64 _titleID)
bool CheckTitleTMD(u64 _titleID, FromWhichRoot from)
{
const std::string TitlePath = GetTMDFileName(_titleID);
const std::string TitlePath = GetTMDFileName(_titleID, from);
if (File::Exists(TitlePath))
{
File::IOFile pTMDFile(TitlePath, "rb");
Expand All @@ -96,9 +102,9 @@ bool CheckTitleTMD(u64 _titleID)
return false;
}

bool CheckTitleTIK(u64 _titleID)
bool CheckTitleTIK(u64 _titleID, FromWhichRoot from)
{
const std::string ticketFileName = Common::GetTicketFileName(_titleID);
const std::string ticketFileName = Common::GetTicketFileName(_titleID, from);
if (File::Exists(ticketFileName))
{
File::IOFile pTIKFile(ticketFileName, "rb");
Expand Down
18 changes: 12 additions & 6 deletions Source/Core/Common/NandPaths.h
Expand Up @@ -21,11 +21,17 @@ namespace Common
void InitializeWiiRoot(bool use_temporary);
void ShutdownWiiRoot();

std::string GetTicketFileName(u64 _titleID);
std::string GetTMDFileName(u64 _titleID);
std::string GetTitleDataPath(u64 _titleID);
std::string GetTitleContentPath(u64 _titleID);
bool CheckTitleTMD(u64 _titleID);
bool CheckTitleTIK(u64 _titleID);
enum FromWhichRoot
{
FROM_CONFIGURED_ROOT, // not related to currently running game - use D_WIIROOT_IDX
FROM_SESSION_ROOT, // request from currently running game - use D_SESSION_WIIROOT_IDX
};

std::string GetTicketFileName(u64 _titleID, FromWhichRoot from);
std::string GetTMDFileName(u64 _titleID, FromWhichRoot from);
std::string GetTitleDataPath(u64 _titleID, FromWhichRoot from);
std::string GetTitleContentPath(u64 _titleID, FromWhichRoot from);
bool CheckTitleTMD(u64 _titleID, FromWhichRoot from);
bool CheckTitleTIK(u64 _titleID, FromWhichRoot from);
void ReadReplacements(replace_v& replacements);
}
2 changes: 1 addition & 1 deletion Source/Core/Core/Boot/Boot.cpp
Expand Up @@ -79,7 +79,7 @@ bool CBoot::FindMapFile(std::string* existing_map_file,
{
case SConfig::BOOT_WII_NAND:
{
const DiscIO::INANDContentLoader& Loader =
const DiscIO::CNANDContentLoader& Loader =
DiscIO::CNANDContentManager::Access().GetNANDLoader(_StartupPara.m_strFilename);
if (Loader.IsValid())
{
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/Boot/Boot_BS2Emu.cpp
Expand Up @@ -187,7 +187,7 @@ bool CBoot::SetupWiiMemory(DiscIO::IVolume::ECountry country)

SettingsHandler gen;
std::string serno;
std::string settings_Filename(Common::GetTitleDataPath(TITLEID_SYSMENU) + WII_SETTING);
std::string settings_Filename(Common::GetTitleDataPath(TITLEID_SYSMENU, Common::FROM_SESSION_ROOT) + WII_SETTING);
if (File::Exists(settings_Filename))
{
File::IOFile settingsFileHandle(settings_Filename, "rb");
Expand Down
6 changes: 3 additions & 3 deletions Source/Core/Core/Boot/Boot_WiiWAD.cpp
Expand Up @@ -49,7 +49,7 @@ struct StateFlags

bool CBoot::Boot_WiiWAD(const std::string& _pFilename)
{
std::string state_filename(Common::GetTitleDataPath(TITLEID_SYSMENU) + WII_STATE);
std::string state_filename(Common::GetTitleDataPath(TITLEID_SYSMENU, Common::FROM_SESSION_ROOT) + WII_STATE);

if (File::Exists(state_filename))
{
Expand All @@ -75,13 +75,13 @@ bool CBoot::Boot_WiiWAD(const std::string& _pFilename)
state_file.WriteBytes(&state, sizeof(StateFlags));
}

const DiscIO::INANDContentLoader& ContentLoader = DiscIO::CNANDContentManager::Access().GetNANDLoader(_pFilename);
const DiscIO::CNANDContentLoader& ContentLoader = DiscIO::CNANDContentManager::Access().GetNANDLoader(_pFilename);
if (!ContentLoader.IsValid())
return false;

u64 titleID = ContentLoader.GetTitleID();
// create data directory
File::CreateFullPath(Common::GetTitleDataPath(titleID));
File::CreateFullPath(Common::GetTitleDataPath(titleID, Common::FROM_SESSION_ROOT));

if (titleID == TITLEID_SYSMENU)
HLE_IPC_CreateVirtualFATFilesystem();
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/ConfigManager.cpp
Expand Up @@ -757,7 +757,7 @@ bool SConfig::AutoSetup(EBootBS2 _BootBS2)
else if (DiscIO::CNANDContentManager::Access().GetNANDLoader(m_strFilename).IsValid())
{
std::unique_ptr<DiscIO::IVolume> pVolume(DiscIO::CreateVolumeFromFilename(m_strFilename));
const DiscIO::INANDContentLoader& ContentLoader = DiscIO::CNANDContentManager::Access().GetNANDLoader(m_strFilename);
const DiscIO::CNANDContentLoader& ContentLoader = DiscIO::CNANDContentManager::Access().GetNANDLoader(m_strFilename);

if (ContentLoader.GetContentByIndex(ContentLoader.GetBootIndex()) == nullptr)
{
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/HW/EXI_DeviceMemoryCard.cpp
Expand Up @@ -145,7 +145,7 @@ void CEXIMemoryCard::SetupGciFolder(u16 sizeMb)
u32 CurrentGameId = 0;
if (strUniqueID == TITLEID_SYSMENU_STRING)
{
const DiscIO::INANDContentLoader & SysMenu_Loader = DiscIO::CNANDContentManager::Access().GetNANDLoader(TITLEID_SYSMENU, false);
const DiscIO::CNANDContentLoader & SysMenu_Loader = DiscIO::CNANDContentManager::Access().GetNANDLoader(TITLEID_SYSMENU, Common::FROM_SESSION_ROOT);
if (SysMenu_Loader.IsValid())
{
country_code = DiscIO::CountrySwitch(SysMenu_Loader.GetCountryChar());
Expand Down
3 changes: 2 additions & 1 deletion Source/Core/Core/HW/WiiSaveCrypted.cpp
Expand Up @@ -569,7 +569,8 @@ bool CWiiSaveCrypted::getPaths(bool for_export)
{
if (m_title_id)
{
m_wii_title_path = Common::GetTitleDataPath(m_title_id);
// CONFIGURED because this whole class is only used from the GUI, not directly by games.
m_wii_title_path = Common::GetTitleDataPath(m_title_id, Common::FROM_CONFIGURED_ROOT);
}

if (for_export)
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_FileIO.cpp
Expand Up @@ -41,7 +41,7 @@ std::string HLE_IPC_BuildFilename(std::string path_wii)
void HLE_IPC_CreateVirtualFATFilesystem()
{
const int cdbSize = 0x01400000;
const std::string cdbPath = Common::GetTitleDataPath(TITLEID_SYSMENU) + "cdb.vff";
const std::string cdbPath = Common::GetTitleDataPath(TITLEID_SYSMENU, Common::FROM_SESSION_ROOT) + "cdb.vff";
if ((int)File::GetSize(cdbPath) < cdbSize)
{
// cdb.vff is a virtual Fat filesystem created on first launch of sysmenu
Expand Down

0 comments on commit 05e339a

Please sign in to comment.