fix(Core/AI): Prevent uint32 underflow in ScriptedEscortAI (#25485)
Co-authored-by: zhangjunming <zhangjunming@DESKTOP-LQP9RI3.local>
This commit is contained in:
parent
3bb2815da7
commit
b53e1b8eac
1 changed files with 2 additions and 3 deletions
|
|
@ -549,8 +549,6 @@ void npc_escortAI::GenerateWaypointArray(Movement::PointsArray* points)
|
||||||
if (WaypointList.empty())
|
if (WaypointList.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
uint32 startingWaypointId = CurrentWP->id;
|
|
||||||
|
|
||||||
// Flying unit, just fill array
|
// Flying unit, just fill array
|
||||||
if (me->m_movementInfo.HasMovementFlag((MovementFlags)(MOVEMENTFLAG_CAN_FLY | MOVEMENTFLAG_DISABLE_GRAVITY)))
|
if (me->m_movementInfo.HasMovementFlag((MovementFlags)(MOVEMENTFLAG_CAN_FLY | MOVEMENTFLAG_DISABLE_GRAVITY)))
|
||||||
{
|
{
|
||||||
|
|
@ -562,12 +560,13 @@ void npc_escortAI::GenerateWaypointArray(Movement::PointsArray* points)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
uint32 remainingWaypoints = std::distance(CurrentWP, WaypointList.end());
|
||||||
for (float size = 1.0f; size; size *= 0.5f)
|
for (float size = 1.0f; size; size *= 0.5f)
|
||||||
{
|
{
|
||||||
std::vector<G3D::Vector3> pVector;
|
std::vector<G3D::Vector3> pVector;
|
||||||
// xinef: first point in vector is unit real position
|
// xinef: first point in vector is unit real position
|
||||||
pVector.push_back(G3D::Vector3(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ()));
|
pVector.push_back(G3D::Vector3(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ()));
|
||||||
uint32 length = (WaypointList.size() - startingWaypointId) * size;
|
uint32 length = remainingWaypoints * size;
|
||||||
|
|
||||||
uint32 cnt = 0;
|
uint32 cnt = 0;
|
||||||
for (std::list<Escort_Waypoint>::const_iterator itr = CurrentWP; itr != WaypointList.end() && cnt <= length; ++itr, ++cnt)
|
for (std::list<Escort_Waypoint>::const_iterator itr = CurrentWP; itr != WaypointList.end() && cnt <= length; ++itr, ++cnt)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue