Skip to content

Commit

Permalink
Optional: Separate CreatureTypeFlags into their own namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
insunaa committed Oct 8, 2024
1 parent 49ac1bb commit b841e74
Show file tree
Hide file tree
Showing 10 changed files with 90 additions and 87 deletions.
2 changes: 1 addition & 1 deletion src/game/AI/BaseAI/CreatureAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ CreatureAI::CreatureAI(Creature* creature, uint32 combatActions) :
m_creature(creature),
m_deathPrevented(false), m_followAngle(0.f), m_followDist(0.f)
{
m_dismountOnAggro = !(m_creature->GetCreatureInfo()->CreatureTypeFlags & CREATURE_TYPEFLAGS_MOUNTED_COMBAT);
m_dismountOnAggro = !(m_creature->GetCreatureInfo()->CreatureTypeFlags & CreatureTypeFlags::MOUNTED_COMBAT);
SetMeleeEnabled(!(m_creature->GetSettings().HasFlag(CreatureStaticFlags::NO_MELEE_FLEE)
|| m_creature->GetSettings().HasFlag(CreatureStaticFlags4::NO_MELEE_APPROACH)));
if (m_creature->GetSettings().HasFlag(CreatureStaticFlags::SESSILE))
Expand Down
2 changes: 1 addition & 1 deletion src/game/AI/ScriptDevAI/base/escort_ai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ bool npc_escortAI::AssistPlayerInCombat(Unit* who)
return false;

// experimental (unknown) flag not present
if (!(m_creature->GetCreatureInfo()->CreatureTypeFlags & CREATURE_TYPEFLAGS_CAN_ASSIST))
if (!(m_creature->GetCreatureInfo()->CreatureTypeFlags & CreatureTypeFlags::CAN_ASSIST))
return false;

// unit state prevents (similar check is done in CanInitiateAttack which also include checking unit_flags. We skip those here)
Expand Down
2 changes: 1 addition & 1 deletion src/game/AI/ScriptDevAI/base/follower_ai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ bool FollowerAI::AssistPlayerInCombat(Unit* who)
return false;

// experimental (unknown) flag not present
if (!(m_creature->GetCreatureInfo()->CreatureTypeFlags & CREATURE_TYPEFLAGS_CAN_ASSIST))
if (!(m_creature->GetCreatureInfo()->CreatureTypeFlags & CreatureTypeFlags::CAN_ASSIST))
return false;

// unit state prevents (similar check is done in CanInitiateAttack which also include checking unit_flags. We skip those here)
Expand Down
2 changes: 1 addition & 1 deletion src/game/Entities/Creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2171,7 +2171,7 @@ bool Creature::IsVisibleInGridForPlayer(Player* pl) const
}

// Dead player can see ghosts
if (GetCreatureInfo()->CreatureTypeFlags & CREATURE_TYPEFLAGS_GHOST_VISIBLE)
if (GetCreatureInfo()->CreatureTypeFlags & CreatureTypeFlags::GHOST_VISIBLE)
return true;

// and not see any other
Expand Down
12 changes: 6 additions & 6 deletions src/game/Entities/Creature.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,24 +194,24 @@ struct CreatureInfo

SkillType GetRequiredLootSkill() const
{
if (CreatureTypeFlags & CREATURE_TYPEFLAGS_HERBLOOT)
if (CreatureTypeFlags & CreatureTypeFlags::HERBLOOT)
return SKILL_HERBALISM;
if (CreatureTypeFlags & CREATURE_TYPEFLAGS_MININGLOOT)
if (CreatureTypeFlags & CreatureTypeFlags::MININGLOOT)
return SKILL_MINING;
if (CreatureTypeFlags & CREATURE_TYPEFLAGS_ENGINEERLOOT)
if (CreatureTypeFlags & CreatureTypeFlags::ENGINEERLOOT)
return SKILL_ENGINEERING;
return SKILL_SKINNING;
// normal case
}

bool IsExotic() const
{
return (CreatureTypeFlags & CREATURE_TYPEFLAGS_EXOTIC) != 0;
return (CreatureTypeFlags & CreatureTypeFlags::EXOTIC) != 0;
}

bool isTameable(bool exotic) const
{
if (CreatureType != CREATURE_TYPE_BEAST || Family == 0 || (CreatureTypeFlags & CREATURE_TYPEFLAGS_TAMEABLE) == 0)
if (CreatureType != CREATURE_TYPE_BEAST || Family == 0 || (CreatureTypeFlags & CreatureTypeFlags::TAMEABLE) == 0)
return false;

// if can tame exotic then can tame any tameable
Expand Down Expand Up @@ -783,7 +783,7 @@ class Creature : public Unit
uint32 GetInteractionPauseTimer() const { return m_interactionPauseTimer; }

GridReference<Creature>& GetGridRef() { return m_gridRef; }
bool IsRegeneratingHealth() const { return (GetCreatureInfo()->RegenerateStats & REGEN_FLAG_HEALTH) != 0 && !(GetCreatureInfo()->CreatureTypeFlags & CREATURE_TYPEFLAGS_SIEGE_WEAPON); }
bool IsRegeneratingHealth() const { return (GetCreatureInfo()->RegenerateStats & REGEN_FLAG_HEALTH) != 0 && !(GetCreatureInfo()->CreatureTypeFlags & CreatureTypeFlags::SIEGE_WEAPON); }
bool IsRegeneratingPower() const;
virtual uint8 GetPetAutoSpellSize() const { return CREATURE_MAX_SPELLS; }
virtual uint32 GetPetAutoSpellOnPos(uint8 pos) const
Expand Down
22 changes: 11 additions & 11 deletions src/game/Entities/Relations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ bool Unit::IsFriend(const Unit* unit) const
// WotLK+: Special flag overrides reaction
if (GetTypeId() == TYPEID_UNIT)
{
if (static_cast<const Creature*>(this)->GetCreatureInfo()->CreatureTypeFlags & CREATURE_TYPEFLAGS_TREAT_AS_IN_RAID)
if (static_cast<const Creature*>(this)->GetCreatureInfo()->CreatureTypeFlags & CreatureTypeFlags::TREAT_AS_IN_RAID)
return true;
}
return (GetReactionTo(unit) > REP_NEUTRAL);
Expand Down Expand Up @@ -367,7 +367,7 @@ bool Unit::CanAttack(const Unit* unit) const
// Creatures cannot attack player ghosts, unless it is a specially flagged ghost creature
if (GetTypeId() == TYPEID_UNIT && unit->GetTypeId() == TYPEID_PLAYER && static_cast<const Player*>(unit)->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST))
{
if (!(static_cast<const Creature*>(this)->GetCreatureInfo()->CreatureTypeFlags & CREATURE_TYPEFLAGS_GHOST_VISIBLE))
if (!(static_cast<const Creature*>(this)->GetCreatureInfo()->CreatureTypeFlags & CreatureTypeFlags::GHOST_VISIBLE))
return false;
}

Expand Down Expand Up @@ -478,7 +478,7 @@ bool Unit::CanAttackNow(const Unit* unit) const
if (IsMounted())
{
// ... unless we are a creature with a special flag
if (GetTypeId() != TYPEID_UNIT || !(static_cast<const Creature*>(this)->GetCreatureInfo()->CreatureTypeFlags & CREATURE_TYPEFLAGS_MOUNTED_COMBAT))
if (GetTypeId() != TYPEID_UNIT || !(static_cast<const Creature*>(this)->GetCreatureInfo()->CreatureTypeFlags & CreatureTypeFlags::MOUNTED_COMBAT))
return false;
}

Expand Down Expand Up @@ -524,7 +524,7 @@ bool Unit::CanAssist(const Unit* unit, bool ignoreFlags) const
if (GetReactionTo(unit) < REP_FRIENDLY)
{
// ... unless we are a creature with a special flag
if (GetTypeId() != TYPEID_UNIT || !(static_cast<const Creature*>(this)->GetCreatureInfo()->CreatureTypeFlags & CREATURE_TYPEFLAGS_TREAT_AS_IN_RAID))
if (GetTypeId() != TYPEID_UNIT || !(static_cast<const Creature*>(this)->GetCreatureInfo()->CreatureTypeFlags & CreatureTypeFlags::TREAT_AS_IN_RAID))
return false;
}

Expand Down Expand Up @@ -568,10 +568,10 @@ bool Unit::CanAssist(const Unit* unit, bool ignoreFlags) const
{
if (const uint32 flags = static_cast<const Creature*>(unit)->GetCreatureInfo()->CreatureTypeFlags)
{
if (flags & CREATURE_TYPEFLAGS_CAN_ASSIST)
if (flags & CreatureTypeFlags::CAN_ASSIST)
return true;

if (flags & CREATURE_TYPEFLAGS_TREAT_AS_IN_RAID)
if (flags & CreatureTypeFlags::TREAT_AS_IN_RAID)
return true;
}
}
Expand Down Expand Up @@ -668,14 +668,14 @@ bool Unit::CanInteract(const Unit* unit) const
// We can't interact with anyone as a ghost except specially flagged NPCs
if (GetTypeId() == TYPEID_PLAYER && static_cast<const Player*>(this)->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST))
{
if (unit->GetTypeId() != TYPEID_UNIT || !(static_cast<const Creature*>(unit)->GetCreatureInfo()->CreatureTypeFlags & CREATURE_TYPEFLAGS_GHOST_VISIBLE))
if (unit->GetTypeId() != TYPEID_UNIT || !(static_cast<const Creature*>(unit)->GetCreatureInfo()->CreatureTypeFlags & CreatureTypeFlags::GHOST_VISIBLE))
return false;
}

// WotLK+: personal squire support
if (GetTypeId() == TYPEID_PLAYER && unit->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP) && unit->GetTypeId() == TYPEID_UNIT)
{
if ((static_cast<const Creature*>(unit)->GetCreatureInfo()->CreatureTypeFlags & CREATURE_TYPEFLAGS_SQUIRE) && unit->GetOwnerGuid() != GetObjectGuid())
if ((static_cast<const Creature*>(unit)->GetCreatureInfo()->CreatureTypeFlags & CreatureTypeFlags::SQUIRE) && unit->GetOwnerGuid() != GetObjectGuid())
return false;
}

Expand Down Expand Up @@ -724,7 +724,7 @@ bool Unit::CanInteractNow(const Unit* unit) const
// We can't interact with dead units, unless it's a creature with special flag
if (!unit->IsAlive())
{
if (GetTypeId() != TYPEID_UNIT || !(static_cast<const Creature*>(unit)->GetCreatureInfo()->CreatureTypeFlags & CREATURE_TYPEFLAGS_INTERACT_DEAD))
if (GetTypeId() != TYPEID_UNIT || !(static_cast<const Creature*>(unit)->GetCreatureInfo()->CreatureTypeFlags & CreatureTypeFlags::INTERACT_DEAD))
return false;
}

Expand All @@ -739,7 +739,7 @@ bool Unit::CanInteractNow(const Unit* unit) const
bool interactable = false;

// We can interact with siege weapons in fight
if (!interactable && unit->GetTypeId() == TYPEID_UNIT && (static_cast<const Creature*>(unit)->GetCreatureInfo()->CreatureTypeFlags & CREATURE_TYPEFLAGS_SIEGE_WEAPON))
if (!interactable && unit->GetTypeId() == TYPEID_UNIT && (static_cast<const Creature*>(unit)->GetCreatureInfo()->CreatureTypeFlags & CreatureTypeFlags::SIEGE_WEAPON))
interactable = true;

// We can interact with UNIT_FLAG2_INTERACT_ANY_REACTION flagged units even in fight
Expand Down Expand Up @@ -1368,7 +1368,7 @@ bool Unit::CanAttackServerside(const Unit* unit, bool ignoreFlagsSource, bool ig
// Creatures cannot attack player ghosts, unless it is a specially flagged ghost creature
if (GetTypeId() == TYPEID_UNIT && unit->GetTypeId() == TYPEID_PLAYER && static_cast<const Player*>(unit)->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST))
{
if (!(static_cast<const Creature*>(this)->GetCreatureInfo()->CreatureTypeFlags & CREATURE_TYPEFLAGS_GHOST_VISIBLE))
if (!(static_cast<const Creature*>(this)->GetCreatureInfo()->CreatureTypeFlags & CreatureTypeFlags::GHOST_VISIBLE))
return false;
}

Expand Down
64 changes: 32 additions & 32 deletions src/game/Globals/ObjectMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1040,69 +1040,69 @@ VehicleSeatParameters const* ObjectMgr::GetVehicleSeatParameters(uint32 seatEntr
uint32 ObjectMgr::GetTypeFlagsFromStaticFlags(uint32 typeFlags, uint32 staticFlags1, uint32 staticFlags2, uint32 staticFlags3, uint32 staticFlags4) const
{
if (staticFlags1 & uint32(CreatureStaticFlags::TAMEABLE))
typeFlags |= CREATURE_TYPEFLAGS_TAMEABLE;
typeFlags |= CreatureTypeFlags::TAMEABLE;
if (staticFlags1 & uint32(CreatureStaticFlags::BOSS_MOB))
typeFlags |= CREATURE_TYPEFLAGS_BOSS_MOB;
typeFlags |= CreatureTypeFlags::BOSS_MOB;
if (staticFlags1 & uint32(CreatureStaticFlags::VISIBLE_TO_GHOSTS))
typeFlags |= CREATURE_TYPEFLAGS_GHOST_VISIBLE;
typeFlags |= CreatureTypeFlags::GHOST_VISIBLE;
if (staticFlags1 & uint32(CreatureStaticFlags::NO_FACTION_TOOLTIP))
typeFlags |= CREATURE_TYPEFLAGS_NO_FACTION_TOOLTIP;
typeFlags |= CreatureTypeFlags::NO_FACTION_TOOLTIP;
if (staticFlags1 & uint32(CreatureStaticFlags::DO_NOT_PLAY_WOUND_ANIM))
typeFlags |= CREATURE_TYPEFLAGS_NO_WOUND_ANIM;
typeFlags |= CreatureTypeFlags::NO_WOUND_ANIM;
if (staticFlags1 & uint32(CreatureStaticFlags::MORE_AUDIBLE))
typeFlags |= CREATURE_TYPEFLAGS_MORE_AUDIBLE;
typeFlags |= CreatureTypeFlags::MORE_AUDIBLE;
if (staticFlags2 & uint32(CreatureStaticFlags2::SPELL_ATTACKABLE))
typeFlags |= CREATURE_TYPEFLAGS_SPELL_ATTACKABLE;
typeFlags |= CreatureTypeFlags::SPELL_ATTACKABLE;
if (staticFlags2 & uint32(CreatureStaticFlags2::INTERACT_WHILE_DEAD))
typeFlags |= CREATURE_TYPEFLAGS_INTERACT_DEAD;
typeFlags |= CreatureTypeFlags::INTERACT_DEAD;
if (staticFlags2 & uint32(CreatureStaticFlags2::SKIN_WITH_HERBALISM))
typeFlags |= CREATURE_TYPEFLAGS_HERBLOOT;
typeFlags |= CreatureTypeFlags::HERBLOOT;
if (staticFlags2 & uint32(CreatureStaticFlags2::SKIN_WITH_MINING))
typeFlags |= CREATURE_TYPEFLAGS_MININGLOOT;
typeFlags |= CreatureTypeFlags::MININGLOOT;
if (staticFlags2 & uint32(CreatureStaticFlags2::ALLOW_MOUNTED_COMBAT))
typeFlags |= CREATURE_TYPEFLAGS_MOUNTED_COMBAT;
typeFlags |= CreatureTypeFlags::MOUNTED_COMBAT;
if (staticFlags2 & uint32(CreatureStaticFlags2::NO_DEATH_MESSAGE))
typeFlags |= CREATURE_TYPEFLAGS_NO_DEATH_MSG;
typeFlags |= CreatureTypeFlags::NO_DEATH_MSG;
if (staticFlags2 & uint32(CreatureStaticFlags2::CAN_ASSIST))
typeFlags |= CREATURE_TYPEFLAGS_CAN_ASSIST;
typeFlags |= CreatureTypeFlags::CAN_ASSIST;
if (staticFlags2 & uint32(CreatureStaticFlags2::NO_PET_BAR))
typeFlags |= CREATURE_TYPEFLAGS_NO_PET_BAR;
typeFlags |= CreatureTypeFlags::NO_PET_BAR;
if (staticFlags3 & uint32(CreatureStaticFlags3::MASK_UID))
typeFlags |= CREATURE_TYPEFLAGS_MASK_UID;
typeFlags |= CreatureTypeFlags::MASK_UID;
if (staticFlags3 & uint32(CreatureStaticFlags3::SKIN_WITH_ENGINEERING))
typeFlags |= CREATURE_TYPEFLAGS_ENGINEERLOOT;
typeFlags |= CreatureTypeFlags::ENGINEERLOOT;
if (staticFlags3 & uint32(CreatureStaticFlags3::TAMEABLE_EXOTIC))
typeFlags |= CREATURE_TYPEFLAGS_EXOTIC;
typeFlags |= CreatureTypeFlags::EXOTIC;
if (staticFlags3 & uint32(CreatureStaticFlags3::NO_NAME_PLATE))
typeFlags |= CREATURE_TYPEFLAGS_NO_NAMEPLATE;
typeFlags |= CreatureTypeFlags::NO_NAMEPLATE;
if (staticFlags3 & uint32(CreatureStaticFlags3::USE_MODEL_COLLISION_SIZE))
typeFlags |= CREATURE_TYPEFLAGS_MODEL_COLLISION_SIZE;
typeFlags |= CreatureTypeFlags::MODEL_COLLISION_SIZE;
if (staticFlags3 & uint32(CreatureStaticFlags3::ALLOW_INTERACTION_WHILE_IN_COMBAT))
typeFlags |= CREATURE_TYPEFLAGS_SIEGE_WEAPON;
typeFlags |= CreatureTypeFlags::SIEGE_WEAPON;
if (staticFlags3 & uint32(CreatureStaticFlags3::COLLIDE_WITH_MISSILES))
typeFlags |= CREATURE_TYPEFLAGS_COLLIDE_WITH_MISSILES;
typeFlags |= CreatureTypeFlags::COLLIDE_WITH_MISSILES;
if (staticFlags3 & uint32(CreatureStaticFlags3::DO_NOT_PLAY_MOUNTED_ANIMATIONS))
typeFlags |= CREATURE_TYPEFLAGS_NO_MOUNTED_ANIM;
typeFlags |= CreatureTypeFlags::NO_MOUNTED_ANIM;
if (staticFlags3 & uint32(CreatureStaticFlags3::LINK_ALL))
typeFlags |= CREATURE_TYPEFLAGS_LINK_ALL;
typeFlags |= CreatureTypeFlags::LINK_ALL;
if (staticFlags4 & uint32(CreatureStaticFlags4::INTERACT_ONLY_WITH_CREATOR))
typeFlags |= CREATURE_TYPEFLAGS_SQUIRE;
typeFlags |= CreatureTypeFlags::SQUIRE;
if (staticFlags4 & uint32(CreatureStaticFlags4::DO_NOT_PLAY_UNIT_EVENT_SOUNDS))
typeFlags |= CREATURE_TYPEFLAGS_NO_DEATH_SOUND;
typeFlags |= CreatureTypeFlags::NO_DEATH_SOUND;
if (staticFlags4 & uint32(CreatureStaticFlags4::HAS_NO_SHADOW_BLOB))
typeFlags |= CREATURE_TYPEFLAGS_NO_SHADOW_BLOB;
typeFlags |= CreatureTypeFlags::NO_SHADOW_BLOB;
if (staticFlags4 & uint32(CreatureStaticFlags4::TREAT_AS_RAID_UNIT_FOR_HELPFUL_SPELLS))
typeFlags |= CREATURE_TYPEFLAGS_TREAT_AS_IN_RAID;
typeFlags |= CreatureTypeFlags::TREAT_AS_IN_RAID;
if (staticFlags4 & uint32(CreatureStaticFlags4::FORCE_GOSSIP))
typeFlags |= CREATURE_TYPEFLAGS_FORCE_GOSSIP;
typeFlags |= CreatureTypeFlags::FORCE_GOSSIP;
if (staticFlags4 & uint32(CreatureStaticFlags4::DO_NOT_SHEATHE))
typeFlags |= CREATURE_TYPEFLAGS_DO_NOT_SHEATHE;
typeFlags |= CreatureTypeFlags::DO_NOT_SHEATHE;
if (staticFlags4 & uint32(CreatureStaticFlags4::DO_NOT_TARGET_ON_INTERACTION))
typeFlags |= CREATURE_TYPEFLAGS_NO_INTERACT_TARGET;
typeFlags |= CreatureTypeFlags::NO_INTERACT_TARGET;
if (staticFlags4 & uint32(CreatureStaticFlags4::DO_NOT_RENDER_OBJECT_NAME))
typeFlags |= CREATURE_TYPEFLAGS_DO_NOT_RENDER_NAME;
typeFlags |= CreatureTypeFlags::DO_NOT_RENDER_NAME;
if (staticFlags4 & uint32(CreatureStaticFlags4::QUEST_BOSS))
typeFlags |= CREATURE_TYPEFLAGS_QUEST_BOSS;
typeFlags |= CreatureTypeFlags::QUEST_BOSS;
return typeFlags;
}

Expand Down
Loading

0 comments on commit b841e74

Please sign in to comment.