diff options
author | Killyana <morphone1@gmail.com> | 2019-12-14 23:28:45 +0100 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2021-12-19 01:36:54 +0100 |
commit | 89edc84c23f867855ee119c7a9eb5dbf31692cf8 (patch) | |
tree | 460e99abc92c0b37163bc8e368cdff475a3afd55 /src | |
parent | 656ab93eb2147db8737d2a4424159e09d8405ffb (diff) |
Core/Log: Gameobjects may have faction template id = 0
Ref https://github.com/TrinityCore/TrinityCore/pull/22922
(cherry picked from commit 8b03fe95061f870efbe5352530c25a0175c4d8ee)
Diffstat (limited to 'src')
-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 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; |