fix(Core/Movement): use-after-free using DontCacheRandomMovementPaths (#24935)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -211,7 +211,8 @@ void RandomMovementGenerator<Creature>::_setRandomLocation(Creature* creature)
|
|||||||
}
|
}
|
||||||
|
|
||||||
_currentPoint = newPoint;
|
_currentPoint = newPoint;
|
||||||
G3D::Vector3& finalPoint = finalPath[finalPath.size() - 1];
|
ASSERT(!finalPath.empty());
|
||||||
|
G3D::Vector3 finalPoint = finalPath.back();
|
||||||
_currDestPosition.Relocate(finalPoint.x, finalPoint.y, finalPoint.z);
|
_currDestPosition.Relocate(finalPoint.x, finalPoint.y, finalPoint.z);
|
||||||
|
|
||||||
creature->AddUnitState(UNIT_STATE_ROAMING_MOVE);
|
creature->AddUnitState(UNIT_STATE_ROAMING_MOVE);
|
||||||
@@ -239,12 +240,13 @@ void RandomMovementGenerator<Creature>::_setRandomLocation(Creature* creature)
|
|||||||
_moveCount = 0;
|
_moveCount = 0;
|
||||||
_nextMoveTime.Reset(urand(4000, 8000));
|
_nextMoveTime.Reset(urand(4000, 8000));
|
||||||
}
|
}
|
||||||
if (sWorld->getBoolConfig(CONFIG_DONT_CACHE_RANDOM_MOVEMENT_PATHS))
|
|
||||||
_preComputedPaths.erase(pathIdx);
|
|
||||||
|
|
||||||
//Call for creature group update
|
//Call for creature group update
|
||||||
if (creature->GetFormation() && creature->GetFormation()->GetLeader() == creature)
|
if (creature->GetFormation() && creature->GetFormation()->GetLeader() == creature)
|
||||||
creature->GetFormation()->LeaderMoveTo(finalPoint.x, finalPoint.y, finalPoint.z, 0);
|
creature->GetFormation()->LeaderMoveTo(finalPoint.x, finalPoint.y, finalPoint.z, 0);
|
||||||
|
|
||||||
|
if (sWorld->getBoolConfig(CONFIG_DONT_CACHE_RANDOM_MOVEMENT_PATHS))
|
||||||
|
_preComputedPaths.erase(pathIdx);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
|
|||||||
Reference in New Issue
Block a user