From: terencehill Date: Wed, 8 Mar 2017 19:03:32 +0000 (+0100) Subject: Remove navigation_hasgoals field, use goalentity to check if navigation has goals X-Git-Tag: xonotic-v0.8.2~103 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=6edbdd1418b391f15e31ae1a24b55561fb5a2cf7;p=xonotic%2Fxonotic-data.pk3dir.git Remove navigation_hasgoals field, use goalentity to check if navigation has goals --- diff --git a/qcsrc/server/bot/default/havocbot/havocbot.qc b/qcsrc/server/bot/default/havocbot/havocbot.qc index 2d7cbb4a7..4c3c3f02c 100644 --- a/qcsrc/server/bot/default/havocbot/havocbot.qc +++ b/qcsrc/server/bot/default/havocbot/havocbot.qc @@ -1218,7 +1218,7 @@ bool havocbot_moveto_refresh_route(entity this) navigation_goalrating_start(this); navigation_routerating(this, wp, 10000, 10000); navigation_goalrating_end(this); - return this.navigation_hasgoals; + return (this.goalentity != NULL); } float havocbot_moveto(entity this, vector pos) diff --git a/qcsrc/server/bot/default/navigation.qc b/qcsrc/server/bot/default/navigation.qc index 24cc29bdc..e026e1c76 100644 --- a/qcsrc/server/bot/default/navigation.qc +++ b/qcsrc/server/bot/default/navigation.qc @@ -253,7 +253,6 @@ bool tracewalk(entity e, vector start, vector m1, vector m2, vector end, float m void navigation_clearroute(entity this) { //print("bot ", etos(this), " clear\n"); - this.navigation_hasgoals = false; this.goalentity = NULL; this.goalcurrent = NULL; this.goalstack01 = NULL; @@ -867,13 +866,11 @@ void navigation_routerating(entity this, entity e, float f, float rangebias) // adds an item to the the goal stack with the path to a given item bool navigation_routetogoal(entity this, entity e, vector startposition) { - this.goalentity = e; - // if there is no goal, just exit if (!e) return false; - this.navigation_hasgoals = true; + this.goalentity = e; // put the entity on the goal stack //print("routetogoal ", etos(e), "\n"); @@ -1028,7 +1025,6 @@ void navigation_goalrating_start(entity this) this.navigation_jetpack_goal = NULL; navigation_bestrating = -1; - this.navigation_hasgoals = false; navigation_clearroute(this); navigation_bestgoal = NULL; navigation_markroutes(this, NULL); @@ -1044,16 +1040,13 @@ void navigation_goalrating_end(entity this) LOG_DEBUG("best goal ", this.goalcurrent.classname); // If the bot got stuck then try to reach the farthest waypoint - if (!this.navigation_hasgoals) - if (autocvar_bot_wander_enable) + if (!this.goalentity && autocvar_bot_wander_enable) { if (!(this.aistatus & AI_STATUS_STUCK)) { LOG_DEBUG(this.netname, " cannot walk to any goal"); this.aistatus |= AI_STATUS_STUCK; } - - this.navigation_hasgoals = false; // Reset this value } } diff --git a/qcsrc/server/bot/default/navigation.qh b/qcsrc/server/bot/default/navigation.qh index 889169163..8f1f03ad1 100644 --- a/qcsrc/server/bot/default/navigation.qh +++ b/qcsrc/server/bot/default/navigation.qh @@ -28,7 +28,6 @@ entity navigation_bestgoal; .entity wp_goal_prev1; .float nearestwaypointtimeout; -.float navigation_hasgoals; .float lastteleporttime; .float blacklisted; diff --git a/qcsrc/server/mutators/mutator/gamemode_ctf.qc b/qcsrc/server/mutators/mutator/gamemode_ctf.qc index b1d0ab646..8a88d5d2e 100644 --- a/qcsrc/server/mutators/mutator/gamemode_ctf.qc +++ b/qcsrc/server/mutators/mutator/gamemode_ctf.qc @@ -1686,7 +1686,7 @@ void havocbot_role_ctf_carrier(entity this) navigation_goalrating_end(this); - if (this.navigation_hasgoals) + if (this.goalentity) this.havocbot_cantfindflag = time + 10; else if (time > this.havocbot_cantfindflag) {