From ffc8a804728428ab278dea5c25404c31ff0ebb66 Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 14 Mar 2020 11:28:57 +1000 Subject: [PATCH] Allow chmap and map shorthands for gotomap to be votable (if available) without needing to explicitly list all of them in sv_vote_commands --- commands.cfg | 2 +- qcsrc/server/command/vote.qc | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/commands.cfg b/commands.cfg index 5a5667c8c..d3a22cabc 100644 --- a/commands.cfg +++ b/commands.cfg @@ -324,7 +324,7 @@ set sv_vote_command_help_gotomap "\nUsage:^3 vcall gotomap mapname\n^7 Where 'm // ================================= set sv_vote_call 1 "Allow users to call a vote for the commands in sv_vote_commands" set sv_vote_change 1 "Allow voters to change their mind after already voting" -set sv_vote_commands "restart fraglimit chmap gotomap nextmap endmatch reducematchtime extendmatchtime allready kick cointoss movetoauto shuffleteams bots nobots" "these commands can be voted by players or used directly by masters (vdo) in addition to sv_vote_master_commands" +set sv_vote_commands "restart fraglimit gotomap nextmap endmatch reducematchtime extendmatchtime allready kick cointoss movetoauto shuffleteams bots nobots" "these commands can be voted by players or used directly by masters (vdo) in addition to sv_vote_master_commands" set sv_vote_only_commands "" set sv_vote_limit 160 "Maximum allowed length of a vote command" set sv_vote_master_commands "movetored movetoblue movetoyellow movetopink movetospec" "Extra commands which vote masters can execute by themselves, along with the normal sv_vote_commands." // maybe add kickban here (but then sv_vote_master 0) diff --git a/qcsrc/server/command/vote.qc b/qcsrc/server/command/vote.qc index 90073beaa..1869a15a8 100644 --- a/qcsrc/server/command/vote.qc +++ b/qcsrc/server/command/vote.qc @@ -542,11 +542,21 @@ float VoteCommand_checknasty(string vote_command) return true; } +// NOTE: requires input to be surrounded by spaces +string VoteCommand_checkreplacements(string input) +{ + string output = input; + // allow gotomap replacements + output = strreplace(" map ", " gotomap ", output); + output = strreplace(" chmap ", " gotomap ", output); + return output; +} + float VoteCommand_checkinlist(string vote_command, string list) { - string l = strcat(" ", list, " "); + string l = VoteCommand_checkreplacements(strcat(" ", list, " ")); - if (strstrofs(l, strcat(" ", vote_command, " "), 0) >= 0) return true; + if (strstrofs(l, VoteCommand_checkreplacements(strcat(" ", vote_command, " ")), 0) >= 0) return true; return false; } -- 2.39.2