#include "../../race.qh"
#include <common/t_items.qh>
-#include "../../mutators/_mod.qh"
+#include <server/mutators/_mod.qh>
#include "../../weapons/accuracy.qh"
if (!IS_BOT_CLIENT(this))
return;
bot_clearqueue(this);
- if(this.cleanname)
- strunzone(this.cleanname);
- if(this.netname_freeme)
- strunzone(this.netname_freeme);
- if(this.playermodel_freeme)
- strunzone(this.playermodel_freeme);
- if(this.playerskin_freeme)
- strunzone(this.playerskin_freeme);
- this.cleanname = string_null;
- this.netname_freeme = string_null;
- this.playermodel_freeme = string_null;
- this.playerskin_freeme = string_null;
+ strfree(this.cleanname);
+ strfree(this.netname_freeme);
+ strfree(this.playermodel_freeme);
+ strfree(this.playerskin_freeme);
if(this.bot_cmd_current)
delete(this.bot_cmd_current);
if(bot_waypoint_queue_owner == this)
++realplayers;
});
}
- if(currentbots == -1)
- {
- currentbots = 0;
- // human players joining early may cause weird issues (bots appearing on
- // the scoreboard as spectators) when switching map with the gotomap
- // command, as it doesn't remove bots of the previous match, and with
- // minplayers > 1, so ignore human players in the first bot frame
- // TODO maybe find a cleaner solution
- activerealplayers = 0;
- }
int bots;
// add/remove bots if needed to make sure there are at least
void bot_serverframe()
{
+ if (intermission_running && currentbots > 0)
+ {
+ // after the end of the match all bots stay unless all human players disconnect
+ int realplayers = 0;
+ FOREACH_CLIENT(IS_REAL_CLIENT(it), { ++realplayers; });
+ if (!realplayers)
+ {
+ FOREACH_CLIENT(IS_BOT_CLIENT(it), { dropclient(it); });
+ currentbots = 0;
+ }
+ return;
+ }
+
if (game_stopped)
return;
- if (time < 2)
+ // Added 0.5 to avoid possible addition + immediate removal of bots that would make them appear as
+ // spectators in the scoreboard and never go away. This issue happens at time 2 if map is changed
+ // with the gotomap command, minplayers is > 1 and human clients join as players very soon
+ // either intentionally or automatically (sv_spectate 0)
+ if (time < 2.5)
{
currentbots = -1;
return;
}
+ if (currentbots == -1)
+ {
+ // count bots already in the server from the previous match
+ currentbots = 0;
+ FOREACH_CLIENT(IS_BOT_CLIENT(it), { ++currentbots; });
+ }
+
if(autocvar_skill != skill)
{
float wpcost_update = false;