From: terencehill Date: Sat, 26 Jan 2019 15:06:37 +0000 (+0100) Subject: Add minplayers_per_team cvar: fill server with bots to reach this number of players... X-Git-Tag: xonotic-v0.8.5~1605^2 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=da55ff304a42651add06ef87cae5f4ae012c098f;p=xonotic%2Fxonotic-data.pk3dir.git Add minplayers_per_team cvar: fill server with bots to reach this number of players per team (if bot_number is not enough); it implements #2064 --- diff --git a/commands.cfg b/commands.cfg index 0f2e56892..798104a68 100644 --- a/commands.cfg +++ b/commands.cfg @@ -117,9 +117,9 @@ alias menu_showquitdialog "menu_cmd directmenu Quit" alias menu_showmonstertools "menu_cmd directmenu MonsterTools" // command executed before loading a map by the menu -// makes sure maxplayers is at least minplayers or bot_number + 1 +// makes sure maxplayers is at least minplayers or minplayers_per_team * 4 or bot_number + 1 alias _menu_loadmap_prepare_maxpl "maxplayers $_menu_loadmap_maxplayers" -alias menu_loadmap_prepare "disconnect; wait; g_campaign 0; menu_cmd rpn /_menu_loadmap_maxplayers menu_maxplayers minplayers bot_number 1 add max max def; _menu_loadmap_prepare_maxpl; g_maplist_shufflenow" +alias menu_loadmap_prepare "disconnect; wait; g_campaign 0; menu_cmd rpn /_menu_loadmap_maxplayers menu_maxplayers minplayers bot_number 1 add max minplayers_per_team 4 mul max max def; _menu_loadmap_prepare_maxpl; g_maplist_shufflenow" // ========================================================== diff --git a/qcsrc/server/autocvars.qh b/qcsrc/server/autocvars.qh index b23f6f148..a50191775 100644 --- a/qcsrc/server/autocvars.qh +++ b/qcsrc/server/autocvars.qh @@ -251,6 +251,7 @@ bool autocvar_lastlevel; int autocvar_leadlimit_and_fraglimit; int autocvar_leadlimit_override; int autocvar_minplayers; +int autocvar_minplayers_per_team; string autocvar_nextmap; string autocvar_quit_and_redirect; float autocvar_quit_and_redirect_timer; diff --git a/qcsrc/server/bot/default/bot.qc b/qcsrc/server/bot/default/bot.qc index 9ebcffae3..a0b7e47fb 100644 --- a/qcsrc/server/bot/default/bot.qc +++ b/qcsrc/server/bot/default/bot.qc @@ -604,6 +604,8 @@ bool bot_fixcount() else if ((realplayers || autocvar_bot_join_empty || (currentbots > 0 && time < 5))) { int minplayers = max(0, floor(autocvar_minplayers)); + if (teamplay) + minplayers = max(0, floor(autocvar_minplayers_per_team) * AvailableTeams()); int minbots = max(0, floor(autocvar_bot_number)); // add bots to reach minplayers if needed diff --git a/qcsrc/server/command/sv_cmd.qc b/qcsrc/server/command/sv_cmd.qc index c3e5bf901..5dc92eb90 100644 --- a/qcsrc/server/command/sv_cmd.qc +++ b/qcsrc/server/command/sv_cmd.qc @@ -330,6 +330,7 @@ void GameCommand_bot_cmd(int request, int argc, string command) { cvar_settemp("bot_vs_human", "0"); cvar_settemp("minplayers", "0"); + cvar_settemp("minplayers_per_team", "0"); cvar_settemp("bot_number", "0"); bot_fixcount(); cvar_settemp("bot_number", argv(2)); @@ -362,6 +363,7 @@ void GameCommand_bot_cmd(int request, int argc, string command) { cvar_settemp("bot_vs_human", "0"); cvar_settemp("minplayers", "0"); + cvar_settemp("minplayers_per_team", "0"); cvar_settemp("bot_number", "0"); bot_fixcount(); cvar_settemp("bot_number", argv(3)); @@ -1281,6 +1283,7 @@ void GameCommand_setbots(int request, int argc) if (argc >= 2) { cvar_settemp("minplayers", "0"); + cvar_settemp("minplayers_per_team", "0"); cvar_settemp("bot_number", argv(1)); bot_fixcount(); return; diff --git a/qcsrc/server/g_world.qc b/qcsrc/server/g_world.qc index 522f4f041..12fcaae63 100644 --- a/qcsrc/server/g_world.qc +++ b/qcsrc/server/g_world.qc @@ -431,6 +431,7 @@ void cvar_changes_init() BADCVAR("log_file"); BADCVAR("maxplayers"); BADCVAR("minplayers"); + BADCVAR("minplayers_per_team"); BADCVAR("net_address"); BADCVAR("port"); BADCVAR("rcon_password"); @@ -1004,8 +1005,11 @@ float GetMaplistPosition() bool MapHasRightSize(string map) { - if(currentbots || autocvar_bot_number || player_count < autocvar_minplayers) - if(autocvar_g_maplist_check_waypoints) + int minplayers = max(0, floor(autocvar_minplayers)); + if (teamplay) + minplayers = max(0, floor(autocvar_minplayers_per_team) * AvailableTeams()); + if (autocvar_g_maplist_check_waypoints + && (currentbots || autocvar_bot_number || player_count < minplayers)) { string checkwp_msg = strcat("checkwp ", map); if(!fexists(strcat("maps/", map, ".waypoints"))) diff --git a/xonotic-server.cfg b/xonotic-server.cfg index e25ae7fac..bb0d59371 100644 --- a/xonotic-server.cfg +++ b/xonotic-server.cfg @@ -10,7 +10,8 @@ set sv_autotaunt 1 "allow autotaunts on the server" // server settings hostname "Xonotic $g_xonoticversion Server" set sv_mapchange_delay 5 -set minplayers 0 "fill server with bots to reach this number of players (if bot_number is not enough)" +set minplayers 0 "fill server with bots to reach this number of players in teamless games (if bot_number is not enough)" +set minplayers_per_team 0 "fill server with bots to reach this number of players per team (if bot_number is not enough)" // restart server if all players hit "ready"-button set sv_ready_restart 0 "allow a map to be restarted once all players pressed the \"ready\" button"