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:
@@ -272,6 +272,10 @@ ServerLobbyThread::AddConnection(boost::shared_ptr<tcp::socket> sock)
|
||||
netAnnounce->serverType = serverType_serverTypeInternetAuth;
|
||||
break;
|
||||
}
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_statMutex);
|
||||
netAnnounce->numPlayersOnServer = m_statData.numberOfPlayersOnServer;
|
||||
}
|
||||
GetSender().Send(sessionData, packet);
|
||||
|
||||
sock->async_read_some(
|
||||
@@ -1984,7 +1988,8 @@ void
|
||||
ServerLobbyThread::UpdateStatisticsNumberOfPlayers()
|
||||
{
|
||||
ServerStats stats;
|
||||
unsigned curNumberOfPlayersOnServer = m_sessionManager.GetRawSessionCount() + m_gameSessionManager.GetRawSessionCount();
|
||||
// Get all logged-in sessions and all sessions within a game.
|
||||
unsigned curNumberOfPlayersOnServer = m_sessionManager.GetEstablishedSessionCount() + m_gameSessionManager.GetRawSessionCount();
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_statMutex);
|
||||
if (curNumberOfPlayersOnServer != m_statData.numberOfPlayersOnServer) {
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user