aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/server/game/Entities/Object/Object.cpp27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp
index 298d2199c5d..abeec0d3a37 100644
--- a/src/server/game/Entities/Object/Object.cpp
+++ b/src/server/game/Entities/Object/Object.cpp
@@ -2573,17 +2573,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;