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
|
|
@ -121,6 +121,7 @@ public:
|
||||||
void handleDeath (edict_t *killer, edict_t *victim);
|
void handleDeath (edict_t *killer, edict_t *victim);
|
||||||
void setLastWinner (int winner);
|
void setLastWinner (int winner);
|
||||||
void checkBotModel (edict_t *ent, char *infobuffer);
|
void checkBotModel (edict_t *ent, char *infobuffer);
|
||||||
|
void checkNeedsToBeKicked ();
|
||||||
|
|
||||||
bool isTeamStacked (int team);
|
bool isTeamStacked (int team);
|
||||||
bool kickRandom (bool decQuota = true, Team fromTeam = Team::Unassigned);
|
bool kickRandom (bool decQuota = true, Team fromTeam = Team::Unassigned);
|
||||||
|
|
|
||||||
|
|
@ -2759,12 +2759,6 @@ void Bot::frame () {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bot::update () {
|
void Bot::update () {
|
||||||
|
|
||||||
// kick bot from server if requested
|
|
||||||
if (m_kickMeFromServer) {
|
|
||||||
kick ();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const auto tid = getCurrentTaskId ();
|
const auto tid = getCurrentTaskId ();
|
||||||
|
|
||||||
m_canChooseAimDirection = true;
|
m_canChooseAimDirection = true;
|
||||||
|
|
|
||||||
|
|
@ -1030,6 +1030,9 @@ void Game::slowFrame () {
|
||||||
// display welcome message
|
// display welcome message
|
||||||
util.checkWelcome ();
|
util.checkWelcome ();
|
||||||
|
|
||||||
|
// kick failed bots
|
||||||
|
bots.checkNeedsToBeKicked ();
|
||||||
|
|
||||||
// update next update time
|
// update next update time
|
||||||
m_oneSecondFrame = nextUpdate + 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) {
|
void BotManager::setWeaponMode (int selection) {
|
||||||
// this function sets bots weapon mode
|
// this function sets bots weapon mode
|
||||||
|
|
||||||
|
|
@ -1659,7 +1668,7 @@ void Bot::kick (bool silent) {
|
||||||
// this function kick off one bot from the server.
|
// this function kick off one bot from the server.
|
||||||
auto username = pev->netname.chars ();
|
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;
|
return;
|
||||||
}
|
}
|
||||||
markStale ();
|
markStale ();
|
||||||
|
|
|
||||||
|
|
@ -3052,7 +3052,7 @@ void Bot::syncFindPath (int srcIndex, int destIndex, FindPath pathType) {
|
||||||
srcIndex = changeNodeIndex (graph.getNearestNoBuckets (pev->origin, 256.0f));
|
srcIndex = changeNodeIndex (graph.getNearestNoBuckets (pev->origin, 256.0f));
|
||||||
|
|
||||||
if (!graph.exists (srcIndex)) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -3063,7 +3063,7 @@ void Bot::syncFindPath (int srcIndex, int destIndex, FindPath pathType) {
|
||||||
destIndex = graph.random ();
|
destIndex = graph.random ();
|
||||||
|
|
||||||
if (!graph.exists (destIndex)) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -3071,7 +3071,7 @@ void Bot::syncFindPath (int srcIndex, int destIndex, FindPath pathType) {
|
||||||
|
|
||||||
// do not process if src points to dst
|
// do not process if src points to dst
|
||||||
if (srcIndex == destIndex) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
clearSearchNodes ();
|
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
|
m_kickMeFromServer = true; // bot should be kicked within main thread, not here
|
||||||
|
|
||||||
// bot should not roam when this occurs
|
// 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;
|
break;
|
||||||
|
|
||||||
case AStarResult::Failed:
|
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
|
findShortestPath (srcIndex, destIndex); // A* found no path, try floyd pathfinder instead
|
||||||
|
|
||||||
if (cv_debug.bool_ ()) {
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue