3 #include <common/command/_mod.qh>
4 REGISTRY(COMMON_COMMANDS, BITS(7))
5 #define COMMON_COMMANDS_from(i) _COMMON_COMMANDS_from(i, NULL)
6 REGISTER_REGISTRY(COMMON_COMMANDS)
7 REGISTRY_SORT(COMMON_COMMANDS)
9 #define COMMON_COMMAND(id, description) \
10 CLASS(commoncommand_##id, Command) \
11 ATTRIB(commoncommand_##id, m_name, string, #id); \
12 ATTRIB(commoncommand_##id, m_description, string, description); \
13 ENDCLASS(commoncommand_##id) \
14 REGISTER(COMMON_COMMANDS, CMD_SV, id, m_id, NEW(commoncommand_##id)); \
15 METHOD(commoncommand_##id, m_invokecmd, void(commoncommand_##id this, int request, entity caller, int arguments, string command))
17 STATIC_INIT(COMMON_COMMANDS_aliases) {
18 FOREACH(COMMON_COMMANDS, true, LAMBDA(localcmd(sprintf("alias %1$s \"%2$s %1$s ${* ?}\"\n", it.m_name, "qc_cmd_svcmd"))));
22 #include <common/monsters/sv_spawn.qh>
24 #include <common/command/_mod.qh>
26 // ============================================================
27 // Shared declarations for server commands, written by Samual
28 // Last updated: December 30th, 2011
29 // ============================================================
31 // client verification results
32 const float CLIENT_ACCEPTABLE = 1;
33 const float CLIENT_DOESNT_EXIST = -1;
34 const float CLIENT_NOT_REAL = -2;
35 const float CLIENT_NOT_BOT = -3;
37 // definitions for timeouts
38 const float TIMEOUT_INACTIVE = 0;
39 const float TIMEOUT_LEADTIME = 1;
40 const float TIMEOUT_ACTIVE = 2;
42 // timeout which pauses the game by setting the slowmo value extremely low.
43 const float TIMEOUT_SLOWMO_VALUE = 0.0001;
45 // global timeout information declarations
46 entity timeout_caller; // contains the entity of the player who started the last timeout
47 entity timeout_handler; // responsible for centerprinting the timeout countdowns and playing sounds
48 float sys_frametime; // gets initialised in worldspawn, saves the value from autocvar_sys_ticrate
49 float orig_slowmo; // contains the value of autocvar_slowmo so that, after timeout finished, it isn't set to slowmo 1 necessarily
50 float timeout_time; // contains the time in seconds that the active timeout has left
51 float timeout_leadtime; // contains the number of seconds left of the leadtime (before the timeout starts)
52 float timeout_status; // (values: 0, 1, 2) contains whether a timeout is not active (0), was called but still at leadtime (1) or is active (2)
53 .float allowed_timeouts; // contains the number of allowed timeouts for each player
54 .vector lastV_angle; // used when pausing the game in order to force the player to keep his old view angle fixed
56 // allow functions to be used in other code like g_world.qc and teamplay.qc
57 void timeout_handler_think(entity this);
59 // used by common/command/generic.qc:GenericCommand_dumpcommands to list all commands into a .txt file
60 void CommonCommand_macro_write_aliases(float fh);
62 // keep track of the next token to use for argc
65 // select the proper prefix for usage and other messages
66 string GetCommandPrefix(entity caller);
68 // if client return player nickname, or if server return admin nickname
69 string GetCallerName(entity caller);
71 // verify that the client provided is acceptable for kicking
72 float VerifyKickableEntity(entity client);
74 // verify that the client provided is acceptable for use
75 float VerifyClientEntity(entity client, float must_be_real, float must_be_bots);
77 // if the client is not acceptable, return a string to be used for error messages
78 string GetClientErrorString_color(float clienterror, string original_input, string col);
79 #define GetClientErrorString(clienterror, original_input) GetClientErrorString_color(clienterror, original_input, "^7")
81 // is this entity number even in the possible range of entities?
82 float VerifyClientNumber(float tmp_number);
84 entity GetIndexedEntity(float argc, float start_index);
86 // find a player which matches the input string, and return their entity
87 entity GetFilteredEntity(string input);
89 // same thing, but instead return their edict number
90 float GetFilteredNumber(string input);
92 // switch between sprint and print depending on whether the receiver is the server or a player
93 void print_to(entity to, string input);
95 // ==========================================
96 // Supporting functions for common commands
97 // ==========================================
99 // used by CommonCommand_timeout() and CommonCommand_timein() to handle game pausing and messaging and such.
100 void timeout_handler_reset(entity this);
102 void timeout_handler_think(entity this);
104 // ===================================================
105 // Common commands used in both sv_cmd.qc and cmd.qc
106 // ===================================================
108 void CommonCommand_cvar_changes(float request, entity caller);
110 void CommonCommand_cvar_purechanges(float request, entity caller);
112 void CommonCommand_editmob(float request, entity caller, float argc);
114 void CommonCommand_info(float request, entity caller, float argc);
116 void CommonCommand_ladder(float request, entity caller);
118 void CommonCommand_lsmaps(float request, entity caller);
120 void CommonCommand_printmaplist(float request, entity caller);
122 void CommonCommand_rankings(float request, entity caller);
124 void CommonCommand_records(float request, entity caller);
126 void CommonCommand_teamstatus(float request, entity caller);
128 void CommonCommand_time(float request, entity caller);
130 void CommonCommand_timein(float request, entity caller);
132 void CommonCommand_timeout(float request, entity caller);
134 void CommonCommand_who(float request, entity caller, float argc);
137 // ==================================
138 // Macro system for common commands
139 // ==================================
141 // Do not hard code aliases for these, instead create them in commands.cfg... also: keep in alphabetical order, please ;)
142 COMMON_COMMAND(cvar_changes, "Prints a list of all changed server cvars") { CommonCommand_cvar_changes(request, caller); }
143 COMMON_COMMAND(cvar_purechanges, "Prints a list of all changed gameplay cvars") { CommonCommand_cvar_purechanges(request, caller); }
144 COMMON_COMMAND(editmob, "Modifies a monster or all monsters") { CommonCommand_editmob(request, caller, arguments); }
145 COMMON_COMMAND(info, "Request for unique server information set up by admin") { CommonCommand_info(request, caller, arguments); }
146 COMMON_COMMAND(ladder, "Get information about top players if supported") { CommonCommand_ladder(request, caller); }
147 COMMON_COMMAND(lsmaps, "List maps which can be used with the current game mode") { CommonCommand_lsmaps(request, caller); }
148 COMMON_COMMAND(printmaplist, "Display full server maplist reply") { CommonCommand_printmaplist(request, caller); }
149 COMMON_COMMAND(rankings, "Print information about rankings") { CommonCommand_rankings(request, caller); }
150 COMMON_COMMAND(records, "List top 10 records for the current map") { CommonCommand_records(request, caller); }
151 COMMON_COMMAND(teamstatus, "Show information about player and team scores") { CommonCommand_teamstatus(request, caller); }
152 COMMON_COMMAND(time, "Print different formats/readouts of time") { CommonCommand_time(request, caller); }
153 COMMON_COMMAND(timein, "Resume the game from being paused with a timeout") { CommonCommand_timein(request, caller); }
154 COMMON_COMMAND(timeout, "Call a timeout which pauses the game for certain amount of time unless unpaused") { CommonCommand_timeout(request, caller); }
155 COMMON_COMMAND(vote, "Request an action to be voted upon by players") { VoteCommand(request, caller, arguments, command); }
156 COMMON_COMMAND(who, "Display detailed client information about all players") { CommonCommand_who(request, caller, arguments);}
158 void CommonCommand_macro_help(entity caller)
160 FOREACH(COMMON_COMMANDS, true, LAMBDA(print_to(caller, sprintf(" ^2%s^7: %s", it.m_name, it.m_description))));
163 float CommonCommand_macro_command(float argc, entity caller, string command)
165 string c = strtolower(argv(0));
166 FOREACH(COMMON_COMMANDS, it.m_name == c, LAMBDA(
167 it.m_invokecmd(it, CMD_REQUEST_COMMAND, caller, argc, command);
173 float CommonCommand_macro_usage(float argc, entity caller)
175 string c = strtolower(argv(1));
176 FOREACH(COMMON_COMMANDS, it.m_name == c, LAMBDA(
177 it.m_invokecmd(it, CMD_REQUEST_USAGE, caller, argc, "");
183 void CommonCommand_macro_write_aliases(float fh)
185 FOREACH(COMMON_COMMANDS, true, LAMBDA(CMD_Write_Alias("qc_cmd_svcmd", it.m_name, it.m_description)));