From e4767aec5574feb8c8442e4626674bc00966f2e8 Mon Sep 17 00:00:00 2001 From: Rachel Bryk Date: Fri, 19 Jul 2013 18:48:27 -0400 Subject: [PATCH] Sync some important settings with server during netplay. --- Source/Core/Core/Src/BootManager.cpp | 12 +++++++++++- Source/Core/Core/Src/NetPlay.cpp | 19 ++++++++++++++++++- Source/Core/Core/Src/NetPlay.h | 12 +++++++++++- Source/Core/Core/Src/NetPlayClient.cpp | 11 ++++++++--- Source/Core/Core/Src/NetPlayServer.cpp | 8 +++++++- 5 files changed, 55 insertions(+), 7 deletions(-) diff --git a/Source/Core/Core/Src/BootManager.cpp b/Source/Core/Core/Src/BootManager.cpp index 33f656ca4d..871af5059c 100644 --- a/Source/Core/Core/Src/BootManager.cpp +++ b/Source/Core/Core/Src/BootManager.cpp @@ -34,6 +34,7 @@ #include "Host.h" #include "VideoBackendBase.h" #include "Movie.h" +#include "NetPlay.h" namespace BootManager { @@ -42,7 +43,7 @@ namespace BootManager // Apply fire liberally struct ConfigCache { - bool valid, bCPUThread, bSkipIdle, bEnableFPRF, bMMU, bDCBZOFF, + bool valid, bCPUThread, bSkipIdle, bEnableFPRF, bMMU, bDCBZOFF, m_EnableJIT, bVBeamSpeedHack, bSyncGPU, bFastDiscSpeed, bMergeBlocks, bDSPHLE, bHLE_BS2; int iTLBHack, iCPUCore; std::string strBackend; @@ -91,6 +92,7 @@ bool BootCore(const std::string& _rFilename) config_cache.bDSPHLE = StartUp.bDSPHLE; config_cache.strBackend = StartUp.m_strVideoBackend; config_cache.bHLE_BS2 = StartUp.bHLE_BS2; + config_cache.m_EnableJIT = SConfig::GetInstance().m_EnableJIT; // General settings game_ini.Get("Core", "CPUThread", &StartUp.bCPUThread, StartUp.bCPUThread); @@ -134,6 +136,13 @@ bool BootCore(const std::string& _rFilename) } } + if (NetPlay::GetNetPlayPtr()) + { + StartUp.bCPUThread = g_NetPlaySettings.m_CPUthread; + StartUp.bDSPHLE = g_NetPlaySettings.m_DSPHLE; + SConfig::GetInstance().m_EnableJIT = g_NetPlaySettings.m_DSPEnableJIT; + } + // Run the game // Init the core if (!Core::Init()) @@ -170,6 +179,7 @@ void Stop() StartUp.m_strVideoBackend = config_cache.strBackend; VideoBackend::ActivateBackend(StartUp.m_strVideoBackend); StartUp.bHLE_BS2 = config_cache.bHLE_BS2; + SConfig::GetInstance().m_EnableJIT = config_cache.m_EnableJIT; } } diff --git a/Source/Core/Core/Src/NetPlay.cpp b/Source/Core/Core/Src/NetPlay.cpp index de788d7657..b9c5e95a5b 100644 --- a/Source/Core/Core/Src/NetPlay.cpp +++ b/Source/Core/Core/Src/NetPlay.cpp @@ -15,9 +15,11 @@ #include "HW/EXI_DeviceIPL.h" // for wiimote/ OSD messages #include "Core.h" +#include "ConfigManager.h" std::mutex crit_netplay_ptr; static NetPlay* netplay_ptr = NULL; +NetSettings g_NetPlaySettings; #define RPT_SIZE_HACK (1 << 16) @@ -281,6 +283,21 @@ u8 NetPlay::GetPadNum(u8 numPAD) return i; } +void NetPlay::GetNetSettings() +{ + SConfig &instance = SConfig::GetInstance(); + g_NetPlaySettings.m_CPUthread = instance.m_LocalCoreStartupParameter.bCPUThread; + g_NetPlaySettings.m_DSPHLE = instance.m_LocalCoreStartupParameter.bDSPHLE; + g_NetPlaySettings.m_DSPEnableJIT = instance.m_EnableJIT; + for (int i = 0; i < 4; ++i) + { + if (SConfig::GetInstance().m_SIDevice[i] == SIDEVICE_GC_CONTROLLER) + g_NetPlaySettings.m_Controllers |= (1 << i); + if (g_wiimote_sources[i] != WIIMOTE_SRC_NONE) + g_NetPlaySettings.m_Controllers |= (1 << (i + 4)); + } +} + // stuff hacked into dolphin // called from ---CPU--- thread @@ -394,5 +411,5 @@ NetPlay* NetPlay::GetNetPlayPtr() bool NetPlay::IsUsingPad(int pad) { - return netplay_ptr->m_local_player->pad_map[pad] != -1; + return ((g_NetPlaySettings.m_Controllers & (1 << pad)) != 0); } \ No newline at end of file diff --git a/Source/Core/Core/Src/NetPlay.h b/Source/Core/Core/Src/NetPlay.h index 0ea5cb1b3f..08199b21a3 100644 --- a/Source/Core/Core/Src/NetPlay.h +++ b/Source/Core/Core/Src/NetPlay.h @@ -31,6 +31,15 @@ public: u32 nLo; }; +struct NetSettings +{ + bool m_CPUthread; + bool m_DSPHLE; + bool m_DSPEnableJIT; + u8 m_Controllers; +}; +extern NetSettings g_NetPlaySettings; + struct Rpt : public std::vector { u16 channel; @@ -38,7 +47,7 @@ struct Rpt : public std::vector typedef std::vector NetWiimote; -#define NETPLAY_VERSION "Dolphin NetPlay 2013-04-11" +#define NETPLAY_VERSION "Dolphin NetPlay 2013-07-19" // messages enum @@ -125,6 +134,7 @@ public: protected: //void GetBufferedPad(const u8 pad_nb, NetPad* const netvalues); void ClearBuffers(); + void GetNetSettings(); virtual void SendPadState(const PadMapping local_nb, const NetPad& np) = 0; struct diff --git a/Source/Core/Core/Src/NetPlayClient.cpp b/Source/Core/Core/Src/NetPlayClient.cpp index aa7a678230..fb60764256 100644 --- a/Source/Core/Core/Src/NetPlayClient.cpp +++ b/Source/Core/Core/Src/NetPlayClient.cpp @@ -193,6 +193,10 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet) { std::lock_guard lkg(m_crit.game); packet >> m_current_game; + packet >> g_NetPlaySettings.m_CPUthread; + packet >> g_NetPlaySettings.m_DSPEnableJIT; + packet >> g_NetPlaySettings.m_DSPHLE; + packet >> g_NetPlaySettings.m_Controllers; } m_dialog->OnMsgStartGame(); @@ -317,13 +321,14 @@ bool NetPlayClient::StartGame(const std::string &path) { std::lock_guard lkg(m_crit.game); - if (false == NetPlay::StartGame(path)) - return false; - // tell server i started the game sf::Packet spac; spac << (MessageId)NP_MSG_START_GAME; spac << m_current_game; + spac << (char *)&g_NetPlaySettings; + + if (false == NetPlay::StartGame(path)) + return false; std::lock_guard lks(m_crit.send); m_socket.Send(spac); diff --git a/Source/Core/Core/Src/NetPlayServer.cpp b/Source/Core/Core/Src/NetPlayServer.cpp index 850954ac55..90ac6b7f59 100644 --- a/Source/Core/Core/Src/NetPlayServer.cpp +++ b/Source/Core/Core/Src/NetPlayServer.cpp @@ -590,6 +590,7 @@ bool NetPlayServer::StartGame(const std::string &path) { std::lock_guard lkg(m_crit.game); + GetNetSettings(); if (false == NetPlay::StartGame(path)) return false; @@ -602,7 +603,12 @@ bool NetPlayServer::StartGame(const std::string &path) // tell clients to start game sf::Packet spac; spac << (MessageId)NP_MSG_START_GAME; - spac << m_current_game; + spac << NetPlay::m_current_game; + spac << g_NetPlaySettings.m_CPUthread; + spac << g_NetPlaySettings.m_DSPEnableJIT; + spac << g_NetPlaySettings.m_DSPHLE; + spac << g_NetPlaySettings.m_Controllers; + std::lock_guard lkp(m_crit.players); std::lock_guard lks(m_crit.send);