Move spectators to lobby before closing a game.
This commit is contained in:
@@ -589,6 +589,9 @@ AbstractClientStateReceiving::HandlePacket(boost::shared_ptr<ClientThread> clien
|
||||
case RemovedFromGameMessage::removedStartFailed :
|
||||
removeReason = NTF_NET_REMOVED_START_FAILED;
|
||||
break;
|
||||
case RemovedFromGameMessage::gameClosed :
|
||||
removeReason = NTF_NET_REMOVED_GAME_CLOSED;
|
||||
break;
|
||||
default :
|
||||
removeReason = NTF_NET_REMOVED_ON_REQUEST;
|
||||
break;
|
||||
|
||||
@@ -198,6 +198,21 @@ ServerGame::RemoveAllSessions()
|
||||
SetState(ServerGameStateFinal::Instance());
|
||||
}
|
||||
|
||||
void
|
||||
ServerGame::MoveSpectatorsToLobby()
|
||||
{
|
||||
PlayerIdList spectatorList = GetSpectatorIdList();
|
||||
PlayerIdList::const_iterator i = spectatorList.begin();
|
||||
PlayerIdList::const_iterator end = spectatorList.end();
|
||||
while (i != end) {
|
||||
boost::shared_ptr<SessionData> tmpSession = GetSessionManager().GetSessionByUniquePlayerId(*i);
|
||||
// Only remove if the spectator was found.
|
||||
if (tmpSession)
|
||||
MoveSessionToLobby(tmpSession, NTF_NET_REMOVED_GAME_CLOSED);
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ServerGame::TimerVoteKick(const boost::system::error_code &ec)
|
||||
{
|
||||
|
||||
@@ -1835,6 +1835,7 @@ ServerLobbyThread::TimerRemoveGame(const boost::system::error_code &ec)
|
||||
++next;
|
||||
boost::shared_ptr<ServerGame> tmpGame = i->second;
|
||||
if (!tmpGame->GetSessionManager().HasSessionWithState(SessionData::Game))
|
||||
tmpGame->MoveSpectatorsToLobby();
|
||||
InternalRemoveGame(tmpGame); // This will delete the game.
|
||||
i = next;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user