Core: Pass Netplay SRAM through boot process.

This removes the Netplay classes touching emulated hardware structures before emulation even starts.
This commit is contained in:
Admiral H. Curtiss
2022-09-13 04:44:59 +02:00
parent 9963637463
commit 0a517ebdbd
12 changed files with 37 additions and 56 deletions

View File

@ -1436,20 +1436,9 @@ bool NetPlayServer::StartGame()
const std::string region = Config::GetDirectoryForRegion(
Config::ToGameCubeRegion(m_dialog->FindGameFile(m_selected_game_identifier)->GetRegion()));
// sync GC SRAM with clients
if (!g_SRAM_netplay_initialized)
{
SConfig::GetInstance().m_strSRAM = File::GetUserPath(F_GCSRAM_IDX);
InitSRAM(&g_SRAM, SConfig::GetInstance().m_strSRAM);
g_SRAM_netplay_initialized = true;
}
sf::Packet srampac;
srampac << MessageID::SyncGCSRAM;
for (size_t i = 0; i < sizeof(g_SRAM) - offsetof(Sram, settings); ++i)
{
srampac << g_SRAM[offsetof(Sram, settings) + i];
}
SendAsyncToClients(std::move(srampac), 1);
// load host's GC SRAM
SConfig::GetInstance().m_strSRAM = File::GetUserPath(F_GCSRAM_IDX);
InitSRAM(&m_settings.sram, SConfig::GetInstance().m_strSRAM);
// tell clients to start game
sf::Packet spac;
@ -1544,6 +1533,9 @@ bool NetPlayServer::StartGame()
spac << m_settings.use_fma;
spac << m_settings.hide_remote_gbas;
for (size_t i = 0; i < sizeof(m_settings.sram); ++i)
spac << m_settings.sram[i];
SendAsyncToClients(std::move(spac));
m_start_pending = false;