Merge branch 'netplay' into netplay_dev
This commit is contained in:
commit
93def6b1dc
|
@ -44,7 +44,6 @@ static void SetSettings();
|
||||||
|
|
||||||
// l = local, r = remote
|
// l = local, r = remote
|
||||||
static s32 Start(s32 lhandle, u16 lport, std::string& raddr, u16 rport, s32 ldelay, u32 pred);
|
static s32 Start(s32 lhandle, u16 lport, std::string& raddr, u16 rport, s32 ldelay, u32 pred);
|
||||||
static void Close();
|
|
||||||
|
|
||||||
static void AdvanceFrame(u16 checksum = 0);
|
static void AdvanceFrame(u16 checksum = 0);
|
||||||
static void RunFrame();
|
static void RunFrame();
|
||||||
|
@ -139,8 +138,10 @@ s32 Netplay::Start(s32 lhandle, u16 lport, std::string& raddr, u16 rport, s32 ld
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Netplay::Close()
|
void Netplay::CloseSession()
|
||||||
{
|
{
|
||||||
|
Assert(IsActive());
|
||||||
|
|
||||||
ggpo_close_session(s_ggpo);
|
ggpo_close_session(s_ggpo);
|
||||||
s_ggpo = nullptr;
|
s_ggpo = nullptr;
|
||||||
s_save_buffer_pool.clear();
|
s_save_buffer_pool.clear();
|
||||||
|
@ -210,7 +211,7 @@ void Netplay::HandleTimeSyncEvent(float frame_delta, int update_interval)
|
||||||
float iterations_per_frame = 1.0f / s_frame_period;
|
float iterations_per_frame = 1.0f / s_frame_period;
|
||||||
|
|
||||||
s_target_speed = (s_frame_period + added_time_per_frame) * iterations_per_frame;
|
s_target_speed = (s_frame_period + added_time_per_frame) * iterations_per_frame;
|
||||||
s_next_timesync_recovery_frame = CurrentFrame() + std::ceil(static_cast<float>(update_interval) * 0.8f);
|
s_next_timesync_recovery_frame = CurrentFrame() + static_cast<s32>(std::ceil(static_cast<float>(update_interval) * 0.8f));
|
||||||
|
|
||||||
UpdateThrottlePeriod();
|
UpdateThrottlePeriod();
|
||||||
|
|
||||||
|
@ -381,7 +382,8 @@ void Netplay::StopNetplaySession()
|
||||||
if (!IsActive())
|
if (!IsActive())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Close();
|
// This will call back to us.
|
||||||
|
System::ShutdownSystem(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Netplay::NetplayAdvanceFrame(Netplay::Input inputs[], int disconnect_flags)
|
void Netplay::NetplayAdvanceFrame(Netplay::Input inputs[], int disconnect_flags)
|
||||||
|
@ -393,13 +395,13 @@ void Netplay::NetplayAdvanceFrame(Netplay::Input inputs[], int disconnect_flags)
|
||||||
|
|
||||||
void Netplay::ExecuteNetplay()
|
void Netplay::ExecuteNetplay()
|
||||||
{
|
{
|
||||||
while (System::IsValid())
|
while (System::IsRunning())
|
||||||
{
|
{
|
||||||
Netplay::RunFrame();
|
Netplay::RunFrame();
|
||||||
|
|
||||||
// this can shut us down
|
// this can shut us down
|
||||||
Host::PumpMessagesOnCPUThread();
|
Host::PumpMessagesOnCPUThread();
|
||||||
if (!System::IsValid() || !Netplay::IsActive())
|
if (!System::IsValid())
|
||||||
break;
|
break;
|
||||||
|
|
||||||
System::PresentFrame();
|
System::PresentFrame();
|
||||||
|
|
|
@ -19,6 +19,10 @@ void StopNetplaySession();
|
||||||
|
|
||||||
bool IsActive();
|
bool IsActive();
|
||||||
|
|
||||||
|
/// Frees up resources associated with the current netplay session.
|
||||||
|
/// Should only be called by System::ShutdownSystem().
|
||||||
|
void CloseSession();
|
||||||
|
|
||||||
/// Runs the VM and netplay loop. when the netplay loop cancels it switches to normal execute mode.
|
/// Runs the VM and netplay loop. when the netplay loop cancels it switches to normal execute mode.
|
||||||
void ExecuteNetplay();
|
void ExecuteNetplay();
|
||||||
|
|
||||||
|
|
|
@ -1532,7 +1532,7 @@ void System::Execute()
|
||||||
|
|
||||||
// this can shut us down
|
// this can shut us down
|
||||||
Host::PumpMessagesOnCPUThread();
|
Host::PumpMessagesOnCPUThread();
|
||||||
if (!IsValid() || Netplay::IsActive())
|
if (!IsValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (s_frame_step_request)
|
if (s_frame_step_request)
|
||||||
|
@ -3741,6 +3741,9 @@ void System::ShutdownSystem(bool save_resume_state)
|
||||||
if (!IsValid())
|
if (!IsValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (Netplay::IsActive())
|
||||||
|
Netplay::CloseSession();
|
||||||
|
|
||||||
if (save_resume_state)
|
if (save_resume_state)
|
||||||
SaveResumeState();
|
SaveResumeState();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue