From 8947cfd41c77406a4d8ab81841f77d8efff2ccc1 Mon Sep 17 00:00:00 2001 From: Trazom62 Date: Thu, 11 Mar 2010 23:12:44 +0100 Subject: Fix crash in getFactionTemplateEntry. Fixe issues #1050. --HG-- branch : trunk --- src/game/Unit.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index cd175627a02..162166e5bf6 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -8633,10 +8633,13 @@ FactionTemplateEntry const* Unit::getFactionTemplateEntry() const if(GetGUID() != guid) { - if(GetTypeId() == TYPEID_PLAYER) - sLog.outError("Player %s have invalid faction (faction template id) #%u", this->ToPlayer()->GetName(), getFaction()); - else - sLog.outError("Creature (template id: %u) have invalid faction (faction template id) #%u", this->ToCreature()->GetCreatureInfo()->Entry, getFaction()); + if (const Player *player = ToPlayer()) + sLog.outError("Player %s has invalid faction (faction template id) #%u", player->GetName(), getFaction()); + else if (const Creature *creature = ToCreature()) + sLog.outError("Creature (template id: %u) has invalid faction (faction template id) #%u", creature->GetCreatureInfo()->Entry, getFaction()); + else + sLog.outError("Unit (name=%s, type=%u) has invalid faction (faction template id) #%u", GetName(), uint32(GetTypeId()), getFaction()); + guid = GetGUID(); } } -- cgit v1.2.3