]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Bot AI: optimize removal of the first waypoint of the route when bot is really close...
authorterencehill <piuntn@gmail.com>
Sun, 2 Dec 2018 16:35:36 +0000 (17:35 +0100)
committerterencehill <piuntn@gmail.com>
Sun, 2 Dec 2018 16:35:36 +0000 (17:35 +0100)
qcsrc/server/bot/default/navigation.qc

index 6c5e2769b4c6e3d070e91b64258e1373adf2fe55..1a491530a815b20d34fc342c7e9c406c5f95f067 100644 (file)
@@ -1796,6 +1796,7 @@ void navigation_goalrating_start(entity this)
        navigation_clearroute(this);
        navigation_bestgoal = NULL;
        navigation_markroutes(this, wp);
+       this.goalstack31 = wp; // temporarly save the really close waypoint
 }
 
 // ends a goal selection session (updates goal stack to the best goal)
@@ -1804,9 +1805,15 @@ void navigation_goalrating_end(entity this)
        if(this.aistatus & AI_STATUS_STUCK)
                return;
 
+       entity wp = this.goalstack31; // save to wp as this.goalstack31 is set by navigation_routetogoal
+       this.goalstack31 = NULL;
+
        navigation_routetogoal(this, navigation_bestgoal, this.origin);
        LOG_DEBUG("best goal ", this.goalcurrent.classname);
 
+       if (wp && this.goalcurrent == wp)
+               navigation_poproute(this);
+
        // If the bot got stuck then try to reach the farthest waypoint
        if (!this.goalentity)
        {