client: fixed crash that happened when trying to send a game command in the replay viewer

This commit is contained in:
Max-Wilhelm Bruker 2012-06-25 21:11:01 +02:00
parent e7b58c4d8e
commit b1f37a18c9

View file

@ -813,7 +813,9 @@ AbstractClient *TabGame::getClientForPlayer(int playerId) const
playerId = getActiveLocalPlayer()->getId(); playerId = getActiveLocalPlayer()->getId();
return clients.at(playerId); return clients.at(playerId);
} else } else if (clients.isEmpty())
return 0;
else
return clients.first(); return clients.first();
} }
@ -830,12 +832,17 @@ int TabGame::getPlayerIdByName(const QString &playerName) const
void TabGame::sendGameCommand(PendingCommand *pend, int playerId) 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) void TabGame::sendGameCommand(const google::protobuf::Message &command, int playerId)
{ {
AbstractClient *client = getClientForPlayer(playerId); AbstractClient *client = getClientForPlayer(playerId);
if (!client)
return;
client->sendCommand(prepareGameCommand(command)); client->sendCommand(prepareGameCommand(command));
} }