#include <common/mapinfo.qh>
#include <common/util.qh>
#include <server/bot/api.qh>
+#include <server/bot/default/cvars.qh>
#include <server/campaign.qh>
#include <server/client.qh>
#include <server/mapvoting.qh>
{
int minplayers = max(0, floor(autocvar_minplayers));
if (teamplay)
- minplayers = max(0, floor(autocvar_minplayers_per_team) * AvailableTeams());
+ minplayers = max(0, floor(autocvar_minplayers_per_team) * AVAILABLE_TEAMS);
if (autocvar_g_maplist_check_waypoints
&& (currentbots || autocvar_bot_number || player_count < minplayers))
{
return true;
// open map size restriction file
- string opensize_msg = strcat("opensize ", map);
- float fh = fopen(strcat("maps/", map, ".sizes"), FILE_READ);
+ if(!MapReadSizes(map))
+ return true; // map has no size restrictions
+
+ string checksize_msg = strcat("MapHasRightSize ", map);
int player_limit = ((autocvar_g_maplist_sizes_count_maxplayers) ? GetPlayerLimit() : 0);
int pcount = ((player_limit > 0) ? min(player_count, player_limit) : player_count); // bind it to the player limit so that forced spectators don't influence the limits
+
if(!autocvar_g_maplist_sizes_count_bots)
pcount -= currentbots;
- if(fh >= 0)
+ pcount -= rint(cvar("g_maplist_sizes_specparty") * pcount);
+
+ // ensure small maps can be selected when pcount is low
+ if(map_minplayers <= (_MapInfo_GetTeamPlayBool(MapInfo_CurrentGametype()) ? 4 : 2))
+ map_minplayers = 0;
+
+ if(pcount < map_minplayers)
{
- opensize_msg = strcat(opensize_msg, ": ok, ");
- int mapmin = stoi(fgets(fh));
- int mapmax = stoi(fgets(fh));
- fclose(fh);
- if(pcount < mapmin)
- {
- LOG_TRACE(opensize_msg, "not enough");
- return false;
- }
- if(mapmax && pcount > mapmax)
- {
- LOG_TRACE(opensize_msg, "too many");
- return false;
- }
- LOG_TRACE(opensize_msg, "right size");
- return true;
+ LOG_TRACE(checksize_msg, ": not enough");
+ return false;
+ }
+ if(map_maxplayers && pcount > map_maxplayers)
+ {
+ LOG_TRACE(checksize_msg, ": too many");
+ return false;
}
- LOG_TRACE(opensize_msg, ": not found");
+ LOG_TRACE(checksize_msg, ": right size");
return true;
}
if(!MapInfo_CheckMap(m))
return "The map you suggested does not support the current game mode.";
cvar_set("nextmap", m);
- cvar_set("timelimit", "-1");
+ if (!intermission_running)
+ cvar_set("_endmatch", "1");
if(mapvote_initialized || alreadychangedlevel)
{
if(DoNextMapOverride(0))
{
FixIntermissionClient(this);
- float server_screenshot = (autocvar_sv_autoscreenshot && CS(this).cvar_cl_autoscreenshot);
- float client_screenshot = (CS(this).cvar_cl_autoscreenshot == 2);
+ float server_screenshot = (autocvar_sv_autoscreenshot && CS_CVAR(this).cvar_cl_autoscreenshot);
+ float client_screenshot = (CS_CVAR(this).cvar_cl_autoscreenshot == 2);
if( (server_screenshot || client_screenshot)
&& ((this.autoscreenshot > 0) && (time > this.autoscreenshot)) )
{
this.autoscreenshot = -1;
- if(IS_REAL_CLIENT(this)) { stuffcmd(this, sprintf("\nscreenshot screenshots/autoscreenshot/%s-%s.jpg; echo \"^5A screenshot has been taken at request of the server.\"\n", GetMapname(), strftime(false, "%s"))); }
+ if(IS_REAL_CLIENT(this))
+ {
+ string num = strftime_s(); // strftime(false, "%s") isn't reliable, see strftime_s description
+ stuffcmd(this, sprintf("\nscreenshot screenshots/autoscreenshot/%s-%s.jpg; "
+ "echo \"^5A screenshot has been taken at request of the server.\"\n", GetMapname(), num));
+ }
return;
}
if(!e.autoscreenshot) // initial call
{
e.autoscreenshot = time + 0.8; // used for autoscreenshot
- SetResourceExplicit(e, RES_HEALTH, -2342);
- // first intermission phase; voting phase has positive health (used to decide whether to send SVC_FINALE or not)
+ SetResourceExplicit(e, RES_HEALTH, -2342); // health in the first intermission phase
for (int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
{
- .entity weaponentity = weaponentities[slot];
+ .entity weaponentity = weaponentities[slot];
if(e.(weaponentity))
{
e.(weaponentity).effects = EF_NODRAW;