]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Lets now make the weapon config dump system actually work
authorSamual Lenks <samual@xonotic.org>
Sun, 30 Jun 2013 03:29:45 +0000 (23:29 -0400)
committerSamual Lenks <samual@xonotic.org>
Sun, 30 Jun 2013 03:29:45 +0000 (23:29 -0400)
qcsrc/common/command/generic.qc
qcsrc/common/weapons/config.qc
qcsrc/common/weapons/config.qh
qcsrc/common/weapons/w_devastator.qc
qcsrc/server/progs.src

index 143f3bd78c03591919a40be9aebe3d90d479f172..b06eac1fc9b0c983c1255e38d3b4554de01f3eb6 100644 (file)
@@ -239,12 +239,12 @@ void GenericCommand_dumpnotifs(float request)
                        
                        if(filename == "")
                        {
-                               filename = "notifications.cfg";
+                               filename = "notifications_dump.cfg";
                                alsoprint = FALSE;
                        }
                        else if(filename == "-")
                        {
-                               filename = "notifications.cfg";
+                               filename = "notifications_dump.cfg";
                                alsoprint = TRUE;
                        }
                        fh = fopen(filename, FILE_WRITE);
@@ -269,7 +269,60 @@ void GenericCommand_dumpnotifs(float request)
                case CMD_REQUEST_USAGE:
                {
                        print(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " dumpnotifs [filename]"));
-                       print("  Where 'filename' is the file to write (default is notifications.cfg),\n");
+                       print("  Where 'filename' is the file to write (default is notifications_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_dumpweapons(float request) // WEAPONTODO: make this work with other progs than just server
+{
+       switch(request)
+       {
+               case CMD_REQUEST_COMMAND:
+               {
+                       #ifdef SVQC
+                       wep_config_file = -1;
+                       wep_config_alsoprint = -1;
+                       string filename = argv(1);
+                       
+                       if(filename == "")
+                       {
+                               filename = "weapons_dump.cfg";
+                               wep_config_alsoprint = FALSE;
+                       }
+                       else if(filename == "-")
+                       {
+                               filename = "weapons_dump.cfg";
+                               wep_config_alsoprint = TRUE;
+                       }
+                       wep_config_file = fopen(filename, FILE_WRITE);
+                       
+                       if(wep_config_file >= 0)
+                       {
+                               Dump_Weapon_Settings();
+                               print(sprintf("Dumping weapons... File located in ^2data/data/%s^7.\n", filename));
+                               fclose(wep_config_file);
+                               wep_config_file = -1;
+                               wep_config_alsoprint = -1;
+                       }
+                       else
+                       {
+                               print(sprintf("^1Error: ^7Could not open file '%s'!\n", filename));
+                       }
+                       #else
+                       print(_("Weapons dump command only works with sv_cmd.\n"));
+                       #endif
+                       return;
+               }
+                       
+               default:
+               case CMD_REQUEST_USAGE:
+               {
+                       print(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " dumpweapons [filename]"));
+                       print("  Where 'filename' is the file to write (default is weapons_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;
@@ -583,6 +636,7 @@ void GenericCommand_(float request)
        GENERIC_COMMAND("addtolist", GenericCommand_addtolist(request, arguments), "Add a string to a cvar") \
        GENERIC_COMMAND("dumpcommands", GenericCommand_dumpcommands(request), "Dump all commands on the program to *_cmd_dump.txt") \
        GENERIC_COMMAND("dumpnotifs", GenericCommand_dumpnotifs(request), "Dump all notifications into notifications_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") \
        GENERIC_COMMAND("qc_curl", GenericCommand_qc_curl(request, arguments), "Queries a URL") \
index 9e05602f880d5fb63f094c22b5a22780061a1387..424d9cdc249d1120a6370307b5bc68e32c8d01c5 100644 (file)
@@ -2,14 +2,16 @@
 //  Balance Config Generator
 // ==========================
 
-void Dump_Weapon_Settings(float fh, float alsoprint)
+void Dump_Weapon_Settings(void)
 {
        float i;
        for(i = WEP_FIRST; i <= WEP_LAST; ++i)
        {
-               WEP_ACTION(i, WR_CONFIG)
+               WEP_CONFIG_WRITE(sprintf("// {{{ #%d: %s\n", i, W_Name(i)))
+               WEP_ACTION(i, WR_CONFIG);
+               WEP_CONFIG_WRITE("// }}}\n")
        }
-
+}
        /*
        #define WEP_BAL_WRITE(a) { \
                fputs(fh, a); \
@@ -107,5 +109,5 @@ void Dump_Weapon_Settings(float fh, float alsoprint)
        return;
        #undef NOTIF_WRITE_HARDCODED
        #undef NOTIF_WRITE_ENTITY
-       #undef NOTIF_WRITE*/
-}
+       #undef NOTIF_WRITE
+}*/
index 462c988d77b3ab0ee95e4bc39cf9785a3e12ce92..2719cec707d9e97f185e197033df9e2d8974d52e 100644 (file)
@@ -2,7 +2,7 @@
 //  Balance Config Generator
 // ==========================
 
-void Dump_Weapon_Settings(float fh, float alsoprint);
+void Dump_Weapon_Settings(void);
 float wep_config_file;
 float wep_config_alsoprint;
 
@@ -12,18 +12,37 @@ float wep_config_alsoprint;
 
 #define WEP_CONFIG_WRITE_CVARS(weapon,mode,name) \
        #if mode == MO_PRI \
-               WEP_CONFIG_WRITE(sprintf("set g_balance_%s_primary_%s", #weapon, #name)) \
+               { WEP_CONFIG_WRITE(sprintf( \
+                       "set g_balance_%s_primary_%s %f\n", \
+                       #weapon, \
+                       #name, \
+                       autocvar_g_balance_##weapon##_primary_##name)) } \
        #endif \
        #if mode == MO_SEC \
-               WEP_CONFIG_WRITE(sprintf("set g_balance_%s_secondary_%s", #weapon, #name)) \
+               { WEP_CONFIG_WRITE(sprintf("set g_balance_%s_secondary_%s %f\n", \
+                       #weapon, \
+                       #name, \
+                       autocvar_g_balance_##weapon##_secondary_##name)) } \
        #endif \
        #if mode == MO_BOTH \
-               WEP_CONFIG_WRITE(sprintf("set g_balance_%s_primary_%s", #weapon, #name)) \
-               WEP_CONFIG_WRITE(sprintf("set g_balance_%s_secondary_%s", #weapon, #name)) \
+               { WEP_CONFIG_WRITE(sprintf("set g_balance_%s_primary_%s %f\n", \
+                       #weapon, \
+                       #name, \
+                       autocvar_g_balance_##weapon##_primary_##name)) } \
+               { WEP_CONFIG_WRITE(sprintf("set g_balance_%s_secondary_%s %f\n", \
+                       #weapon, \
+                       #name, \
+                       autocvar_g_balance_##weapon##_secondary_##name)) } \
        #endif \
        #if mode == MO_NONE \
-               WEP_CONFIG_WRITE(sprintf("set g_balance_%s_%s", #weapon, #name)) \
+               { WEP_CONFIG_WRITE(sprintf("set g_balance_%s_%s %f\n", \
+                       #weapon, \
+                       #name, \
+                       autocvar_g_balance_##weapon##_##name)) } \
        #endif
        
 #define WEP_CONFIG_WRITE_PROPS(weapon,prop,name) \
-       { WEP_CONFIG_WRITE(sprintf("set g_balance_%s_%s", #weapon, #name)) }
+       { WEP_CONFIG_WRITE(sprintf("set g_balance_%s_%s %f\n", \
+                       #weapon, \
+                       #name, \
+                       autocvar_g_balance_##weapon##_##name)) } 
index 5f889b75e2819077a93a49ab81e53003663bc2a0..10ca7528f91b0af52563694540ca0196f72d60e2 100644 (file)
@@ -317,7 +317,7 @@ float W_Devastator(float req)
        float ammo_amount;
        switch(req)
        {
-               case WR_AIM:
+               case WR_AIM: // WEAPONTODO: rewrite this, it's WAY too complicated for what it should be
                {
                        // aim and decide to fire if appropriate
                        self.BUTTON_ATCK = bot_aim(WEP_CVAR(devastator, speed), 0, WEP_CVAR(devastator, lifetime), FALSE);
@@ -475,8 +475,8 @@ float W_Devastator(float req)
                case WR_CONFIG:
                {
                        #define WEP_ADD_CVAR(weapon,mode,name) WEP_CONFIG_WRITE_CVARS(weapon,mode,name)
-                       #define WEP_ADD_PROP(weapon,prop,name) WEP_CONFIG_WRITE_PROPS(weapon,mode,name)
-                       ARC_SETTINGS(devastator)
+                       #define WEP_ADD_PROP(weapon,prop,name) WEP_CONFIG_WRITE_PROPS(weapon,prop,name)
+                       DEVASTATOR_SETTINGS(devastator)
                        #undef WEP_ADD_CVAR
                        #undef WEP_ADD_PROP
                        return TRUE;
index b7e822d1a1b183bd7be100b26f12286cff61b177..ff1944c1b63040273ab3838d354eb7dcf3921a44 100644 (file)
@@ -143,6 +143,7 @@ weapons/hitplot.qc
 weapons/main.qc
 weapons/common.qc
 weapons/csqcprojectile.qc // TODO
+../common/weapons/config.qc
 ../common/weapons/weapons.qc // TODO
 
 t_items.qc