4 changes: 3 additions & 1 deletion Source/Core/Core/NetPlayProto.h
Expand Up @@ -12,6 +12,7 @@
#include "Core/Config/SYSCONFSettings.h"
#include "Core/HW/EXI/EXI.h"
#include "Core/HW/EXI/EXI_Device.h"
#include "Core/HW/Sram.h"

namespace DiscIO
{
Expand Down Expand Up @@ -105,6 +106,8 @@ struct NetSettings
bool use_fma = false;
bool hide_remote_gbas = false;

Sram sram;

// These aren't sent over the network directly
bool is_hosting = false;
std::array<std::string, 4> gba_rom_paths{};
Expand Down Expand Up @@ -180,7 +183,6 @@ enum class MessageID : u8
Pong = 0xE1,
PlayerPingData = 0xE2,

SyncGCSRAM = 0xF0,
SyncSaveData = 0xF1,
SyncCodes = 0xF2,
};
Expand Down
20 changes: 6 additions & 14 deletions Source/Core/Core/NetPlayServer.cpp
Expand Up @@ -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_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;
Expand Down Expand Up @@ -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;
Expand Down
7 changes: 7 additions & 0 deletions Source/Core/Core/System.cpp
Expand Up @@ -10,6 +10,7 @@
#include "Core/HW/AudioInterface.h"
#include "Core/HW/DVD/DVDInterface.h"
#include "Core/HW/DVD/DVDThread.h"
#include "Core/HW/Sram.h"

namespace Core
{
Expand All @@ -22,6 +23,7 @@ struct System::Impl
AudioInterface::AudioInterfaceState m_audio_interface_state;
DVDInterface::DVDInterfaceState m_dvd_interface_state;
DVDThread::DVDThreadState m_dvd_thread_state;
Sram m_sram;
};

System::System() : m_impl{std::make_unique<Impl>()}
Expand Down Expand Up @@ -80,4 +82,9 @@ DVDThread::DVDThreadState& System::GetDVDThreadState() const
{
return m_impl->m_dvd_thread_state;
}

Sram& System::GetSRAM() const
{
return m_impl->m_sram;
}
} // namespace Core
2 changes: 2 additions & 0 deletions Source/Core/Core/System.h
Expand Up @@ -6,6 +6,7 @@
#include <memory>

class SoundStream;
struct Sram;

namespace AudioInterface
{
Expand Down Expand Up @@ -56,6 +57,7 @@ class System
AudioInterface::AudioInterfaceState& GetAudioInterfaceState() const;
DVDInterface::DVDInterfaceState& GetDVDInterfaceState() const;
DVDThread::DVDThreadState& GetDVDThreadState() const;
Sram& GetSRAM() const;

private:
System();
Expand Down