]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
CA: fix bots getting stuck right after one of them dies
authorterencehill <piuntn@gmail.com>
Sat, 5 Nov 2016 19:16:02 +0000 (20:16 +0100)
committerterencehill <piuntn@gmail.com>
Sat, 5 Nov 2016 23:03:45 +0000 (00:03 +0100)
qcsrc/server/bot/api.qh
qcsrc/server/bot/default/bot.qc
qcsrc/server/bot/default/bot.qh
qcsrc/server/mutators/mutator/gamemode_ca.qc

index 64957b92e09c0b7ea7b26e8955cebcc3e784a60f..0de29af065b8bd274785902f077c9e8749bd51bb 100644 (file)
@@ -54,6 +54,7 @@ void bot_endgame();
 bool bot_fixcount();
 void bot_list_commands();
 void bot_queuecommand(entity bot, string cmdstring);
+void bot_clear(entity this);
 void bot_relinkplayerlist();
 void bot_resetqueues();
 void bot_serverframe();
index 2a7478dee2d7688322dfa3006b4534957159bcd3..d39e0654eb2cdf562fc38dfe8330f6fa1f021e32 100644 (file)
@@ -338,9 +338,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);
@@ -397,7 +396,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;
 }
 
@@ -630,6 +629,38 @@ 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;
+}
+
 void bot_serverframe()
 {
        if (intermission_running)
index 0959307608d3239bd7405bc809c2352467fd1c6c..05c6a5ed9a0643b4a1d8232c70a13d96262009b9 100644 (file)
@@ -89,6 +89,7 @@ void bot_setnameandstuff(entity this);
 void bot_custom_weapon_priority_setup();
 void bot_endgame();
 void bot_relinkplayerlist();
+void bot_clear(entity this);
 void bot_clientdisconnect(entity this);
 void bot_clientconnect(entity this);
 void bot_removefromlargestteam();
index ebfcd9540282d99f853c94cbb6c0f5d94ca75d04..561a30d222a40b223d14d41a702403efba0f2a14 100644 (file)
@@ -209,6 +209,7 @@ MUTATOR_HOOKFUNCTION(ca, reset_map_players)
                        PutClientInServer(it);
                }
        });
+       bot_relinkplayerlist();
        return true;
 }
 
@@ -265,6 +266,8 @@ MUTATOR_HOOKFUNCTION(ca, PlayerDies)
                frag_target.respawn_flags =  RESPAWN_SILENT;
        if (!warmup_stage)
                eliminatedPlayers.SendFlags |= 1;
+       if(IS_BOT_CLIENT(frag_target))
+               bot_clear(frag_target);
        return true;
 }