mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-20 01:15:35 +01:00
Merge pull request #17138 from ForesterDev/creature_family
Core/Misc: Define CREATURE_FAMILY_NONE to avoid magic numbers in code
(cherry picked from commit 62635f07d0)
This commit is contained in:
@@ -334,7 +334,7 @@ struct TC_GAME_API CreatureTemplate
|
||||
uint32 unit_flags; // enum UnitFlags mask values
|
||||
uint32 unit_flags2; // enum UnitFlags2 mask values
|
||||
uint32 dynamicflags;
|
||||
uint32 family; // enum CreatureFamily values (optional)
|
||||
CreatureFamily family; // enum CreatureFamily values (optional)
|
||||
uint32 trainer_type;
|
||||
uint32 trainer_class;
|
||||
uint32 trainer_race;
|
||||
@@ -391,7 +391,7 @@ struct TC_GAME_API CreatureTemplate
|
||||
|
||||
bool IsTameable(bool canTameExotic) const
|
||||
{
|
||||
if (type != CREATURE_TYPE_BEAST || family == 0 || (type_flags & CREATURE_TYPE_FLAG_TAMEABLE_PET) == 0)
|
||||
if (type != CREATURE_TYPE_BEAST || family == CREATURE_FAMILY_NONE || (type_flags & CREATURE_TYPE_FLAG_TAMEABLE_PET) == 0)
|
||||
return false;
|
||||
|
||||
// if can tame exotic then can tame any tameable
|
||||
|
||||
@@ -496,7 +496,7 @@ void ObjectMgr::LoadCreatureTemplate(Field* fields)
|
||||
creatureTemplate.unit_flags = fields[32].GetUInt32();
|
||||
creatureTemplate.unit_flags2 = fields[33].GetUInt32();
|
||||
creatureTemplate.dynamicflags = fields[34].GetUInt32();
|
||||
creatureTemplate.family = uint32(fields[35].GetUInt8());
|
||||
creatureTemplate.family = CreatureFamily(fields[35].GetUInt8());
|
||||
creatureTemplate.trainer_type = uint32(fields[36].GetUInt8());
|
||||
creatureTemplate.trainer_class = uint32(fields[37].GetUInt8());
|
||||
creatureTemplate.trainer_race = uint32(fields[38].GetUInt8());
|
||||
@@ -915,7 +915,7 @@ void ObjectMgr::CheckCreatureTemplate(CreatureTemplate const* cInfo)
|
||||
if (cInfo->family && !sCreatureFamilyStore.LookupEntry(cInfo->family) && cInfo->family != CREATURE_FAMILY_HORSE_CUSTOM)
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "Creature (Entry: %u) has invalid creature family (%u) in `family`.", cInfo->Entry, cInfo->family);
|
||||
const_cast<CreatureTemplate*>(cInfo)->family = 0;
|
||||
const_cast<CreatureTemplate*>(cInfo)->family = CREATURE_FAMILY_NONE;
|
||||
}
|
||||
|
||||
if (cInfo->InhabitType <= 0 || cInfo->InhabitType > INHABIT_ANYWHERE)
|
||||
|
||||
@@ -3794,6 +3794,7 @@ uint32 const CREATURE_TYPEMASK_MECHANICAL_OR_ELEMENTAL = (1 << (CREATURE_TYPE_ME
|
||||
// CreatureFamily.dbc (6.0.2.18988)
|
||||
enum CreatureFamily
|
||||
{
|
||||
CREATURE_FAMILY_NONE = 0,
|
||||
CREATURE_FAMILY_WOLF = 1,
|
||||
CREATURE_FAMILY_CAT = 2,
|
||||
CREATURE_FAMILY_SPIDER = 3,
|
||||
|
||||
@@ -69,10 +69,10 @@ public:
|
||||
}
|
||||
|
||||
CreatureTemplate const* creatureTemplate = creatureTarget->GetCreatureTemplate();
|
||||
// Creatures with family 0 crashes the server
|
||||
if (!creatureTemplate->family)
|
||||
// Creatures with family CREATURE_FAMILY_NONE crashes the server
|
||||
if (creatureTemplate->family == CREATURE_FAMILY_NONE)
|
||||
{
|
||||
handler->PSendSysMessage("This creature cannot be tamed. (family id: 0).");
|
||||
handler->PSendSysMessage("This creature cannot be tamed. Family id: 0 (CREATURE_FAMILY_NONE).");
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -494,6 +494,8 @@ class spell_warl_demonic_empowerment : public SpellScriptLoader
|
||||
case CREATURE_FAMILY_IMP:
|
||||
targetCreature->CastSpell(targetCreature, SPELL_WARLOCK_DEMONIC_EMPOWERMENT_IMP, true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user