Fixing player counter - only count sessions which are established (after login). Send number of players in announce message. (Bug found through test case.)

This commit is contained in:
lotodore
2011-02-13 17:24:40 +00:00
parent fdcf1ce297
commit dafd78c578
3 changed files with 24 additions and 1 deletions
+17
View File
@@ -295,6 +295,23 @@ SessionManager::GetRawSessionCount()
return m_sessionMap.size();
}
unsigned
SessionManager::GetEstablishedSessionCount()
{
unsigned counter = 0;
boost::recursive_mutex::scoped_lock lock(m_sessionMapMutex);
SessionMap::const_iterator i = m_sessionMap.begin();
SessionMap::const_iterator end = m_sessionMap.end();
while (i != end) {
if ((*i).second.sessionData->GetState() >= SessionData::Established)
++counter;
++i;
}
return counter;
}
void
SessionManager::SendToAllSessions(SenderHelper &sender, boost::shared_ptr<NetPacket> packet, SessionData::State state)
{