]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add a generic command to dump all commands from a program into a file -- makes it...
authorSamual <samual@xonotic.org>
Wed, 28 Dec 2011 21:58:15 +0000 (16:58 -0500)
committerSamual <samual@xonotic.org>
Wed, 28 Dec 2011 21:58:15 +0000 (16:58 -0500)
qcsrc/client/command/cl_cmd.qc
qcsrc/client/command/cl_cmd.qh
qcsrc/common/command/generic.qc
qcsrc/common/command/generic.qh
qcsrc/server/command/cmd.qc
qcsrc/server/command/cmd.qh
qcsrc/server/command/common.qc
qcsrc/server/command/common.qh
qcsrc/server/command/sv_cmd.qc
qcsrc/server/command/sv_cmd.qh

index 9babf43dbe3818c5ceb379ecaf5b2277b3ca4c0d..f16de6ea3ccb06147d175a596cdac354b2a9d505 100644 (file)
@@ -342,6 +342,17 @@ float LocalCommand_macro_usage(float argc)
        return FALSE;
 }
 
+void LocalCommand_macro_write_aliases(float fh)
+{
+       #define CLIENT_COMMAND(name,function,description) \
+               { CMD_Write_Alias("cl_cmd", name, description); }
+               
+       CLIENT_COMMANDS(0, 0)
+       #undef CLIENT_COMMAND
+       
+       return;
+}
+
 
 // =========================================
 //  Main Function Called By Engine (cl_cmd)
index 6e562af9258023b92a260724d3475ea468f6e1e0..f2db76a2cf293de7b05291bc1dcd4e24b9d33f22 100644 (file)
@@ -4,4 +4,7 @@
 // ==============================================
 
 void Cmd_HUD_SetFields(float);
-void Cmd_HUD_Help();
\ No newline at end of file
+void Cmd_HUD_Help();
+
+// used by common/command/generic.qc:GenericCommand_dumpcommands to list all commands into a .txt file
+void LocalCommand_macro_write_aliases(float fh);
\ No newline at end of file
index 61977f6787f6cb2231b19b076c6bdd7d75f5260c..8508ef354618342604b17c18aa3fbe067e9319bc 100644 (file)
@@ -1,5 +1,5 @@
 // =========================================================
-//  Generic program common command code, reworked by Samual
+//  Generic program common command code, written by Samual
 //  Last updated: December 28th, 2011
 // =========================================================
 
@@ -56,6 +56,70 @@ void GenericCommand_addtolist(float request, float argc)
        }
 }
 
+void GenericCommand_dumpcommands(float request)
+{
+       switch(request)
+       {
+               case CMD_REQUEST_COMMAND:
+               {
+                       float fh;
+                       string filename = strcat(GetProgramCommandPrefix(), "_dump.txt");
+                       fh = fopen(filename, FILE_WRITE);
+                       
+                       if(fh >= 0)
+                       {
+#ifdef SVQC
+                               
+                               // write sv_cmd aliases
+                               CMD_Write("dump of server console commands:\n");
+                               GameCommand_macro_write_aliases(fh);
+                               
+                               // write client only aliases
+                               CMD_Write("\ndump of networked client only commands:\n");
+                               ClientCommand_macro_write_aliases(fh);
+                               
+                               // write common aliases
+                               CMD_Write("\ndump of common commands:\n");
+                               CommonCommand_macro_write_aliases(fh);
+
+                               // write ban aliases
+                               CMD_Write("\ndump of ban commands:\n");
+                               
+#endif
+                               
+#ifdef CSQC
+                               
+                               // write cl_cmd aliases
+                               CMD_Write("dump of client commands:\n");
+                               LocalCommand_macro_write_aliases(fh);
+                               
+#endif
+                               
+                               // write generic commands
+                               CMD_Write("\ndump of generic commands:\n");
+                               GenericCommand_macro_write_aliases(fh);
+                               
+                               print("Completed dump of aliases in ^2", GetProgramCommandPrefix(), "_dump.txt^7.\n");
+                               
+                               fclose(fh);
+                       }
+                       else
+                       {
+                               print("^1Error: ^7Could not dump to file!\n");
+                       }
+                       return;
+               }
+                       
+               default:
+               case CMD_REQUEST_USAGE:
+               {
+                       print(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " dumpcommands"));
+                       print("  No arguments required.\n");
+                       return;
+               }
+       }
+}
+
 void GenericCommand_maplist(float request, float argc)
 {
        switch(request)
@@ -132,6 +196,7 @@ void GenericCommand_maplist(float request, float argc)
                }
                        
                default:
+                       print("Incorrect parameters for ^2maplist^7\n");
                case CMD_REQUEST_USAGE:
                {
                        print(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " maplist command [map]")); // todo
@@ -210,7 +275,7 @@ void GenericCommand_(float request)
                default:
                case CMD_REQUEST_USAGE:
                {
-                       print(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " ")));
+                       print(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " "));
                        print("  No arguments required.\n");
                        return;
                }
@@ -225,6 +290,7 @@ void GenericCommand_(float request)
 // Do not hard code aliases for these, instead create them in commands.cfg... also: keep in alphabetical order, please ;)
 #define GENERIC_COMMANDS(request,arguments,command) \
        GENERIC_COMMAND("addtolist", GenericCommand_addtolist(request, arguments), "Add a string to a cvar at the end of a list") \
+       GENERIC_COMMAND("dumpcommands", GenericCommand_dumpcommands(request), "Dump all commands on the program to *_cmd_dump.txt") \
        GENERIC_COMMAND("maplist", GenericCommand_maplist(request, arguments), "Automatic control of maplist") \
        GENERIC_COMMAND("rpn", GenericCommand_rpn(request, arguments, command), "RPN calculator") \
        GENERIC_COMMAND("settemp", GenericCommand_settemp(request, arguments), "Temporarily set a value to a cvar which is restored later") \
@@ -263,6 +329,17 @@ float GenericCommand_macro_usage(float argc)
        
        return FALSE;
 }
+
+void GenericCommand_macro_write_aliases(float fh)
+{
+       #define GENERIC_COMMAND(name,function,description) \
+               { CMD_Write_Alias("qc_cmd_svmenu", name, description); }
+       
+       GENERIC_COMMANDS(0, 0, "")
+       #undef GENERIC_COMMAND
+       
+       return;
+}
        
 
 // ===========================================
index 4533eb67bfaafaf912477f3162c0c084fadfa79d..3078a0f05439af3fcad58b2ac96a808f08b6e64e 100644 (file)
@@ -9,4 +9,9 @@
 float GenericCommand(string command);
 
 // Returns command prefix specific for whatever program it is compiled in
-string GetProgramCommandPrefix(void); 
\ No newline at end of file
+string GetProgramCommandPrefix(void); 
+
+// used by common/command/generic.qc:GenericCommand_dumpcommands to list all commands into a .txt file
+#define CMD_Write(s) fputs(fh, s)
+#define CMD_Write_Alias(execute,command,description) CMD_Write(sprintf("alias %-20s \"%-13s %-20s ${* ?}\" // %s\n", command, execute, command, description))
+void GenericCommand_macro_write_aliases(float fh);
\ No newline at end of file
index 4ba8e1185937b91a9d2e280363c344ab18baf20a..19be426d5363937c86882d78c25e65845eefcec4 100644 (file)
@@ -598,6 +598,16 @@ float ClientCommand_macro_usage(float argc)
        return FALSE;
 }
 
+void ClientCommand_macro_write_aliases(float fh)
+{
+       #define CLIENT_COMMAND(name,function,description) \
+               { CMD_Write_Alias("cmd", name, description); } 
+               
+       CLIENT_COMMANDS(0, 0, "")
+       #undef CLIENT_COMMAND
+       
+       return;
+}
 
 // ======================================
 //  Main Function Called By Engine (cmd)
index 4a0d771e19de3a28fd540be141e461f979319059..e64cbc267ac505e61d579318cd644a2e7b2d4595 100644 (file)
@@ -9,3 +9,6 @@
 .float checkfail;
 
 string MapVote_Suggest(string m);
+
+// used by common/command/generic.qc:GenericCommand_dumpcommands to list all commands into a .txt file
+void ClientCommand_macro_write_aliases(float fh);
\ No newline at end of file
index 821bf15c84627fb4ffd083dde5c626fbf6b79b0d..9247dffea74ee64e71f072bace05fa2ab77a68db 100644 (file)
@@ -717,3 +717,14 @@ float CommonCommand_macro_usage(float argc)
        
        return FALSE;
 }
+
+void CommonCommand_macro_write_aliases(float fh)
+{
+       #define COMMON_COMMAND(name,function,description) \
+               { CMD_Write_Alias("qc_cmd_svcmd", name, description); }
+               
+       COMMON_COMMANDS(0, 0, "")
+       #undef COMMON_COMMAND
+       
+       return;
+}
\ No newline at end of file
index f11a25338fdeded16d56f2fab95ad3774a8cf4c1..9f719892b27cfa28a7d0dd9a44413002c64ecc5a 100644 (file)
@@ -29,4 +29,7 @@ float timeout_status; // (values: 0, 1, 2) contains whether a timeout is not act
 .vector lastV_angle; //used when pausing the game in order to force the player to keep his old view angle fixed
 
 // allow functions to be used in other code like g_world.qc and teamplay.qc
-void timeout_handler_think();
\ No newline at end of file
+void timeout_handler_think();
+
+// used by common/command/generic.qc:GenericCommand_dumpcommands to list all commands into a .txt file
+void CommonCommand_macro_write_aliases(float fh);
\ No newline at end of file
index ec756d45189aceb9b3fe6793847b1eb3abb79e4f..9f0dcdd1ef378fd2f3112dde092bad26d6d14379 100644 (file)
@@ -1711,6 +1711,17 @@ float GameCommand_macro_usage(float argc)
        
        return FALSE;
 }
+
+void GameCommand_macro_write_aliases(float fh)
+{
+       #define SERVER_COMMAND(name,function,description) \
+               { CMD_Write_Alias("sv_cmd", name, description); }
+               
+       SERVER_COMMANDS(0, 0, "")
+       #undef SERVER_COMMAND
+       
+       return;
+}
        
 
 // =========================================
index 6ccfb1c7bbaf71a5d3cbb8e94525e21d74837a2d..03bd80cefc2f71fea3ddcdb4d7cbaa60bef1b2be 100644 (file)
@@ -11,3 +11,6 @@ void race_deleteTime(string map, float pos);
 #define SHUFFLETEAMS_MAX_TEAMS 4
 float shuffleteams_players[SHUFFLETEAMS_MAX_PLAYERS]; // maximum of 255 player slots
 float shuffleteams_teams[SHUFFLETEAMS_MAX_TEAMS]; // maximum of 4 teams
+
+// used by common/command/generic.qc:GenericCommand_dumpcommands to list all commands into a .txt file
+void GameCommand_macro_write_aliases(float fh);
\ No newline at end of file