From 89edc84c23f867855ee119c7a9eb5dbf31692cf8 Mon Sep 17 00:00:00 2001 From: Killyana Date: Sat, 14 Dec 2019 23:28:45 +0100 Subject: Core/Log: Gameobjects may have faction template id = 0 Ref https://github.com/TrinityCore/TrinityCore/pull/22922 (cherry picked from commit 8b03fe95061f870efbe5352530c25a0175c4d8ee) --- src/server/game/Entities/Object/Object.cpp | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index 8ad61e05493..0ea32573030 100644 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -2400,17 +2400,26 @@ void WorldObject::SendSpellMiss(Unit* target, uint32 spellID, SpellMissInfo miss FactionTemplateEntry const* WorldObject::GetFactionTemplateEntry() const { - FactionTemplateEntry const* entry = sFactionTemplateStore.LookupEntry(GetFaction()); + uint32 factionId = GetFaction(); + FactionTemplateEntry const* entry = sFactionTemplateStore.LookupEntry(factionId); if (!entry) { - if (Player const* player = ToPlayer()) - TC_LOG_ERROR("entities.faction", "Player %s has invalid faction (faction template id) #%u", player->GetName().c_str(), GetFaction()); - else if (Creature const* creature = ToCreature()) - TC_LOG_ERROR("entities.faction", "Creature (template id: %u) has invalid faction (faction template id) #%u", creature->GetCreatureTemplate()->Entry, GetFaction()); - else if (GameObject const* go = ToGameObject()) - TC_LOG_ERROR("entities.faction", "GameObject (template id: %u) has invalid faction (faction template id) #%u", go->GetGOInfo()->entry, GetFaction()); - else - TC_LOG_ERROR("entities.faction", "WorldObject (name: %s, type: %u) has invalid faction (faction template id) #%u", GetName().c_str(), uint32(GetTypeId()), GetFaction()); + switch (GetTypeId()) + { + case TYPEID_PLAYER: + TC_LOG_ERROR("entities.unit", "Player %s has invalid faction (faction template id) #%u", ToPlayer()->GetName().c_str(), factionId); + break; + case TYPEID_UNIT: + TC_LOG_ERROR("entities.unit", "Creature (template id: %u) has invalid faction (faction template Id) #%u", ToCreature()->GetCreatureTemplate()->Entry, factionId); + break; + case TYPEID_GAMEOBJECT: + if (factionId) // Gameobjects may have faction template id = 0 + TC_LOG_ERROR("entities.faction", "GameObject (template id: %u) has invalid faction (faction template Id) #%u", ToGameObject()->GetGOInfo()->entry, factionId); + break; + default: + TC_LOG_ERROR("entities.unit", "Object (name=%s, type=%u) has invalid faction (faction template Id) #%u", GetName().c_str(), uint32(GetTypeId()), factionId); + break; + } } return entry; -- cgit v1.2.3