From 487fee0636e9e98ed4057c320ebd958a03463e8d Mon Sep 17 00:00:00 2001 From: Marcus Hutchings Date: Sat, 6 Jan 2024 18:40:18 +0000 Subject: [PATCH] Stop rapid repathing scenario. Allow searches to find a good quad for large goal radius. --- rts/Sim/Path/QTPFS/PathSearch.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/rts/Sim/Path/QTPFS/PathSearch.cpp b/rts/Sim/Path/QTPFS/PathSearch.cpp index d670017cdf..734dc73c79 100644 --- a/rts/Sim/Path/QTPFS/PathSearch.cpp +++ b/rts/Sim/Path/QTPFS/PathSearch.cpp @@ -112,12 +112,13 @@ void QTPFS::PathSearch::InitializeThread(SearchThreadData* threadData) { if (tgtNode->AllSquaresImpassable()) { // find nearest acceptable node because this will otherwise trigger a full walk of every pathable node. + int searchWidth = std::max(int(goalDistance)/SQUARE_SIZE, 16); INode* altTgtNode = nodeLayer->GetNearestNodeInArea ( SRectangle - ( std::max(int(tgtNode->xmin()) - 16, 0) - , std::max(int(tgtNode->zmin()) - 16, 0) - , std::min(int(tgtNode->xmax()) + 16, mapDims.mapx) - , std::min(int(tgtNode->zmax()) + 16, mapDims.mapy) + ( std::max(int(tgtNode->xmin()) - searchWidth, 0) + , std::max(int(tgtNode->zmin()) - searchWidth, 0) + , std::min(int(tgtNode->xmax()) + searchWidth, mapDims.mapx) + , std::min(int(tgtNode->zmax()) + searchWidth, mapDims.mapy) ) , int2(fwd.tgtPoint.x / SQUARE_SIZE, fwd.tgtPoint.z / SQUARE_SIZE) , searchThreadData->tmpNodesStore @@ -1171,6 +1172,9 @@ void QTPFS::PathSearch::TracePath(IPath* path) { break; if (repathIndex != 0 && curPoint.dist < halfWay) // try to get point close to the middle. break; + // prevent a repath being triggered immediately when the first two points are taken immediately. + if (curPoint.index <= 2) + break; repathIndex = curPoint.index; }