diff options
| author | Killyana <morphone1@gmail.com> | 2019-12-14 23:28:45 +0100 |
|---|---|---|
| committer | Killyana <morphone1@gmail.com> | 2019-12-14 23:28:45 +0100 |
| commit | 8b03fe95061f870efbe5352530c25a0175c4d8ee (patch) | |
| tree | fc47a0cb0297011264e88fe1767ad8d56a01a609 | |
| parent | 62ac5c67bf1673bb8052976749de18dec1126956 (diff) | |
Core/Log: Gameobjects may have faction template id = 0
Ref https://github.com/TrinityCore/TrinityCore/pull/22922
| -rw-r--r-- | src/server/game/Entities/Object/Object.cpp | 27 |
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; |
