mutex and ghost games fixes

This commit is contained in:
Max-Wilhelm Bruker 2011-03-29 23:54:08 +02:00
parent 8e0f7dcf03
commit 6d5b29395c
4 changed files with 9 additions and 14 deletions

View file

@ -64,8 +64,11 @@ void Server_Game::pingClockTimeout()
QList<ServerInfo_PlayerPing *> pingList;
QMapIterator<int, Server_Player *> playerIterator(players);
bool allPlayersInactive = true;
int playerCount = 0;
while (playerIterator.hasNext()) {
Server_Player *player = playerIterator.next().value();
if (!player->getSpectator())
++playerCount;
int pingTime;
if (player->getProtocolHandler()) {
pingTime = player->getProtocolHandler()->getLastCommandTime();
@ -78,7 +81,7 @@ void Server_Game::pingClockTimeout()
const int maxTime = static_cast<Server_Room *>(parent())->getServer()->getMaxGameInactivityTime();
if (allPlayersInactive) {
if ((++inactivityCounter >= maxTime) && (maxTime > 0))
if (((++inactivityCounter >= maxTime) && (maxTime > 0)) || (playerCount < maxPlayers))
deleteLater();
} else
inactivityCounter = 0;