From 761b57f71443dd6f880f566d4fb2d9548f8629f6 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Tue, 10 Feb 2009 06:20:32 +0300 Subject: [PATCH] [7260] Fixed access to uninitilized fields in FleeingMovementGenerator and Creature::IsOutOfThreatArea. --- src/game/FleeingMovementGenerator.cpp | 21 ++++++++++++++------- src/game/Unit.cpp | 6 +++++- src/shared/revision_nr.h | 2 +- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/game/FleeingMovementGenerator.cpp b/src/game/FleeingMovementGenerator.cpp index 655e9da36..073a95ade 100644 --- a/src/game/FleeingMovementGenerator.cpp +++ b/src/game/FleeingMovementGenerator.cpp @@ -283,15 +283,22 @@ FleeingMovementGenerator::Initialize(T &owner) if(!&owner) return; - Unit * fright = ObjectAccessor::GetUnit(owner, i_frightGUID); - if(!fright) - return; - _Init(owner); owner.RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); - i_caster_x = fright->GetPositionX(); - i_caster_y = fright->GetPositionY(); - i_caster_z = fright->GetPositionZ(); + + if(Unit * fright = ObjectAccessor::GetUnit(owner, i_frightGUID)) + { + 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_cur_angle = 0.0f; i_last_distance_from_caster = 0.0f; diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index a9f55de79..edb21c115 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -7112,6 +7112,11 @@ bool Unit::Attack(Unit *victim, bool meleeAttack) if(meleeAttack) 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->_addAttacker(this); @@ -7126,7 +7131,6 @@ bool Unit::Attack(Unit *victim, bool meleeAttack) ((WorldObject*)this)->SendMessageToSet(&data, true); ((Creature*)this)->CallAssistance(); - ((Creature*)this)->SetCombatStartPosition(GetPositionX(), GetPositionY(), GetPositionZ()); } // delay offhand weapon attack to next attack time diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index a8fa06366..7beb04f0c 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "7259" + #define REVISION_NR "7260" #endif // __REVISION_NR_H__ -- 2.11.4.GIT