mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-28 16:49:58 -06:00
NetPlayServer: Make g_initial_netplay_rtc a member variable of NetPlayClient
Behaviorally, this belongs within the netplay client. The server will always transmit a known RTC value, so it doesn't even need a global for this. Given the client receives the packet containing said RTC value, we can store it as a member variable and provide an accessor for reading that value. This removes another global variable within the netplay code.
This commit is contained in:
@ -56,8 +56,6 @@
|
||||
|
||||
namespace NetPlay
|
||||
{
|
||||
u64 g_netplay_initial_rtc = 1272737767;
|
||||
|
||||
NetPlayServer::~NetPlayServer()
|
||||
{
|
||||
if (is_connected)
|
||||
@ -908,10 +906,7 @@ bool NetPlayServer::StartGame()
|
||||
// no change, just update with clients
|
||||
AdjustPadBufferSize(m_target_buffer_size);
|
||||
|
||||
if (SConfig::GetInstance().bEnableCustomRTC)
|
||||
g_netplay_initial_rtc = SConfig::GetInstance().m_customRTCValue;
|
||||
else
|
||||
g_netplay_initial_rtc = Common::Timer::GetLocalTimeSinceJan1970();
|
||||
const u64 initial_rtc = GetInitialNetPlayRTC();
|
||||
|
||||
const std::string region = SConfig::GetDirectoryForRegion(
|
||||
SConfig::ToGameCubeRegion(m_dialog->FindGameFile(m_selected_game)->GetRegion()));
|
||||
@ -974,7 +969,7 @@ bool NetPlayServer::StartGame()
|
||||
spac << m_settings.m_ArbitraryMipmapDetectionThreshold;
|
||||
spac << m_settings.m_EnableGPUTextureDecoding;
|
||||
spac << m_settings.m_StrictSettingsSync;
|
||||
Common::PacketWriteU64(spac, g_netplay_initial_rtc);
|
||||
Common::PacketWriteU64(spac, initial_rtc);
|
||||
spac << m_settings.m_SyncSaveData;
|
||||
spac << region;
|
||||
|
||||
@ -1289,6 +1284,16 @@ bool NetPlayServer::CompressBufferIntoPacket(const std::vector<u8>& in_buffer, s
|
||||
return true;
|
||||
}
|
||||
|
||||
u64 NetPlayServer::GetInitialNetPlayRTC() const
|
||||
{
|
||||
const auto& config = SConfig::GetInstance();
|
||||
|
||||
if (config.bEnableCustomRTC)
|
||||
return config.m_customRTCValue;
|
||||
|
||||
return Common::Timer::GetLocalTimeSinceJan1970();
|
||||
}
|
||||
|
||||
// called from multiple threads
|
||||
void NetPlayServer::SendToClients(const sf::Packet& packet, const PlayerId skip_pid)
|
||||
{
|
||||
|
Reference in New Issue
Block a user