From 3fb42f6bb618aa70c5879806885d838e920611cf Mon Sep 17 00:00:00 2001 From: LPFaint99 Date: Sun, 21 Aug 2011 18:20:22 -0700 Subject: [PATCH] split adding the ticket to its own function (installing a wad) --- Source/Core/DiscIO/Src/NANDContentLoader.cpp | 28 ++++++++++++-------- Source/Core/DiscIO/Src/NANDContentLoader.h | 2 +- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/Source/Core/DiscIO/Src/NANDContentLoader.cpp b/Source/Core/DiscIO/Src/NANDContentLoader.cpp index c8e409636b..3e799ffd8b 100644 --- a/Source/Core/DiscIO/Src/NANDContentLoader.cpp +++ b/Source/Core/DiscIO/Src/NANDContentLoader.cpp @@ -536,20 +536,14 @@ u64 CNANDContentManager::Install_WiiWAD(std::string &fileName) pTMDFile.Close(); + + + //Extract and copy WAD's ticket to ticket directory - std::string TicketFileName = Common::GetTicketFileName(TitleID); - - File::CreateFullPath(TicketFileName); - File::IOFile pTicketFile(TicketFileName, "wb"); - if (!pTicketFile) + if (!Add_Ticket(TitleID, ContentLoader.GetTIK(), ContentLoader.GetTIKSize())) { - PanicAlertT("WAD installation failed: error creating %s", TicketFileName.c_str()); + PanicAlertT("WAD installation failed: error creating ticket"); return 0; - } - - if (ContentLoader.GetTIK()) - { - pTicketFile.WriteBytes(ContentLoader.GetTIK(), ContentLoader.GetTIKSize()); } cUIDsys::AccessInstance().AddTitle(TitleID); @@ -558,6 +552,18 @@ u64 CNANDContentManager::Install_WiiWAD(std::string &fileName) return TitleID; } +bool Add_Ticket(u64 TitleID, const u8 *p_tik, u32 tikSize) +{ + std::string TicketFileName = Common::GetTicketFileName(TitleID); + File::CreateFullPath(TicketFileName); + File::IOFile pTicketFile(TicketFileName, "wb"); + if (!pTicketFile || !p_tik) + { + //PanicAlertT("WAD installation failed: error creating %s", TicketFileName.c_str()); + return false; + } + return pTicketFile.WriteBytes(p_tik, tikSize); +} } // namespace end diff --git a/Source/Core/DiscIO/Src/NANDContentLoader.h b/Source/Core/DiscIO/Src/NANDContentLoader.h index 14a2062641..63135df693 100644 --- a/Source/Core/DiscIO/Src/NANDContentLoader.h +++ b/Source/Core/DiscIO/Src/NANDContentLoader.h @@ -29,7 +29,7 @@ namespace DiscIO { - + bool Add_Ticket(u64 TitleID, const u8 *p_tik, u32 tikSize); struct SNANDContent { u32 m_ContentID;