]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/command/vote.qc
Reset: Use proper game_starttime
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / command / vote.qc
index 2c915863ef98add4e2aee3bf65f9c663e95112d0..6276d2e3c93f3e97575b4551ff719817696cfbe1 100644 (file)
@@ -390,8 +390,8 @@ void reset_map(bool dorespawn)
        {
                if (!MUTATOR_CALLHOOK(reset_map_players))
                {
-                       if (restart_mapalreadyrestarted || (time < game_starttime))
-                       {
+                       //if (restart_mapalreadyrestarted || (time < game_starttime))
+                       //{
                                FOREACH_CLIENT(IS_PLAYER(it),
                                {
                                        /*
@@ -408,7 +408,7 @@ void reset_map(bool dorespawn)
                                        CS(it).movement = '0 0 0';
                                        PutClientInServer(it);
                                });
-                       }
+                       //}
                }
        }
 }
@@ -436,9 +436,11 @@ void ReadyRestart_force()
        if (checkrules_overtimesadded > 0 && g_race_qualifying != 2)
                cvar_set("timelimit", ftos(autocvar_timelimit - (checkrules_overtimesadded * autocvar_timelimit_overtime)));
        checkrules_suddendeathend = checkrules_overtimesadded = checkrules_suddendeathwarning = 0;
-
-       readyrestart_happened = true;
-       game_starttime = time + RESTART_COUNTDOWN;
+       
+       if(!warmup_stage)
+               game_starttime = time + RESTART_COUNTDOWN;
+       else
+               game_starttime = time; // No countdown in warmup
 
        // clear player attributes
        FOREACH_CLIENT(IS_PLAYER(it), {
@@ -451,9 +453,8 @@ void ReadyRestart_force()
        restart_mapalreadyrestarted = false; // reset this var, needed when cvar sv_ready_restart_repeatable is in use
 
        // disable the warmup global for the server
-       if(warmup_stage)
+       if(!warmup_stage)
                localcmd("\nsv_hook_warmupend\n");
-       warmup_stage = 0;                // once the game is restarted the game is in match stage
 
        // reset the .ready status of all players (also spectators)
        FOREACH_CLIENT(IS_REAL_CLIENT(it), { it.ready = false; });
@@ -462,13 +463,10 @@ void ReadyRestart_force()
 
        // lock teams with lockonrestart
        if (autocvar_teamplay_lockonrestart && teamplay)
-       {
-               lockteams = true;
-               bprint("^1The teams are now locked.\n");
-       }
+               lockteams = !warmup_stage;
 
        // initiate the restart-countdown-announcer entity
-       if (sv_ready_restart_after_countdown)
+       if (sv_ready_restart_after_countdown && !warmup_stage)
        {
                entity restart_timer = new_pure(restart_timer);
                setthink(restart_timer, ReadyRestart_think);
@@ -481,7 +479,7 @@ void ReadyRestart_force()
                FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), { CS(it).allowed_timeouts = autocvar_sv_timeout_number; });
        }
 
-       if (!sv_ready_restart_after_countdown) reset_map(true);
+       if (!sv_ready_restart_after_countdown || warmup_stage) reset_map(true);
        if (autocvar_sv_eventlog) GameLogEcho(":restart");
 }
 
@@ -514,7 +512,11 @@ void ReadyCount()
        ready_needed_factor = bound(0.5, cvar("g_warmup_majority_factor"), 0.999);
        ready_needed_count = floor(t_players * ready_needed_factor) + 1;
 
-       if (readycount >= ready_needed_count) ReadyRestart();
+       if (readycount >= ready_needed_count)
+       {
+               warmup_stage = 0;
+               ReadyRestart();
+       }
 }
 
 
@@ -715,7 +717,11 @@ int VoteCommand_parse(entity caller, string vote_command, string vote_list, floa
                                vote_parsed_command = strcat(first_command, " # ", ftos(etof(victim)), " ", command_arguments);
                                vote_parsed_display = sprintf("^1%s #%d ^7%s^1 %s", first_command, etof(victim), victim.netname, reason);
                        }
-                       else { print_to(caller, strcat("vcall: ", GetClientErrorString(accepted, argv(startpos + 1)), ".\n")); return 0; }
+                       else
+                       {
+                               print_to(caller, strcat("vcall: ", GetClientErrorString(accepted, argv(startpos + 1)), ".\n"));
+                               return 0;
+                       }
 
                        break;
                }
@@ -803,7 +809,9 @@ void VoteCommand_abstain(int request, entity caller)  // CLIENT ONLY
                                print_to(caller, "^1You abstained from your vote.");
                                caller.vote_selection = VOTE_SELECT_ABSTAIN;
                                msg_entity = caller;
-                               if (!autocvar_sv_vote_singlecount)   VoteCount(false); }
+                               if (!autocvar_sv_vote_singlecount)
+                                       VoteCount(false);
+                       }
 
                        return;
                }
@@ -818,6 +826,11 @@ void VoteCommand_abstain(int request, entity caller)  // CLIENT ONLY
        }
 }
 
+void print_available_commands_to(entity caller)
+{
+       print_to(caller, strcat("You can call a vote for or execute these commands: ^3", autocvar_sv_vote_commands, "^7 and maybe further ^3arguments^7"));
+}
+
 void VoteCommand_call(int request, entity caller, int argc, string vote_command)  // BOTH
 {
        switch (request)
@@ -829,7 +842,10 @@ void VoteCommand_call(int request, entity caller, int argc, string vote_command)
 
                        vote_command = VoteCommand_extractcommand(vote_command, 2, argc);
 
-                       if (!autocvar_sv_vote_call && caller) { print_to(caller, "^1Vote calling is not allowed."); }
+                       if (!autocvar_sv_vote_call && caller)
+                       {
+                               print_to(caller, "^1Vote calling is not allowed.");
+                       }
                        else if (!autocvar_sv_vote_gamestart && time < game_starttime)
                        {
                                print_to(caller, "^1Vote calling is not allowed before the match has started.");
@@ -856,12 +872,17 @@ void VoteCommand_call(int request, entity caller, int argc, string vote_command)
                        }
                        else if (!VoteCommand_checknasty(vote_command))
                        {
-                               print_to(caller, "^1Syntax error in command, see 'vhelp' for more info.");
+                               print_to(caller, "^1Syntax error in command.");
                        }
                        else if ((parse_error = VoteCommand_parse(caller, vote_command, autocvar_sv_vote_commands, 2, argc)) <= 0)
                        {
                                if(parse_error == 0)
-                                       print_to(caller, "^1This command is not acceptable, see 'vhelp' for more info.");
+                               {
+                                       if (vote_called_command == "")
+                                               VoteCommand_call(CMD_REQUEST_USAGE, caller, argc, vote_command);
+                                       else
+                                               print_to(caller, "^1This command is not acceptable or not available.");
+                               }
                        }
                        else  // everything went okay, continue with calling the vote
                        {
@@ -901,6 +922,8 @@ void VoteCommand_call(int request, entity caller, int argc, string vote_command)
                        print_to(caller, "  Where <command> is the command to request a vote upon.");
                        print_to(caller, strcat("Examples: ", GetCommandPrefix(caller), " vote call gotomap dance"));
                        print_to(caller, strcat("          ", GetCommandPrefix(caller), " vote call endmatch"));
+                       print_available_commands_to(caller);
+                       print_to(caller, "Shortcuts: ^2vcall <command>, vend, vmap, vkick, ...");
                        return;
                }
        }
@@ -925,12 +948,17 @@ void VoteCommand_master(int request, entity caller, int argc, string vote_comman
                                                        print_to(caller, "^1You do not have vote master privileges.");
                                                else if (!VoteCommand_checknasty(vote_command))
                                                {
-                                                       print_to(caller, "^1Syntax error in command, see 'vhelp' for more info.");
+                                                       print_to(caller, "^1Syntax error in command.");
                                                }
                                                else if ((parse_error = VoteCommand_parse(caller, vote_command, strcat(autocvar_sv_vote_commands, " ", autocvar_sv_vote_master_commands), 3, argc)) <= 0)
                                                {
                                                        if(parse_error == 0)
-                                                               print_to(caller, "^1This command is not acceptable, see 'vhelp' for more info.");
+                                                       {
+                                                               if (vote_called_command == "")
+                                                                       VoteCommand_master(CMD_REQUEST_USAGE, caller, argc, vote_command);
+                                                               else
+                                                                       print_to(caller, "^1This command is not acceptable or not available.");
+                                                       }
                                                }
                                                else  // everything went okay, proceed with command
                                                {
@@ -1187,11 +1215,11 @@ void VoteCommand_macro_help(entity caller, int argc)
                        { if (Votecommand_check_assignment(caller, assignment)) { print_to(caller, strcat("  ^2", name, "^7: ", description)); } }
 
                VOTE_COMMANDS(0, caller, 0, "");
-#undef VOTE_COMMAND
+               #undef VOTE_COMMAND
 
                print_to(caller, strcat("\nUsage:^3 ", command_origin, " vote <command>^7, where possible commands are listed above.\n"));
                print_to(caller, strcat("For help about a specific command, type ", command_origin, " vote help <command>"));
-               print_to(caller, strcat("\n^7You can call a vote for or execute these commands: ^3", autocvar_sv_vote_commands, "^7 and maybe further ^3arguments^7"));
+               print_available_commands_to(caller);
        }
        else  // usage for individual command
        {
@@ -1199,12 +1227,12 @@ void VoteCommand_macro_help(entity caller, int argc)
                        { if (Votecommand_check_assignment(caller, assignment)) { if (name == strtolower(argv(2))) { function; return; } } }
 
                VOTE_COMMANDS(CMD_REQUEST_USAGE, caller, argc, "");
-#undef VOTE_COMMAND
+               #undef VOTE_COMMAND
 
                string cvarname = strcat("sv_vote_command_help_", argv(2));
                if(cvar_type(cvarname) & CVAR_TYPEFLAG_EXISTS)
                        wordwrap_sprint(caller, cvar_string(cvarname), 1000);
-               else
+               else if (argv(2) != "")
                        print_to(caller, "No documentation exists for this vote");
        }
 }
@@ -1215,7 +1243,7 @@ float VoteCommand_macro_command(entity caller, int argc, string vote_command)
                { if (Votecommand_check_assignment(caller, assignment)) { if (name == strtolower(argv(1))) { function; return true; } } }
 
        VOTE_COMMANDS(CMD_REQUEST_COMMAND, caller, argc, vote_command);
-#undef VOTE_COMMAND
+       #undef VOTE_COMMAND
 
        return false;
 }