summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorAdmiral H. Curtiss <pikachu025@gmail.com>2020-11-19 03:19:56 +0100
committerAdmiral H. Curtiss <pikachu025@gmail.com>2020-11-19 03:26:27 +0100
commit83c235b7cbde672a935aa94ef8422fba2d974375 (patch)
treed480381b5270395a1d3c962588adbec3e74bcff0 /Source/Core
parent59c362d002522b4d04fd0b4b2cc58ee7e2545a22 (diff)
WiiUtils: Create Wii Shop log files when installing a WAD.
Fixes https://bugs.dolphin-emu.org/issues/12269
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Core/WiiUtils.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/Source/Core/Core/WiiUtils.cpp b/Source/Core/Core/WiiUtils.cpp
index 667fe0e663..f8ff946abb 100644
--- a/Source/Core/Core/WiiUtils.cpp
+++ b/Source/Core/Core/WiiUtils.cpp
@@ -36,6 +36,7 @@
#include "Core/IOS/ES/Formats.h"
#include "Core/IOS/FS/FileSystem.h"
#include "Core/IOS/IOS.h"
+#include "Core/IOS/Uids.h"
#include "Core/SysConf.h"
#include "DiscIO/DiscExtractor.h"
#include "DiscIO/Enums.h"
@@ -57,6 +58,7 @@ static bool ImportWAD(IOS::HLE::Kernel& ios, const DiscIO::VolumeWAD& wad,
const auto tmd = wad.GetTMD();
const auto es = ios.GetES();
+ const auto fs = ios.GetFS();
IOS::HLE::Device::ES::Context context;
IOS::HLE::ReturnCode ret;
@@ -99,6 +101,38 @@ static bool ImportWAD(IOS::HLE::Kernel& ios, const DiscIO::VolumeWAD& wad,
return false;
}
+ // Under normal conditions, these two log files are created by the Wii Shop channel at some point
+ // during the process of downloading a game, and some games (eg. Mega Man 9) refuse to load DLC if
+ // they are not present. So ensure they exist and create them if they don't.
+ const bool shop_logs_exist = [&] {
+ const std::array<u8, 32> dummy_data{};
+ for (const std::string& path : {"/shared2/ec/shopsetu.log", "/shared2/succession/shop.log"})
+ {
+ constexpr IOS::HLE::FS::Mode rw_mode = IOS::HLE::FS::Mode::ReadWrite;
+ if (fs->CreateFullPath(IOS::SYSMENU_UID, IOS::SYSMENU_GID, path, 0,
+ {rw_mode, rw_mode, rw_mode}) != IOS::HLE::FS::ResultCode::Success)
+ {
+ return false;
+ }
+
+ const auto old_handle = fs->OpenFile(IOS::SYSMENU_UID, IOS::SYSMENU_GID, path, rw_mode);
+ if (old_handle)
+ continue;
+
+ const auto new_handle = fs->CreateAndOpenFile(IOS::SYSMENU_UID, IOS::SYSMENU_GID, path,
+ {rw_mode, rw_mode, rw_mode});
+ if (!new_handle || !new_handle->Write(dummy_data.data(), dummy_data.size()))
+ return false;
+ }
+ return true;
+ }();
+
+ if (!shop_logs_exist)
+ {
+ PanicAlertFmtT("WAD installation failed: Could not create Wii Shop log files.");
+ return false;
+ }
+
return true;
}