Core/Misc: Ensure GetVictim() returns a valid reference when expected

Add a new method EnsureVictim() which asserts a valid not NULL reference will be returned to the caller. Use this whenever the GetVictim() would be dereferenced .
This commit is contained in:
jackpoz committed 2014-04-19 21:48:22 +02:00
1 parent fac3f445b1
commit 8ca6371793
39 files changed
+73 -67

No files matched your search

+3 -3
View File
@@ -15559,7 +15559,7 @@ void Unit::SetStunned(bool apply)
else
{
if (IsAlive() && GetVictim())
SetTarget(GetVictim()->GetGUID());
SetTarget(EnsureVictim()->GetGUID());
// don't remove UNIT_FLAG_STUNNED for pet when owner is mounted (disabled pet's interface)
Unit* owner = GetOwner();
@@ -15650,7 +15650,7 @@ void Unit::SetFeared(bool apply)
if (GetMotionMaster()->GetCurrentMovementGeneratorType() == FLEEING_MOTION_TYPE)
GetMotionMaster()->MovementExpired();
if (GetVictim())
SetTarget(GetVictim()->GetGUID());
SetTarget(EnsureVictim()->GetGUID());
}
}
@@ -15672,7 +15672,7 @@ void Unit::SetConfused(bool apply)
if (GetMotionMaster()->GetCurrentMovementGeneratorType() == CONFUSED_MOTION_TYPE)
GetMotionMaster()->MovementExpired();
if (GetVictim())
SetTarget(GetVictim()->GetGUID());
SetTarget(EnsureVictim()->GetGUID());
}
}