From: Mario Date: Sat, 28 Dec 2019 13:25:05 +0000 (+1000) Subject: Create aliases for commands on roughly their correct VM, restores settemp functionality X-Git-Tag: xonotic-v0.8.5~1179 X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=commitdiff_plain;h=6cd374ba7ed0935e308cbddf633d30332170d59c Create aliases for commands on roughly their correct VM, restores settemp functionality --- diff --git a/qcsrc/common/command/generic.qc b/qcsrc/common/command/generic.qc index dcd8d95842..2c34fea44a 100644 --- a/qcsrc/common/command/generic.qc +++ b/qcsrc/common/command/generic.qc @@ -169,7 +169,7 @@ void GenericCommand_qc_curl(int request, int argc) } } -GENERIC_COMMAND(dumpcommands, "Dump all commands on the program to _cmd_dump.txt") +GENERIC_COMMAND(dumpcommands, "Dump all commands on the program to _cmd_dump.txt", false) { switch(request) { @@ -532,16 +532,16 @@ void GenericCommand_(int 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(maplist, "Automatic control of maplist") { GenericCommand_maplist(request, arguments); } -GENERIC_COMMAND(nextframe, "Execute the given command next frame of this VM") { GenericCommand_nextframe(request, command); } -GENERIC_COMMAND(qc_curl, "Queries a URL") { GenericCommand_qc_curl(request, arguments); } -GENERIC_COMMAND(removefromlist, "Remove a string from a cvar") { GenericCommand_removefromlist(request, arguments); } -GENERIC_COMMAND(restartnotifs, "Re-initialize all notifications") { GenericCommand_restartnotifs(request); } -GENERIC_COMMAND(rpn, "RPN calculator") { GenericCommand_rpn(request, arguments, command); } -GENERIC_COMMAND(settemp, "Temporarily set a value to a cvar which is restored later") { GenericCommand_settemp(request, arguments); } -GENERIC_COMMAND(settemp_restore, "Restore all cvars set by settemp command") { GenericCommand_settemp_restore(request); } -GENERIC_COMMAND(runtest, "Run unit tests") { GenericCommand_runtest(request, arguments); } +GENERIC_COMMAND(addtolist, "Add a string to a cvar", true) { GenericCommand_addtolist(request, arguments); } +GENERIC_COMMAND(maplist, "Automatic control of maplist", true) { GenericCommand_maplist(request, arguments); } +GENERIC_COMMAND(nextframe, "Execute the given command next frame of this VM", true) { GenericCommand_nextframe(request, command); } +GENERIC_COMMAND(qc_curl, "Queries a URL", true) { GenericCommand_qc_curl(request, arguments); } +GENERIC_COMMAND(removefromlist, "Remove a string from a cvar", true) { GenericCommand_removefromlist(request, arguments); } +GENERIC_COMMAND(restartnotifs, "Re-initialize all notifications", false) { GenericCommand_restartnotifs(request); } +GENERIC_COMMAND(rpn, "RPN calculator", true) { GenericCommand_rpn(request, arguments, command); } +GENERIC_COMMAND(settemp, "Temporarily set a value to a cvar which is restored later", false) { GenericCommand_settemp(request, arguments); } +GENERIC_COMMAND(settemp_restore, "Restore all cvars set by settemp command", false) { GenericCommand_settemp_restore(request); } +GENERIC_COMMAND(runtest, "Run unit tests", false) { GenericCommand_runtest(request, arguments); } void GenericCommand_macro_help() { diff --git a/qcsrc/common/command/reg.qh b/qcsrc/common/command/reg.qh index 9868e2490a..a6f669fd91 100644 --- a/qcsrc/common/command/reg.qh +++ b/qcsrc/common/command/reg.qh @@ -6,14 +6,17 @@ REGISTRY(GENERIC_COMMANDS, BITS(7)) REGISTER_REGISTRY(GENERIC_COMMANDS) REGISTRY_SORT(GENERIC_COMMANDS) -#define GENERIC_COMMAND(id, description) \ +.bool m_menubased; // switch to tell whether this alias should be registered as a menu or client based command + +#define GENERIC_COMMAND(id, description, menubased) \ CLASS(genericcommand_##id, Command) \ ATTRIB(genericcommand_##id, m_name, string, #id); \ ATTRIB(genericcommand_##id, m_description, string, description); \ + ATTRIB(genericcommand_##id, m_menubased, bool, menubased); \ ENDCLASS(genericcommand_##id) \ REGISTER(GENERIC_COMMANDS, CMD_G, id, m_id, NEW(genericcommand_##id)); \ METHOD(genericcommand_##id, m_invokecmd, void(genericcommand_##id this, int request, entity caller, int arguments, string command)) STATIC_INIT(GENERIC_COMMANDS_aliases) { - FOREACH(GENERIC_COMMANDS, true, localcmd(sprintf("alias %1$s \"%2$s %1$s ${* ?}\"\n", it.m_name, "qc_cmd_svmenu"))); + FOREACH(GENERIC_COMMANDS, true, localcmd(sprintf("alias %1$s \"%2$s %1$s ${* ?}\"\n", it.m_name, ((it.m_menubased) ? "qc_cmd_svmenu" : "qc_cmd_svcl")))); } diff --git a/qcsrc/common/debug.qh b/qcsrc/common/debug.qh index 05064ca967..c95bb2d73c 100644 --- a/qcsrc/common/debug.qh +++ b/qcsrc/common/debug.qh @@ -197,7 +197,7 @@ bool autocvar_debugdraw; #endif -GENERIC_COMMAND(bufstr_get, "Examine a string buffer object") +GENERIC_COMMAND(bufstr_get, "Examine a string buffer object", false) { switch (request) { @@ -219,7 +219,7 @@ GENERIC_COMMAND(bufstr_get, "Examine a string buffer object") } -GENERIC_COMMAND(version, "Print the current version") +GENERIC_COMMAND(version, "Print the current version", false) { switch (request) { @@ -241,7 +241,7 @@ GENERIC_COMMAND(version, "Print the current version") #ifdef CSQC void(float bufhandle, string pattern, string antipattern) buf_cvarlist = #517; #endif -GENERIC_COMMAND(cvar_localchanges, "Print locally changed cvars") +GENERIC_COMMAND(cvar_localchanges, "Print locally changed cvars", false) { switch (request) { @@ -332,7 +332,7 @@ STATIC_INIT(TRACE_ENT) #endif -GENERIC_COMMAND(find, "Search through entities for matching classname") +GENERIC_COMMAND(find, "Search through entities for matching classname", false) { switch (request) { @@ -363,7 +363,7 @@ GENERIC_COMMAND(find, "Search through entities for matching classname") } -GENERIC_COMMAND(findat, "Search through entities for matching origin") +GENERIC_COMMAND(findat, "Search through entities for matching origin", false) { switch (request) { diff --git a/qcsrc/common/effects/effectinfo.qc b/qcsrc/common/effects/effectinfo.qc index 68c245db4a..79d31eb46b 100644 --- a/qcsrc/common/effects/effectinfo.qc +++ b/qcsrc/common/effects/effectinfo.qc @@ -285,7 +285,7 @@ void effectinfo_dump(int fh, bool alsoprint) #undef WRITE } -GENERIC_COMMAND(dumpeffectinfo, "Dump all effectinfo to effectinfo_dump.txt") +GENERIC_COMMAND(dumpeffectinfo, "Dump all effectinfo to effectinfo_dump.txt", false) { switch (request) { case CMD_REQUEST_COMMAND: { diff --git a/qcsrc/common/items/all.qh b/qcsrc/common/items/all.qh index 3ff4a54155..3ae473503d 100644 --- a/qcsrc/common/items/all.qh +++ b/qcsrc/common/items/all.qh @@ -19,7 +19,7 @@ STATIC_INIT(Items) { FOREACH(Items, true, it.m_id = i); } void Dump_Items(); -GENERIC_COMMAND(dumpitems, "Dump all items to the console") { +GENERIC_COMMAND(dumpitems, "Dump all items to the console", false) { switch (request) { case CMD_REQUEST_COMMAND: { Dump_Items(); diff --git a/qcsrc/common/notifications/all.qh b/qcsrc/common/notifications/all.qh index e9ddf429cd..7c341293b9 100644 --- a/qcsrc/common/notifications/all.qh +++ b/qcsrc/common/notifications/all.qh @@ -160,7 +160,7 @@ void Create_Notification_Entity_Choice(entity notif, void Dump_Notifications(int fh, bool alsoprint); -GENERIC_COMMAND(dumpnotifs, "Dump all notifications into notifications_dump.txt") +GENERIC_COMMAND(dumpnotifs, "Dump all notifications into notifications_dump.txt", false) { switch (request) { diff --git a/qcsrc/common/turrets/all.qh b/qcsrc/common/turrets/all.qh index 3d0528a251..9dedc89cb7 100644 --- a/qcsrc/common/turrets/all.qh +++ b/qcsrc/common/turrets/all.qh @@ -57,7 +57,7 @@ REGISTRY_CHECK(Turrets) #define TR_CONFIG_END() #endif -GENERIC_COMMAND(dumpturrets, "Dump all turrets into turrets_dump.txt") +GENERIC_COMMAND(dumpturrets, "Dump all turrets into turrets_dump.txt", false) { switch(request) { diff --git a/qcsrc/common/weapons/all.qh b/qcsrc/common/weapons/all.qh index 0be413f0fb..131e7b49ef 100644 --- a/qcsrc/common/weapons/all.qh +++ b/qcsrc/common/weapons/all.qh @@ -38,7 +38,7 @@ STATIC_INIT(WeaponPickup) { FOREACH(Weapons, true, it.m_pickup = NEW(WeaponPicku #define WepSet_FromWeapon(it) ((it).m_wepset) WepSet _WepSet_FromWeapon(int i); -GENERIC_COMMAND(dumpweapons, "Dump all weapons into weapons_dump.txt") // WEAPONTODO: make this work with other progs than just server +GENERIC_COMMAND(dumpweapons, "Dump all weapons into weapons_dump.txt", false) // WEAPONTODO: make this work with other progs than just server { switch(request) { diff --git a/qcsrc/lib/matrix/command.qc b/qcsrc/lib/matrix/command.qc index 1b58eb1b9f..0cfe564f07 100644 --- a/qcsrc/lib/matrix/command.qc +++ b/qcsrc/lib/matrix/command.qc @@ -2,7 +2,7 @@ #include -GENERIC_COMMAND(mx, "Send a matrix command") { +GENERIC_COMMAND(mx, "Send a matrix command", false) { switch (argv(1)) { case "user": strcpy(matrix_user, substring(command, argv_start_index(2), -1));