From 39314ac16264cacf4802c81ae79715700b96951b Mon Sep 17 00:00:00 2001 From: "Admiral H. Curtiss" Date: Sat, 10 Sep 2022 04:24:57 +0200 Subject: [PATCH] Add more logging around Wii save copying for Netplay. --- Source/Core/Core/NetPlayClient.cpp | 5 +++++ Source/Core/Core/WiiRoot.cpp | 28 ++++++++++++++++++++++++---- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/Source/Core/Core/NetPlayClient.cpp b/Source/Core/Core/NetPlayClient.cpp index 9c744420e5..b181cf1ffc 100644 --- a/Source/Core/Core/NetPlayClient.cpp +++ b/Source/Core/Core/NetPlayClient.cpp @@ -1696,6 +1696,11 @@ bool NetPlayClient::StartGame(const std::string& path) // boot game auto boot_session_data = std::make_unique(); + + INFO_LOG_FMT(NETPLAY, + "Setting Wii sync data: has FS {}, sync_titles = {:016x}, redirect folder = {}", + !!m_wii_sync_fs, fmt::join(m_wii_sync_titles, ", "), m_wii_sync_redirect_folder); + boot_session_data->SetWiiSyncData(std::move(m_wii_sync_fs), std::move(m_wii_sync_titles), std::move(m_wii_sync_redirect_folder), [] { // on emulation end clean up the Wii save sync directory -- diff --git a/Source/Core/Core/WiiRoot.cpp b/Source/Core/Core/WiiRoot.cpp index 5ff55a91f4..73f7f2f2af 100644 --- a/Source/Core/Core/WiiRoot.cpp +++ b/Source/Core/Core/WiiRoot.cpp @@ -151,8 +151,11 @@ static void InitializeDeterministicWiiSaves(FS::FileSystem* session_fs, auto& sync_titles = boot_session_data.GetWiiSyncTitles(); if (sync_fs) { + INFO_LOG_FMT(CORE, "Wii Save Init: Copying from sync_fs to session_fs."); + for (const u64 title : sync_titles) { + INFO_LOG_FMT(CORE, "Wii Save Init: Copying {0:016x}.", title); CopySave(sync_fs, session_fs, title); } @@ -165,15 +168,19 @@ static void InitializeDeterministicWiiSaves(FS::FileSystem* session_fs, } else { + INFO_LOG_FMT(CORE, "Wii Save Init: Copying from configured_fs to session_fs."); + if (NetPlay::IsSyncingAllWiiSaves()) { for (const u64 title : sync_titles) { + INFO_LOG_FMT(CORE, "Wii Save Init: Copying {0:016x}.", title); CopySave(configured_fs.get(), session_fs, title); } } else { + INFO_LOG_FMT(CORE, "Wii Save Init: Copying {0:016x}.", title_id); CopySave(configured_fs.get(), session_fs, title_id); } @@ -375,11 +382,22 @@ void InitializeWiiFileSystemContents( void CleanUpWiiFileSystemContents(const BootSessionData& boot_session_data) { - if (!WiiRootIsTemporary() || !Config::Get(Config::SESSION_SAVE_DATA_WRITABLE) || - boot_session_data.GetWiiSyncFS()) - { + const bool wii_root_is_temporary = WiiRootIsTemporary(); + const bool session_save_data_writable = Config::Get(Config::SESSION_SAVE_DATA_WRITABLE); + const bool has_wii_sync_fs = !!boot_session_data.GetWiiSyncFS(); + const bool cleanup_required = + wii_root_is_temporary && session_save_data_writable && !has_wii_sync_fs; + + INFO_LOG_FMT(CORE, + "Wii FS Cleanup: cleanup_required = {} (wii_root_is_temporary = {}, " + "session_save_data_writable = {}, has_wii_sync_fs = {})", + cleanup_required, wii_root_is_temporary, session_save_data_writable, + has_wii_sync_fs); + + if (!cleanup_required) return; - } + + INFO_LOG_FMT(CORE, "Wii FS Cleanup: Copying from temporary FS to configured_fs."); // copy back the temp nand redirected files to where they should normally be redirected to for (const auto& redirect : s_temp_nand_redirects) @@ -402,6 +420,8 @@ void CleanUpWiiFileSystemContents(const BootSessionData& boot_session_data) for (const u64 title_id : ios->GetES()->GetInstalledTitles()) { + INFO_LOG_FMT(CORE, "Wii FS Cleanup: Copying {0:016x}.", title_id); + const auto session_save = WiiSave::MakeNandStorage(ios->GetFS().get(), title_id); // FS won't write the save if the directory doesn't exist