prevent short pathfinder to go into impassable region, fixes #3785

This was SVN commit r17765.
This commit is contained in:
mimo 2016-02-15 21:24:27 +00:00
parent a9376eeebb
commit 41d7e64271

View File

@ -838,6 +838,11 @@ void CCmpPathfinder::ComputeShortPath(const IObstructionTestFilter& filter,
else else
{ {
npos = vertexes[n].p; npos = vertexes[n].p;
// Prevent cases where a path along an obstruction will end up in an impassable region
u16 i, j;
Pathfinding::NearestNavcell(npos.X, npos.Y, i, j, m_Grid->m_W, m_Grid->m_H);
if (!IS_PASSABLE(m_Grid->get(i, j), passClass))
continue;
} }
// Work out which quadrant(s) we're approaching the new vertex from // Work out which quadrant(s) we're approaching the new vertex from
@ -853,10 +858,8 @@ void CCmpPathfinder::ComputeShortPath(const IObstructionTestFilter& filter,
// Hack: Always head towards the goal if possible, to avoid missing it if it's // Hack: Always head towards the goal if possible, to avoid missing it if it's
// inside another unit // inside another unit
if (n != GOAL_VERTEX_ID) if (n != GOAL_VERTEX_ID)
{
continue; continue;
} }
}
bool visible = bool visible =
CheckVisibilityLeft(vertexes[curr.id].p, npos, edgesLeft) && CheckVisibilityLeft(vertexes[curr.id].p, npos, edgesLeft) &&