From 6f765d311bf481f51f96db3896c2e0c7c3c8bff6 Mon Sep 17 00:00:00 2001 From: lotodore Date: Tue, 9 Oct 2007 22:01:12 +0000 Subject: [PATCH] Fixed changing admin when admin player leaves. --- src/net/common/servergamethread.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/net/common/servergamethread.cpp b/src/net/common/servergamethread.cpp index 9d8b7a4d..8804229c 100644 --- a/src/net/common/servergamethread.cpp +++ b/src/net/common/servergamethread.cpp @@ -317,13 +317,15 @@ ServerGameThread::GracefulRemoveSession(SessionWrapper session) if (tmpPlayerData->GetRights() == PLAYER_RIGHTS_ADMIN) { // Find new admin for the game - PlayerIdList idList(GetSessionManager().GetPlayerIdList()); - if (!idList.empty()) + PlayerDataList playerList(GetSessionManager().GetPlayerDataList()); + if (!playerList.empty()) { + boost::shared_ptr newAdmin = playerList.front(); + newAdmin->SetRights(PLAYER_RIGHTS_ADMIN); // Send "Game Admin Changed" to clients. boost::shared_ptr adminChanged(new NetPacketGameAdminChanged); NetPacketGameAdminChanged::Data adminChangedData; - adminChangedData.playerId = idList.front(); // Choose next player as admin. + adminChangedData.playerId = newAdmin->GetUniqueId(); // Choose next player as admin. static_cast(adminChanged.get())->SetData(adminChangedData); GetSessionManager().SendToAllSessions(GetSender(), adminChanged, SessionData::Game); }