mirror of
https://github.com/liyunfan1223/mod-playerbots.git
synced 2026-06-20 15:39:25 +02:00
fix(Core/Travel): Bail chained probe on non-progress oscillation
This commit is contained in:
parent
7b57fe4b18
commit
2de92e681f
@ -852,6 +852,15 @@ std::vector<WorldPosition> WorldPosition::getPathFromPath(std::vector<WorldPosit
|
|||||||
|
|
||||||
PathGenerator path(pathUnit);
|
PathGenerator path(pathUnit);
|
||||||
|
|
||||||
|
// Non-progress detection: track best distance-to-target across
|
||||||
|
// iterations. If two consecutive steps fail to improve it, the
|
||||||
|
// chained probe is oscillating between polygons in a local navmesh
|
||||||
|
// pocket — bail to avoid accumulating 40 iterations of useless
|
||||||
|
// waypoints that leave the bot stranded mid-terrain.
|
||||||
|
float bestDistToTarget = std::numeric_limits<float>::max();
|
||||||
|
uint32 noProgress = 0;
|
||||||
|
constexpr uint32 MAX_NO_PROGRESS = 2;
|
||||||
|
|
||||||
// Limit the pathfinding attempts
|
// Limit the pathfinding attempts
|
||||||
for (uint32 i = 0; i < maxAttempt; i++)
|
for (uint32 i = 0; i < maxAttempt; i++)
|
||||||
{
|
{
|
||||||
@ -871,6 +880,18 @@ std::vector<WorldPosition> WorldPosition::getPathFromPath(std::vector<WorldPosit
|
|||||||
if (isPathTo(subPath))
|
if (isPathTo(subPath))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
float distNow = this->distance(&subPath.back());
|
||||||
|
if (distNow + 0.5f >= bestDistToTarget)
|
||||||
|
{
|
||||||
|
if (++noProgress >= MAX_NO_PROGRESS)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bestDistToTarget = distNow;
|
||||||
|
noProgress = 0;
|
||||||
|
}
|
||||||
|
|
||||||
currentPos = subPath.back();
|
currentPos = subPath.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user