Core: define CREATURE_FAMILY_NONE to avoid magic numbers in code
This commit is contained in:
1 parent
dadd81afe0
commit
11636faadf
6 files changed
+10
-7
No files matched your search
@@ -109,7 +109,7 @@ struct 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;
|
||||
@@ -167,7 +167,7 @@ struct CreatureTemplate
|
||||
|
||||
bool IsTameable(bool canTameExotic) const
|
||||
{
|
||||
if (type != CREATURE_TYPE_BEAST || family == 0 || (type_flags & CREATURE_TYPEFLAGS_TAMEABLE) == 0)
|
||||
if (type != CREATURE_TYPE_BEAST || family == CREATURE_FAMILY_NONE || (type_flags & CREATURE_TYPEFLAGS_TAMEABLE) == 0)
|
||||
return false;
|
||||
|
||||
// if can tame exotic then can tame any tameable
|
||||
|
||||
@@ -1681,7 +1681,7 @@ bool Player::BuildEnumData(PreparedQueryResult result, ByteBuffer* dataBuffer, B
|
||||
|
||||
uint32 petDisplayId = 0;
|
||||
uint32 petLevel = 0;
|
||||
uint32 petFamily = 0;
|
||||
CreatureFamily petFamily = CREATURE_FAMILY_NONE;
|
||||
// show pet at selection character in character list only for non-ghost character
|
||||
if (result && !(playerFlags & PLAYER_FLAGS_GHOST) && (plrClass == CLASS_WARLOCK || plrClass == CLASS_HUNTER || plrClass == CLASS_DEATH_KNIGHT))
|
||||
{
|
||||
|
||||
@@ -499,7 +499,7 @@ void ObjectMgr::LoadCreatureTemplate(Field* fields)
|
||||
creatureTemplate.unit_flags = fields[31].GetUInt32();
|
||||
creatureTemplate.unit_flags2 = fields[32].GetUInt32();
|
||||
creatureTemplate.dynamicflags = fields[33].GetUInt32();
|
||||
creatureTemplate.family = uint32(fields[34].GetUInt8());
|
||||
creatureTemplate.family = CreatureFamily(uint32(fields[34].GetUInt8()));
|
||||
creatureTemplate.trainer_type = uint32(fields[35].GetUInt8());
|
||||
creatureTemplate.trainer_class = uint32(fields[36].GetUInt8());
|
||||
creatureTemplate.trainer_race = uint32(fields[37].GetUInt8());
|
||||
@@ -909,7 +909,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)
|
||||
|
||||
@@ -2938,6 +2938,7 @@ uint32 const CREATURE_TYPEMASK_MECHANICAL_OR_ELEMENTAL = (1 << (CREATURE_TYPE_ME
|
||||
// CreatureFamily.dbc
|
||||
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
|
||||
// Creatures with family CREATURE_FAMILY_NONE crashes the server
|
||||
if (!creatureTemplate->family)
|
||||
{
|
||||
handler->PSendSysMessage("This creature cannot be tamed. (family id: 0).");
|
||||
handler->PSendSysMessage("This creature cannot be tamed. (family id: CREATURE_FAMILY_NONE).");
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -508,6 +508,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