From dd5c468c6307af02ce34affcb12f829a9cafa7a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Sun, 1 Oct 2017 15:07:59 +0200 Subject: [PATCH] WiiUtils: Allow reusing existing IOS/WAD instance --- Source/Core/Core/WiiUtils.cpp | 17 ++++++++++------- Source/Core/Core/WiiUtils.h | 6 ++++++ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/Source/Core/Core/WiiUtils.cpp b/Source/Core/Core/WiiUtils.cpp index 5bca8ae1cc..2c766015bb 100644 --- a/Source/Core/Core/WiiUtils.cpp +++ b/Source/Core/Core/WiiUtils.cpp @@ -46,7 +46,7 @@ namespace WiiUtils { -static bool InstallWAD(IOS::HLE::Kernel& ios, const DiscIO::WiiWAD& wad) +static bool ImportWAD(IOS::HLE::Kernel& ios, const DiscIO::WiiWAD& wad) { if (!wad.IsValid()) { @@ -109,11 +109,8 @@ static bool InstallWAD(IOS::HLE::Kernel& ios, const DiscIO::WiiWAD& wad) return true; } -bool InstallWAD(const std::string& wad_path) +bool InstallWAD(IOS::HLE::Kernel& ios, const DiscIO::WiiWAD& wad) { - IOS::HLE::Kernel ios; - const DiscIO::WiiWAD wad{wad_path}; - if (!wad.GetTMD().IsValid()) return false; @@ -131,12 +128,18 @@ bool InstallWAD(const std::string& wad_path) return false; } - const bool result = InstallWAD(ios, wad); + const bool result = ImportWAD(ios, wad); DiscIO::NANDContentManager::Access().ClearCache(); return result; } +bool InstallWAD(const std::string& wad_path) +{ + IOS::HLE::Kernel ios; + return InstallWAD(ios, DiscIO::WiiWAD{wad_path}); +} + // Common functionality for system updaters. class SystemUpdater { @@ -685,7 +688,7 @@ UpdateResult DiscSystemUpdater::ProcessEntry(u32 type, std::bitset<32> attrs, return UpdateResult::DiscReadFailed; } const DiscIO::WiiWAD wad{std::move(blob)}; - return InstallWAD(m_ios, wad) ? UpdateResult::Succeeded : UpdateResult::ImportFailed; + return ImportWAD(m_ios, wad) ? UpdateResult::Succeeded : UpdateResult::ImportFailed; } UpdateResult DoOnlineUpdate(UpdateCallback update_callback, const std::string& region) diff --git a/Source/Core/Core/WiiUtils.h b/Source/Core/Core/WiiUtils.h index 0047e2c63d..eb7d669672 100644 --- a/Source/Core/Core/WiiUtils.h +++ b/Source/Core/Core/WiiUtils.h @@ -13,6 +13,10 @@ // Small utility functions for common Wii related tasks. +namespace DiscIO +{ +class WiiWAD; +} namespace IOS { namespace HLE @@ -23,6 +27,8 @@ class Kernel; namespace WiiUtils { +bool InstallWAD(IOS::HLE::Kernel& ios, const DiscIO::WiiWAD& wad); +// Same as the above, but constructs a temporary IOS and WiiWAD instance for importing. bool InstallWAD(const std::string& wad_path); enum class UpdateResult