// Restarts the map after the countdown is over (and cvar sv_ready_restart_after_countdown is set)
void ReadyRestart_think(entity this)
{
- reset_map(true, false);
+ if (!warmup_stage) // if the countdown was not aborted
+ reset_map(true, false);
delete(this);
}
if(forceWarmupEnd || autocvar_g_campaign)
warmup_stage = 0; // forcefully end warmup and go to match stage
else
- warmup_stage = cvar("g_warmup"); // go into warmup if it's enabled, otherwise restart into match stage
+ warmup_stage = autocvar_g_warmup; // go into warmup if it's enabled, otherwise restart into match stage
ReadyRestart_force(false);
}
Nagger_ReadyCounted();
- if (t_players < map_minplayers) // map_minplayers will only be set if g_warmup -1 at worldspawn
+ // can't read warmup_stage here as it could have been set to 0 by ReadyRestart()
+ // and we need to use this when checking if we should abort the countdown
+ // map_minplayers can only be > 0 if g_warmup was -1 at worldspawn
+ int minplayers = autocvar_g_warmup > 1 ? autocvar_g_warmup : map_minplayers;
+
+ if (t_players < minplayers)
{
if (game_starttime > time) // someone bailed during countdown, back to warmup
{
- warmup_stage = -1; // CAN change it AFTER calling Nagger_ReadyCounted() this frame
+ warmup_stage = autocvar_g_warmup; // CAN change it AFTER calling Nagger_ReadyCounted() this frame
game_starttime = time;
- Send_Notification(NOTIF_ALL, NULL, MSG_MULTI, COUNTDOWN_STOP, map_minplayers);
+ Send_Notification(NOTIF_ALL, NULL, MSG_MULTI, COUNTDOWN_STOP, minplayers);
+ if (!sv_ready_restart_after_countdown) // if we ran reset_map() at start of countdown
+ FOREACH_CLIENT(IS_PLAYER(it), { GiveWarmupResources(it); });
}
if (warmup_limit > 0)
warmup_limit = -1;
return; // don't ReadyRestart if players are ready but too few
}
- else if (map_minplayers && warmup_limit <= 0)
+ else if (minplayers && warmup_limit <= 0)
{
// there's enough players now but we're still in infinite warmup
warmup_limit = cvar("g_warmup_limit");
// Supporting functions for VoteCommand
// ======================================
-float Votecommand_check_assignment(entity caller, float assignment)
+bool Votecommand_check_assignment(entity caller, float assignment)
{
- float from_server = (!caller);
+ bool from_server = (!caller);
if ((assignment == VC_ASGNMNT_BOTH)
|| ((!from_server && assignment == VC_ASGNMNT_CLIENTONLY)
return output;
}
-float VoteCommand_checknasty(string vote_command)
+bool VoteCommand_checknasty(string vote_command)
{
- if ((strstrofs(vote_command, ";", 0) >= 0)
+ return !((strstrofs(vote_command, ";", 0) >= 0)
|| (strstrofs(vote_command, "\n", 0) >= 0)
|| (strstrofs(vote_command, "\r", 0) >= 0)
- || (strstrofs(vote_command, "$", 0) >= 0)) return false;
-
- return true;
+ || (strstrofs(vote_command, "$", 0) >= 0));
}
// NOTE: requires input to be surrounded by spaces
string VoteCommand_checkreplacements(string input)
{
- string output = input;
+ // add a space around the input so the start and end of the list is captured
+ string output = strcat(" ", input, " ");
// allow gotomap replacements
output = strreplace(" map ", " gotomap ", output);
output = strreplace(" chmap ", " gotomap ", output);
return output;
}
-float VoteCommand_checkinlist(string vote_command, string list)
+bool VoteCommand_checkinlist(string vote_command, string list)
{
- string l = VoteCommand_checkreplacements(strcat(" ", list, " "));
+ if (vote_command == "" || list == "")
+ return false;
- if (strstrofs(l, VoteCommand_checkreplacements(strcat(" ", vote_command, " ")), 0) >= 0) return true;
-
- return false;
+ string l = VoteCommand_checkreplacements(list);
+ return (strstrofs(l, VoteCommand_checkreplacements(vote_command), 0) >= 0);
}
string ValidateMap(string validated_map, entity caller)