From d17572cbb5d780ca41de6614e2254a864de3bf97 Mon Sep 17 00:00:00 2001 From: doitux Date: Sat, 24 Nov 2007 00:37:33 +0000 Subject: [PATCH] join any game button fix --- .../qt/gamelobbydialog/gamelobbydialogimpl.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp b/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp index aba1021d..5b0c5044 100644 --- a/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp +++ b/src/gui/qt/gamelobbydialog/gamelobbydialogimpl.cpp @@ -179,7 +179,11 @@ void gameLobbyDialogImpl::joinAnyGame() { QTreeWidgetItemIterator it(treeWidget_GameList); while (*it) { - if ((*it)->data(2, Qt::DisplayRole) == tr("open") && (*it)->data(3, Qt::UserRole) == 0) + + bool ok; + int players = (*it)->data(1, Qt::DisplayRole).toString().section("/",0,0).toInt(&ok,10); + int maxPlayers = (*it)->data(1, Qt::DisplayRole).toString().section("/",1,1).toInt(&ok,10); + if ((*it)->data(2, Qt::DisplayRole) == tr("open") && (*it)->data(3, Qt::UserRole) == 0 && players < maxPlayers) { treeWidget_GameList->setCurrentItem((*it)); found = TRUE; @@ -748,16 +752,18 @@ void gameLobbyDialogImpl::showWaitStartGameMsgBox() { void gameLobbyDialogImpl::joinAnyGameButtonRefresh() { - int openNonPrivateGamesCounter = 0; + int openNonPrivateNonFullGamesCounter = 0; QTreeWidgetItemIterator it(treeWidget_GameList); while (*it) { - - if ((*it)->data(2, Qt::DisplayRole) == tr("open") && (*it)->data(3, Qt::UserRole) == 0) { openNonPrivateGamesCounter++; } + bool ok; + int players = (*it)->data(1, Qt::DisplayRole).toString().section("/",0,0).toInt(&ok,10); + int maxPlayers = (*it)->data(1, Qt::DisplayRole).toString().section("/",1,1).toInt(&ok,10); + if ((*it)->data(2, Qt::DisplayRole) == tr("open") && (*it)->data(3, Qt::UserRole) == 0 && players < maxPlayers) { openNonPrivateNonFullGamesCounter++; } ++it; } - if(openNonPrivateGamesCounter) pushButton_joinAnyGame->setEnabled(TRUE); + if(openNonPrivateNonFullGamesCounter) pushButton_joinAnyGame->setEnabled(TRUE); else pushButton_joinAnyGame->setEnabled(FALSE); }