fix: crash on predicted node index use after wiped
refactor: reworked prediction to calc prediction for all bots at one job, instead of firing it for every bot
This commit is contained in:
parent
5ce2032acd
commit
93d9187f6d
12 changed files with 205 additions and 182 deletions
|
|
@ -1623,17 +1623,12 @@ void Bot::overrideConditions () {
|
|||
}
|
||||
}
|
||||
|
||||
void Bot::syncUpdatePredictedIndex () {
|
||||
void Bot::updatePredictedIndex () {
|
||||
auto wipePredict = [this] () {
|
||||
m_lastPredictIndex = kInvalidNodeIndex;
|
||||
m_lastPredictLength = kInfiniteDistanceLong;
|
||||
};
|
||||
|
||||
if (!m_predictLock.tryLock ()) {
|
||||
return; // allow only single instance of search per-bot
|
||||
}
|
||||
ScopedUnlock <Mutex> unlock (m_predictLock);
|
||||
|
||||
const auto lastEnemyOrigin = m_lastEnemyOrigin;
|
||||
const auto currentNodeIndex = m_currentNodeIndex;
|
||||
const auto &botOrigin = pev->origin;
|
||||
|
|
@ -1671,15 +1666,6 @@ void Bot::syncUpdatePredictedIndex () {
|
|||
wipePredict ();
|
||||
}
|
||||
|
||||
void Bot::updatePredictedIndex () {
|
||||
if (m_lastEnemyOrigin.empty ()) {
|
||||
return; // do not run task if no last enemy
|
||||
}
|
||||
worker.enqueue ([this] () {
|
||||
syncUpdatePredictedIndex ();
|
||||
});
|
||||
}
|
||||
|
||||
void Bot::refreshEnemyPredict () {
|
||||
if (game.isNullEntity (m_enemy) && !game.isNullEntity (m_lastEnemy) && !m_lastEnemyOrigin.empty ()) {
|
||||
const auto distanceToLastEnemySq = m_lastEnemyOrigin.distanceSq (pev->origin);
|
||||
|
|
@ -1693,10 +1679,6 @@ void Bot::refreshEnemyPredict () {
|
|||
m_aimFlags |= AimFlags::LastEnemy;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_aimFlags & AimFlags::PredictPath) {
|
||||
updatePredictedIndex ();
|
||||
}
|
||||
}
|
||||
|
||||
void Bot::setConditions () {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue