]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Race/CTS: Add clear_bestcptimes command to clear all your best checkpoint times
authorDes - <gitlab@damianv.com.ar>
Thu, 29 Aug 2024 09:16:44 +0000 (09:16 +0000)
committerterencehill <piuntn@gmail.com>
Thu, 29 Aug 2024 09:16:44 +0000 (09:16 +0000)
commands.cfg
qcsrc/server/command/cmd.qc
qcsrc/server/race.qc
qcsrc/server/race.qh

index 4f0721fecb5925f59176714320eb5f0e7c27bf6a..8ff4e78b838aeecf71bdd36690509c7065e118cc 100644 (file)
@@ -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
index 0fd1442d65d10b86c017531e5e1c87b4bf491b9b..25a8c1b67676dd0ee5bbb383bea2e36233208689 100644 (file)
@@ -32,6 +32,7 @@
 #include <server/mapvoting.qh>
 #include <server/mutators/_mod.qh>
 #include <server/player.qh>
+#include <server/race.qh>
 #include <server/scores.qh>
 #include <server/teamplay.qh>
 #include <server/world.qh>
@@ -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); }
index 065bfefe936b15d5d3580f69388faa89e15ee0c2..2430a6cbddb7801772797e32482d24bf7d7536f9 100644 (file)
@@ -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)
index e408e82097c82463e908d024f364e56af25a302b..8978de2d50717ccf2e22f0c98625481a87f32459 100644 (file)
@@ -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);