mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-31 09:33:47 +00:00
Implemented GetPhaseByAuras removing redundant code (DRY)
This commit is contained in:
@@ -3029,11 +3029,7 @@ void Player::SetGameMaster(bool on)
|
||||
else
|
||||
{
|
||||
// restore phase
|
||||
uint32 newPhase = 0;
|
||||
AuraEffectList const& phases = GetAuraEffectsByType(SPELL_AURA_PHASE);
|
||||
if (!phases.empty())
|
||||
for (AuraEffectList::const_iterator itr = phases.begin(); itr != phases.end(); ++itr)
|
||||
newPhase |= (*itr)->GetMiscValue();
|
||||
uint32 newPhase = GetPhaseByAuras();
|
||||
|
||||
if (!newPhase)
|
||||
newPhase = PHASEMASK_NORMAL;
|
||||
@@ -25241,22 +25237,14 @@ void Player::_LoadSkills(PreparedQueryResult result)
|
||||
}
|
||||
|
||||
uint32 Player::GetPhaseMaskForSpawn() const
|
||||
{
|
||||
uint32 phase = PHASEMASK_NORMAL;
|
||||
if (!IsGameMaster())
|
||||
phase = GetPhaseMask();
|
||||
else
|
||||
{
|
||||
AuraEffectList const& phases = GetAuraEffectsByType(SPELL_AURA_PHASE);
|
||||
if (!phases.empty())
|
||||
phase = phases.front()->GetMiscValue();
|
||||
}
|
||||
{
|
||||
uint32 phase = IsGameMaster() ? GetPhaseByAuras() : GetPhaseMask();
|
||||
|
||||
// some aura phases include 1 normal map in addition to phase itself
|
||||
if (uint32 n_phase = phase & ~PHASEMASK_NORMAL)
|
||||
return n_phase;
|
||||
|
||||
return PHASEMASK_NORMAL;
|
||||
return phase;
|
||||
}
|
||||
|
||||
InventoryResult Player::CanEquipUniqueItem(Item* pItem, uint8 eslot, uint32 limit_count) const
|
||||
|
||||
@@ -17556,6 +17556,17 @@ float Unit::MeleeSpellMissChance(const Unit* victim, WeaponAttackType attType, i
|
||||
return missChance;
|
||||
}
|
||||
|
||||
uint32 Unit::GetPhaseByAuras() const
|
||||
{
|
||||
uint32 currentPhase = 0;
|
||||
AuraEffectList const& phases = GetAuraEffectsByType(SPELL_AURA_PHASE);
|
||||
if (!phases.empty())
|
||||
for (AuraEffectList::const_iterator itr = phases.begin(); itr != phases.end(); ++itr)
|
||||
currentPhase |= (*itr)->GetMiscValue();
|
||||
|
||||
return currentPhase;
|
||||
}
|
||||
|
||||
void Unit::SetPhaseMask(uint32 newPhaseMask, bool update)
|
||||
{
|
||||
if (newPhaseMask == GetPhaseMask())
|
||||
|
||||
@@ -2125,6 +2125,7 @@ class Unit : public WorldObject
|
||||
void SetModelVisible(bool on);
|
||||
|
||||
// common function for visibility checks for player/creatures with detection code
|
||||
uint32 GetPhaseByAuras() const;
|
||||
void SetPhaseMask(uint32 newPhaseMask, bool update);// overwrite WorldObject::SetPhaseMask
|
||||
void UpdateObjectVisibility(bool forced = true, bool fromUpdate = false);
|
||||
|
||||
|
||||
@@ -1711,20 +1711,16 @@ void AuraEffect::HandlePhase(AuraApplication const* aurApp, uint8 mode, bool app
|
||||
Unit* target = aurApp->GetTarget();
|
||||
|
||||
// no-phase is also phase state so same code for apply and remove
|
||||
uint32 newPhase = 0;
|
||||
Unit::AuraEffectList const& phases = target->GetAuraEffectsByType(SPELL_AURA_PHASE);
|
||||
if (!phases.empty())
|
||||
for (Unit::AuraEffectList::const_iterator itr = phases.begin(); itr != phases.end(); ++itr)
|
||||
newPhase |= (*itr)->GetMiscValue();
|
||||
uint32 newPhase = target->GetPhaseByAuras();
|
||||
|
||||
if (Player* player = target->ToPlayer())
|
||||
{
|
||||
if (!newPhase)
|
||||
newPhase = PHASEMASK_NORMAL;
|
||||
|
||||
// GM-mode have mask 0xFFFFFFFF
|
||||
// do not change phase to GM with all phases enabled
|
||||
if (player->IsGameMaster())
|
||||
newPhase = 0xFFFFFFFF;
|
||||
newPhase = PHASEMASK_ANYWHERE;
|
||||
|
||||
player->SetPhaseMask(newPhase, false);
|
||||
player->GetSession()->SendSetPhaseShift(newPhase);
|
||||
|
||||
Reference in New Issue
Block a user