[7260] Fixed access to uninitilized fields in FleeingMovementGenerator and Creature::IsOutOfThreatArea. Author: VladimirMangos

--HG--
branch : trunk
This commit is contained in:
megamage
2009-02-10 10:03:39 -06:00
parent 22855d6e79
commit 31f4993264
3 changed files with 26 additions and 14 deletions
+14 -7
View File
@@ -301,19 +301,26 @@ FleeingMovementGenerator<T>::Initialize(T &owner)
if(!&owner) if(!&owner)
return; return;
Unit * fright = ObjectAccessor::GetUnit(owner, i_frightGUID);
if(!fright)
return;
_Init(owner); _Init(owner);
owner.CastStop(); owner.CastStop();
owner.addUnitState(UNIT_STAT_FLEEING); owner.addUnitState(UNIT_STAT_FLEEING);
owner.SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_FLEEING); owner.SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_FLEEING);
owner.SetUInt64Value(UNIT_FIELD_TARGET, 0); owner.SetUInt64Value(UNIT_FIELD_TARGET, 0);
owner.RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); owner.RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
i_caster_x = fright->GetPositionX();
i_caster_y = fright->GetPositionY(); if(Unit * fright = ObjectAccessor::GetUnit(owner, i_frightGUID))
i_caster_z = fright->GetPositionZ(); {
i_caster_x = fright->GetPositionX();
i_caster_y = fright->GetPositionY();
i_caster_z = fright->GetPositionZ();
}
else
{
i_caster_x = owner.GetPositionX();
i_caster_y = owner.GetPositionY();
i_caster_z = owner.GetPositionZ();
}
i_only_forward = true; i_only_forward = true;
i_cur_angle = 0.0f; i_cur_angle = 0.0f;
i_last_distance_from_caster = 0.0f; i_last_distance_from_caster = 0.0f;
+11 -6
View File
@@ -7427,6 +7427,11 @@ bool Unit::Attack(Unit *victim, bool meleeAttack)
if(meleeAttack) if(meleeAttack)
addUnitState(UNIT_STAT_MELEE_ATTACKING); addUnitState(UNIT_STAT_MELEE_ATTACKING);
// set position before any AI calls/assistance
//if(GetTypeId()==TYPEID_UNIT)
// ((Creature*)this)->SetCombatStartPosition(GetPositionX(), GetPositionY(), GetPositionZ());
m_attacking = victim; m_attacking = victim;
m_attacking->_addAttacker(this); m_attacking->_addAttacker(this);
@@ -7435,18 +7440,18 @@ bool Unit::Attack(Unit *victim, bool meleeAttack)
if(GetTypeId()==TYPEID_UNIT) if(GetTypeId()==TYPEID_UNIT)
{ {
// should not let player enter combat by right clicking target
SetInCombatWith(victim);
if(victim->GetTypeId() == TYPEID_PLAYER)
victim->SetInCombatWith(this);
AddThreat(victim, 0.0f);
WorldPacket data(SMSG_AI_REACTION, 12); WorldPacket data(SMSG_AI_REACTION, 12);
data << uint64(GetGUID()); data << uint64(GetGUID());
data << uint32(AI_REACTION_AGGRO); // Aggro sound data << uint32(AI_REACTION_AGGRO); // Aggro sound
((WorldObject*)this)->SendMessageToSet(&data, true); ((WorldObject*)this)->SendMessageToSet(&data, true);
((Creature*)this)->CallAssistance(); ((Creature*)this)->CallAssistance();
// should not let player enter combat by right clicking target
SetInCombatWith(victim);
if(victim->GetTypeId() == TYPEID_PLAYER)
victim->SetInCombatWith(this);
AddThreat(victim, 0.0f);
} }
// delay offhand weapon attack to next attack time // delay offhand weapon attack to next attack time
+1 -1
View File
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "7259" #define REVISION_NR "7260"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__