From 0be7632875fb3018bad7cd726b2c72d55f0b4262 Mon Sep 17 00:00:00 2001 From: lotodore Date: Sat, 29 Jun 2013 23:44:00 +0200 Subject: [PATCH] Fixing session counter with regard to spectators. --- src/net/common/servergamestate.cpp | 2 +- src/net/common/serverlobbythread.cpp | 2 +- src/net/common/sessionmanager.cpp | 4 ++-- src/net/sessionmanager.h | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/net/common/servergamestate.cpp b/src/net/common/servergamestate.cpp index c1bc64c8..976e8fe6 100644 --- a/src/net/common/servergamestate.cpp +++ b/src/net/common/servergamestate.cpp @@ -779,7 +779,7 @@ ServerGameStateStartGame::InternalProcessPacket(boost::shared_ptr se { if (packet->GetMsg()->messagetype() == PokerTHMessage::Type_StartEventAckMessage) { session->SetReadyFlag(); - if (server->GetSessionManager().CountReadySessions() == server->GetSessionManager().GetRawSessionCount()) { + if (server->GetSessionManager().CountReadySessions() == server->GetSessionManager().GetSessionCountWithState(SessionData::Game)) { // Everyone is ready. server->GetSessionManager().ResetAllReadyFlags(); DoStart(server); diff --git a/src/net/common/serverlobbythread.cpp b/src/net/common/serverlobbythread.cpp index b96d6f55..9df8d104 100644 --- a/src/net/common/serverlobbythread.cpp +++ b/src/net/common/serverlobbythread.cpp @@ -2125,7 +2125,7 @@ ServerLobbyThread::UpdateStatisticsNumberOfPlayers() { ServerStats stats; // Get all logged-in sessions and all sessions within a game. - unsigned curNumberOfPlayersOnServer = m_sessionManager.GetEstablishedSessionCount() + m_gameSessionManager.GetRawSessionCount(); + unsigned curNumberOfPlayersOnServer = m_sessionManager.GetSessionCountWithState(SessionData::Established) + m_gameSessionManager.GetRawSessionCount(); { boost::mutex::scoped_lock lock(m_statMutex); if (curNumberOfPlayersOnServer != m_statData.numberOfPlayersOnServer) { diff --git a/src/net/common/sessionmanager.cpp b/src/net/common/sessionmanager.cpp index 628057ac..c77ee161 100644 --- a/src/net/common/sessionmanager.cpp +++ b/src/net/common/sessionmanager.cpp @@ -302,7 +302,7 @@ SessionManager::GetRawSessionCount() } unsigned -SessionManager::GetEstablishedSessionCount() +SessionManager::GetSessionCountWithState(int state) { unsigned counter = 0; boost::recursive_mutex::scoped_lock lock(m_sessionMapMutex); @@ -311,7 +311,7 @@ SessionManager::GetEstablishedSessionCount() SessionMap::const_iterator end = m_sessionMap.end(); while (i != end) { - if ((*i).second->GetState() >= SessionData::Established) + if ((i->second->GetState() & state) != 0) ++counter; ++i; } diff --git a/src/net/sessionmanager.h b/src/net/sessionmanager.h index 03247215..81ff5916 100644 --- a/src/net/sessionmanager.h +++ b/src/net/sessionmanager.h @@ -73,7 +73,7 @@ public: void Clear(); unsigned GetRawSessionCount(); - unsigned GetEstablishedSessionCount(); + unsigned GetSessionCountWithState(int state); void SendToAllSessions(SenderHelper &sender, boost::shared_ptr packet, int state); void SendLobbyMsgToAllSessions(SenderHelper &sender, boost::shared_ptr packet, int state);