From 243f33b5eae4e5dc96e8134c650ea74daa07ee35 Mon Sep 17 00:00:00 2001 From: n0n4m3 Date: Sat, 19 Dec 2009 10:12:40 +0100 Subject: Implement new visibility system, based on Silverice patch for mangos --HG-- branch : trunk --- src/game/Unit.cpp | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'src/game/Unit.cpp') diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index af07f8eee97..4f3e90bf507 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -11220,7 +11220,22 @@ void Unit::SetVisibility(UnitVisibility x) { m_Visibility = x; - SetToNotify(); + if(IsInWorld()) + { + Map *m = GetMap(); + CellPair p(Trinity::ComputeCellPair(GetPositionX(), GetPositionY())); + Cell cell(p); + + if(GetTypeId() == TYPEID_PLAYER) + { + m->UpdatePlayerVisibility((Player*)this, cell, p); + m->UpdateObjectsVisibilityFor((Player*)this, cell, p); + } + else + m->UpdateObjectVisibility(this, cell, p); + + AddToNotify(NOTIFY_AI_RELOCATION); + } if (x == VISIBILITY_GROUP_STEALTH) DestroyForNearbyPlayers(); @@ -14034,9 +14049,10 @@ bool Unit::HandleAuraRaidProcFromCharge(AuraEffect* triggeredByAura) void Unit::SetToNotify() { - // it is called somewhere when obj is not in world (crash when log in instance) - if (m_NotifyListPos < 0) - GetMap()->AddUnitToNotify(this); + if (GetTypeId() == TYPEID_PLAYER) + AddToNotify(NOTIFY_VISIBILITY_CHANGED | NOTIFY_AI_RELOCATION | NOTIFY_PLAYER_VISIBILITY); + else + AddToNotify(NOTIFY_VISIBILITY_CHANGED | NOTIFY_AI_RELOCATION); } void Unit::Kill(Unit *pVictim, bool durabilityLoss) -- cgit v1.2.3