Ticket #3785: real_fix.patch

File real_fix.patch, 1.4 KB (added by wraitii, 7 years ago)
  • source/simulation2/components/CCmpPathfinder_Vertex.cpp

    diff --git a/source/simulation2/components/CCmpPathfinder_Vertex.cpp b/source/simulation2/components/CCmpPathfinder_Vertex.cpp
    index 1ab8932..b15e275 100644
    a b void CCmpPathfinder::ComputeShortPath(const IObstructionTestFilter& filter,  
    831831
    832832            bool visible = true;
    833833            u16 i, j;
    834             Pathfinding::NearestNavcell(vertexes[curr.id].p.X, vertexes[curr.id].p.Y, i, j, m_Grid->m_W, m_Grid->m_H);
    835             if (!IS_PASSABLE(m_Grid->get(i, j), passClass))
     834
     835            Pathfinding::NearestNavcell(npos.X, npos.Y, i, j, m_Grid->m_W, m_Grid->m_H);
     836            // we may not go on impassable vertexes, so close it if this vertex is like that.
     837            // lazily computed for performance.
     838            // NB: this is only possible because we do not add the "search area" edges,
     839            // and some obstructions may create vertexes outside of it where terrain edges are not computed.
     840            if (!IS_PASSABLE(m_TerrainOnlyGrid->get(i, j), passClass))
    836841            {
    837                 Pathfinding::NearestNavcell(npos.X, npos.Y, i, j, m_Grid->m_W, m_Grid->m_H);
    838                 // Do not allow path between two impassable vertexes to prevent cases
    839                 // where a path along an obstruction will end up in an impassable region
    840                 if (!IS_PASSABLE(m_Grid->get(i, j), passClass))
    841                     visible = false;
     842                vertexes[n].status = Vertex::CLOSED;
     843                continue;
    842844            }
    843845
    844846            visible = visible &&