From b1f37a18c9e1a3c54d02bf48ae09670afedfef03 Mon Sep 17 00:00:00 2001 From: Max-Wilhelm Bruker Date: Mon, 25 Jun 2012 21:11:01 +0200 Subject: [PATCH] client: fixed crash that happened when trying to send a game command in the replay viewer --- cockatrice/src/tab_game.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/cockatrice/src/tab_game.cpp b/cockatrice/src/tab_game.cpp index a8f12cc6..632d4ecd 100644 --- a/cockatrice/src/tab_game.cpp +++ b/cockatrice/src/tab_game.cpp @@ -813,7 +813,9 @@ AbstractClient *TabGame::getClientForPlayer(int playerId) const playerId = getActiveLocalPlayer()->getId(); return clients.at(playerId); - } else + } else if (clients.isEmpty()) + return 0; + else return clients.first(); } @@ -830,12 +832,17 @@ int TabGame::getPlayerIdByName(const QString &playerName) const void TabGame::sendGameCommand(PendingCommand *pend, int playerId) { - getClientForPlayer(playerId)->sendCommand(pend); + AbstractClient *client = getClientForPlayer(playerId); + if (!client) + return; + client->sendCommand(pend); } void TabGame::sendGameCommand(const google::protobuf::Message &command, int playerId) { AbstractClient *client = getClientForPlayer(playerId); + if (!client) + return; client->sendCommand(prepareGameCommand(command)); }