]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Fix bots standing still after one of them is forced to observe with movetospec or...
authorterencehill <piuntn@gmail.com>
Thu, 25 Mar 2021 15:48:36 +0000 (16:48 +0100)
committerterencehill <piuntn@gmail.com>
Thu, 25 Mar 2021 15:48:36 +0000 (16:48 +0100)
qcsrc/common/gamemodes/gamemode/clanarena/sv_clanarena.qc
qcsrc/common/gamemodes/gamemode/lms/sv_lms.qc
qcsrc/server/bot/api.qh
qcsrc/server/bot/default/bot.qc
qcsrc/server/bot/default/bot.qh
qcsrc/server/bot/default/havocbot/havocbot.qc
qcsrc/server/bot/default/scripting.qc
qcsrc/server/bot/default/scripting.qh
qcsrc/server/client.qc

index bb23f51c8087833caa2e6511a46476ae4b8137c9..a5367322f0b949fb535abcdea4687056aef4ee8e 100644 (file)
@@ -224,7 +224,6 @@ MUTATOR_HOOKFUNCTION(ca, reset_map_players)
                        PutClientInServer(it);
                }
        });
-       bot_relinkplayerlist();
        return true;
 }
 
@@ -286,11 +285,7 @@ MUTATOR_HOOKFUNCTION(ca, PlayerDies)
        }
        frag_target.respawn_flags |= RESPAWN_FORCE;
        if (!warmup_stage)
-       {
                eliminatedPlayers.SendFlags |= 1;
-               if (IS_BOT_CLIENT(frag_target))
-                       bot_clear(frag_target);
-       }
        return true;
 }
 
index d35da5186913044842cfee135512176d9700163f..dc18b7c9072413a51d0d93d2aff0993682cb0750 100644 (file)
@@ -192,8 +192,6 @@ void lms_RemovePlayer(entity player)
        {
                if (player.lms_spectate_warning < 2)
                {
-                       if(IS_BOT_CLIENT(player))
-                               bot_clear(player);
                        player.frags = FRAGS_PLAYER_OUT_OF_GAME;
                        int pl_cnt = 0;
                        FOREACH_CLIENT(IS_PLAYER(it) && it.frags != FRAGS_PLAYER_OUT_OF_GAME, {
@@ -314,8 +312,6 @@ MUTATOR_HOOKFUNCTION(lms, GiveFragsForKill)
                        FOREACH_CLIENT(IS_PLAYER(it) && it.frags != FRAGS_PLAYER_OUT_OF_GAME, {
                                pl_cnt++;
                        });
-                       if(IS_BOT_CLIENT(frag_target))
-                               bot_clear(frag_target);
                        frag_target.frags = FRAGS_PLAYER_OUT_OF_GAME;
                        GameRules_scoring_add(frag_target, LMS_RANK, pl_cnt);
                }
index 44ed3b8db6f4d6fba13d837be78096f9f069b0db..0759d46365f14e65d9e227fb17b18468f6d5c42c 100644 (file)
@@ -73,7 +73,6 @@ 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 59bf07a7a9e07f48fd0149ef9978866a0dff4e5e..b9d468fbf1002e07cd53b6cd102cab9eb67be3c7 100644 (file)
@@ -113,16 +113,19 @@ void bot_think(entity this)
        }
 
        // if dead, just wait until we can respawn
-       if (IS_DEAD(this))
+       if (IS_DEAD(this) || IS_OBSERVER(this))
        {
                if (bot_waypoint_queue_owner == this)
                        bot_waypoint_queue_owner = NULL;
                this.aistatus = 0;
                CS(this).movement = '0 0 0';
-               if (this.deadflag == DEAD_DEAD)
+               if (IS_OBSERVER(this))
+                       return;
+               if (IS_DEAD(this))
                {
                        PHYS_INPUT_BUTTON_JUMP(this) = true; // press jump to respawn
-                       navigation_goalrating_timeout_force(this);
+                       if (!navigation_goalrating_timeout(this))
+                               navigation_goalrating_timeout_force(this);
                }
        }
        else if(this.aistatus & AI_STATUS_STUCK)
@@ -383,17 +386,19 @@ void bot_relinkplayerlist()
 
                if(IS_BOT_CLIENT(it))
                {
-                       if(prevbot)
-                               prevbot.nextbot = it;
-                       else
-                               bot_list = it;
-                       prevbot = it;
+                       if (!IS_OBSERVER(it) && !bot_ispaused(it))
+                       {
+                               if(prevbot)
+                                       prevbot.nextbot = it;
+                               else
+                                       bot_list = it;
+                               prevbot = it;
+                       }
                        ++currentbots;
                }
        });
        if(prevbot)
                prevbot.nextbot = NULL;
-       LOG_TRACE("relink: ", ftos(currentbots), " bots seen.");
        bot_strategytoken = bot_list;
        bot_strategytoken_taken = true;
 }
@@ -644,39 +649,6 @@ bool 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 && currentbots > 0)
index 88dba449d5fe245d9a63b05c019f9c1ffd1009ec..f94d282aabb957945806f3e0ef96ac2584a78687 100644 (file)
@@ -95,7 +95,6 @@ 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 64d3c91539822b71350bbf395aebd5822c4099e6..41851afc007cadbff723da1360dfa6c36e3a64a6 100644 (file)
@@ -43,6 +43,10 @@ void havocbot_ai(entity this)
        if(bot_execute_commands(this))
                return;
 
+       // after bot_execute_commands otherwise bots can't be unpaused
+       if (bot_ispaused(this))
+               return;
+
        if (bot_strategytoken == this && !bot_strategytoken_taken)
        {
                if(this.havocbot_blockhead)
index c904c5db492fca709df0ec3fa93d94dfc270746f..5a13330652f576268b6ce42a2939716d4517a66f 100644 (file)
@@ -493,8 +493,8 @@ float bot_cmd_impulse(entity this)
 
 float bot_cmd_continue(entity this)
 {
-       bot_relinkplayerlist();
        this.bot_exec_status &= ~BOT_EXEC_STATUS_PAUSED;
+       bot_relinkplayerlist();
        return CMD_STATUS_FINISHED;
 }
 
@@ -1000,6 +1000,11 @@ float bot_cmd_releasekey(entity this)
        return bot_cmd_keypress_handler(this, key,false);
 }
 
+bool bot_ispaused(entity this)
+{
+       return(this.bot_exec_status & BOT_EXEC_STATUS_PAUSED);
+}
+
 float bot_cmd_pause(entity this)
 {
        PHYS_INPUT_BUTTON_DRAG(this) = false;
@@ -1014,8 +1019,8 @@ float bot_cmd_pause(entity this)
        CS(this).movement = '0 0 0';
        this.bot_cmd_keys = BOT_CMD_KEY_NONE;
 
-       bot_clear(this);
        this.bot_exec_status |= BOT_EXEC_STATUS_PAUSED;
+       bot_relinkplayerlist();
        return CMD_STATUS_FINISHED;
 }
 
index cb5bf625f6cb0c37a71f445e33683f4cbfa70239..58c1fe8bd7cb22f5196001712a6f6180c416c5be 100644 (file)
@@ -71,6 +71,8 @@ float bot_barriertime;
 .float bot_cmd_execution_index;                // Position in the queue of the command to be executed
 
 
+bool bot_ispaused(entity this);
+
 void bot_resetqueues();
 void bot_queuecommand(entity bot, string cmdstring);
 void bot_cmdhelp(string scmd);
index bdfc3c1fdfd80a8e018d2a597f7e9ef5a0a8152e..2a31be2a05c3b61fbb85b081bd0dd9052df43878 100644 (file)
@@ -395,6 +395,9 @@ void PutObserverInServer(entity this)
                SetPlayerTeam(this, -1, TEAM_CHANGE_SPECTATOR);
                this.frags = FRAGS_SPECTATOR;
        }
+
+       bot_relinkplayerlist();
+
        if (CS(this).just_joined)
                CS(this).just_joined = false;
 }
@@ -825,6 +828,8 @@ void PutClientInServer(entity this)
        } else if (IS_PLAYER(this)) {
                PutPlayerInServer(this);
        }
+
+       bot_relinkplayerlist();
 }
 
 // TODO do we need all these fields, or should we stop autodetecting runtime