Use system time for start time in netplay.

This commit is contained in:
Rachel Bryk 2015-03-08 08:21:03 -04:00
parent a3f6cbfe6b
commit e7d237f199
5 changed files with 19 additions and 13 deletions

View File

@ -12,6 +12,7 @@
#include "Core/Core.h" #include "Core/Core.h"
#include "Core/CoreTiming.h" #include "Core/CoreTiming.h"
#include "Core/Movie.h" #include "Core/Movie.h"
#include "Core/NetPlayProto.h"
#include "Core/HW/EXI_DeviceIPL.h" #include "Core/HW/EXI_DeviceIPL.h"
#include "Core/HW/SystemTimers.h" #include "Core/HW/SystemTimers.h"
@ -345,15 +346,16 @@ u32 CEXIIPL::GetGCTime()
// let's keep time moving forward, regardless of what it starts at // let's keep time moving forward, regardless of what it starts at
ltime += CoreTiming::GetTicks() / SystemTimers::GetTicksPerSecond(); ltime += CoreTiming::GetTicks() / SystemTimers::GetTicksPerSecond();
} }
else else if (NetPlay::IsNetPlayRunning())
{ {
// hack in some netplay stuff
ltime = NetPlay_GetGCTime(); ltime = NetPlay_GetGCTime();
if (0 == ltime) // let's keep time moving forward, regardless of what it starts at
ltime = Common::Timer::GetLocalTimeSinceJan1970(); ltime += CoreTiming::GetTicks() / SystemTimers::GetTicksPerSecond();
else }
ltime += CoreTiming::GetTicks() / SystemTimers::GetTicksPerSecond(); else
{
ltime = Common::Timer::GetLocalTimeSinceJan1970();
} }
return ((u32)ltime - cJanuary2000); return ((u32)ltime - cJanuary2000);

View File

@ -20,7 +20,7 @@ public:
void DoState(PointerWrap &p) override; void DoState(PointerWrap &p) override;
static u32 GetGCTime(); static u32 GetGCTime();
static u32 NetPlay_GetGCTime(); static u64 NetPlay_GetGCTime();
static void Descrambler(u8* data, u32 size); static void Descrambler(u8* data, u32 size);

View File

@ -382,7 +382,10 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet)
packet >> tmp; packet >> tmp;
g_NetPlaySettings.m_EXIDevice[1] = (TEXIDevices)tmp; g_NetPlaySettings.m_EXIDevice[1] = (TEXIDevices)tmp;
packet >> g_netplay_initial_gctime; u32 x, y;
packet >> x;
packet >> y;
g_netplay_initial_gctime = x | ((u64)y >> 32);
} }
m_dialog->OnMsgStartGame(); m_dialog->OnMsgStartGame();
@ -1061,7 +1064,7 @@ bool WiimoteEmu::Wiimote::NetPlay_GetWiimoteData(int wiimote, u8* data, u8 size)
// called from ---CPU--- thread // called from ---CPU--- thread
// so all players' games get the same time // so all players' games get the same time
u32 CEXIIPL::NetPlay_GetGCTime() u64 CEXIIPL::NetPlay_GetGCTime()
{ {
std::lock_guard<std::mutex> lk(crit_netplay_client); std::lock_guard<std::mutex> lk(crit_netplay_client);

View File

@ -32,7 +32,7 @@ typedef std::vector<u8> NetWiimote;
#define NETPLAY_VERSION "Dolphin NetPlay 2014-01-08" #define NETPLAY_VERSION "Dolphin NetPlay 2014-01-08"
extern int g_netplay_initial_gctime; extern u64 g_netplay_initial_gctime;
// messages // messages
enum enum

View File

@ -20,7 +20,7 @@
#include <arpa/inet.h> #include <arpa/inet.h>
#endif #endif
int g_netplay_initial_gctime = 1272737767; u64 g_netplay_initial_gctime = 1272737767;
NetPlayServer::~NetPlayServer() NetPlayServer::~NetPlayServer()
{ {
@ -648,7 +648,7 @@ bool NetPlayServer::StartGame()
// no change, just update with clients // no change, just update with clients
AdjustPadBufferSize(m_target_buffer_size); AdjustPadBufferSize(m_target_buffer_size);
g_netplay_initial_gctime = CEXIIPL::GetGCTime(); g_netplay_initial_gctime = Common::Timer::GetLocalTimeSinceJan1970();
// tell clients to start game // tell clients to start game
sf::Packet spac; sf::Packet spac;
@ -663,7 +663,8 @@ bool NetPlayServer::StartGame()
spac << m_settings.m_OCFactor; spac << m_settings.m_OCFactor;
spac << m_settings.m_EXIDevice[0]; spac << m_settings.m_EXIDevice[0];
spac << m_settings.m_EXIDevice[1]; spac << m_settings.m_EXIDevice[1];
spac << g_netplay_initial_gctime; spac << (u32)g_netplay_initial_gctime;
spac << (u32)g_netplay_initial_gctime << 32;
std::lock_guard<std::recursive_mutex> lkp(m_crit.players); std::lock_guard<std::recursive_mutex> lkp(m_crit.players);
std::lock_guard<std::recursive_mutex> lks(m_crit.send); std::lock_guard<std::recursive_mutex> lks(m_crit.send);