diff --git a/common/server_game.cpp b/common/server_game.cpp index 5838e3f9..47457869 100644 --- a/common/server_game.cpp +++ b/common/server_game.cpp @@ -56,7 +56,7 @@ Server_Game::~Server_Game() room->removeGame(this); delete creatorInfo; - qDebug("Server_Game destructor"); + qDebug() << "Server_Game destructor: gameId=" << gameId; } void Server_Game::pingClockTimeout() diff --git a/common/server_protocolhandler.cpp b/common/server_protocolhandler.cpp index 437ba7af..e79bf259 100644 --- a/common/server_protocolhandler.cpp +++ b/common/server_protocolhandler.cpp @@ -207,25 +207,26 @@ void Server_ProtocolHandler::processCommandContainer(CommandContainer *cont) gameListMutex.lock(); GameEventContainer *gQPublic = cont->getGameEventQueuePublic(); if (gQPublic) { - Server_Game *game = games.value(gQPublic->getGameId()).first; - Server_Player *player = games.value(gQPublic->getGameId()).second; - GameEventContainer *gQPrivate = cont->getGameEventQueuePrivate(); - GameEventContainer *gQOmniscient = cont->getGameEventQueueOmniscient(); - if (gQPrivate) { - int privatePlayerId = cont->getPrivatePlayerId(); - Server_Player *privatePlayer; - if (privatePlayerId == -1) - privatePlayer = player; - else - privatePlayer = game->getPlayer(privatePlayerId); - if (gQOmniscient) { - game->sendGameEventContainer(gQPublic, privatePlayer, true); - game->sendGameEventContainerOmniscient(gQOmniscient, privatePlayer); + QPair gamePlayerPair = games.value(gQPublic->getGameId()); + if (gamePlayerPair.first) { + GameEventContainer *gQPrivate = cont->getGameEventQueuePrivate(); + GameEventContainer *gQOmniscient = cont->getGameEventQueueOmniscient(); + if (gQPrivate) { + int privatePlayerId = cont->getPrivatePlayerId(); + Server_Player *privatePlayer; + if (privatePlayerId == -1) + privatePlayer = gamePlayerPair.second; + else + privatePlayer = gamePlayerPair.first->getPlayer(privatePlayerId); + if (gQOmniscient) { + gamePlayerPair.first->sendGameEventContainer(gQPublic, privatePlayer, true); + gamePlayerPair.first->sendGameEventContainerOmniscient(gQOmniscient, privatePlayer); + } else + gamePlayerPair.first->sendGameEventContainer(gQPublic, privatePlayer); + privatePlayer->sendProtocolItem(gQPrivate); } else - game->sendGameEventContainer(gQPublic, privatePlayer); - privatePlayer->sendProtocolItem(gQPrivate); - } else - game->sendGameEventContainer(gQPublic); + gamePlayerPair.first->sendGameEventContainer(gQPublic); + } } gameListMutex.unlock();