aboutsummaryrefslogtreecommitdiff
path: root/src/game/Unit.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/Unit.cpp')
-rw-r--r--src/game/Unit.cpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index 79e31ce6dce..e845dff66cf 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -80,7 +80,7 @@ static bool procPrepared = InitTriggerAuraData();
Unit::Unit()
: WorldObject(), i_motionMaster(this), m_ThreatManager(this), m_HostilRefManager(this)
-, m_IsInNotifyList(false), m_Notified(false), IsAIEnabled(false), NeedChangeAI(false)
+, m_NotifyListPos(-1), m_Notified(false), IsAIEnabled(false), NeedChangeAI(false)
, i_AI(NULL), i_disabledAI(NULL), m_removedAurasCount(0), m_Vehicle(NULL), m_transport(NULL)
, m_ControlledByPlayer(false), m_procDeep(0)
{
@@ -10448,8 +10448,7 @@ void Unit::SetVisibility(UnitVisibility x)
{
m_Visibility = x;
- if(IsInWorld())
- SetToNotify();
+ SetToNotify();
if(x == VISIBILITY_GROUP_STEALTH)
DestroyForNearbyPlayers();
@@ -11683,7 +11682,7 @@ void Unit::AddToWorld()
{
WorldObject::AddToWorld();
m_Notified = false;
- m_IsInNotifyList = false;
+ assert(m_NotifyListPos < 0);
SetToNotify();
}
}
@@ -11702,6 +11701,12 @@ void Unit::RemoveFromWorld()
RemoveNotOwnSingleTargetAuras();
ExitVehicle();
+ if(m_NotifyListPos >= 0)
+ {
+ GetMap()->RemoveUnitFromNotify(m_NotifyListPos);
+ m_NotifyListPos = -1;
+ }
+
if(GetCharmerGUID())
{
sLog.outCrash("Unit %u has charmer guid when removed from world", GetEntry());
@@ -13227,11 +13232,9 @@ bool Unit::HandleAuraRaidProcFromCharge( AuraEffect* triggeredByAura )
void Unit::SetToNotify()
{
- if(m_IsInNotifyList)
- return;
-
- if(Map *map = GetMap())
- map->AddUnitToNotify(this);
+ // it is called somewhere when obj is not in world (crash when log in instance)
+ if(m_NotifyListPos < 0 && IsInWorld())
+ GetMap()->AddUnitToNotify(this);
}
void Unit::Kill(Unit *pVictim, bool durabilityLoss)