From 64d5496f37e2f20f847b74638f38d49a15835c56 Mon Sep 17 00:00:00 2001 From: Samual Lenks Date: Sat, 29 Jun 2013 23:29:45 -0400 Subject: [PATCH] Lets now make the weapon config dump system actually work --- qcsrc/common/command/generic.qc | 60 ++++++++++++++++++++++++++-- qcsrc/common/weapons/config.qc | 12 +++--- qcsrc/common/weapons/config.qh | 33 +++++++++++---- qcsrc/common/weapons/w_devastator.qc | 6 +-- qcsrc/server/progs.src | 1 + 5 files changed, 94 insertions(+), 18 deletions(-) diff --git a/qcsrc/common/command/generic.qc b/qcsrc/common/command/generic.qc index 143f3bd78..b06eac1fc 100644 --- a/qcsrc/common/command/generic.qc +++ b/qcsrc/common/command/generic.qc @@ -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") \ diff --git a/qcsrc/common/weapons/config.qc b/qcsrc/common/weapons/config.qc index 9e05602f8..424d9cdc2 100644 --- a/qcsrc/common/weapons/config.qc +++ b/qcsrc/common/weapons/config.qc @@ -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 +}*/ diff --git a/qcsrc/common/weapons/config.qh b/qcsrc/common/weapons/config.qh index 462c988d7..2719cec70 100644 --- a/qcsrc/common/weapons/config.qh +++ b/qcsrc/common/weapons/config.qh @@ -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)) } diff --git a/qcsrc/common/weapons/w_devastator.qc b/qcsrc/common/weapons/w_devastator.qc index 5f889b75e..10ca7528f 100644 --- a/qcsrc/common/weapons/w_devastator.qc +++ b/qcsrc/common/weapons/w_devastator.qc @@ -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; diff --git a/qcsrc/server/progs.src b/qcsrc/server/progs.src index b7e822d1a..ff1944c1b 100644 --- a/qcsrc/server/progs.src +++ b/qcsrc/server/progs.src @@ -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 -- 2.39.2