NetPlay: Pass Wii FS sync data directly to game boot logic instead of indirectly through globals.
This commit is contained in:
parent
894773f607
commit
6350c93ae1
|
@ -76,8 +76,6 @@ using namespace WiimoteCommon;
|
|||
|
||||
static std::mutex crit_netplay_client;
|
||||
static NetPlayClient* netplay_client = nullptr;
|
||||
static std::unique_ptr<IOS::HLE::FS::FileSystem> s_wii_sync_fs;
|
||||
static std::vector<u64> s_wii_sync_titles;
|
||||
static bool s_si_poll_batching = false;
|
||||
|
||||
// called from ---GUI--- thread
|
||||
|
@ -1192,7 +1190,7 @@ void NetPlayClient::OnSyncSaveDataWii(sf::Packet& packet)
|
|||
}
|
||||
}
|
||||
|
||||
SetWiiSyncData(std::move(temp_fs), titles);
|
||||
SetWiiSyncData(std::move(temp_fs), std::move(titles));
|
||||
SyncSaveDataResponse(true);
|
||||
}
|
||||
|
||||
|
@ -1722,7 +1720,14 @@ bool NetPlayClient::StartGame(const std::string& path)
|
|||
}
|
||||
|
||||
// boot game
|
||||
m_dialog->BootGame(path, nullptr);
|
||||
auto boot_session_data = std::make_unique<BootSessionData>();
|
||||
boot_session_data->SetWiiSyncData(std::move(m_wii_sync_fs), std::move(m_wii_sync_titles), [] {
|
||||
// on emulation end clean up the Wii save sync directory -- see OnSyncSaveDataWii()
|
||||
const std::string path = File::GetUserPath(D_USER_IDX) + "Wii" GC_MEMCARD_NETPLAY DIR_SEP;
|
||||
if (File::Exists(path))
|
||||
File::DeleteDirRecursively(path);
|
||||
});
|
||||
m_dialog->BootGame(path, std::move(boot_session_data));
|
||||
|
||||
UpdateDevices();
|
||||
|
||||
|
@ -2252,8 +2257,6 @@ bool NetPlayClient::StopGame()
|
|||
// stop game
|
||||
m_dialog->StopGame();
|
||||
|
||||
ClearWiiSyncData();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2497,6 +2500,13 @@ void NetPlayClient::AdjustPadBufferSize(const unsigned int size)
|
|||
m_dialog->OnPadBufferChanged(size);
|
||||
}
|
||||
|
||||
void NetPlayClient::SetWiiSyncData(std::unique_ptr<IOS::HLE::FS::FileSystem> fs,
|
||||
std::vector<u64> titles)
|
||||
{
|
||||
m_wii_sync_fs = std::move(fs);
|
||||
m_wii_sync_titles = std::move(titles);
|
||||
}
|
||||
|
||||
SyncIdentifier NetPlayClient::GetSDCardIdentifier()
|
||||
{
|
||||
return SyncIdentifier{{}, "sd", {}, {}, {}, {}};
|
||||
|
@ -2539,33 +2549,6 @@ const NetSettings& GetNetSettings()
|
|||
return netplay_client->GetNetSettings();
|
||||
}
|
||||
|
||||
IOS::HLE::FS::FileSystem* GetWiiSyncFS()
|
||||
{
|
||||
return s_wii_sync_fs.get();
|
||||
}
|
||||
|
||||
const std::vector<u64>& GetWiiSyncTitles()
|
||||
{
|
||||
return s_wii_sync_titles;
|
||||
}
|
||||
|
||||
void SetWiiSyncData(std::unique_ptr<IOS::HLE::FS::FileSystem> fs, const std::vector<u64>& titles)
|
||||
{
|
||||
s_wii_sync_fs = std::move(fs);
|
||||
s_wii_sync_titles.insert(s_wii_sync_titles.end(), titles.begin(), titles.end());
|
||||
}
|
||||
|
||||
void ClearWiiSyncData()
|
||||
{
|
||||
// We're just assuming it will always be here because it is
|
||||
const std::string path = File::GetUserPath(D_USER_IDX) + "Wii" GC_MEMCARD_NETPLAY DIR_SEP;
|
||||
if (File::Exists(path))
|
||||
File::DeleteDirRecursively(path);
|
||||
|
||||
s_wii_sync_fs.reset();
|
||||
s_wii_sync_titles.clear();
|
||||
}
|
||||
|
||||
void SetSIPollBatching(bool state)
|
||||
{
|
||||
s_si_poll_batching = state;
|
||||
|
|
|
@ -25,6 +25,11 @@
|
|||
|
||||
class BootSessionData;
|
||||
|
||||
namespace IOS::HLE::FS
|
||||
{
|
||||
class FileSystem;
|
||||
}
|
||||
|
||||
namespace UICommon
|
||||
{
|
||||
class GameFile;
|
||||
|
@ -80,6 +85,8 @@ public:
|
|||
const std::vector<int>& players) = 0;
|
||||
virtual void HideChunkedProgressDialog() = 0;
|
||||
virtual void SetChunkedProgress(int pid, u64 progress) = 0;
|
||||
|
||||
virtual void SetHostWiiSyncTitles(std::vector<u64> titles) = 0;
|
||||
};
|
||||
|
||||
class Player
|
||||
|
@ -150,6 +157,8 @@ public:
|
|||
|
||||
void AdjustPadBufferSize(unsigned int size);
|
||||
|
||||
void SetWiiSyncData(std::unique_ptr<IOS::HLE::FS::FileSystem> fs, std::vector<u64> titles);
|
||||
|
||||
static SyncIdentifier GetSDCardIdentifier();
|
||||
|
||||
protected:
|
||||
|
@ -316,6 +325,9 @@ private:
|
|||
|
||||
u64 m_initial_rtc = 0;
|
||||
u32 m_timebase_frame = 0;
|
||||
|
||||
std::unique_ptr<IOS::HLE::FS::FileSystem> m_wii_sync_fs;
|
||||
std::vector<u64> m_wii_sync_titles;
|
||||
};
|
||||
|
||||
void NetPlay_Enable(NetPlayClient* const np);
|
||||
|
|
|
@ -257,10 +257,6 @@ bool IsNetPlayRunning();
|
|||
// Precondition: A netplay client instance must be present. In other words,
|
||||
// IsNetPlayRunning() must be true before calling this.
|
||||
const NetSettings& GetNetSettings();
|
||||
IOS::HLE::FS::FileSystem* GetWiiSyncFS();
|
||||
const std::vector<u64>& GetWiiSyncTitles();
|
||||
void SetWiiSyncData(std::unique_ptr<IOS::HLE::FS::FileSystem> fs, const std::vector<u64>& titles);
|
||||
void ClearWiiSyncData();
|
||||
void SetSIPollBatching(bool state);
|
||||
void SendPowerButtonEvent();
|
||||
bool IsSyncingAllWiiSaves();
|
||||
|
|
|
@ -1819,7 +1819,7 @@ bool NetPlayServer::SyncSaveData()
|
|||
}
|
||||
|
||||
// Set titles for host-side loading in WiiRoot
|
||||
SetWiiSyncData(nullptr, titles);
|
||||
m_dialog->SetHostWiiSyncTitles(std::move(titles));
|
||||
|
||||
SendChunkedToClients(std::move(pac), 1, "Wii Save Synchronization");
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#ifdef HAS_LIBMGBA
|
||||
#include "Core/HW/GBACore.h"
|
||||
#endif
|
||||
#include "Core/IOS/FS/FileSystem.h"
|
||||
#include "Core/NetPlayServer.h"
|
||||
#include "Core/SyncIdentifier.h"
|
||||
|
||||
|
@ -1177,3 +1178,10 @@ void NetPlayDialog::SetChunkedProgress(const int pid, const u64 progress)
|
|||
m_chunked_progress_dialog->SetProgress(pid, progress);
|
||||
});
|
||||
}
|
||||
|
||||
void NetPlayDialog::SetHostWiiSyncTitles(std::vector<u64> titles)
|
||||
{
|
||||
auto client = Settings::Instance().GetNetPlayClient();
|
||||
if (client)
|
||||
client->SetWiiSyncData(nullptr, std::move(titles));
|
||||
}
|
||||
|
|
|
@ -94,6 +94,9 @@ public:
|
|||
const std::vector<int>& players) override;
|
||||
void HideChunkedProgressDialog() override;
|
||||
void SetChunkedProgress(int pid, u64 progress) override;
|
||||
|
||||
void SetHostWiiSyncTitles(std::vector<u64> titles) override;
|
||||
|
||||
signals:
|
||||
void Stop();
|
||||
|
||||
|
|
Loading…
Reference in New Issue