]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
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

qcsrc/server/bot/api.qh
qcsrc/server/bot/default/bot.qc
qcsrc/server/bot/default/bot.qh
qcsrc/server/bot/default/scripting.qc
qcsrc/server/mutators/mutator/gamemode_ca.qc
qcsrc/server/mutators/mutator/gamemode_lms.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 9c84a6b67d3b74f2e3a1a2ae9aec07559b8c4742..ed9070f9cdd60821538da821afdceab6a2405cab 100644 (file)
@@ -340,9 +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 +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,6 +631,39 @@ 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 (gameover)
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 f96099087b7b345ec65aa6e14fe5fead95e5509f..0d34ae3c24bc973d285c3ab07a0ab7713afbdac5 100644 (file)
@@ -485,6 +485,7 @@ float bot_cmd_impulse(entity this)
 
 float bot_cmd_continue(entity this)
 {
+       bot_relinkplayerlist();
        this.bot_exec_status &= ~BOT_EXEC_STATUS_PAUSED;
        return CMD_STATUS_FINISHED;
 }
@@ -991,6 +992,7 @@ float bot_cmd_pause(entity this)
        this.movement = '0 0 0';
        this.bot_cmd_keys = BOT_CMD_KEY_NONE;
 
+       bot_clear(this);
        this.bot_exec_status |= BOT_EXEC_STATUS_PAUSED;
        return CMD_STATUS_FINISHED;
 }
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;
 }
 
index c325a359500a955812465a4443a512420730be0a..25f6d3e0ab03ae441a08313a3606bf7869222b25 100644 (file)
@@ -176,6 +176,8 @@ void lms_RemovePlayer(entity player)
                FOREACH_CLIENT(IS_PLAYER(it), { pl_cnt++; });
                if (player.lms_spectate_warning != 2)
                {
+                       if(IS_BOT_CLIENT(player))
+                               bot_clear(player);
                        player.frags = FRAGS_LMS_LOSER;
                        PlayerScore_Add(player, SP_LMS_RANK, pl_cnt + 1);
                }
@@ -281,6 +283,8 @@ MUTATOR_HOOKFUNCTION(lms, GiveFragsForKill)
                {
                        int pl_cnt = 0;
                        FOREACH_CLIENT(IS_PLAYER(it), { pl_cnt++; });
+                       if(IS_BOT_CLIENT(frag_target))
+                               bot_clear(frag_target);
                        frag_target.frags = FRAGS_LMS_LOSER;
                        PlayerScore_Add(frag_target, SP_LMS_RANK, pl_cnt);
                }