Merge pull request #4629 from JosJuice/es-movie-title-id

Don't call Movie::SetTitleId from ES
This commit is contained in:
Mat M 2017-02-05 09:26:08 -05:00 committed by GitHub
commit 1f1a232546
7 changed files with 60 additions and 76 deletions

View File

@ -413,6 +413,7 @@ void RestoreConfig()
{ {
SConfig::GetInstance().LoadSettingsFromSysconf(); SConfig::GetInstance().LoadSettingsFromSysconf();
SConfig::GetInstance().m_strGameID = "00000000"; SConfig::GetInstance().m_strGameID = "00000000";
SConfig::GetInstance().m_title_id = 0;
config_cache.RestoreConfig(&SConfig::GetInstance()); config_cache.RestoreConfig(&SConfig::GetInstance());
} }

View File

@ -753,6 +753,7 @@ void SConfig::LoadDefaults()
m_strName = "NONE"; m_strName = "NONE";
m_strGameID = "00000000"; m_strGameID = "00000000";
m_title_id = 0;
m_revision = 0; m_revision = 0;
} }
@ -835,6 +836,7 @@ bool SConfig::AutoSetup(EBootBS2 _BootBS2)
} }
m_strName = pVolume->GetInternalName(); m_strName = pVolume->GetInternalName();
m_strGameID = pVolume->GetGameID(); m_strGameID = pVolume->GetGameID();
pVolume->GetTitleID(&m_title_id);
m_revision = pVolume->GetRevision(); m_revision = pVolume->GetRevision();
// Check if we have a Wii disc // Check if we have a Wii disc
@ -901,6 +903,7 @@ bool SConfig::AutoSetup(EBootBS2 _BootBS2)
{ {
m_strName = pVolume->GetInternalName(); m_strName = pVolume->GetInternalName();
m_strGameID = pVolume->GetGameID(); m_strGameID = pVolume->GetGameID();
pVolume->GetTitleID(&m_title_id);
} }
else else
{ {
@ -908,12 +911,13 @@ bool SConfig::AutoSetup(EBootBS2 _BootBS2)
// if this is the second boot we would be using the Name and id of the last title // if this is the second boot we would be using the Name and id of the last title
m_strName.clear(); m_strName.clear();
m_strGameID.clear(); m_strGameID.clear();
m_title_id = 0;
} }
// Use the TitleIDhex for name and/or game ID if launching // Use the TitleIDhex for name and/or game ID if launching
// from nand folder or if it is not ascii characters // from nand folder or if it is not ascii characters
// (specifically sysmenu could potentially apply to other things) // (specifically sysmenu could potentially apply to other things)
std::string titleidstr = StringFromFormat("%016" PRIx64, ContentLoader.GetTitleID()); std::string titleidstr = StringFromFormat("%016" PRIx64, m_title_id);
if (m_strName.empty()) if (m_strName.empty())
{ {

View File

@ -202,6 +202,7 @@ struct SConfig : NonCopyable
std::string m_strDVDRoot; std::string m_strDVDRoot;
std::string m_strApploader; std::string m_strApploader;
std::string m_strGameID; std::string m_strGameID;
u64 m_title_id;
std::string m_strName; std::string m_strName;
std::string m_strWiiSDCardPath; std::string m_strWiiSDCardPath;
u16 m_revision; u16 m_revision;

View File

@ -57,16 +57,11 @@
#include "Core/IOS/ES/Formats.h" #include "Core/IOS/ES/Formats.h"
#include "Core/IOS/USB/Bluetooth/BTEmu.h" #include "Core/IOS/USB/Bluetooth/BTEmu.h"
#include "Core/IOS/USB/Bluetooth/WiimoteDevice.h" #include "Core/IOS/USB/Bluetooth/WiimoteDevice.h"
#include "Core/Movie.h"
#include "Core/PowerPC/PowerPC.h" #include "Core/PowerPC/PowerPC.h"
#include "Core/ec_wii.h" #include "Core/ec_wii.h"
#include "DiscIO/NANDContentLoader.h" #include "DiscIO/NANDContentLoader.h"
#include "DiscIO/Volume.h" #include "DiscIO/Volume.h"
#ifdef _WIN32
#include <Windows.h>
#endif
namespace IOS namespace IOS
{ {
namespace HLE namespace HLE
@ -1316,52 +1311,6 @@ u32 ES::ES_DIVerify(const std::vector<u8>& tmd)
File::CreateFullPath(tmd_path); File::CreateFullPath(tmd_path);
File::CreateFullPath(Common::GetTitleDataPath(tmd_title_id, Common::FROM_SESSION_ROOT)); File::CreateFullPath(Common::GetTitleDataPath(tmd_title_id, Common::FROM_SESSION_ROOT));
Movie::SetTitleId(tmd_title_id);
std::string save_path = Common::GetTitleDataPath(tmd_title_id, Common::FROM_SESSION_ROOT);
if (Movie::IsRecordingInput())
{
// TODO: Check for the actual save data
if (File::Exists(save_path + "banner.bin"))
Movie::SetClearSave(false);
else
Movie::SetClearSave(true);
}
// TODO: Force the game to save to another location, instead of moving the user's save.
if (Movie::IsPlayingInput() && Movie::IsConfigSaved() && Movie::IsStartingFromClearSave())
{
if (File::Exists(save_path + "banner.bin"))
{
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);
}
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
}
}
}
else if (File::Exists(save_path + "../backup/"))
{
// 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
}
if (!File::Exists(tmd_path)) if (!File::Exists(tmd_path))
{ {
File::IOFile tmd_file(tmd_path, "wb"); File::IOFile tmd_file(tmd_path, "wb");

View File

@ -77,7 +77,6 @@ static bool s_bDiscChange = false;
static bool s_bReset = false; static bool s_bReset = false;
static std::string s_author = ""; static std::string s_author = "";
static std::string s_discChange = ""; static std::string s_discChange = "";
static u64 s_titleID = 0;
static u8 s_MD5[16]; static u8 s_MD5[16];
static u8 s_bongos, s_memcards; static u8 s_bongos, s_memcards;
static u8 s_revision[20]; static u8 s_revision[20];
@ -375,11 +374,6 @@ u64 GetTotalLagCount()
return s_totalLagCount; return s_totalLagCount;
} }
void SetClearSave(bool enabled)
{
s_bClearSave = enabled;
}
void SignalDiscChange(const std::string& new_path) void SignalDiscChange(const std::string& new_path)
{ {
if (Movie::IsRecordingInput()) if (Movie::IsRecordingInput())
@ -403,11 +397,6 @@ void SetReset(bool reset)
s_bReset = reset; s_bReset = reset;
} }
void SetTitleId(u64 title_id)
{
s_titleID = title_id;
}
bool IsUsingPad(int controller) bool IsUsingPad(int controller)
{ {
return ((s_controllers & (1 << controller)) != 0); return ((s_controllers & (1 << controller)) != 0);
@ -579,17 +568,6 @@ bool BeginRecordingInput(int controllers)
State::SaveAs(save_path); State::SaveAs(save_path);
s_bRecordingFromSaveState = true; s_bRecordingFromSaveState = true;
// This is only done here if starting from save state because otherwise we won't have the
// titleid. Otherwise it's set in IOS::HLE::Device::ES.
// TODO: find a way to GetTitleDataPath() from Movie::Init()
if (SConfig::GetInstance().bWii)
{
if (File::Exists(Common::GetTitleDataPath(s_titleID, Common::FROM_SESSION_ROOT) +
"banner.bin"))
Movie::s_bClearSave = false;
else
Movie::s_bClearSave = true;
}
std::thread md5thread(GetMD5); std::thread md5thread(GetMD5);
md5thread.detach(); md5thread.detach();
GetSettings(); GetSettings();
@ -1491,6 +1469,9 @@ void GetSettings()
s_bNetPlay = NetPlay::IsNetPlayRunning(); s_bNetPlay = NetPlay::IsNetPlayRunning();
if (SConfig::GetInstance().bWii) if (SConfig::GetInstance().bWii)
{ {
u64 title_id = SConfig::GetInstance().m_title_id;
s_bClearSave =
!File::Exists(Common::GetTitleDataPath(title_id, Common::FROM_SESSION_ROOT) + "banner.bin");
s_language = SConfig::GetInstance().m_wii_language; s_language = SConfig::GetInstance().m_wii_language;
} }
else else

View File

@ -129,10 +129,8 @@ u64 GetTotalInputCount();
u64 GetCurrentLagCount(); u64 GetCurrentLagCount();
u64 GetTotalLagCount(); u64 GetTotalLagCount();
void SetClearSave(bool enabled);
void SignalDiscChange(const std::string& new_path); void SignalDiscChange(const std::string& new_path);
void SetReset(bool reset); void SetReset(bool reset);
void SetTitleId(u64 title_id);
bool IsConfigSaved(); bool IsConfigSaved();
bool IsDualCore(); bool IsDualCore();

View File

@ -9,15 +9,63 @@
#include "Common/Logging/Log.h" #include "Common/Logging/Log.h"
#include "Common/NandPaths.h" #include "Common/NandPaths.h"
#include "Common/SysConf.h" #include "Common/SysConf.h"
#include "Core/ConfigManager.h"
#include "Core/Movie.h"
#include "Core/WiiRoot.h" #include "Core/WiiRoot.h"
#ifdef _WIN32
#include <Windows.h>
#endif
namespace Core namespace Core
{ {
static std::string s_temp_wii_root; static std::string s_temp_wii_root;
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())
{
if (File::Exists(save_path + "banner.bin"))
{
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);
}
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
}
}
}
else if (File::Exists(save_path + "../backup/"))
{
// 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
}
}
void InitializeWiiRoot(bool use_temporary) void InitializeWiiRoot(bool use_temporary)
{ {
ShutdownWiiRoot(); ShutdownWiiRoot();
if (use_temporary) if (use_temporary)
{ {
s_temp_wii_root = File::CreateTempDir(); s_temp_wii_root = File::CreateTempDir();
@ -44,6 +92,8 @@ void InitializeWiiRoot(bool use_temporary)
{ {
File::SetUserPath(D_SESSION_WIIROOT_IDX, File::GetUserPath(D_WIIROOT_IDX)); File::SetUserPath(D_SESSION_WIIROOT_IDX, File::GetUserPath(D_WIIROOT_IDX));
} }
InitializeDeterministicWiiSaves();
} }
void ShutdownWiiRoot() void ShutdownWiiRoot()