From: z411 Date: Sat, 3 Jul 2021 06:47:46 +0000 (-0400) Subject: Initial srestart command testing (#2609) X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=36c83cf228cd329fa763c56045ad128f906bb859;p=xonotic%2Fxonotic-data.pk3dir.git Initial srestart command testing (#2609) --- diff --git a/qcsrc/server/command/sv_cmd.qc b/qcsrc/server/command/sv_cmd.qc index 9b72f7a3f..a173d46fb 100644 --- a/qcsrc/server/command/sv_cmd.qc +++ b/qcsrc/server/command/sv_cmd.qc @@ -216,7 +216,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; } @@ -1388,6 +1395,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. @@ -1712,7 +1740,7 @@ SERVER_COMMAND(setflag, "Set client flag") { GameCommand_setflag(request, argume SERVER_COMMAND(teamname, "Set team name") { GameCommand_teamname(request, arguments); } 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); } @@ -1737,6 +1765,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); } diff --git a/qcsrc/server/command/vote.qc b/qcsrc/server/command/vote.qc index 57d58dc95..850e84eed 100644 --- a/qcsrc/server/command/vote.qc +++ b/qcsrc/server/command/vote.qc @@ -400,8 +400,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), { /* @@ -418,7 +418,7 @@ void reset_map(bool dorespawn) CS(it).movement = '0 0 0'; PutClientInServer(it); }); - } + //} } } } @@ -447,9 +447,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), { @@ -462,9 +470,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), { @@ -476,13 +483,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); @@ -495,8 +499,8 @@ void ReadyRestart_force() FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), { CS(it).allowed_timeouts = autocvar_sv_timeout_number; }); } - round_handler_Activate(true); - if (!sv_ready_restart_after_countdown) reset_map(true); + round_handler_Activate(!warmup_stage); + if (!sv_ready_restart_after_countdown || warmup_stage) reset_map(true); if (autocvar_sv_eventlog) GameLogEcho(":restart"); }