diff options
Diffstat (limited to 'src/game/World.cpp')
-rw-r--r-- | src/game/World.cpp | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/src/game/World.cpp b/src/game/World.cpp index 520749285f8..cb9f2acf396 100644 --- a/src/game/World.cpp +++ b/src/game/World.cpp @@ -247,7 +247,7 @@ World::AddSession_ (WorldSession* s) if(decrease_session) --Sessions; - if (pLimit > 0 && Sessions >= pLimit && s->GetSecurity () == SEC_PLAYER ) + if (pLimit > 0 && Sessions >= pLimit && s->GetSecurity () == SEC_PLAYER && !HasRecentlyDisconnected(s) ) { AddQueuedPlayer (s); UpdateMaxSessionCounters (); @@ -276,6 +276,26 @@ World::AddSession_ (WorldSession* s) } } +bool World::HasRecentlyDisconnected(WorldSession* session) +{ + if(!session) return false; + + if(uint32 tolerance = getConfig(CONFIG_INTERVAL_DISCONNECT_TOLERANCE)) + { + for(DisconnectMap::iterator i = m_disconnects.begin(); i != m_disconnects.end(); ++i) + { + if(difftime(i->second, time(NULL)) < tolerance) + { + if(i->first == session->GetAccountId()) + return true; + } + else + m_disconnects.erase(i); + } + } + return false; + } + int32 World::GetQueuePos(WorldSession* sess) { uint32 position = 1; @@ -544,6 +564,7 @@ void World::LoadConfigSettings(bool reload) m_configs[CONFIG_ADDON_CHANNEL] = sConfig.GetBoolDefault("AddonChannel", true); m_configs[CONFIG_GRID_UNLOAD] = sConfig.GetBoolDefault("GridUnload", true); m_configs[CONFIG_INTERVAL_SAVE] = sConfig.GetIntDefault("PlayerSaveInterval", 900000); + m_configs[CONFIG_INTERVAL_DISCONNECT_TOLERANCE] = sConfig.GetIntDefault("DisconnectToleranceInterval", 0); m_configs[CONFIG_INTERVAL_GRIDCLEAN] = sConfig.GetIntDefault("GridCleanUpDelay", 300000); if(m_configs[CONFIG_INTERVAL_GRIDCLEAN] < MIN_GRID_DELAY) @@ -2939,7 +2960,8 @@ void World::UpdateSessions( uint32 diff ) ///- and remove not active sessions from the list if(!itr->second->Update(diff)) // As interval = 0 { - RemoveQueuedPlayer (itr->second); + if(!RemoveQueuedPlayer(itr->second) && itr->second && getConfig(CONFIG_INTERVAL_DISCONNECT_TOLERANCE)) + m_disconnects[itr->second->GetAccountId()] = time(NULL); delete itr->second; m_sessions.erase(itr); } |