Pass on admin state if the admin leaves the network game, so that someone else can start the game.

This commit is contained in:
lotodore
2007-10-03 13:36:47 +00:00
parent 8385b2e28d
commit 076d44b0ae
19 changed files with 239 additions and 49 deletions
+17
View File
@@ -300,6 +300,23 @@ ServerGameThread::GracefulRemoveSession(SessionWrapper session)
static_cast<NetPacketPlayerLeft *>(thisPlayerLeft.get())->SetData(thisPlayerLeftData);
GetSessionManager().SendToAllSessions(GetSender(), thisPlayerLeft, SessionData::Game);
if (tmpPlayerData->GetRights() == PLAYER_RIGHTS_ADMIN)
{
// Find new admin for the game
PlayerIdList idList(GetSessionManager().GetPlayerIdList());
if (!idList.empty())
{
// Send "Game Admin Changed" to clients.
boost::shared_ptr<NetPacket> adminChanged(new NetPacketGameAdminChanged);
NetPacketGameAdminChanged::Data adminChangedData;
adminChangedData.playerId = idList.front(); // Choose next player as admin.
static_cast<NetPacketGameAdminChanged *>(adminChanged.get())->SetData(adminChangedData);
GetSessionManager().SendToAllSessions(GetSender(), adminChanged, SessionData::Game);
}
}
// Reset player rights.
tmpPlayerData->SetRights(PLAYER_RIGHTS_NORMAL);
GetLobbyThread().NotifyPlayerLeftGame(GetId(), session.playerData->GetUniqueId());
}
}