Core/Movement: Remove unsafe target resetting in TimedFleeingMovementGenerator::Finalize (starts new movement inside MotionMaster::DirectAdd)
Closes #31824 (cherry picked from commit 7f36470a23b3794f6ddda6a55ca918d474750dab)
This commit is contained in:
@@ -1292,12 +1292,11 @@ void MotionMaster::DirectAdd(MovementGenerator* movement, MovementSlot slot/* =
|
||||
break;
|
||||
case MOTION_SLOT_ACTIVE:
|
||||
{
|
||||
auto where = _generators.lower_bound(movement);
|
||||
if (!_generators.empty())
|
||||
{
|
||||
auto where = _generators.find(movement); // find movement with equal priority
|
||||
bool replacesExisting = !movement->HasFlag(MOVEMENTGENERATOR_FLAG_IMMEDIATE)
|
||||
&& where != _generators.end()
|
||||
&& !_generators.key_comp()(movement, *where);
|
||||
&& where != _generators.end();
|
||||
auto top = _generators.begin();
|
||||
if (replacesExisting)
|
||||
Remove(where, where == top, false);
|
||||
@@ -1309,7 +1308,7 @@ void MotionMaster::DirectAdd(MovementGenerator* movement, MovementSlot slot/* =
|
||||
|
||||
if (!movement->HasFlag(MOVEMENTGENERATOR_FLAG_IMMEDIATE))
|
||||
{
|
||||
_generators.emplace_hint(where, movement);
|
||||
_generators.insert(movement);
|
||||
AddBaseUnitState(movement);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -214,19 +214,10 @@ bool TimedFleeingMovementGenerator::Update(Unit* owner, uint32 diff)
|
||||
|
||||
void TimedFleeingMovementGenerator::Finalize(Unit* owner, bool active, bool movementInform)
|
||||
{
|
||||
AddFlag(MOVEMENTGENERATOR_FLAG_FINALIZED);
|
||||
if (!active)
|
||||
return;
|
||||
FleeingMovementGenerator::Finalize(owner, active, movementInform);
|
||||
|
||||
owner->StopMoving();
|
||||
if (owner->IsCreature() && owner->IsAlive())
|
||||
{
|
||||
if (Unit* victim = owner->GetVictim())
|
||||
{
|
||||
owner->AttackStop();
|
||||
owner->GetAI()->AttackStart(victim);
|
||||
}
|
||||
}
|
||||
if (active)
|
||||
owner->StopMoving();
|
||||
|
||||
if (movementInform)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user