]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/command/vote.qc
Using a separate global to keep track of overtime phase
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / command / vote.qc
index aefbc3fd1c502896cd6cfc41c4dc67053bdbe080..7ff8d2a133e16abd24425031214f7f11201c35aa 100644 (file)
@@ -336,14 +336,19 @@ void VoteThink()
 // =======================
 
 // Resets the state of all clients, items, weapons, waypoints, ... of the map.
-void reset_map(bool dorespawn)
+void reset_map(bool dorespawn, bool is_fake_round_start)
 {
        if (time <= game_starttime)
        {
                if (game_stopped)
                        return;
 
-               PlayerStats_GameReport_Reset_All();
+               if (!is_fake_round_start)
+               {
+                       Score_ClearAll();
+                       PlayerStats_GameReport_Reset_All();
+               }
+
                if (round_handler_IsActive())
                        round_handler_Reset(game_starttime);
        }
@@ -413,26 +418,25 @@ void reset_map(bool dorespawn)
 // 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);
-       Score_ClearAll();
+       reset_map(true, false);
        delete(this);
 }
 
 // Forces a restart of the game without actually reloading the map // this is a mess...
-void ReadyRestart_force()
+void ReadyRestart_force(bool is_fake_round_start)
 {
        if (time <= game_starttime && game_stopped)
                return;
-
-       bprint("^1Match is restarting...\n");
+       if (!is_fake_round_start)
+               bprint("^1Match is restarting...\n");
 
        VoteReset();
 
        // clear overtime, we have to decrease timelimit to its original value again.
        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;
-       
+       checkrules_suddendeathend = checkrules_overtimesadded = checkrules_suddendeathwarning = overtimes = 0;
+
        if(warmup_stage)
                game_starttime = time; // Warmup: No countdown in warmup
        else
@@ -445,7 +449,7 @@ void ReadyRestart_force()
        });
 
        // if we're ending the warmup stage call the corresponding hook
-       if(!warmup_stage)
+       if(!is_fake_round_start && !warmup_stage)
                localcmd("\nsv_hook_warmupend\n");
 
        // reset the .ready status of all players (also spectators)
@@ -458,7 +462,7 @@ void ReadyRestart_force()
                lockteams = !warmup_stage;
 
        // initiate the restart-countdown-announcer entity
-       if (sv_ready_restart_after_countdown && !warmup_stage)
+       if (!is_fake_round_start && sv_ready_restart_after_countdown && !warmup_stage)
        {
                entity restart_timer = new_pure(restart_timer);
                setthink(restart_timer, ReadyRestart_think);
@@ -471,7 +475,9 @@ 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 || warmup_stage) reset_map(true);
+       if (!sv_ready_restart_after_countdown || warmup_stage)
+               reset_map(true, is_fake_round_start);
+
        if (autocvar_sv_eventlog) GameLogEcho(":restart");
 }
 
@@ -480,16 +486,12 @@ void ReadyRestart(bool forceWarmupEnd)
        if (MUTATOR_CALLHOOK(ReadyRestart_Deny) || intermission_running || race_completing) localcmd("restart\n");
        else localcmd("\nsv_hook_readyrestart\n");
 
-       // Reset ALL scores, but only do that at the beginning of the countdown if sv_ready_restart_after_countdown is off!
-       // Otherwise scores could be manipulated during the countdown.
-       if (!sv_ready_restart_after_countdown) Score_ClearAll();
-
        if(forceWarmupEnd)
                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
 
-       ReadyRestart_force();
+       ReadyRestart_force(false);
 }
 
 // Count the players who are ready and determine whether or not to restart the match
@@ -498,7 +500,7 @@ void ReadyCount()
        float ready_needed_factor, ready_needed_count;
        float t_ready = 0, t_players = 0;
 
-       FOREACH_CLIENT(IS_REAL_CLIENT(it) && (IS_PLAYER(it) || it.caplayer == 1), {
+       FOREACH_CLIENT(IS_REAL_CLIENT(it) && (IS_PLAYER(it) || INGAME_JOINED(it)), {
                ++t_players;
                if (it.ready) ++t_ready;
        });
@@ -759,11 +761,12 @@ int VoteCommand_parse(entity caller, string vote_command, string vote_list, floa
                        break;
                }
 
-               case "restart":
-               case "resetmatch":  // re-direct all match restarting to resetmatch
+               case "restart": // re-direct all match restarting to resetmatch
+                       vote_command = "resetmatch"; // fall-through
+               case "resetmatch":
                {
-                       vote_parsed_command = "resetmatch";
-                       vote_parsed_display = strzone("^1resetmatch");
+                       vote_parsed_command = vote_command;
+                       vote_parsed_display = strzone(strcat("^1", vote_command));
 
                        break;
                }