WiiUtils: Create Wii Shop log files when installing a WAD.
Fixes https://bugs.dolphin-emu.org/issues/12269
This commit is contained in:
parent
59c362d002
commit
83c235b7cb
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue