]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Initial srestart command testing (#2609)
authorz411 <z411@omaera.org>
Sat, 3 Jul 2021 06:47:46 +0000 (02:47 -0400)
committerz411 <z411@omaera.org>
Sat, 3 Jul 2021 06:47:46 +0000 (02:47 -0400)
qcsrc/server/command/sv_cmd.qc
qcsrc/server/command/vote.qc

index 5a9fae567589e695843c8702ff91ef11e0dea5ea..3187d5d3a1014f7780b7ab1257897094a3e8849e 100644 (file)
@@ -161,7 +161,14 @@ void GameCommand_allready(int request)
        {
                case CMD_REQUEST_COMMAND:
                {
-                       ReadyRestart();
+                       if(warmup_stage)
+                       {
+                               warmup_stage = 0;
+                               ReadyRestart();
+                       }
+                       else
+                               LOG_INFO("Not in warmup.");
+
                        return;
                }
 
@@ -1302,6 +1309,27 @@ void GameCommand_shuffleteams(int request)
        }
 }
 
+void GameCommand_srestart(int request)
+{
+       switch (request)
+       {
+               case CMD_REQUEST_COMMAND:
+               {
+                       warmup_stage = cvar("g_warmup");
+                       ReadyRestart();
+                       return;
+               }
+
+               default:
+               case CMD_REQUEST_USAGE:
+               {
+                       LOG_HELP("Usage:^3 sv_cmd srestart");
+                       LOG_HELP("  No arguments required.");
+                       return;
+               }
+       }
+}
+
 void GameCommand_stuffto(int request, int argc)
 {
        // This... is a fairly dangerous and powerful command... - It allows any arguments to be sent to a client via rcon.
@@ -1623,7 +1651,7 @@ void GameCommand_(int request)
 
 // Do not hard code aliases for these, instead create them in commands.cfg... also: keep in alphabetical order, please ;)
 SERVER_COMMAND(adminmsg, "Send an admin message to a client directly") { GameCommand_adminmsg(request, arguments); }
-SERVER_COMMAND(allready, "Restart the server and reset the players") { GameCommand_allready(request); }
+SERVER_COMMAND(allready, "Ends warmup and starts the match") { GameCommand_allready(request); }
 SERVER_COMMAND(allspec, "Force all players to spectate") { GameCommand_allspec(request, arguments); }
 SERVER_COMMAND(anticheat, "Create an anticheat report for a client") { GameCommand_anticheat(request, arguments); }
 SERVER_COMMAND(animbench, "Benchmark model animation (LAGS)") { GameCommand_animbench(request, arguments); }
@@ -1648,6 +1676,7 @@ SERVER_COMMAND(radarmap, "Generate a radar image of the map") { GameCommand_rada
 SERVER_COMMAND(reducematchtime, "Decrease the timelimit value incrementally") { GameCommand_reducematchtime(request); }
 SERVER_COMMAND(setbots, "Adjust how many bots are in the match") { GameCommand_setbots(request, arguments); }
 SERVER_COMMAND(shuffleteams, "Randomly move players to different teams") { GameCommand_shuffleteams(request); }
+SERVER_COMMAND(srestart, "Soft restart the server and reset the players") { GameCommand_srestart(request); }
 SERVER_COMMAND(stuffto, "Send a command to be executed on a client") { GameCommand_stuffto(request, arguments); }
 SERVER_COMMAND(trace, "Various debugging tools with tracing") { GameCommand_trace(request, arguments); }
 SERVER_COMMAND(unlockteams, "Enable the ability for players to switch or enter teams") { GameCommand_unlockteams(request); }
index ffc81c4685794480cf749cea7b87129134b8de71..0784376c197b47772df3374c8ee976d213b32d00 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,17 @@ 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)
+       {
+               readyrestart_happened = true;
+               game_starttime = time + RESTART_COUNTDOWN;
+       }
+       else
+       {
+               readyrestart_happened = false;
+               game_starttime = 0;
+       }
 
        // clear player attributes
        FOREACH_CLIENT(IS_PLAYER(it), {
@@ -451,9 +459,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 +469,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 +485,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");
 }