diff options
| author | Techjar <tecknojar@gmail.com> | 2020-01-19 03:42:23 -0500 |
|---|---|---|
| committer | Techjar <tecknojar@gmail.com> | 2020-01-19 03:57:41 -0500 |
| commit | de27dcebf62363ac482f62532f43f2f69e3315ea (patch) | |
| tree | 68e59379196b527230a7de5dcb744862350fdb36 /Source/Core | |
| parent | c74b1140a58d20a3f9f0ba3a0f7077d2e6231f12 (diff) | |
Core/NetPlayServer: Sync SRAM on every game start
This solves the issue of booting games locally while connected to
NetPlay causing desync.
Diffstat (limited to 'Source/Core')
| -rw-r--r-- | Source/Core/Core/NetPlayServer.cpp | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/Source/Core/Core/NetPlayServer.cpp b/Source/Core/Core/NetPlayServer.cpp index 4789ef8900..b99be9a4dc 100644 --- a/Source/Core/Core/NetPlayServer.cpp +++ b/Source/Core/Core/NetPlayServer.cpp @@ -434,21 +434,6 @@ unsigned int NetPlayServer::OnConnect(ENetPeer* socket, sf::Packet& rpac) spac << m_host_input_authority; Send(player.socket, spac); - // sync GC SRAM with new client - if (!g_SRAM_netplay_initialized) - { - SConfig::GetInstance().m_strSRAM = File::GetUserPath(F_GCSRAM_IDX); - InitSRAM(); - g_SRAM_netplay_initialized = true; - } - spac.clear(); - spac << static_cast<MessageId>(NP_MSG_SYNC_GC_SRAM); - for (size_t i = 0; i < sizeof(g_SRAM) - offsetof(Sram, settings); ++i) - { - spac << g_SRAM[offsetof(Sram, settings) + i]; - } - Send(player.socket, spac); - // sync values with new client for (const auto& p : m_players) { @@ -1275,6 +1260,21 @@ bool NetPlayServer::StartGame() const std::string region = SConfig::GetDirectoryForRegion( SConfig::ToGameCubeRegion(m_dialog->FindGameFile(m_selected_game)->GetRegion())); + // sync GC SRAM with clients + if (!g_SRAM_netplay_initialized) + { + SConfig::GetInstance().m_strSRAM = File::GetUserPath(F_GCSRAM_IDX); + InitSRAM(); + g_SRAM_netplay_initialized = true; + } + sf::Packet srampac; + srampac << static_cast<MessageId>(NP_MSG_SYNC_GC_SRAM); + 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); + // tell clients to start game sf::Packet spac; spac << static_cast<MessageId>(NP_MSG_START_GAME); |
