Merge pull request #8570 from Techjar/always-sync-sram

Core/NetPlayServer: Sync SRAM on every game start
This commit is contained in:
JMC47 2020-01-21 20:55:52 -05:00 committed by GitHub
commit f0669f5aa6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 15 deletions

View File

@ -434,21 +434,6 @@ unsigned int NetPlayServer::OnConnect(ENetPeer* socket, sf::Packet& rpac)
spac << m_host_input_authority; spac << m_host_input_authority;
Send(player.socket, spac); 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 // sync values with new client
for (const auto& p : m_players) for (const auto& p : m_players)
{ {
@ -1275,6 +1260,21 @@ bool NetPlayServer::StartGame()
const std::string region = SConfig::GetDirectoryForRegion( const std::string region = SConfig::GetDirectoryForRegion(
SConfig::ToGameCubeRegion(m_dialog->FindGameFile(m_selected_game)->GetRegion())); 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 // tell clients to start game
sf::Packet spac; sf::Packet spac;
spac << static_cast<MessageId>(NP_MSG_START_GAME); spac << static_cast<MessageId>(NP_MSG_START_GAME);