Implemented GetPhaseByAuras removing redundant code (DRY)
This commit is contained in:
@@ -3029,11 +3029,7 @@ void Player::SetGameMaster(bool on)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// restore phase
|
// restore phase
|
||||||
uint32 newPhase = 0;
|
uint32 newPhase = GetPhaseByAuras();
|
||||||
AuraEffectList const& phases = GetAuraEffectsByType(SPELL_AURA_PHASE);
|
|
||||||
if (!phases.empty())
|
|
||||||
for (AuraEffectList::const_iterator itr = phases.begin(); itr != phases.end(); ++itr)
|
|
||||||
newPhase |= (*itr)->GetMiscValue();
|
|
||||||
|
|
||||||
if (!newPhase)
|
if (!newPhase)
|
||||||
newPhase = PHASEMASK_NORMAL;
|
newPhase = PHASEMASK_NORMAL;
|
||||||
@@ -25241,22 +25237,14 @@ void Player::_LoadSkills(PreparedQueryResult result)
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32 Player::GetPhaseMaskForSpawn() const
|
uint32 Player::GetPhaseMaskForSpawn() const
|
||||||
{
|
{
|
||||||
uint32 phase = PHASEMASK_NORMAL;
|
uint32 phase = IsGameMaster() ? GetPhaseByAuras() : GetPhaseMask();
|
||||||
if (!IsGameMaster())
|
|
||||||
phase = GetPhaseMask();
|
|
||||||
else
|
|
||||||
{
|
|
||||||
AuraEffectList const& phases = GetAuraEffectsByType(SPELL_AURA_PHASE);
|
|
||||||
if (!phases.empty())
|
|
||||||
phase = phases.front()->GetMiscValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
// some aura phases include 1 normal map in addition to phase itself
|
// some aura phases include 1 normal map in addition to phase itself
|
||||||
if (uint32 n_phase = phase & ~PHASEMASK_NORMAL)
|
if (uint32 n_phase = phase & ~PHASEMASK_NORMAL)
|
||||||
return n_phase;
|
return n_phase;
|
||||||
|
|
||||||
return PHASEMASK_NORMAL;
|
return phase;
|
||||||
}
|
}
|
||||||
|
|
||||||
InventoryResult Player::CanEquipUniqueItem(Item* pItem, uint8 eslot, uint32 limit_count) const
|
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;
|
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)
|
void Unit::SetPhaseMask(uint32 newPhaseMask, bool update)
|
||||||
{
|
{
|
||||||
if (newPhaseMask == GetPhaseMask())
|
if (newPhaseMask == GetPhaseMask())
|
||||||
|
|||||||
@@ -2125,6 +2125,7 @@ class Unit : public WorldObject
|
|||||||
void SetModelVisible(bool on);
|
void SetModelVisible(bool on);
|
||||||
|
|
||||||
// common function for visibility checks for player/creatures with detection code
|
// common function for visibility checks for player/creatures with detection code
|
||||||
|
uint32 GetPhaseByAuras() const;
|
||||||
void SetPhaseMask(uint32 newPhaseMask, bool update);// overwrite WorldObject::SetPhaseMask
|
void SetPhaseMask(uint32 newPhaseMask, bool update);// overwrite WorldObject::SetPhaseMask
|
||||||
void UpdateObjectVisibility(bool forced = true, bool fromUpdate = false);
|
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();
|
Unit* target = aurApp->GetTarget();
|
||||||
|
|
||||||
// no-phase is also phase state so same code for apply and remove
|
// no-phase is also phase state so same code for apply and remove
|
||||||
uint32 newPhase = 0;
|
uint32 newPhase = target->GetPhaseByAuras();
|
||||||
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();
|
|
||||||
|
|
||||||
if (Player* player = target->ToPlayer())
|
if (Player* player = target->ToPlayer())
|
||||||
{
|
{
|
||||||
if (!newPhase)
|
if (!newPhase)
|
||||||
newPhase = PHASEMASK_NORMAL;
|
newPhase = PHASEMASK_NORMAL;
|
||||||
|
|
||||||
// GM-mode have mask 0xFFFFFFFF
|
// do not change phase to GM with all phases enabled
|
||||||
if (player->IsGameMaster())
|
if (player->IsGameMaster())
|
||||||
newPhase = 0xFFFFFFFF;
|
newPhase = PHASEMASK_ANYWHERE;
|
||||||
|
|
||||||
player->SetPhaseMask(newPhase, false);
|
player->SetPhaseMask(newPhase, false);
|
||||||
player->GetSession()->SendSetPhaseShift(newPhase);
|
player->GetSession()->SendSetPhaseShift(newPhase);
|
||||||
|
|||||||
Reference in New Issue
Block a user