Skip to content

Commit

Permalink
[11536] Override Unit::SetPhaseMask for players, move some functional…
Browse files Browse the repository at this point in the history
…ity from Aura::HandlePhase
  • Loading branch information
SilverIce committed May 25, 2011
1 parent 8589ce1 commit e028f3b
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 35 deletions.
14 changes: 14 additions & 0 deletions src/game/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19980,6 +19980,20 @@ template void Player::UpdateVisibilityOf(WorldObject const* viewPoint, Corpse*
template void Player::UpdateVisibilityOf(WorldObject const* viewPoint, GameObject* target, UpdateData& data, std::set<WorldObject*>& visibleNow);
template void Player::UpdateVisibilityOf(WorldObject const* viewPoint, DynamicObject* target, UpdateData& data, std::set<WorldObject*>& visibleNow);

void Player::SetPhaseMask(uint32 newPhaseMask, bool update)
{
// GM-mode have mask PHASEMASK_ANYWHERE always
if (isGameMaster())
newPhaseMask = PHASEMASK_ANYWHERE;

// phase auras normally not expected at BG but anyway better check
if (BattleGround *bg = GetBattleGround())
bg->EventPlayerDroppedFlag(this);

Unit::SetPhaseMask(newPhaseMask, update);
GetSession()->SendSetPhaseShift(GetPhaseMask());
}

void Player::InitPrimaryProfessions()
{
SetFreePrimaryProfessions(sWorld.getConfig(CONFIG_UINT32_MAX_PRIMARY_TRADE_SKILL));
Expand Down
2 changes: 2 additions & 0 deletions src/game/Player.h
Original file line number Diff line number Diff line change
Expand Up @@ -2235,6 +2235,8 @@ class MANGOS_DLL_SPEC Player : public Unit

Camera& GetCamera() { return m_camera; }

virtual void SetPhaseMask(uint32 newPhaseMask, bool update);// overwrite Unit::SetPhaseMask

uint8 m_forced_speed_changes[MAX_MOVE_TYPE];

bool HasAtLoginFlag(AtLoginFlags f) const { return m_atLoginFlags & f; }
Expand Down
49 changes: 15 additions & 34 deletions src/game/SpellAuras.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8214,49 +8214,30 @@ void Aura::HandlePhase(bool apply, bool Real)
target->RemoveAurasDueToSpell(phases.front()->GetId(), GetHolder());
}

target->SetPhaseMask(apply ? GetMiscValue() : PHASEMASK_NORMAL, true);
// no-phase is also phase state so same code for apply and remove

// phase auras normally not expected at BG but anyway better check
if(target->GetTypeId() == TYPEID_PLAYER)
if (GetEffIndex() == EFFECT_INDEX_0 && target->GetTypeId() == TYPEID_PLAYER)
{
// drop flag at invisible in bg
if(((Player*)target)->InBattleGround())
if(BattleGround *bg = ((Player*)target)->GetBattleGround())
bg->EventPlayerDroppedFlag((Player*)target);

// GM-mode have mask 0xFFFFFFFF
if(!((Player*)target)->isGameMaster())
target->SetPhaseMask(apply ? GetMiscValue() : PHASEMASK_NORMAL, false);

((Player*)target)->GetSession()->SendSetPhaseShift(apply ? GetMiscValue() : PHASEMASK_NORMAL);

if (GetEffIndex() == EFFECT_INDEX_0)
SpellAreaForAreaMapBounds saBounds = sSpellMgr.GetSpellAreaForAuraMapBounds(GetId());
if(saBounds.first != saBounds.second)
{
SpellAreaForAreaMapBounds saBounds = sSpellMgr.GetSpellAreaForAuraMapBounds(GetId());
if(saBounds.first != saBounds.second)
{
uint32 zone, area;
target->GetZoneAndAreaId(zone, area);
uint32 zone, area;
target->GetZoneAndAreaId(zone, area);

for(SpellAreaForAreaMap::const_iterator itr = saBounds.first; itr != saBounds.second; ++itr)
for(SpellAreaForAreaMap::const_iterator itr = saBounds.first; itr != saBounds.second; ++itr)
{
// some auras remove at aura remove
if(!itr->second->IsFitToRequirements((Player*)target, zone, area))
target->RemoveAurasDueToSpell(itr->second->spellId);
// some auras applied at aura apply
else if(itr->second->autocast)
{
// some auras remove at aura remove
if(!itr->second->IsFitToRequirements((Player*)target, zone, area))
target->RemoveAurasDueToSpell(itr->second->spellId);
// some auras applied at aura apply
else if(itr->second->autocast)
{
if (!target->HasAura(itr->second->spellId, EFFECT_INDEX_0))
target->CastSpell(target, itr->second->spellId, true);
}
if (!target->HasAura(itr->second->spellId, EFFECT_INDEX_0))
target->CastSpell(target, itr->second->spellId, true);
}
}
}
}
else
target->SetPhaseMask(apply ? GetMiscValue() : PHASEMASK_NORMAL, false);

target->UpdateVisibilityAndView();
}

void Aura::HandleAuraSafeFall( bool Apply, bool Real )
Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_nr.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "11535"
#define REVISION_NR "11536"
#endif // __REVISION_NR_H__

0 comments on commit e028f3b

Please sign in to comment.