]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/command/generic.qc
Merge branch 'master' into Mario/turrets
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / command / generic.qc
index 6aa93a024ed209475f9a4b5d673e4654b46312a5..9fa9872a2bcde8b3429c070f9f341e70acb9f998 100644 (file)
@@ -20,7 +20,7 @@
        #include "../../server/command/cmd.qh"
        #include "../../server/command/common.qh"
        #include "../../server/command/sv_cmd.qh"
-
+       #include "../../common/turrets/config.qh"
        #include "../../common/weapons/config.qh"
 #endif
 
@@ -363,6 +363,59 @@ void GenericCommand_dumpweapons(float request) // WEAPONTODO: make this work wit
        }
 }
 
+void GenericCommand_dumpturrets(float request)
+{
+       switch(request)
+       {
+               case CMD_REQUEST_COMMAND:
+               {
+                       #ifdef SVQC
+                       tur_config_file = -1;
+                       tur_config_alsoprint = -1;
+                       string filename = argv(1);
+                       
+                       if(filename == "")
+                       {
+                               filename = "turrets_dump.cfg";
+                               tur_config_alsoprint = FALSE;
+                       }
+                       else if(filename == "-")
+                       {
+                               filename = "turrets_dump.cfg";
+                               tur_config_alsoprint = TRUE;
+                       }
+                       tur_config_file = fopen(filename, FILE_WRITE);
+                       
+                       if(tur_config_file >= 0)
+                       {
+                               Dump_Turret_Settings();
+                               print(sprintf("Dumping turrets... File located in ^2data/data/%s^7.\n", filename));
+                               fclose(tur_config_file);
+                               tur_config_file = -1;
+                               tur_config_alsoprint = -1;
+                       }
+                       else
+                       {
+                               print(sprintf("^1Error: ^7Could not open file '%s'!\n", filename));
+                       }
+                       #else
+                       print(_("Turrets dump command only works with sv_cmd.\n"));
+                       #endif
+                       return;
+               }
+                       
+               default:
+               case CMD_REQUEST_USAGE:
+               {
+                       print(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " dumpturrets [filename]"));
+                       print("  Where 'filename' is the file to write (default is turrets_dump.cfg),\n");
+                       print("  if supplied with '-' output to console as well as default,\n");
+                       print("  if left blank, it will only write to default.\n");
+                       return;
+               }
+       }
+}
+
 void GenericCommand_maplist(float request, float argc)
 {
        switch(request)
@@ -672,6 +725,7 @@ void GenericCommand_(float request)
        GENERIC_COMMAND("dumpcommands", GenericCommand_dumpcommands(request), "Dump all commands on the program to *_cmd_dump.txt") \
        GENERIC_COMMAND("dumpitems", GenericCommand_dumpitems(request), "Dump all items to the console") \
        GENERIC_COMMAND("dumpnotifs", GenericCommand_dumpnotifs(request), "Dump all notifications into notifications_dump.txt") \
+       GENERIC_COMMAND("dumpturrets", GenericCommand_dumpturrets(request), "Dump all turrets into turrets_dump.txt") \
        GENERIC_COMMAND("dumpweapons", GenericCommand_dumpweapons(request), "Dump all weapons into weapons_dump.txt") \
        GENERIC_COMMAND("maplist", GenericCommand_maplist(request, arguments), "Automatic control of maplist") \
        GENERIC_COMMAND("nextframe", GenericCommand_nextframe(request, arguments, command), "Execute the given command next frame of this VM") \