Netplay: Sync GameCube SRAM.
This commit is contained in:
parent
9e00ddbdf7
commit
abb65515b9
|
@ -35,6 +35,7 @@
|
|||
#include "Core/NetPlayProto.h"
|
||||
#include "Core/HW/EXI.h"
|
||||
#include "Core/HW/SI.h"
|
||||
#include "Core/HW/Sram.h"
|
||||
#include "Core/HW/WiimoteReal/WiimoteReal.h"
|
||||
#include "DiscIO/Volume.h"
|
||||
#include "DiscIO/VolumeCreator.h"
|
||||
|
@ -246,6 +247,8 @@ bool BootCore(const std::string& _rFilename)
|
|||
StartUp.bDSPHLE = g_NetPlaySettings.m_DSPHLE;
|
||||
StartUp.bEnableMemcardSaving = g_NetPlaySettings.m_WriteToMemcard;
|
||||
StartUp.iCPUCore = g_NetPlaySettings.m_CPUcore;
|
||||
StartUp.SelectedLanguage = g_NetPlaySettings.m_SelectedLanguage;
|
||||
StartUp.bOverrideGCLanguage = g_NetPlaySettings.m_OverrideGCLanguage;
|
||||
SConfig::GetInstance().m_DSPEnableJIT = g_NetPlaySettings.m_DSPEnableJIT;
|
||||
SConfig::GetInstance().m_OCEnable = g_NetPlaySettings.m_OCEnable;
|
||||
SConfig::GetInstance().m_OCFactor = g_NetPlaySettings.m_OCFactor;
|
||||
|
@ -254,6 +257,10 @@ bool BootCore(const std::string& _rFilename)
|
|||
config_cache.bSetEXIDevice[0] = true;
|
||||
config_cache.bSetEXIDevice[1] = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_SRAM_netplay_initialized = false;
|
||||
}
|
||||
|
||||
SConfig::GetInstance().m_SYSCONF->SetData("IPL.PGS", StartUp.bProgressive);
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "Core/PowerPC/PowerPC.h"
|
||||
|
||||
SRAM g_SRAM;
|
||||
bool g_SRAM_netplay_initialized = false;
|
||||
|
||||
namespace ExpansionInterface
|
||||
{
|
||||
|
@ -30,7 +31,11 @@ static void UpdateInterruptsCallback(u64 userdata, int cycles_late);
|
|||
|
||||
void Init()
|
||||
{
|
||||
InitSRAM();
|
||||
if (!g_SRAM_netplay_initialized)
|
||||
{
|
||||
InitSRAM();
|
||||
}
|
||||
|
||||
for (u32 i = 0; i < MAX_EXI_CHANNELS; i++)
|
||||
g_Channels[i] = new CEXIChannel(i);
|
||||
|
||||
|
|
|
@ -128,8 +128,15 @@ CEXIIPL::~CEXIIPL()
|
|||
m_pIPL = nullptr;
|
||||
|
||||
// SRAM
|
||||
File::IOFile file(SConfig::GetInstance().m_strSRAM, "wb");
|
||||
file.WriteArray(&g_SRAM, 1);
|
||||
if (!g_SRAM_netplay_initialized)
|
||||
{
|
||||
File::IOFile file(SConfig::GetInstance().m_strSRAM, "wb");
|
||||
file.WriteArray(&g_SRAM, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_SRAM_netplay_initialized = false;
|
||||
}
|
||||
}
|
||||
void CEXIIPL::DoState(PointerWrap &p)
|
||||
{
|
||||
|
|
|
@ -84,3 +84,4 @@ void FixSRAMChecksums();
|
|||
|
||||
extern SRAM sram_dump;
|
||||
extern SRAM g_SRAM;
|
||||
extern bool g_SRAM_netplay_initialized;
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "Core/HW/SI_DeviceDanceMat.h"
|
||||
#include "Core/HW/SI_DeviceGCController.h"
|
||||
#include "Core/HW/SI_DeviceGCSteeringWheel.h"
|
||||
#include "Core/HW/Sram.h"
|
||||
#include "Core/HW/WiimoteEmu/WiimoteEmu.h"
|
||||
#include "Core/HW/WiimoteReal/WiimoteReal.h"
|
||||
#include "Core/IPC_HLE/WII_IPC_HLE_Device_usb.h"
|
||||
|
@ -378,6 +379,8 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet)
|
|||
packet >> m_current_game;
|
||||
packet >> g_NetPlaySettings.m_CPUthread;
|
||||
packet >> g_NetPlaySettings.m_CPUcore;
|
||||
packet >> g_NetPlaySettings.m_SelectedLanguage;
|
||||
packet >> g_NetPlaySettings.m_OverrideGCLanguage;
|
||||
packet >> g_NetPlaySettings.m_DSPEnableJIT;
|
||||
packet >> g_NetPlaySettings.m_DSPHLE;
|
||||
packet >> g_NetPlaySettings.m_WriteToMemcard;
|
||||
|
@ -462,6 +465,22 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet)
|
|||
}
|
||||
break;
|
||||
|
||||
case NP_MSG_SYNC_GC_SRAM:
|
||||
{
|
||||
u8 sram[sizeof(g_SRAM.p_SRAM)];
|
||||
for (int i = 0; i < sizeof(g_SRAM.p_SRAM); ++i)
|
||||
{
|
||||
packet >> sram[i];
|
||||
}
|
||||
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lkg(m_crit.game);
|
||||
memcpy(g_SRAM.p_SRAM, sram, sizeof(g_SRAM.p_SRAM));
|
||||
g_SRAM_netplay_initialized = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
PanicAlertT("Unknown message received with id : %d", mid);
|
||||
break;
|
||||
|
|
|
@ -12,6 +12,8 @@ struct NetSettings
|
|||
{
|
||||
bool m_CPUthread;
|
||||
int m_CPUcore;
|
||||
int m_SelectedLanguage;
|
||||
bool m_OverrideGCLanguage;
|
||||
bool m_DSPHLE;
|
||||
bool m_DSPEnableJIT;
|
||||
bool m_WriteToMemcard;
|
||||
|
@ -29,7 +31,7 @@ struct Rpt : public std::vector<u8>
|
|||
|
||||
typedef std::vector<u8> NetWiimote;
|
||||
|
||||
#define NETPLAY_VERSION "Dolphin NetPlay 2015-03-10"
|
||||
#define NETPLAY_VERSION "Dolphin NetPlay 2015-06-14"
|
||||
|
||||
extern u64 g_netplay_initial_gctime;
|
||||
|
||||
|
@ -62,6 +64,8 @@ enum
|
|||
NP_MSG_PING = 0xE0,
|
||||
NP_MSG_PONG = 0xE1,
|
||||
NP_MSG_PLAYER_PING_DATA = 0xE2,
|
||||
|
||||
NP_MSG_SYNC_GC_SRAM = 0xF0,
|
||||
};
|
||||
|
||||
typedef u8 MessageId;
|
||||
|
|
|
@ -5,12 +5,15 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
#include "Common/ENetUtil.h"
|
||||
#include "Common/FileUtil.h"
|
||||
#include "Common/IniFile.h"
|
||||
#include "Common/StdMakeUnique.h"
|
||||
#include "Common/StringUtil.h"
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "Core/NetPlayClient.h" //for NetPlayUI
|
||||
#include "Core/NetPlayServer.h"
|
||||
#include "Core/HW/EXI_DeviceIPL.h"
|
||||
#include "Core/HW/Sram.h"
|
||||
#include "InputCommon/GCPadStatus.h"
|
||||
#if !defined(_WIN32)
|
||||
#include <sys/types.h>
|
||||
|
@ -303,6 +306,21 @@ unsigned int NetPlayServer::OnConnect(ENetPeer* socket)
|
|||
spac << (u32)m_target_buffer_size;
|
||||
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 << (MessageId)NP_MSG_SYNC_GC_SRAM;
|
||||
for (int i = 0; i < sizeof(g_SRAM.p_SRAM); ++i)
|
||||
{
|
||||
spac << g_SRAM.p_SRAM[i];
|
||||
}
|
||||
Send(player.socket, spac);
|
||||
|
||||
// sync values with new client
|
||||
for (const auto& p : m_players)
|
||||
{
|
||||
|
@ -697,6 +715,8 @@ bool NetPlayServer::StartGame()
|
|||
*spac << m_current_game;
|
||||
*spac << m_settings.m_CPUthread;
|
||||
*spac << m_settings.m_CPUcore;
|
||||
*spac << m_settings.m_SelectedLanguage;
|
||||
*spac << m_settings.m_OverrideGCLanguage;
|
||||
*spac << m_settings.m_DSPEnableJIT;
|
||||
*spac << m_settings.m_DSPHLE;
|
||||
*spac << m_settings.m_WriteToMemcard;
|
||||
|
|
|
@ -252,6 +252,8 @@ void NetPlayDialog::GetNetSettings(NetSettings &settings)
|
|||
SConfig &instance = SConfig::GetInstance();
|
||||
settings.m_CPUthread = instance.bCPUThread;
|
||||
settings.m_CPUcore = instance.iCPUCore;
|
||||
settings.m_SelectedLanguage = instance.SelectedLanguage;
|
||||
settings.m_OverrideGCLanguage = instance.bOverrideGCLanguage;
|
||||
settings.m_DSPHLE = instance.bDSPHLE;
|
||||
settings.m_DSPEnableJIT = instance.m_DSPEnableJIT;
|
||||
settings.m_WriteToMemcard = m_memcard_write->GetValue();
|
||||
|
|
Loading…
Reference in New Issue