From 3b3f0caa69c9df629b6ab0793b50d20bd2f03ac6 Mon Sep 17 00:00:00 2001 From: Spp Date: Sun, 9 May 2010 21:32:49 +0200 Subject: Fix a crash in GameObject::TakenDamage Fixes issue 2082 --HG-- branch : trunk --- src/game/GameObject.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp index 6119ecc87be..a4d31a19c67 100644 --- a/src/game/GameObject.cpp +++ b/src/game/GameObject.cpp @@ -1576,11 +1576,13 @@ void GameObject::TakenDamage(uint32 damage, Unit *who) return; Player* pwho = NULL; - if (who && who->GetTypeId() == TYPEID_PLAYER) - pwho = who->ToPlayer(); - - if (who && who->IsVehicle()) - pwho = who->GetCharmerOrOwner()->ToPlayer(); + if (who) + { + if (who->GetTypeId() == TYPEID_PLAYER) + pwho = who->ToPlayer(); + else if (who->IsVehicle() && who->GetCharmerOrOwner()) + pwho = who->GetCharmerOrOwner()->ToPlayer(); + } if (m_goValue->building.health > damage) m_goValue->building.health -= damage; -- cgit v1.2.3