Skip to content

Commit a0ac6a7

Browse files
committed
Discard stale waypoint route on rollback
1 parent 1f55e18 commit a0ac6a7

1 file changed

Lines changed: 7 additions & 13 deletions

File tree

utils/RCBot2_meta/bot_waypoint.cpp

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,21 +1267,15 @@ void CWaypointNavigator :: rollBackPosition ()
12671267
m_vPreviousPoint = m_pBot->getOrigin();
12681268
m_iCurrentWaypoint = CWaypointLocations::NearestWaypoint(m_vPreviousPoint,CWaypointLocations::REACHABLE_RANGE,m_iLastFailedWpt,true,false,true, nullptr,false,m_pBot->getTeam());
12691269

1270-
// TODO: figure out what this is actually intended to do
1271-
while ( !m_currentRoute.empty() ) // reached goal!!
1272-
{
1273-
const int iRouteWaypoint = m_currentRoute.top();
1274-
m_currentRoute.pop();
1275-
if (m_iCurrentWaypoint == iRouteWaypoint && !m_currentRoute.empty())
1276-
{
1277-
m_iCurrentWaypoint = m_currentRoute.top();
1278-
m_currentRoute.pop();
1279-
}
1280-
}
1270+
// The bot strayed off the waypoint network (e.g. a medic following a heal
1271+
// target), so the queued route is stale. Re-anchoring m_iCurrentWaypoint to
1272+
// the bot's body above is the only thing that needs to survive: every caller
1273+
// fail()s immediately after, which makes the next nav task rebuild the route
1274+
// from scratch. Just discard the stale route here.
1275+
std::stack<int>().swap(m_currentRoute);
12811276

1282-
if ( m_iCurrentWaypoint == -1 )
1277+
if ( m_iCurrentWaypoint == -1 )
12831278
m_iCurrentWaypoint = CWaypointLocations::NearestWaypoint(m_pBot->getOrigin(),CWaypointLocations::REACHABLE_RANGE,-1,true,false,true, nullptr,false,m_pBot->getTeam());
1284-
// find waypoint in route
12851279
}
12861280
// update the bots current walk vector
12871281
void CWaypointNavigator :: updatePosition ()

0 commit comments

Comments
 (0)