nav: reworked bot dropping on pathfinder failure
This commit is contained in:
parent
259dd18330
commit
375a64b861
5 changed files with 19 additions and 12 deletions
|
|
@ -2759,12 +2759,6 @@ void Bot::frame () {
|
|||
}
|
||||
|
||||
void Bot::update () {
|
||||
|
||||
// kick bot from server if requested
|
||||
if (m_kickMeFromServer) {
|
||||
kick ();
|
||||
return;
|
||||
}
|
||||
const auto tid = getCurrentTaskId ();
|
||||
|
||||
m_canChooseAimDirection = true;
|
||||
|
|
|
|||
|
|
@ -1030,6 +1030,9 @@ void Game::slowFrame () {
|
|||
// display welcome message
|
||||
util.checkWelcome ();
|
||||
|
||||
// kick failed bots
|
||||
bots.checkNeedsToBeKicked ();
|
||||
|
||||
// update next update time
|
||||
m_oneSecondFrame = nextUpdate + time ();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -816,6 +816,15 @@ void BotManager::checkBotModel (edict_t *ent, char *infobuffer) {
|
|||
}
|
||||
}
|
||||
|
||||
void BotManager::checkNeedsToBeKicked () {
|
||||
for (const auto &bot : bots) {
|
||||
if (bot->m_kickMeFromServer) {
|
||||
bot->kick (); // kick bot from server if requested
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BotManager::setWeaponMode (int selection) {
|
||||
// this function sets bots weapon mode
|
||||
|
||||
|
|
@ -1659,7 +1668,7 @@ void Bot::kick (bool silent) {
|
|||
// this function kick off one bot from the server.
|
||||
auto username = pev->netname.chars ();
|
||||
|
||||
if (!(pev->flags & FL_CLIENT) || strings.isEmpty (username)) {
|
||||
if (!(pev->flags & FL_CLIENT) || (pev->flags & FL_DORMANT) || strings.isEmpty (username)) {
|
||||
return;
|
||||
}
|
||||
markStale ();
|
||||
|
|
|
|||
|
|
@ -3052,7 +3052,7 @@ void Bot::syncFindPath (int srcIndex, int destIndex, FindPath pathType) {
|
|||
srcIndex = changeNodeIndex (graph.getNearestNoBuckets (pev->origin, 256.0f));
|
||||
|
||||
if (!graph.exists (srcIndex)) {
|
||||
printf ("%s source path index not valid (%d).\n", __func__, srcIndex);
|
||||
fprintf (stderr, "%s source path index not valid (%d).\n", __func__, srcIndex);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -3063,7 +3063,7 @@ void Bot::syncFindPath (int srcIndex, int destIndex, FindPath pathType) {
|
|||
destIndex = graph.random ();
|
||||
|
||||
if (!graph.exists (destIndex)) {
|
||||
printf ("%s dest path index not valid (%d).\n", __func__, destIndex);
|
||||
fprintf (stderr, "%s dest path index not valid (%d).\n", __func__, destIndex);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -3071,7 +3071,7 @@ void Bot::syncFindPath (int srcIndex, int destIndex, FindPath pathType) {
|
|||
|
||||
// do not process if src points to dst
|
||||
if (srcIndex == destIndex) {
|
||||
printf ("%s source path is same as dest (%d).\n", __func__, destIndex);
|
||||
fprintf (stderr, "%s source path is same as dest (%d).\n", __func__, destIndex);
|
||||
return;
|
||||
}
|
||||
clearSearchNodes ();
|
||||
|
|
@ -3126,7 +3126,7 @@ void Bot::syncFindPath (int srcIndex, int destIndex, FindPath pathType) {
|
|||
m_kickMeFromServer = true; // bot should be kicked within main thread, not here
|
||||
|
||||
// bot should not roam when this occurs
|
||||
printf ("A* Search for bot \"%s\" failed with internal pathfinder error. Seems to be graph is broken. Bot removed (re-added).\n", pev->netname.chars ());
|
||||
fprintf (stderr, "A* Search for bot \"%s\" failed with internal pathfinder error. Seems to be graph is broken. Bot removed (re-added).\n", pev->netname.chars ());
|
||||
break;
|
||||
|
||||
case AStarResult::Failed:
|
||||
|
|
@ -3134,7 +3134,7 @@ void Bot::syncFindPath (int srcIndex, int destIndex, FindPath pathType) {
|
|||
findShortestPath (srcIndex, destIndex); // A* found no path, try floyd pathfinder instead
|
||||
|
||||
if (cv_debug.bool_ ()) {
|
||||
printf ("A* Search for bot \"%s\" has failed. Falling back to shortest-path algorithm. Seems to be graph is broken.\n", pev->netname.chars ());
|
||||
fprintf (stderr, "A* Search for bot \"%s\" has failed. Falling back to shortest-path algorithm. Seems to be graph is broken.\n", pev->netname.chars ());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue