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
@@ -18,7 +18,7 @@
#include <net/socket_msg.h>
gameLobbyDialogImpl::gameLobbyDialogImpl(QWidget *parent, ConfigFile *c)
: QDialog(parent), myW(NULL), myConfig(c), mySession(NULL), currentGameName(""), isAdmin(false), inGame(false), myChat(NULL)
: QDialog(parent), myW(NULL), myConfig(c), mySession(NULL), currentGameName(""), myPlayerId(0), isAdmin(false), inGame(false), myChat(NULL)
{
setupUi(this);
@@ -343,6 +343,7 @@ void gameLobbyDialogImpl::clearDialog()
myChat->clearChat();
inGame = false;
isAdmin = false;
myPlayerId = 0;
}
void gameLobbyDialogImpl::checkPlayerQuantity() {
@@ -367,6 +368,7 @@ void gameLobbyDialogImpl::joinedNetworkGame(unsigned playerId, QString playerNam
inGame = true;
joinedGameDialogUpdate();
myPlayerId = playerId;
isAdmin = rights == PLAYER_RIGHTS_ADMIN;
addConnectedPlayer(playerId, playerName, rights);
}
@@ -418,6 +420,15 @@ void gameLobbyDialogImpl::removePlayer(unsigned playerId, QString) {
checkPlayerQuantity();
}
void gameLobbyDialogImpl::newGameAdmin(unsigned playerId, QString)
{
if (myPlayerId == playerId)
{
isAdmin = true;
checkPlayerQuantity();
}
}
void gameLobbyDialogImpl::joinedGameDialogUpdate() {
groupBox_GameInfo->setEnabled(true);
groupBox_GameInfo->setTitle(currentGameName);
@@ -71,6 +71,7 @@ public slots:
void addConnectedPlayer(unsigned, QString, int);
void updatePlayer(unsigned, QString);
void removePlayer(unsigned, QString);
void newGameAdmin(unsigned, QString);
void playerSelected(QTreeWidgetItem*, QTreeWidgetItem*);
void refresh(int actionID);
@@ -99,6 +100,7 @@ private:
Session *mySession;
createInternetGameDialogImpl *myCreateInternetGameDialog;
QString currentGameName;
unsigned myPlayerId;
bool isAdmin;
bool inGame;
LobbyChat *myChat;