Copy Wii save for current game for Netplay and TAS

This commit is contained in:
Chris Burgener 2016-12-23 20:37:23 -05:00
parent 1f1a232546
commit 5224771dac
15 changed files with 64 additions and 30 deletions

View File

@ -76,6 +76,7 @@
#define PIPES_DIR "Pipes"
#define MEMORYWATCHER_DIR "MemoryWatcher"
#define WFSROOT_DIR "WFS"
#define BACKUP_DIR "Backup"
// This one is only used to remove it if it was present
#define SHADERCACHE_LEGACY_DIR "ShaderCache"

View File

@ -781,6 +781,7 @@ static void RebuildUserDirectories(unsigned int dir_index)
s_user_paths[D_THEMES_IDX] = s_user_paths[D_USER_IDX] + THEMES_DIR DIR_SEP;
s_user_paths[D_PIPES_IDX] = s_user_paths[D_USER_IDX] + PIPES_DIR DIR_SEP;
s_user_paths[D_WFSROOT_IDX] = s_user_paths[D_USER_IDX] + WFSROOT_DIR DIR_SEP;
s_user_paths[D_BACKUP_IDX] = s_user_paths[D_USER_IDX] + BACKUP_DIR DIR_SEP;
s_user_paths[F_DOLPHINCONFIG_IDX] = s_user_paths[D_CONFIG_IDX] + DOLPHIN_CONFIG;
s_user_paths[F_DEBUGGERCONFIG_IDX] = s_user_paths[D_CONFIG_IDX] + DEBUGGER_CONFIG;
s_user_paths[F_LOGGERCONFIG_IDX] = s_user_paths[D_CONFIG_IDX] + LOGGER_CONFIG;

View File

@ -47,6 +47,7 @@ enum
D_PIPES_IDX,
D_MEMORYWATCHER_IDX,
D_WFSROOT_IDX,
D_BACKUP_IDX,
F_DOLPHINCONFIG_IDX,
F_DEBUGGERCONFIG_IDX,
F_LOGGERCONFIG_IDX,

View File

@ -354,6 +354,7 @@ bool BootCore(const std::string& _rFilename)
StartUp.bEnableCheats = g_NetPlaySettings.m_EnableCheats;
StartUp.bDSPHLE = g_NetPlaySettings.m_DSPHLE;
StartUp.bEnableMemcardSdWriting = g_NetPlaySettings.m_WriteToMemcard;
StartUp.bCopyWiiSaveNetplay = g_NetPlaySettings.m_CopyWiiSave;
StartUp.iCPUCore = g_NetPlaySettings.m_CPUcore;
StartUp.SelectedLanguage = g_NetPlaySettings.m_SelectedLanguage;
StartUp.bOverrideGCLanguage = g_NetPlaySettings.m_OverrideGCLanguage;

View File

@ -97,6 +97,7 @@ struct SConfig : NonCopyable
bool bHLE_BS2 = true;
bool bEnableCheats = false;
bool bEnableMemcardSdWriting = true;
bool bCopyWiiSaveNetplay = true;
bool bDPL2Decoder = false;
int iLatency = 14;

View File

@ -22,6 +22,7 @@
#include "Core/HW/VideoInterface.h"
#include "Core/HW/WII_IPC.h"
#include "Core/IOS/IPC.h"
#include "Core/Movie.h"
#include "Core/State.h"
#include "Core/WiiRoot.h"
#include "DiscIO/NANDContentLoader.h"

View File

@ -58,6 +58,7 @@
#include "Core/IOS/USB/Bluetooth/BTEmu.h"
#include "Core/IOS/USB/Bluetooth/WiimoteDevice.h"
#include "Core/PowerPC/PowerPC.h"
#include "Core/WiiRoot.h"
#include "Core/ec_wii.h"
#include "DiscIO/NANDContentLoader.h"
#include "DiscIO/Volume.h"

View File

@ -374,6 +374,11 @@ u64 GetTotalLagCount()
return s_totalLagCount;
}
void SetClearSave(bool enabled)
{
s_bClearSave = enabled;
}
void SignalDiscChange(const std::string& new_path)
{
if (Movie::IsRecordingInput())

View File

@ -129,6 +129,7 @@ u64 GetTotalInputCount();
u64 GetCurrentLagCount();
u64 GetTotalLagCount();
void SetClearSave(bool enabled);
void SignalDiscChange(const std::string& new_path);
void SetReset(bool reset);

View File

@ -411,6 +411,7 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet)
packet >> g_NetPlaySettings.m_DSPEnableJIT;
packet >> g_NetPlaySettings.m_DSPHLE;
packet >> g_NetPlaySettings.m_WriteToMemcard;
packet >> g_NetPlaySettings.m_CopyWiiSave;
packet >> g_NetPlaySettings.m_OCEnable;
packet >> g_NetPlaySettings.m_OCFactor;

View File

@ -21,6 +21,7 @@ struct NetSettings
bool m_DSPHLE;
bool m_DSPEnableJIT;
bool m_WriteToMemcard;
bool m_CopyWiiSave;
bool m_OCEnable;
float m_OCFactor;
TEXIDevices m_EXIDevice[2];

View File

@ -807,6 +807,7 @@ bool NetPlayServer::StartGame()
*spac << m_settings.m_DSPEnableJIT;
*spac << m_settings.m_DSPHLE;
*spac << m_settings.m_WriteToMemcard;
*spac << m_settings.m_CopyWiiSave;
*spac << m_settings.m_OCEnable;
*spac << m_settings.m_OCFactor;
*spac << m_settings.m_EXIDevice[0];

View File

@ -11,6 +11,7 @@
#include "Common/SysConf.h"
#include "Core/ConfigManager.h"
#include "Core/Movie.h"
#include "Core/NetPlayClient.h"
#include "Core/WiiRoot.h"
#ifdef _WIN32
@ -25,40 +26,29 @@ static void InitializeDeterministicWiiSaves()
{
std::string save_path =
Common::GetTitleDataPath(SConfig::GetInstance().m_title_id, Common::FROM_SESSION_ROOT);
// TODO: Force the game to save to another location, instead of moving the user's save.
if (Movie::IsPlayingInput() && Movie::IsConfigSaved() && Movie::IsStartingFromClearSave())
std::string user_save_path =
Common::GetTitleDataPath(SConfig::GetInstance().m_title_id, Common::FROM_CONFIGURED_ROOT);
if (Movie::IsRecordingInput())
{
if (File::Exists(save_path + "banner.bin"))
if (NetPlay::IsNetPlayRunning() && !SConfig::GetInstance().bCopyWiiSaveNetplay)
{
if (File::Exists(save_path + "../backup/"))
{
// The last run of this game must have been to play back a movie, so their save is already
// backed up.
File::DeleteDirRecursively(save_path);
Movie::SetClearSave(true);
}
else
{
#ifdef _WIN32
MoveFile(UTF8ToTStr(save_path).c_str(), UTF8ToTStr(save_path + "../backup/").c_str());
#else
File::CopyDir(save_path, save_path + "../backup/");
File::DeleteDirRecursively(save_path);
#endif
// TODO: Check for the actual save data
Movie::SetClearSave(!File::Exists(user_save_path + "banner.bin"));
}
}
}
else if (File::Exists(save_path + "../backup/"))
if ((NetPlay::IsNetPlayRunning() && SConfig::GetInstance().bCopyWiiSaveNetplay) ||
(Movie::IsMovieActive() && !Movie::IsStartingFromClearSave()))
{
// Delete the save made by a previous movie, and copy back the user's save.
if (File::Exists(save_path + "banner.bin"))
File::DeleteDirRecursively(save_path);
#ifdef _WIN32
MoveFile(UTF8ToTStr(save_path + "../backup/").c_str(), UTF8ToTStr(save_path).c_str());
#else
File::CopyDir(save_path + "../backup/", save_path);
File::DeleteDirRecursively(save_path + "../backup/");
#endif
// Copy the current user's save to the Blank NAND
if (File::Exists(user_save_path + "banner.bin"))
{
File::CopyDir(user_save_path, save_path);
}
}
}
@ -100,6 +90,27 @@ void ShutdownWiiRoot()
{
if (!s_temp_wii_root.empty())
{
std::string save_path =
Common::GetTitleDataPath(SConfig::GetInstance().m_title_id, Common::FROM_SESSION_ROOT);
std::string user_save_path =
Common::GetTitleDataPath(SConfig::GetInstance().m_title_id, Common::FROM_CONFIGURED_ROOT);
std::string user_backup_path =
File::GetUserPath(D_BACKUP_IDX) +
StringFromFormat("%08x/%08x/", static_cast<u32>(SConfig::GetInstance().m_title_id >> 32),
static_cast<u32>(SConfig::GetInstance().m_title_id));
if (File::Exists(save_path + "banner.bin") && SConfig::GetInstance().bEnableMemcardSdWriting)
{
// Backup the existing save just in case it's still needed.
if (File::Exists(user_save_path + "banner.bin"))
{
if (File::Exists(user_backup_path))
File::DeleteDirRecursively(user_backup_path);
File::CopyDir(user_save_path, user_backup_path);
File::DeleteDirRecursively(user_save_path);
}
File::CopyDir(save_path, user_save_path);
File::DeleteDirRecursively(save_path);
}
File::DeleteDirRecursively(s_temp_wii_root);
s_temp_wii_root.clear();
}

View File

@ -256,12 +256,15 @@ wxSizer* NetPlayDialog::CreateBottomGUI(wxWindow* parent)
padbuf_spin->Bind(wxEVT_SPINCTRL, &NetPlayDialog::OnAdjustBuffer, this);
padbuf_spin->SetMinSize(WxUtils::GetTextWidgetMinSize(padbuf_spin));
m_memcard_write = new wxCheckBox(parent, wxID_ANY, _("Write to memory cards/SD"));
m_memcard_write = new wxCheckBox(parent, wxID_ANY, _("Write save/SD data"));
m_copy_wii_save = new wxCheckBox(parent, wxID_ANY, _("Copy Wii Save"));
bottom_szr->Add(m_start_btn, 0, wxALIGN_CENTER_VERTICAL);
bottom_szr->Add(buffer_lbl, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, space5);
bottom_szr->Add(padbuf_spin, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, space5);
bottom_szr->Add(m_memcard_write, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, space5);
bottom_szr->Add(m_copy_wii_save, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, space5);
bottom_szr->AddSpacer(space5);
}
@ -328,6 +331,7 @@ void NetPlayDialog::GetNetSettings(NetSettings& settings)
settings.m_DSPHLE = instance.bDSPHLE;
settings.m_DSPEnableJIT = instance.m_DSPEnableJIT;
settings.m_WriteToMemcard = m_memcard_write->GetValue();
settings.m_CopyWiiSave = m_copy_wii_save->GetValue();
settings.m_OCEnable = instance.m_OCEnable;
settings.m_OCFactor = instance.m_OCFactor;
settings.m_EXIDevice[0] = instance.m_EXIDevice[0];
@ -406,6 +410,7 @@ void NetPlayDialog::OnMsgStartGame()
{
m_start_btn->Disable();
m_memcard_write->Disable();
m_copy_wii_save->Disable();
m_game_btn->Disable();
m_player_config_btn->Disable();
}
@ -421,6 +426,7 @@ void NetPlayDialog::OnMsgStopGame()
{
m_start_btn->Enable();
m_memcard_write->Enable();
m_copy_wii_save->Enable();
m_game_btn->Enable();
m_player_config_btn->Enable();
}

View File

@ -131,6 +131,7 @@ private:
wxTextCtrl* m_chat_text;
wxTextCtrl* m_chat_msg_text;
wxCheckBox* m_memcard_write;
wxCheckBox* m_copy_wii_save;
wxCheckBox* m_record_chkbox;
std::string m_selected_game;