From 0e1efd7d3894799aac3ccaf9eeadf22d0cdbdc88 Mon Sep 17 00:00:00 2001 From: Rachel Bryk Date: Fri, 19 Jul 2013 15:01:04 -0400 Subject: [PATCH 1/5] Poll the controllers with the same timing as movies for netplay. Might help prevent desyncs. --- Source/Core/Core/Src/HW/SI.cpp | 3 ++- Source/Core/Core/Src/NetPlay.cpp | 5 +++++ Source/Core/Core/Src/NetPlay.h | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Source/Core/Core/Src/HW/SI.cpp b/Source/Core/Core/Src/HW/SI.cpp index f4fcec5743..5d34cef284 100644 --- a/Source/Core/Core/Src/HW/SI.cpp +++ b/Source/Core/Core/Src/HW/SI.cpp @@ -7,6 +7,7 @@ #include "../ConfigManager.h" #include "../CoreTiming.h" #include "../Movie.h" +#include "../NetPlay.h" #include "SystemTimers.h" #include "ProcessorInterface.h" @@ -641,7 +642,7 @@ void RunSIBuffer() int GetTicksToNextSIPoll() { // Poll for input at regular intervals (once per frame) when playing or recording a movie - if (Movie::IsPlayingInput() || Movie::IsRecordingInput()) + if (Movie::IsPlayingInput() || Movie::IsRecordingInput() || NetPlay::GetNetPlayPtr()) { return SystemTimers::GetTicksPerSecond() / VideoInterface::TargetRefreshRate; } diff --git a/Source/Core/Core/Src/NetPlay.cpp b/Source/Core/Core/Src/NetPlay.cpp index 7f4b838ffc..56944dec00 100644 --- a/Source/Core/Core/Src/NetPlay.cpp +++ b/Source/Core/Core/Src/NetPlay.cpp @@ -386,3 +386,8 @@ bool CWII_IPC_HLE_WiiMote::NetPlay_WiimoteInput(int, u16, const void*, u32&) else return false; } + +NetPlay* NetPlay::GetNetPlayPtr() +{ + return netplay_ptr; +} diff --git a/Source/Core/Core/Src/NetPlay.h b/Source/Core/Core/Src/NetPlay.h index 7bed7c6421..05d999e604 100644 --- a/Source/Core/Core/Src/NetPlay.h +++ b/Source/Core/Core/Src/NetPlay.h @@ -119,6 +119,7 @@ public: //void PushPadStates(unsigned int count); u8 GetPadNum(u8 numPAD); + static NetPlay* GetNetPlayPtr(); protected: //void GetBufferedPad(const u8 pad_nb, NetPad* const netvalues); From 919e54c6951fe1150f865e243afadb91557abf9d Mon Sep 17 00:00:00 2001 From: Rachel Bryk Date: Fri, 19 Jul 2013 15:53:20 -0400 Subject: [PATCH 2/5] Automatically connect the appropriate controllers for netplay. --- Source/Core/Core/Src/HW/SI.cpp | 2 ++ Source/Core/Core/Src/NetPlay.cpp | 5 +++++ Source/Core/Core/Src/NetPlay.h | 1 + 3 files changed, 8 insertions(+) diff --git a/Source/Core/Core/Src/HW/SI.cpp b/Source/Core/Core/Src/HW/SI.cpp index 5d34cef284..738b97917d 100644 --- a/Source/Core/Core/Src/HW/SI.cpp +++ b/Source/Core/Core/Src/HW/SI.cpp @@ -262,6 +262,8 @@ void Init() if (Movie::IsRecordingInput() || Movie::IsPlayingInput()) AddDevice(Movie::IsUsingPad(i) ? (Movie::IsUsingBongo(i) ? SIDEVICE_GC_TARUKONGA : SIDEVICE_GC_CONTROLLER) : SIDEVICE_NONE, i); + else if (NetPlay::GetNetPlayPtr()) + AddDevice(NetPlay::IsUsingPad(i) ? SIDEVICE_GC_CONTROLLER : SIDEVICE_NONE, i); else AddDevice(SConfig::GetInstance().m_SIDevice[i], i); } diff --git a/Source/Core/Core/Src/NetPlay.cpp b/Source/Core/Core/Src/NetPlay.cpp index 56944dec00..de788d7657 100644 --- a/Source/Core/Core/Src/NetPlay.cpp +++ b/Source/Core/Core/Src/NetPlay.cpp @@ -391,3 +391,8 @@ NetPlay* NetPlay::GetNetPlayPtr() { return netplay_ptr; } + +bool NetPlay::IsUsingPad(int pad) +{ + return netplay_ptr->m_local_player->pad_map[pad] != -1; +} \ No newline at end of file diff --git a/Source/Core/Core/Src/NetPlay.h b/Source/Core/Core/Src/NetPlay.h index 05d999e604..0ea5cb1b3f 100644 --- a/Source/Core/Core/Src/NetPlay.h +++ b/Source/Core/Core/Src/NetPlay.h @@ -120,6 +120,7 @@ public: u8 GetPadNum(u8 numPAD); static NetPlay* GetNetPlayPtr(); + static bool IsUsingPad(int pad); protected: //void GetBufferedPad(const u8 pad_nb, NetPad* const netvalues); From e4767aec5574feb8c8442e4626674bc00966f2e8 Mon Sep 17 00:00:00 2001 From: Rachel Bryk Date: Fri, 19 Jul 2013 18:48:27 -0400 Subject: [PATCH 3/5] 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); From 96219df4fde48c9e88fb7f372380b9274009c7f5 Mon Sep 17 00:00:00 2001 From: Rachel Bryk Date: Fri, 19 Jul 2013 22:58:33 -0400 Subject: [PATCH 4/5] Allow non-SIDEVICE_GC_CONTROLLER controllers in netplay again. --- Source/Core/Core/Src/HW/SI.cpp | 2 +- Source/Core/Core/Src/NetPlay.cpp | 15 +++------------ Source/Core/Core/Src/NetPlay.h | 3 +-- Source/Core/Core/Src/NetPlayClient.cpp | 3 ++- Source/Core/Core/Src/NetPlayServer.cpp | 4 ++-- 5 files changed, 9 insertions(+), 18 deletions(-) diff --git a/Source/Core/Core/Src/HW/SI.cpp b/Source/Core/Core/Src/HW/SI.cpp index 738b97917d..85c84f92dd 100644 --- a/Source/Core/Core/Src/HW/SI.cpp +++ b/Source/Core/Core/Src/HW/SI.cpp @@ -263,7 +263,7 @@ void Init() if (Movie::IsRecordingInput() || Movie::IsPlayingInput()) AddDevice(Movie::IsUsingPad(i) ? (Movie::IsUsingBongo(i) ? SIDEVICE_GC_TARUKONGA : SIDEVICE_GC_CONTROLLER) : SIDEVICE_NONE, i); else if (NetPlay::GetNetPlayPtr()) - AddDevice(NetPlay::IsUsingPad(i) ? SIDEVICE_GC_CONTROLLER : SIDEVICE_NONE, i); + AddDevice((SIDevices) g_NetPlaySettings.m_Controllers[i], i); else AddDevice(SConfig::GetInstance().m_SIDevice[i], i); } diff --git a/Source/Core/Core/Src/NetPlay.cpp b/Source/Core/Core/Src/NetPlay.cpp index b9c5e95a5b..48eb6f5cad 100644 --- a/Source/Core/Core/Src/NetPlay.cpp +++ b/Source/Core/Core/Src/NetPlay.cpp @@ -289,13 +289,9 @@ void NetPlay::GetNetSettings() 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)); - } + + for (unsigned int i = 0; i < 4; ++i) + g_NetPlaySettings.m_Controllers[i] = SConfig::GetInstance().m_SIDevice[i]; } // stuff hacked into dolphin @@ -408,8 +404,3 @@ NetPlay* NetPlay::GetNetPlayPtr() { return netplay_ptr; } - -bool NetPlay::IsUsingPad(int pad) -{ - 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 08199b21a3..d8ecee016a 100644 --- a/Source/Core/Core/Src/NetPlay.h +++ b/Source/Core/Core/Src/NetPlay.h @@ -36,7 +36,7 @@ struct NetSettings bool m_CPUthread; bool m_DSPHLE; bool m_DSPEnableJIT; - u8 m_Controllers; + u8 m_Controllers[4]; }; extern NetSettings g_NetPlaySettings; @@ -129,7 +129,6 @@ public: u8 GetPadNum(u8 numPAD); static NetPlay* GetNetPlayPtr(); - static bool IsUsingPad(int pad); protected: //void GetBufferedPad(const u8 pad_nb, NetPad* const netvalues); diff --git a/Source/Core/Core/Src/NetPlayClient.cpp b/Source/Core/Core/Src/NetPlayClient.cpp index fb60764256..c72c94efa4 100644 --- a/Source/Core/Core/Src/NetPlayClient.cpp +++ b/Source/Core/Core/Src/NetPlayClient.cpp @@ -196,7 +196,8 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet) packet >> g_NetPlaySettings.m_CPUthread; packet >> g_NetPlaySettings.m_DSPEnableJIT; packet >> g_NetPlaySettings.m_DSPHLE; - packet >> g_NetPlaySettings.m_Controllers; + for (unsigned int i = 0; i < 4; ++i) + packet >> g_NetPlaySettings.m_Controllers[i]; } m_dialog->OnMsgStartGame(); diff --git a/Source/Core/Core/Src/NetPlayServer.cpp b/Source/Core/Core/Src/NetPlayServer.cpp index 90ac6b7f59..d19b6d684a 100644 --- a/Source/Core/Core/Src/NetPlayServer.cpp +++ b/Source/Core/Core/Src/NetPlayServer.cpp @@ -607,8 +607,8 @@ bool NetPlayServer::StartGame(const std::string &path) spac << g_NetPlaySettings.m_CPUthread; spac << g_NetPlaySettings.m_DSPEnableJIT; spac << g_NetPlaySettings.m_DSPHLE; - spac << g_NetPlaySettings.m_Controllers; - + for (unsigned int i = 0; i < 4; ++i) + spac << g_NetPlaySettings.m_Controllers[i]; std::lock_guard lkp(m_crit.players); std::lock_guard lks(m_crit.send); From 41fe2e1466d1e8939b2716c686d094112753a703 Mon Sep 17 00:00:00 2001 From: Rachel Bryk Date: Sat, 20 Jul 2013 13:20:14 -0400 Subject: [PATCH 5/5] Don't sync dual core setting in netplay. --- Source/Core/Core/Src/BootManager.cpp | 1 - Source/Core/Core/Src/NetPlay.cpp | 1 - Source/Core/Core/Src/NetPlay.h | 1 - Source/Core/Core/Src/NetPlayClient.cpp | 1 - Source/Core/Core/Src/NetPlayServer.cpp | 1 - 5 files changed, 5 deletions(-) diff --git a/Source/Core/Core/Src/BootManager.cpp b/Source/Core/Core/Src/BootManager.cpp index 871af5059c..60f718db53 100644 --- a/Source/Core/Core/Src/BootManager.cpp +++ b/Source/Core/Core/Src/BootManager.cpp @@ -138,7 +138,6 @@ 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; } diff --git a/Source/Core/Core/Src/NetPlay.cpp b/Source/Core/Core/Src/NetPlay.cpp index 48eb6f5cad..59b6a05538 100644 --- a/Source/Core/Core/Src/NetPlay.cpp +++ b/Source/Core/Core/Src/NetPlay.cpp @@ -286,7 +286,6 @@ u8 NetPlay::GetPadNum(u8 numPAD) 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; diff --git a/Source/Core/Core/Src/NetPlay.h b/Source/Core/Core/Src/NetPlay.h index d8ecee016a..8b84f43250 100644 --- a/Source/Core/Core/Src/NetPlay.h +++ b/Source/Core/Core/Src/NetPlay.h @@ -33,7 +33,6 @@ public: struct NetSettings { - bool m_CPUthread; bool m_DSPHLE; bool m_DSPEnableJIT; u8 m_Controllers[4]; diff --git a/Source/Core/Core/Src/NetPlayClient.cpp b/Source/Core/Core/Src/NetPlayClient.cpp index c72c94efa4..f01f2155c6 100644 --- a/Source/Core/Core/Src/NetPlayClient.cpp +++ b/Source/Core/Core/Src/NetPlayClient.cpp @@ -193,7 +193,6 @@ 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; for (unsigned int i = 0; i < 4; ++i) diff --git a/Source/Core/Core/Src/NetPlayServer.cpp b/Source/Core/Core/Src/NetPlayServer.cpp index d19b6d684a..31731daa47 100644 --- a/Source/Core/Core/Src/NetPlayServer.cpp +++ b/Source/Core/Core/Src/NetPlayServer.cpp @@ -604,7 +604,6 @@ bool NetPlayServer::StartGame(const std::string &path) sf::Packet spac; spac << (MessageId)NP_MSG_START_GAME; spac << NetPlay::m_current_game; - spac << g_NetPlaySettings.m_CPUthread; spac << g_NetPlaySettings.m_DSPEnableJIT; spac << g_NetPlaySettings.m_DSPHLE; for (unsigned int i = 0; i < 4; ++i)