From 102034a89104c5f1935effb9a0db2f9994ad5fc6 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Thu, 4 Mar 2021 11:40:50 -0500 Subject: [PATCH] Core/WorldSession: Fix idle WorldSessions getting kicked twice as fast as supposed Port From (https://github.com/TrinityCore/TrinityCore/commit/f1388f37b6151252aae7431921564cf2458226a4) --- Source/Game/Server/WorldConfig.cs | 5 +++-- Source/Game/Server/WorldSession.cs | 19 ++++++------------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/Source/Game/Server/WorldConfig.cs b/Source/Game/Server/WorldConfig.cs index b6cad55dc..5b448bd6b 100644 --- a/Source/Game/Server/WorldConfig.cs +++ b/Source/Game/Server/WorldConfig.cs @@ -289,8 +289,9 @@ namespace Game Values[WorldCfg.PortInstance] = GetDefaultValue("InstanceServerPort", 8086); } - Values[WorldCfg.SocketTimeoutTime] = GetDefaultValue("SocketTimeOutTime", 900000); - Values[WorldCfg.SocketTimeoutTimeActive] = GetDefaultValue("SocketTimeOutTimeActive", 60000); + // Config values are in "milliseconds" but we handle SocketTimeOut only as "seconds" so divide by 1000 + Values[WorldCfg.SocketTimeoutTime] = GetDefaultValue("SocketTimeOutTime", 900000) / 1000; + Values[WorldCfg.SocketTimeoutTimeActive] = GetDefaultValue("SocketTimeOutTimeActive", 60000) / 1000; Values[WorldCfg.SessionAddDelay] = GetDefaultValue("SessionAddDelay", 10000); Values[WorldCfg.GroupXpDistance] = GetDefaultValue("MaxGroupXPDistance", 74.0f); diff --git a/Source/Game/Server/WorldSession.cs b/Source/Game/Server/WorldSession.cs index c01f007f2..286b94d3d 100644 --- a/Source/Game/Server/WorldSession.cs +++ b/Source/Game/Server/WorldSession.cs @@ -241,9 +241,6 @@ namespace Game public bool Update(uint diff, PacketFilter updater) { - // Update Timeout timer. - UpdateTimeOutTime(diff); - // Before we process anything: /// If necessary, kick the player because the client didn't send anything for too long /// (or they've been idling in character select) @@ -820,21 +817,17 @@ namespace Game public uint GetLatency() { return m_latency; } public void SetLatency(uint latency) { m_latency = latency; } public void ResetClientTimeDelay() { m_clientTimeDelay = 0; } - void UpdateTimeOutTime(uint diff) - { - if (diff > m_timeOutTime) - m_timeOutTime = 0; - else - m_timeOutTime -= diff; - } public void ResetTimeOutTime(bool onlyActive) { if (GetPlayer()) - m_timeOutTime = WorldConfig.GetIntValue(WorldCfg.SocketTimeoutTimeActive); + m_timeOutTime = GameTime.GetGameTime() + WorldConfig.GetIntValue(WorldCfg.SocketTimeoutTimeActive); else if (!onlyActive) - m_timeOutTime = WorldConfig.GetIntValue(WorldCfg.SocketTimeoutTime); + m_timeOutTime = GameTime.GetGameTime() + WorldConfig.GetIntValue(WorldCfg.SocketTimeoutTime); + } + bool IsConnectionIdle() + { + return m_timeOutTime < GameTime.GetGameTime() && !m_inQueue; } - bool IsConnectionIdle() { return (m_timeOutTime <= 0 && !m_inQueue); } public uint GetRecruiterId() { return recruiterId; } public bool IsARecruiter() { return isRecruiter; }