nextTurn cleanup -> fixed the bug that the game would begin with active player 0 even if there is no player 0

This commit is contained in:
Max-Wilhelm Bruker
2010-08-11 01:17:45 +02:00
parent cbfbc542e7
commit ad40194f25
3 changed files with 19 additions and 13 deletions

View File

@@ -952,18 +952,7 @@ ResponseCode Server_ProtocolHandler::cmdNextTurn(Command_NextTurn * /*cmd*/, Com
if (!game->getGameStarted())
return RespGameNotStarted;
const QMap<int, Server_Player *> &players = game->getPlayers();
const QList<int> keys = players.keys();
int activePlayer = game->getActivePlayer();
int listPos = keys.indexOf(activePlayer);
do {
++listPos;
if (listPos == keys.size())
listPos = 0;
} while (players.value(keys[listPos])->getSpectator());
game->setActivePlayer(keys[listPos]);
game->nextTurn();
return RespOk;
}