Pass on admin state if the admin leaves the network game, so that someone else can start the game.
This commit is contained in:
@@ -23,7 +23,7 @@
|
||||
#include <net/socket_msg.h>
|
||||
|
||||
startNetworkGameDialogImpl::startNetworkGameDialogImpl(QWidget *parent, ConfigFile *config)
|
||||
: QDialog(parent), myW(NULL), isAdmin(false), myConfig(config), mySession(NULL)
|
||||
: QDialog(parent), myW(NULL), myPlayerId(0), isAdmin(false), myConfig(config), mySession(NULL)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
@@ -64,6 +64,7 @@ void startNetworkGameDialogImpl::refresh(int actionID) {
|
||||
|
||||
void startNetworkGameDialogImpl::joinedNetworkGame(unsigned playerId, QString playerName, int rights) {
|
||||
|
||||
myPlayerId = playerId;
|
||||
isAdmin = rights == PLAYER_RIGHTS_ADMIN;
|
||||
addConnectedPlayer(playerId, playerName, rights);
|
||||
}
|
||||
@@ -116,6 +117,15 @@ void startNetworkGameDialogImpl::removePlayer(unsigned playerId, QString) {
|
||||
checkPlayerQuantity();
|
||||
}
|
||||
|
||||
void startNetworkGameDialogImpl::newGameAdmin(unsigned playerId, QString)
|
||||
{
|
||||
if (myPlayerId == playerId)
|
||||
{
|
||||
isAdmin = true;
|
||||
checkPlayerQuantity();
|
||||
}
|
||||
}
|
||||
|
||||
void startNetworkGameDialogImpl::playerSelected(QTreeWidgetItem* item, QTreeWidgetItem*) {
|
||||
|
||||
if (item)
|
||||
@@ -166,6 +176,8 @@ void startNetworkGameDialogImpl::clearDialog()
|
||||
pushButton_startGame->setEnabled(false);
|
||||
treeWidget->clear();
|
||||
checkBox_fillUpWithComputerOpponents->hide();
|
||||
|
||||
myPlayerId = 0;
|
||||
}
|
||||
|
||||
void startNetworkGameDialogImpl::setSession(Session *session)
|
||||
|
||||
@@ -49,6 +49,8 @@ public slots:
|
||||
void addConnectedPlayer(unsigned playerId, QString playerName, int rights);
|
||||
void updatePlayer(unsigned playerId, QString newPlayerName);
|
||||
void removePlayer(unsigned playerId, QString playerName);
|
||||
void newGameAdmin(unsigned playerId, QString playerName);
|
||||
|
||||
void playerSelected(QTreeWidgetItem*, QTreeWidgetItem*);
|
||||
void kickPlayer();
|
||||
void checkPlayerQuantity();
|
||||
@@ -67,6 +69,7 @@ private:
|
||||
|
||||
mainWindowImpl* myW;
|
||||
int maxPlayerNumber;
|
||||
unsigned myPlayerId;
|
||||
bool isAdmin;
|
||||
ConfigFile *myConfig;
|
||||
Session *mySession;
|
||||
|
||||
Reference in New Issue
Block a user