From: terencehill Date: Sat, 5 Nov 2016 19:16:02 +0000 (+0100) Subject: CA: fix bots getting stuck right after one of them dies X-Git-Tag: xonotic-v0.8.2~388^2~5 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=6d94a5a44c5dd5977c82a296ff43331b7bd52335;p=xonotic%2Fxonotic-data.pk3dir.git CA: fix bots getting stuck right after one of them dies --- diff --git a/qcsrc/server/bot/api.qh b/qcsrc/server/bot/api.qh index 64957b92e..0de29af06 100644 --- a/qcsrc/server/bot/api.qh +++ b/qcsrc/server/bot/api.qh @@ -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(); diff --git a/qcsrc/server/bot/default/bot.qc b/qcsrc/server/bot/default/bot.qc index 2a7478dee..d39e0654e 100644 --- a/qcsrc/server/bot/default/bot.qc +++ b/qcsrc/server/bot/default/bot.qc @@ -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) diff --git a/qcsrc/server/bot/default/bot.qh b/qcsrc/server/bot/default/bot.qh index 095930760..05c6a5ed9 100644 --- a/qcsrc/server/bot/default/bot.qh +++ b/qcsrc/server/bot/default/bot.qh @@ -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(); diff --git a/qcsrc/server/mutators/mutator/gamemode_ca.qc b/qcsrc/server/mutators/mutator/gamemode_ca.qc index ebfcd9540..561a30d22 100644 --- a/qcsrc/server/mutators/mutator/gamemode_ca.qc +++ b/qcsrc/server/mutators/mutator/gamemode_ca.qc @@ -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; }