]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Restrict the timelimit vote to values between timelimit_min and timelimit_max
authorMario <mario.mario@y7mail.com>
Fri, 27 Sep 2019 15:29:07 +0000 (01:29 +1000)
committerMario <mario.mario@y7mail.com>
Fri, 27 Sep 2019 15:29:07 +0000 (01:29 +1000)
qcsrc/server/command/vote.qc
xonotic-server.cfg

index a5cc7383404d0f3bc4d179f2be0e1ad4631dfa49..069c0784d30d14ee29ac154775ccc1eec714ba3f 100644 (file)
@@ -711,7 +711,9 @@ int VoteCommand_parse(entity caller, string vote_command, string vote_list, floa
                        break;
                }
 
                        break;
                }
 
-               case "nextmap": // TODO: replicate the old behaviour of being able to vote for maps from different modes on multimode servers (possibly support it in gotomap too), maybe fallback instead of aborting if map name is invalid?
+               // TODO: replicate the old behaviour of being able to vote for maps from different modes on multimode servers (possibly support it in gotomap too)
+               // maybe fallback instead of aborting if map name is invalid?
+               case "nextmap":
                {
                        vote_command = ValidateMap(argv(startpos + 1), caller);
                        if (!vote_command)  return -1;
                {
                        vote_command = ValidateMap(argv(startpos + 1), caller);
                        if (!vote_command)  return -1;
@@ -721,6 +723,21 @@ int VoteCommand_parse(entity caller, string vote_command, string vote_list, floa
                        break;
                }
 
                        break;
                }
 
+               case "timelimit": // include restrictions on the maximum votable time limit
+               {
+                       float timelimit_vote = stof(argv(startpos + 1));
+                       if(timelimit_vote <= 0 || timelimit_vote > autocvar_timelimit_max || timelimit_vote < autocvar_timelimit_min)
+                       {
+                               print_to(caller, strcat("Invalid timelimit vote, accepted values are between ", ftos(autocvar_timelimit_min), " and ", ftos(autocvar_timelimit_max), "."));
+                               return -1;
+                       }
+                       timelimit_vote = bound(autocvar_timelimit_min, timelimit_vote, autocvar_timelimit_max);
+                       vote_parsed_command = strcat("timelimit ", ftos(timelimit_vote));
+                       vote_parsed_display = strzone(strcat("^1", vote_parsed_command));
+
+                       break;
+               }
+
                case "restart":
                {
                        // add a delay so that vote result can be seen and announcer can be heard
                case "restart":
                {
                        // add a delay so that vote result can be seen and announcer can be heard
index 594e2943e28bf5a1fd1a4f621588ed5f7f74fe3e..f1f2898ee3019851331a1fc751827e5cfb12f718 100644 (file)
@@ -384,8 +384,8 @@ set g_banned_list_idmode "1" "when set, the IP banning system always uses the ID
 // useful vote aliases
 set timelimit_increment 5 "number of minutes added to the timer when voting for extendmatchtime"
 set timelimit_decrement 5 "number of minutes removed from the timer when voting for reducematchtime"
 // useful vote aliases
 set timelimit_increment 5 "number of minutes added to the timer when voting for extendmatchtime"
 set timelimit_decrement 5 "number of minutes removed from the timer when voting for reducematchtime"
-set timelimit_min 5 "shortest match time achieveable with reducematchtime votes"
-set timelimit_max 60 "maximum match time achieveable with extendmatchtime votes"
+set timelimit_min 5 "shortest match time achieveable with reducematchtime and timelimit votes"
+set timelimit_max 60 "maximum match time achieveable with extendmatchtime and timelimit votes"
 
 sv_gameplayfix_delayprojectiles 0
 sv_gameplayfix_q2airaccelerate 1
 
 sv_gameplayfix_delayprojectiles 0
 sv_gameplayfix_q2airaccelerate 1