From: Des - Date: Thu, 29 Aug 2024 09:16:44 +0000 (+0000) Subject: Race/CTS: Add clear_bestcptimes command to clear all your best checkpoint times X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=91208d1b121f78a947f8319e82b73245f6752136;p=xonotic%2Fxonotic-data.pk3dir.git Race/CTS: Add clear_bestcptimes command to clear all your best checkpoint times --- diff --git a/commands.cfg b/commands.cfg index 4f0721fec..8ff4e78b8 100644 --- a/commands.cfg +++ b/commands.cfg @@ -182,6 +182,7 @@ seta cl_autoswitch 1 "automatically switch to newly picked up weapons if they ar // commented out commands are really only intended for internal use, or already have declaration in the engine alias autoswitch "qc_cmd_cmd autoswitch ${* ?}" // Whether or not to switch automatically when getting a better weapon +alias clear_bestcptimes "qc_cmd_cmd clear_bestcptimes ${* ?}" // Clear all your best checkpoint times for this Race/CTS match alias clientversion "qc_cmd_cmd clientversion ${* ?}" // Release version of the game alias join "qc_cmd_cmd join ${* ?}" // Become a player in the game //alias kill "qc_cmd_cmd kill ${* ?}" // Become a member of the dead diff --git a/qcsrc/server/command/cmd.qc b/qcsrc/server/command/cmd.qc index 0fd1442d6..25a8c1b67 100644 --- a/qcsrc/server/command/cmd.qc +++ b/qcsrc/server/command/cmd.qc @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -100,6 +101,26 @@ void ClientCommand_clear_ignores(entity caller, int request) } } +void ClientCommand_clear_bestcptimes(entity caller, int request) +{ + switch (request) + { + case CMD_REQUEST_COMMAND: + { + race_ClearPlayerRecords(caller); + return; + } + + default: + case CMD_REQUEST_USAGE: + { + sprint(caller, "\nUsage:^3 cmd clear_bestcptimes\n"); + sprint(caller, " Clear all your checkpoint times for this game.\n"); + return; + } + } +} + void ClientCommand_clientversion(entity caller, int request, int argc) // internal command, used only by code { switch (request) @@ -925,6 +946,7 @@ void ClientCommand_(entity caller, int request) // Do not hard code aliases for these, instead create them in commands.cfg... also: keep in alphabetical order, please ;) CLIENT_COMMAND(autoswitch, "Whether or not to switch automatically when getting a better weapon") { ClientCommand_autoswitch(caller, request, arguments); } +CLIENT_COMMAND(clear_bestcptimes, "Clear all your best checkpoint times for this Race/CTS match") { ClientCommand_clear_bestcptimes(caller, request); } CLIENT_COMMAND(clear_ignores, "Remove all existing ignores of players") { ClientCommand_clear_ignores(caller, request); } CLIENT_COMMAND(clientversion, "Release version of the game") { ClientCommand_clientversion(caller, request, arguments); } CLIENT_COMMAND(ignore, "Ignore a player in the game keeping them out of your personal chat log") { ClientCommand_ignore(caller, request, arguments, command); } diff --git a/qcsrc/server/race.qc b/qcsrc/server/race.qc index 065bfefe9..2430a6cbd 100644 --- a/qcsrc/server/race.qc +++ b/qcsrc/server/race.qc @@ -1218,6 +1218,12 @@ spawnfunc(info_player_race) race_lowest_place_spawn = this.race_place; } +void race_ClearPlayerRecords(entity player) +{ + for(int i = 0; i < MAX_CHECKPOINTS; ++i) + player.race_checkpoint_record[i] = 0; +} + void race_ClearRecords() { for(int j = 0; j < MAX_CHECKPOINTS; ++j) diff --git a/qcsrc/server/race.qh b/qcsrc/server/race.qh index e408e8209..8978de2d5 100644 --- a/qcsrc/server/race.qh +++ b/qcsrc/server/race.qh @@ -48,6 +48,7 @@ string race_readUID(string map, float pos); string race_readName(string map, float pos); void race_checkAndWriteName(entity player); +void race_ClearPlayerRecords(entity player); void race_ClearRecords(); void race_SendNextCheckpoint(entity e, float spec); void race_PreparePlayer(entity this);