// 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)