diff --git a/src/botlib.cpp b/src/botlib.cpp index ce87fc1..69f4197 100644 --- a/src/botlib.cpp +++ b/src/botlib.cpp @@ -1591,10 +1591,11 @@ void Bot::overrideConditions () { void Bot::syncUpdatePredictedIndex () { auto wipePredict = [this] () { m_lastPredictIndex = kInvalidNodeIndex; - m_lastPredictLength = 0; + m_lastPredictLength = kInfiniteDistanceLong; }; if (!m_predictLock.tryLock ()) { + wipePredict (); return; // allow only single instance of search per-bot } ScopedUnlock unlock (m_predictLock); @@ -2716,7 +2717,7 @@ void Bot::updateAimDir () { } } - if (pathLength < cv_max_nodes_for_predict.int_ ()) { + if (graph.exists (predictNode) && pathLength < cv_max_nodes_for_predict.int_ ()) { m_lookAt = graph[predictNode].origin; m_lookAtSafe = m_lookAt; diff --git a/src/navigate.cpp b/src/navigate.cpp index a92051f..01402b3 100644 --- a/src/navigate.cpp +++ b/src/navigate.cpp @@ -1435,7 +1435,6 @@ void Bot::clearSearchNodes () { int Bot::findAimingNode (const Vector &to, int &pathLength) { // return the most distant node which is seen from the bot to the target and is within count - ensureCurrentNodeIndex (); int destIndex = graph.getNearest (to);