From f968aae6c01df1a1f66e86b8d52c689b54fe8961 Mon Sep 17 00:00:00 2001 From: lotodore Date: Tue, 15 Nov 2011 19:56:23 +0000 Subject: [PATCH] Fixing nasty crash when a player left a game which was not running. --- src/net/common/clientstate.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/net/common/clientstate.cpp b/src/net/common/clientstate.cpp index 72af6b14..5d1b93d8 100644 --- a/src/net/common/clientstate.cpp +++ b/src/net/common/clientstate.cpp @@ -674,9 +674,11 @@ AbstractClientStateReceiving::HandlePacket(boost::shared_ptr clien // A player left the game. GamePlayerLeft_t *netLeft = &netGamePlayer->gamePlayerNotification.choice.gamePlayerLeft; - boost::shared_ptr tmpPlayer = client->GetGame()->getPlayerByUniqueId(netLeft->playerId); - if (tmpPlayer) { - tmpPlayer->setIsKicked(netLeft->gamePlayerLeftReason == gamePlayerLeftReason_leftKicked); + if (client->GetGame()) { + boost::shared_ptr tmpPlayer = client->GetGame()->getPlayerByUniqueId(netLeft->playerId); + if (tmpPlayer) { + tmpPlayer->setIsKicked(netLeft->gamePlayerLeftReason == gamePlayerLeftReason_leftKicked); + } } // Signal to GUI and remove from data list. client->RemovePlayerData(netLeft->playerId, netLeft->gamePlayerLeftReason);