Cleaning up the different timeouts and how players can be removed from the game.

This commit is contained in:
lotodore
2011-12-11 14:54:17 +00:00
parent 110a9536f4
commit aad9e271db
16 changed files with 175 additions and 167 deletions
+4 -11
View File
@@ -135,7 +135,7 @@ void
ServerGame::RemoveAllSessions()
{
// Clean up ALL sessions which are left.
GetSessionManager().ForEach(boost::bind(&ServerLobbyThread::RemoveSessionFromGame, boost::ref(*m_lobbyThread), _1));
GetSessionManager().ForEach(&SessionData::Close);
GetSessionManager().Clear();
SetState(ServerGameStateFinal::Instance());
}
@@ -726,7 +726,7 @@ ServerGame::ResetComputerPlayerList()
}
void
ServerGame::GracefulRemoveSession(boost::shared_ptr<SessionData> session, int reason)
ServerGame::RemoveSession(boost::shared_ptr<SessionData> session, int reason)
{
if (!session)
throw ServerException(__FILE__, __LINE__, ERR_NET_INVALID_SESSION, 0);
@@ -794,26 +794,19 @@ ServerGame::RemovePlayerData(boost::shared_ptr<PlayerData> player, int reason)
GetLobbyThread().NotifyPlayerLeftGame(GetId(), player->GetUniqueId());
}
void
ServerGame::ErrorRemoveSession(boost::shared_ptr<SessionData> session)
{
GetLobbyThread().RemoveSessionFromGame(session);
GracefulRemoveSession(session, NTF_NET_INTERNAL);
}
void
ServerGame::SessionError(boost::shared_ptr<SessionData> session, int errorCode)
{
if (!session)
throw ServerException(__FILE__, __LINE__, ERR_NET_INVALID_SESSION, 0);
ErrorRemoveSession(session);
RemoveSession(session, NTF_NET_INTERNAL);
GetLobbyThread().SessionError(session, errorCode);
}
void
ServerGame::MoveSessionToLobby(boost::shared_ptr<SessionData> session, int reason)
{
GracefulRemoveSession(session, reason);
RemoveSession(session, reason);
// Reset ready flag - just in case it is set, player may leave at any time.
session->ResetReadyFlag();
GetLobbyThread().ReAddSession(session, reason, GetId());