aim: fail prediction more correctly

This commit is contained in:
jeefo 2023-05-07 13:21:49 +03:00
commit 0072bbb413
No known key found for this signature in database
GPG key ID: 927BCA0779BEA8ED
2 changed files with 3 additions and 3 deletions

View file

@ -1591,10 +1591,11 @@ void Bot::overrideConditions () {
void Bot::syncUpdatePredictedIndex () { void Bot::syncUpdatePredictedIndex () {
auto wipePredict = [this] () { auto wipePredict = [this] () {
m_lastPredictIndex = kInvalidNodeIndex; m_lastPredictIndex = kInvalidNodeIndex;
m_lastPredictLength = 0; m_lastPredictLength = kInfiniteDistanceLong;
}; };
if (!m_predictLock.tryLock ()) { if (!m_predictLock.tryLock ()) {
wipePredict ();
return; // allow only single instance of search per-bot return; // allow only single instance of search per-bot
} }
ScopedUnlock <Mutex> unlock (m_predictLock); ScopedUnlock <Mutex> 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_lookAt = graph[predictNode].origin;
m_lookAtSafe = m_lookAt; m_lookAtSafe = m_lookAt;

View file

@ -1435,7 +1435,6 @@ void Bot::clearSearchNodes () {
int Bot::findAimingNode (const Vector &to, int &pathLength) { 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 // return the most distant node which is seen from the bot to the target and is within count
ensureCurrentNodeIndex (); ensureCurrentNodeIndex ();
int destIndex = graph.getNearest (to); int destIndex = graph.getNearest (to);