Merge branch 'terencehill/ca_bots_fix' into 'master'
authorMario <zacjardine@y7mail.com>
Sat, 10 Dec 2016 06:20:22 +0000 (06:20 +0000)
committerMario <zacjardine@y7mail.com>
Sat, 10 Dec 2016 06:20:22 +0000 (06:20 +0000)
CA and LMS: fix for bots getting stuck

* CA: fix bots getting stuck right after one of them dies
* LMS: fix bots getting stuck right after one of them is out of lives
* Fix "bot_cmd X pause" command not always working

See merge request !389

1  2 
qcsrc/server/bot/default/bot.qc

@@@ -72,7 -72,6 +72,7 @@@ void bot_think(entity this
  
        if (!IS_PLAYER(this) || (autocvar_g_campaign && !campaign_bots_may_start))
        {
 +              this.movement = '0 0 0';
                this.bot_nextthink = time + 0.5;
                return;
        }
        // if dead, just wait until we can respawn
        if (IS_DEAD(this))
        {
 +              this.movement = '0 0 0';
                if (this.deadflag == DEAD_DEAD)
                {
                        PHYS_INPUT_BUTTON_JUMP(this) = true; // press jump to respawn
@@@ -340,9 -338,8 +340,8 @@@ void bot_custom_weapon_priority_setup(
  
  void bot_endgame()
  {
-       entity e;
-       //dprint("bot_endgame\n");
-       e = bot_list;
+       bot_relinkplayerlist();
+       entity e = bot_list;
        while (e)
        {
                setcolor(e, e.bot_preferredcolors);
@@@ -399,7 -396,7 +398,7 @@@ void bot_clientdisconnect(entity this
        this.playerskin_freeme = string_null;
        if(this.bot_cmd_current)
                delete(this.bot_cmd_current);
-       if(bot_waypoint_queue_owner==this)
+       if(bot_waypoint_queue_owner == this)
                bot_waypoint_queue_owner = NULL;
  }
  
@@@ -632,9 -629,42 +631,42 @@@ float bot_fixcount(
        return true;
  }
  
+ void bot_remove_from_bot_list(entity this)
+ {
+       entity e = bot_list;
+       entity prev_bot = NULL;
+       while (e)
+       {
+               if(e == this)
+               {
+                       if(!prev_bot)
+                               bot_list = this.nextbot;
+                       else
+                               prev_bot.nextbot = this.nextbot;
+                       if(bot_strategytoken == this)
+                       {
+                               bot_strategytoken = this.nextbot;
+                               bot_strategytoken_taken = true;
+                       }
+                       this.nextbot = NULL;
+                       break;
+               }
+               prev_bot = e;
+               e = e.nextbot;
+       }
+ }
+ void bot_clear(entity this)
+ {
+       bot_remove_from_bot_list(this);
+       if(bot_waypoint_queue_owner == this)
+               bot_waypoint_queue_owner = NULL;
+       this.aistatus &= ~AI_STATUS_STUCK; // otherwise bot_waypoint_queue_owner will be set again to this by navigation_unstuck
+ }
  void bot_serverframe()
  {
 -      if (intermission_running)
 +      if (gameover)
                return;
  
        if (time < 2)