// =========================================================
-// Generic program common command code, reworked by Samual
+// Generic program common command code, written by Samual
// Last updated: December 28th, 2011
// =========================================================
}
}
+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)
}
default:
+ print("Incorrect parameters for ^2maplist^7\n");
case CMD_REQUEST_USAGE:
{
print(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " maplist command [map]")); // todo
default:
case CMD_REQUEST_USAGE:
{
- print(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " ")));
+ print(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " "));
print(" No arguments required.\n");
return;
}
// 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") \
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;
+}
// ===========================================
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