alias autoswitch "qc_cmd_cmd autoswitch ${* ?}" // Whether or not to switch automatically when getting a better weapon
alias clientversion "qc_cmd_cmd clientversion ${* ?}" // Release version of the game
alias join "qc_cmd_cmd join ${* ?}" // Become a player in the game
+//alias kill "qc_cmd_cmd kill ${* ?}" // Become a member of the dead
alias minigame "qc_cmd_cmd minigame ${* ?}" // Start a minigame
//alias mv_getpicture "qc_cmd_cmd mv_getpicture ${* ?}" // Retrieve mapshot picture from the server
alias physics "qc_cmd_cmd physics ${* ?}" // Change physics set
-alias ready "qc_cmd_cmd ready ${* ?}" // Qualify as ready to end warmup stage (or restart server if allowed)
-//alias say "qc_cmd_cmd say ${* ?}" // Print a message to chat to all players
-//alias say_team "qc_cmd_cmd say_team ${* ?}" // Print a message to chat to all team mates
+alias ready "qc_cmd_cmd ready ${* ?}" // Qualify as ready to end warmup stage
+//alias say "qc_cmd_cmd say ${* ?}" // Send a public chat message to all players
+//alias say_team "qc_cmd_cmd say_team ${* ?}" // Send a chat message to all team mates
alias selectteam "qc_cmd_cmd selectteam ${* ?}" // Attempt to choose a team to join into
alias selfstuff "qc_cmd_cmd selfstuff ${* ?}" // Stuffcmd a command to your own client
alias sentcvar "qc_cmd_cmd sentcvar ${* ?}" // New system for sending a client cvar to the server
-alias spectate "qc_cmd_cmd spectate ${* ?}" // Become an observer
-alias suggestmap "qc_cmd_cmd suggestmap ${* ?}" // Suggest a map to the mapvote at match end
-//alias tell "qc_cmd_cmd tell ${* ?}" // Send a message directly to a player
+alias spectate "qc_cmd_cmd spectate ${* ?}" // Become a spectator
+alias suggestmap "qc_cmd_cmd suggestmap ${* ?}" // Suggest a map to appear at the map voting screen
+//alias tell "qc_cmd_cmd tell ${* ?}" // Send a private chat message to a player which may be visible to server admins
alias voice "qc_cmd_cmd voice ${* ?}" // Send voice message via sound
alias wpeditor "qc_cmd_cmd wpeditor ${* ?}" // Waypoint editor commands
// Client
-alias ignore "qc_cmd_cmd ignore ${* ?}" // Keep client out of your personal chat log for a match
-alias unignore "qc_cmd_cmd unignore ${* ?}" // Remove an existing ignored client
-alias clear_ignores "qc_cmd_cmd clear_ignores" // Remove all existing ignored clients
+alias ignore "qc_cmd_cmd ignore ${* ?}" // Ignore a player in the game keeping them out of your personal chat log
+alias unignore "qc_cmd_cmd unignore ${* ?}" // Remove an existing ignore of a player
+alias clear_ignores "qc_cmd_cmd clear_ignores" // Remove all existing ignores of players
// Server
alias playban "qc_cmd_sv playban ${* ?}" // Ban disallowing a client from playing (forced to spectate)
#include <server/cheats.qh>
#include <server/client.qh>
#include <server/clientkill.qh>
+#include <server/command/_mod.qh>
#include <server/command/common.qh>
#include <server/command/getreplies.qh>
#include <server/command/vote.qh>
// =====================================
// Do not hard code aliases for these, instead create them in commands.cfg... also: keep in alphabetical order, please ;)
-#define CLIENT_COMMANDS(ent, request, arguments, command) \
- CLIENT_COMMAND("autoswitch", ClientCommand_autoswitch(ent, request, arguments), "Whether or not to switch automatically when getting a better weapon") \
- CLIENT_COMMAND("clear_ignores", ClientCommand_clear_ignores(ent, request), "Remove all existing ignored clients") \
- CLIENT_COMMAND("clientversion", ClientCommand_clientversion(ent, request, arguments), "Release version of the game") \
- CLIENT_COMMAND("ignore", ClientCommand_ignore(ent, request, arguments, command), "Ignore a client in the game keeping out of personal chat log for a match") \
- CLIENT_COMMAND("join", ClientCommand_join(ent, request), "Become a player in the game") \
- CLIENT_COMMAND("kill", ClientCommand_kill(ent, request), "Become a member of the dead") \
- CLIENT_COMMAND("minigame", ClientCommand_minigame(ent, request, arguments, command), "Start a minigame") \
- CLIENT_COMMAND("mv_getpicture", ClientCommand_mv_getpicture(ent, request, arguments), "Retrieve mapshot picture from the server") \
- CLIENT_COMMAND("physics", ClientCommand_physics(ent, request, arguments), "Change physics set") \
- CLIENT_COMMAND("ready", ClientCommand_ready(ent, request), "Qualify as ready to end warmup stage (or restart server if allowed)") \
- CLIENT_COMMAND("say", ClientCommand_say(ent, request, arguments, command), "Print a message to chat to all players") \
- CLIENT_COMMAND("say_team", ClientCommand_say_team(ent, request, arguments, command), "Print a message to chat to all team mates") \
- CLIENT_COMMAND("selectteam", ClientCommand_selectteam(ent, request, arguments), "Attempt to choose a team to join into") \
- CLIENT_COMMAND("selfstuff", ClientCommand_selfstuff(ent, request, command), "Stuffcmd a command to your own client") \
- CLIENT_COMMAND("sentcvar", ClientCommand_sentcvar(ent, request, arguments), "New system for sending a client cvar to the server") \
- CLIENT_COMMAND("spectate", ClientCommand_spectate(ent, request), "Become an observer") \
- CLIENT_COMMAND("suggestmap", ClientCommand_suggestmap(ent, request, arguments), "Suggest a map to the mapvote at match end") \
- CLIENT_COMMAND("tell", ClientCommand_tell(ent, request, arguments, command), "Send a message directly to a player") \
- CLIENT_COMMAND("voice", ClientCommand_voice(ent, request, arguments, command), "Send voice message via sound") \
- CLIENT_COMMAND("unignore", ClientCommand_unignore(ent, request, arguments, command), "Remove an existing ignored player") \
- CLIENT_COMMAND("wpeditor", ClientCommand_wpeditor(ent, request, arguments), "Waypoint editor commands") \
- /* nothing */
+CLIENT_COMMAND(autoswitch, "Whether or not to switch automatically when getting a better weapon") { ClientCommand_autoswitch(caller, request, arguments); }
+CLIENT_COMMAND(clear_ignores, "Remove all existing ignores of players") { ClientCommand_clear_ignores(caller, request); }
+CLIENT_COMMAND(clientversion, "Release version of the game") { ClientCommand_clientversion(caller, request, arguments); }
+CLIENT_COMMAND(ignore, "Ignore a player in the game keeping them out of your personal chat log") { ClientCommand_ignore(caller, request, arguments, command); }
+CLIENT_COMMAND(join, "Become a player in the game") { ClientCommand_join(caller, request); }
+CLIENT_COMMAND(kill, "Become a member of the dead") { ClientCommand_kill(caller, request); }
+CLIENT_COMMAND(minigame, "Start a minigame") { ClientCommand_minigame(caller, request, arguments, command); }
+CLIENT_COMMAND(mv_getpicture, "Retrieve mapshot picture from the server") { ClientCommand_mv_getpicture(caller, request, arguments); }
+CLIENT_COMMAND(physics, "Change physics set") { ClientCommand_physics(caller, request, arguments); }
+CLIENT_COMMAND(ready, "Qualify as ready to end warmup stage") { ClientCommand_ready(caller, request); }
+CLIENT_COMMAND(say, "Send a public chat message to all players") { ClientCommand_say(caller, request, arguments, command); }
+CLIENT_COMMAND(say_team, "Send a chat message to all team mates") { ClientCommand_say_team(caller, request, arguments, command); }
+CLIENT_COMMAND(selectteam, "Attempt to choose a team to join into") { ClientCommand_selectteam(caller, request, arguments); }
+CLIENT_COMMAND(selfstuff, "Stuffcmd a command to your own client") { ClientCommand_selfstuff(caller, request, command); }
+CLIENT_COMMAND(sentcvar, "New system for sending a client cvar to the server") { ClientCommand_sentcvar(caller, request, arguments); }
+CLIENT_COMMAND(spectate, "Become a spectator") { ClientCommand_spectate(caller, request); }
+CLIENT_COMMAND(suggestmap, "Suggest a map to appear at the map voting screen") { ClientCommand_suggestmap(caller, request, arguments); }
+CLIENT_COMMAND(tell, "Send a private chat message to a player which may be visible to server admins") { ClientCommand_tell(caller, request, arguments, command); }
+CLIENT_COMMAND(voice, "Send voice message via sound") { ClientCommand_voice(caller, request, arguments, command); }
+CLIENT_COMMAND(unignore, "Remove an existing ignore of a player") { ClientCommand_unignore(caller, request, arguments, command); }
+CLIENT_COMMAND(wpeditor, "Waypoint editor commands") { ClientCommand_wpeditor(caller, request, arguments); }
void ClientCommand_macro_help(entity caller)
{
- #define CLIENT_COMMAND(name, function, description) \
- { sprint(caller, " ^2", name, "^7: ", description, "\n"); }
-
- CLIENT_COMMANDS(NULL, 0, 0, "");
-#undef CLIENT_COMMAND
+ FOREACH(CLIENT_COMMANDS, true, { print_to(caller, sprintf(" ^2%s^7: %s", it.m_name, it.m_description)); });
}
float ClientCommand_macro_command(int argc, entity caller, string command)
{
- #define CLIENT_COMMAND(name, function, description) \
- { if (name == strtolower(argv(0))) { function; return true; } }
-
- CLIENT_COMMANDS(caller, CMD_REQUEST_COMMAND, argc, command);
-#undef CLIENT_COMMAND
+ string c = strtolower(argv(0));
+ FOREACH(CLIENT_COMMANDS, it.m_name == c, {
+ it.m_invokecmd(it, CMD_REQUEST_COMMAND, caller, argc, command);
+ return true;
+ });
return false;
}
float ClientCommand_macro_usage(int argc, entity caller)
{
- #define CLIENT_COMMAND(name, function, description) \
- { if (name == strtolower(argv(1))) { function; return true; } }
-
- CLIENT_COMMANDS(caller, CMD_REQUEST_USAGE, argc, "");
-#undef CLIENT_COMMAND
+ string c = strtolower(argv(1));
+ FOREACH(CLIENT_COMMANDS, it.m_name == c, {
+ it.m_invokecmd(it, CMD_REQUEST_USAGE, caller, argc, "");
+ return true;
+ });
return false;
}
void ClientCommand_macro_write_aliases(float fh)
{
- #define CLIENT_COMMAND(name, function, description) \
- { CMD_Write_Alias("qc_cmd_cmd", name, description); }
-
- CLIENT_COMMANDS(NULL, 0, 0, "");
-#undef CLIENT_COMMAND
+ FOREACH(CLIENT_COMMANDS, true, { CMD_Write_Alias("qc_cmd_cmd", it.m_name, it.m_description); });
}
// ======================================
#define SERVER_COMMAND(id, description) \
CLASS(servercommand_##id, Command) \
ATTRIB(servercommand_##id, m_name, string, #id); \
- ATTRIB(servercommand_##id, m_description, string, description); \
+ ATTRIB(servercommand_##id, m_description, string, description); \
ENDCLASS(servercommand_##id) \
- REGISTER(SERVER_COMMANDS, CMD_SV, id, m_id, NEW(servercommand_##id)); \
+ REGISTER(SERVER_COMMANDS, CMD_SV, id, m_id, NEW(servercommand_##id)); \
METHOD(servercommand_##id, m_invokecmd, void(servercommand_##id this, int request, entity caller, int arguments, string command))
STATIC_INIT(SERVER_COMMANDS_aliases) {
FOREACH(SERVER_COMMANDS, true, { localcmd(sprintf("alias %1$s \"%2$s %1$s ${* ?}\"\n", it.m_name, "qc_cmd_sv")); });
}
+
+REGISTRY(CLIENT_COMMANDS, 64)
+REGISTER_REGISTRY(CLIENT_COMMANDS)
+REGISTRY_SORT(CLIENT_COMMANDS)
+
+REGISTRY_DEFINE_GET(CLIENT_COMMANDS, NULL)
+
+#define CLIENT_COMMAND(id, description) \
+ CLASS(clientcommand_##id, Command) \
+ ATTRIB(clientcommand_##id, m_name, string, #id); \
+ ATTRIB(clientcommand_##id, m_description, string, description); \
+ ENDCLASS(clientcommand_##id) \
+ REGISTER(CLIENT_COMMANDS, CMD_SVCL, id, m_id, NEW(clientcommand_##id)); \
+ METHOD(clientcommand_##id, m_invokecmd, void(clientcommand_##id this, int request, entity caller, int arguments, string command))