REGISTER(RegisterGENERIC_COMMANDS, CMD_G, GENERIC_COMMANDS, id, m_id, NEW(genericcommand_##id)); \
METHOD(genericcommand_##id, m_invokecmd, void(int request, int arguments, string command))
+STATIC_INIT(GENERIC_COMMANDS_aliases) {
+ FOREACH(GENERIC_COMMANDS, true, LAMBDA(localcmd(sprintf("alias %1$s \"%2$s %1$s ${* ?}\"\n", it.m_name, "qc_cmd_svmenu"))));
+}
+
#include "generic.qh"
#include "markup.qh"
#include "rpn.qh"
}
}
-void GenericCommand_dumpcommands(float request)
+GENERIC_COMMAND(dumpcommands, "Dump all commands on the program to *_cmd_dump.txt")
{
switch(request)
{
}
}
-#ifndef MENUQC
-void effectinfo_dump(int fh, bool alsoprint);
-#endif
-void GenericCommand_dumpeffectinfo(float request)
-{
- switch (request) {
- case CMD_REQUEST_COMMAND: {
- #ifndef MENUQC
- string filename = argv(1);
- bool alsoprint = false;
- if (filename == "") {
- filename = "effectinfo_dump.txt";
- alsoprint = false;
- } else if (filename == "-") {
- filename = "effectinfo_dump.txt";
- alsoprint = true;
- }
- int fh = fopen(filename, FILE_WRITE);
- if (fh >= 0) {
- effectinfo_dump(fh, alsoprint);
- LOG_INFOF("Dumping effectinfo... File located at ^2data/data/%s^7.\n", filename);
- LOG_INFOF("Reload with ^2cl_particles_reloadeffects data/%s^7.\n", filename);
- fclose(fh);
- } else {
- LOG_WARNINGF("Could not open file '%s'!\n", filename);
- }
- #else
- LOG_INFO(_("Effectinfo dump command only works with cl_cmd and sv_cmd.\n"));
- #endif
- return;
- }
- default:
- case CMD_REQUEST_USAGE: {
- LOG_INFO(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " dumpeffectinfo [filename]"));
- LOG_INFO(" Where 'filename' is the file to write (default is effectinfo_dump.txt),\n");
- LOG_INFO(" if supplied with '-' output to console as well as default,\n");
- LOG_INFO(" if left blank, it will only write to default.\n");
- return;
- }
- }
-}
-STATIC_INIT(dumpeffectinfo) { localcmd("alias dumpeffectinfo \"qc_cmd_svcl dumpeffectinfo ${* ?}\"\n"); }
-
-void GenericCommand_dumpitems(float request)
-{
- switch(request)
- {
- case CMD_REQUEST_COMMAND:
- {
- Dump_Items();
- return;
- }
-
- default:
- case CMD_REQUEST_USAGE:
- {
- LOG_INFOF("\nUsage:^3 %s dumpitems", GetProgramCommandPrefix());
- return;
- }
- }
-}
-
-void GenericCommand_dumpnotifs(float request)
-{
- switch(request)
- {
- case CMD_REQUEST_COMMAND:
- {
- #ifndef MENUQC
- float fh, alsoprint = false;
- string filename = argv(1);
-
- if(filename == "")
- {
- filename = "notifications_dump.cfg";
- alsoprint = false;
- }
- else if(filename == "-")
- {
- filename = "notifications_dump.cfg";
- alsoprint = true;
- }
- fh = fopen(filename, FILE_WRITE);
-
- if(fh >= 0)
- {
- Dump_Notifications(fh, alsoprint);
- LOG_INFOF("Dumping notifications... File located in ^2data/data/%s^7.\n", filename);
- fclose(fh);
- }
- else
- {
- LOG_INFOF("^1Error: ^7Could not open file '%s'!\n", filename);
- }
- #else
- LOG_INFO(_("Notification dump command only works with cl_cmd and sv_cmd.\n"));
- #endif
- return;
- }
-
- default:
- case CMD_REQUEST_USAGE:
- {
- LOG_INFO(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " dumpnotifs [filename]"));
- LOG_INFO(" Where 'filename' is the file to write (default is notifications_dump.cfg),\n");
- LOG_INFO(" if supplied with '-' output to console as well as default,\n");
- LOG_INFO(" 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();
- LOG_INFO(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
- {
- LOG_INFO(sprintf("^1Error: ^7Could not open file '%s'!\n", filename));
- }
- #else
- LOG_INFO(_("Weapons dump command only works with sv_cmd.\n"));
- #endif
- return;
- }
-
- default:
- case CMD_REQUEST_USAGE:
- {
- LOG_INFO(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " dumpweapons [filename]"));
- LOG_INFO(" Where 'filename' is the file to write (default is weapons_dump.cfg),\n");
- LOG_INFO(" if supplied with '-' output to console as well as default,\n");
- LOG_INFO(" if left blank, it will only write to default.\n");
- return;
- }
- }
-}
-
-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();
- LOG_INFO(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
- {
- LOG_INFO(sprintf("^1Error: ^7Could not open file '%s'!\n", filename));
- }
- #else
- LOG_INFO(_("Turrets dump command only works with sv_cmd.\n"));
- #endif
- return;
- }
-
- default:
- case CMD_REQUEST_USAGE:
- {
- LOG_INFO(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " dumpturrets [filename]"));
- LOG_INFO(" Where 'filename' is the file to write (default is turrets_dump.cfg),\n");
- LOG_INFO(" if supplied with '-' output to console as well as default,\n");
- LOG_INFO(" if left blank, it will only write to default.\n");
- return;
- }
- }
-}
-
void GenericCommand_maplist(float request, float argc)
{
switch(request)
// Do not hard code aliases for these, instead create them in commands.cfg... also: keep in alphabetical order, please ;)
GENERIC_COMMAND(addtolist, "Add a string to a cvar") { GenericCommand_addtolist(request, arguments); }
-GENERIC_COMMAND(dumpcommands, "Dump all commands on the program to *_cmd_dump.txt") { GenericCommand_dumpcommands(request); }
-GENERIC_COMMAND(dumpeffectinfo, "Dump all effectinfo to effectinfo_dump.txt") { GenericCommand_dumpeffectinfo(request); }
-GENERIC_COMMAND(dumpitems, "Dump all items to the console") { GenericCommand_dumpitems(request); }
-GENERIC_COMMAND(dumpnotifs, "Dump all notifications into notifications_dump.txt") { GenericCommand_dumpnotifs(request); }
-GENERIC_COMMAND(dumpturrets, "Dump all turrets into turrets_dump.txt") { GenericCommand_dumpturrets(request); }
-GENERIC_COMMAND(dumpweapons, "Dump all weapons into weapons_dump.txt") { GenericCommand_dumpweapons(request); }
GENERIC_COMMAND(maplist, "Automatic control of maplist") { GenericCommand_maplist(request, arguments); }
GENERIC_COMMAND(nextframe, "Execute the given command next frame of this VM") { GenericCommand_nextframe(request, arguments, command); }
GENERIC_COMMAND(qc_curl, "Queries a URL") { GenericCommand_qc_curl(request, arguments); }
#undef WRITE
}
+GENERIC_COMMAND(dumpeffectinfo, "Dump all effectinfo to effectinfo_dump.txt")
+{
+ switch (request) {
+ case CMD_REQUEST_COMMAND: {
+ string filename = argv(1);
+ bool alsoprint = false;
+ if (filename == "") {
+ filename = "effectinfo_dump.txt";
+ alsoprint = false;
+ } else if (filename == "-") {
+ filename = "effectinfo_dump.txt";
+ alsoprint = true;
+ }
+ int fh = fopen(filename, FILE_WRITE);
+ if (fh >= 0) {
+ effectinfo_dump(fh, alsoprint);
+ LOG_INFOF("Dumping effectinfo... File located at ^2data/data/%s^7.\n", filename);
+ LOG_INFOF("Reload with ^2cl_particles_reloadeffects data/%s^7.\n", filename);
+ fclose(fh);
+ } else {
+ LOG_WARNINGF("Could not open file '%s'!\n", filename);
+ }
+ return;
+ }
+ default:
+ case CMD_REQUEST_USAGE: {
+ LOG_INFO(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " dumpeffectinfo [filename]"));
+ LOG_INFO(" Where 'filename' is the file to write (default is effectinfo_dump.txt),\n");
+ LOG_INFO(" if supplied with '-' output to console as well as default,\n");
+ LOG_INFO(" if left blank, it will only write to default.\n");
+ return;
+ }
+ }
+}
+
REGISTRY(EffectInfos, BIT(9))
REGISTER_REGISTRY(RegisterEffectInfos)
#ifndef ITEMS_ALL_H
#define ITEMS_ALL_H
+#include "../command/all.qh"
+
#include "item.qh"
REGISTRY(Items, BIT(5))
void Dump_Items();
+GENERIC_COMMAND(dumpitems, "Dump all items to the console") {
+ switch (request) {
+ case CMD_REQUEST_COMMAND: {
+ Dump_Items();
+ return;
+ }
+ default:
+ case CMD_REQUEST_USAGE: {
+ LOG_INFOF("\nUsage:^3 %s dumpitems", GetProgramCommandPrefix());
+ return;
+ }
+ }
+}
+
#ifndef MENUQC
string Item_Model(string item_mdl);
#endif
#ifndef NOTIFICATIONS_H
#define NOTIFICATIONS_H
+#include "command/all.qh"
+
#include "constants.qh"
#include "teams.qh"
#include "util.qh"
void Dump_Notifications(float fh, float alsoprint);
+
+GENERIC_COMMAND(dumpnotifs, "Dump all notifications into notifications_dump.txt")
+{
+ switch(request)
+ {
+ case CMD_REQUEST_COMMAND:
+ {
+ #ifndef MENUQC
+ float fh, alsoprint = false;
+ string filename = argv(1);
+
+ if(filename == "")
+ {
+ filename = "notifications_dump.cfg";
+ alsoprint = false;
+ }
+ else if(filename == "-")
+ {
+ filename = "notifications_dump.cfg";
+ alsoprint = true;
+ }
+ fh = fopen(filename, FILE_WRITE);
+
+ if(fh >= 0)
+ {
+ Dump_Notifications(fh, alsoprint);
+ LOG_INFOF("Dumping notifications... File located in ^2data/data/%s^7.\n", filename);
+ fclose(fh);
+ }
+ else
+ {
+ LOG_INFOF("^1Error: ^7Could not open file '%s'!\n", filename);
+ }
+ #else
+ LOG_INFO(_("Notification dump command only works with cl_cmd and sv_cmd.\n"));
+ #endif
+ return;
+ }
+
+ default:
+ case CMD_REQUEST_USAGE:
+ {
+ LOG_INFO(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " dumpnotifs [filename]"));
+ LOG_INFO(" Where 'filename' is the file to write (default is notifications_dump.cfg),\n");
+ LOG_INFO(" if supplied with '-' output to console as well as default,\n");
+ LOG_INFO(" if left blank, it will only write to default.\n");
+ return;
+ }
+ }
+}
+
#ifdef NOTIFICATIONS_DEBUG
void Debug_Notification(string input);
#endif
#ifndef TURRETS_ALL_H
#define TURRETS_ALL_H
+#include "../command/all.qh"
+#include "config.qh"
+
#include "turret.qh"
REGISTRY(Turrets, BIT(5))
REGISTER_REGISTRY(RegisterTurrets)
+
+
+GENERIC_COMMAND(dumpturrets, "Dump all turrets into turrets_dump.txt")
+{
+ 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();
+ LOG_INFO(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
+ {
+ LOG_INFO(sprintf("^1Error: ^7Could not open file '%s'!\n", filename));
+ }
+ #else
+ LOG_INFO(_("Turrets dump command only works with sv_cmd.\n"));
+ #endif
+ return;
+ }
+
+ default:
+ case CMD_REQUEST_USAGE:
+ {
+ LOG_INFO(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " dumpturrets [filename]"));
+ LOG_INFO(" Where 'filename' is the file to write (default is turrets_dump.cfg),\n");
+ LOG_INFO(" if supplied with '-' output to console as well as default,\n");
+ LOG_INFO(" if left blank, it will only write to default.\n");
+ return;
+ }
+ }
+}
+
+
const int TUR_FIRST = 1;
#define TUR_LAST (Turrets_COUNT - 1)
#ifndef WEAPONS_ALL_H
#define WEAPONS_ALL_H
+#include "../command/all.qh"
+#include "config.qh"
+
// weapon sets
typedef vector WepSet;
#define WEPSET(id) WepSet_FromWeapon(WEP_##id.m_id)
REGISTER_REGISTRY(RegisterWeapons)
entity get_weaponinfo(int id);
+
+GENERIC_COMMAND(dumpweapons, "Dump all weapons into weapons_dump.txt") // 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();
+ LOG_INFO(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
+ {
+ LOG_INFO(sprintf("^1Error: ^7Could not open file '%s'!\n", filename));
+ }
+ #else
+ LOG_INFO(_("Weapons dump command only works with sv_cmd.\n"));
+ #endif
+ return;
+ }
+
+ default:
+ case CMD_REQUEST_USAGE:
+ {
+ LOG_INFO(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " dumpweapons [filename]"));
+ LOG_INFO(" Where 'filename' is the file to write (default is weapons_dump.cfg),\n");
+ LOG_INFO(" if supplied with '-' output to console as well as default,\n");
+ LOG_INFO(" if left blank, it will only write to default.\n");
+ return;
+ }
+ }
+}
+
#define REGISTER_WEAPON(id, inst) \
- /* WepSet WEPSET_##id; */ \
- REGISTER(RegisterWeapons, WEP, Weapons, id, m_id, inst)
+ /* WepSet WEPSET_##id; */ \
+ REGISTER(RegisterWeapons, WEP, Weapons, id, m_id, inst)
// create cvars for weapon settings
#define WEP_ADD_CVAR_NONE(wepname,name) [[last]] float autocvar_g_balance_##wepname##_##name;
#define WEP_ADD_CVAR_PRI(wepname,name) WEP_ADD_CVAR_NONE(wepname, primary_##name)
#define WEP_ADD_CVAR_SEC(wepname,name) WEP_ADD_CVAR_NONE(wepname, secondary_##name)
#define WEP_ADD_CVAR_BOTH(wepname,name) \
- WEP_ADD_CVAR_PRI(wepname, name) \
- WEP_ADD_CVAR_SEC(wepname, name)
+ WEP_ADD_CVAR_PRI(wepname, name) \
+ WEP_ADD_CVAR_SEC(wepname, name)
#define WEP_ADD_CVAR(wepid,wepname,mode,name) WEP_ADD_CVAR_##mode(wepname, name)
// create properties for weapon settings
#define WEP_ADD_PROP(wepid,wepname,type,prop,name) \
- .type prop; \
- [[last]] type autocvar_g_balance_##wepname##_##name;
+ .type prop; \
+ [[last]] type autocvar_g_balance_##wepname##_##name;
// read cvars from weapon settings
#define WEP_CVAR(wepname,name) autocvar_g_balance_##wepname##_##name
entity get_weaponinfo(int id)
{
- if (id >= WEP_FIRST && id <= WEP_LAST) {
- Weapon w = Weapons[id];
- if (w) return w;
- }
- return WEP_Null;
+ if (id >= WEP_FIRST && id <= WEP_LAST) {
+ Weapon w = Weapons[id];
+ if (w) return w;
+ }
+ return WEP_Null;
}
// TODO: remove after 0.8.2. Retains impulse number compatibility because 0.8.1 clients don't reload the weapons.cfg
STATIC_INIT(register_weapons_done)
{
- for (int i = 0; i < Weapons_COUNT; ++i) {
- Weapon it = Weapons[i];
- it.m_id = i;
- WepSet set = WepSet_FromWeapon(it.m_id);
- WEPSET_ALL |= set;
- if ((it.spawnflags) & WEP_FLAG_SUPERWEAPON) WEPSET_SUPERWEAPONS |= set;
- it.weapon = it.m_id;
- it.weapons = set;
- #ifdef CSQC
- it.wr_init(it);
- #endif
- int imp = WEP_IMPULSE_BEGIN + it.m_id - 1;
- if (imp <= WEP_IMPULSE_END)
- localcmd(sprintf("alias weapon_%s \"impulse %d\"\n", it.netname, imp));
- else
- LOG_TRACEF(_("Impulse limit exceeded, weapon will not be directly accessible: %s\n"), it.netname);
- }
- weaponorder_byid = "";
- for (int i = Weapons_MAX - 1; i >= 1; --i)
- if (Weapons[i])
- weaponorder_byid = strcat(weaponorder_byid, " ", ftos(i));
- weaponorder_byid = strzone(substring(weaponorder_byid, 1, strlen(weaponorder_byid) - 1));
+ for (int i = 0; i < Weapons_COUNT; ++i) {
+ Weapon it = Weapons[i];
+ it.m_id = i;
+ WepSet set = WepSet_FromWeapon(it.m_id);
+ WEPSET_ALL |= set;
+ if ((it.spawnflags) & WEP_FLAG_SUPERWEAPON) WEPSET_SUPERWEAPONS |= set;
+ it.weapon = it.m_id;
+ it.weapons = set;
+ #ifdef CSQC
+ it.wr_init(it);
+ #endif
+ int imp = WEP_IMPULSE_BEGIN + it.m_id - 1;
+ if (imp <= WEP_IMPULSE_END)
+ localcmd(sprintf("alias weapon_%s \"impulse %d\"\n", it.netname, imp));
+ else
+ LOG_TRACEF(_("Impulse limit exceeded, weapon will not be directly accessible: %s\n"), it.netname);
+ }
+ weaponorder_byid = "";
+ for (int i = Weapons_MAX - 1; i >= 1; --i)
+ if (Weapons[i])
+ weaponorder_byid = strcat(weaponorder_byid, " ", ftos(i));
+ weaponorder_byid = strzone(substring(weaponorder_byid, 1, strlen(weaponorder_byid) - 1));
}
#endif
#ifndef WEAPONS_CONFIG_H
#define WEAPONS_CONFIG_H
+#ifdef SVQC
// ==========================
// Balance Config Generator
// ==========================
#define WEP_CONFIG_WRITE_PROPS(wepid,wepname,type,prop,name) WEP_CONFIG_WRITE_PROPS_##type(wepname,name)
#endif
+#endif