#include "../mapvoting.qh"
#include "../miscfunctions.qh"
+#include "../mutators/events.qh"
+
#include "../../common/mapinfo.qh"
#include "../../common/command/generic.qh"
#ifndef CAMERATEST
}
#endif
-
- return;
}
-bool ConsoleCommand_macro_normal(int argc)
+bool ConsoleCommand_macro_normal(string s, int argc)
{
#define CONSOLE_COMMAND(name,execution) \
- { if(name == strtolower(argv(0))) { { execution } return true; } }
+ { if (name == s) { { execution } return true; } }
CONSOLE_COMMANDS_NORMAL();
#undef CONSOLE_COMMAND
return false;
}
-bool ConsoleCommand_macro_movement(int argc)
+bool ConsoleCommand_macro_movement(string s, int argc)
{
if(camera_active)
{
#define CONSOLE_COMMAND(name,execution) \
- { if(name == strtolower(argv(0))) { { execution } return true; } }
+ { if (name == s) { { execution } return true; } }
CONSOLE_COMMANDS_MOVEMENT();
#undef CONSOLE_COMMAND
bool CSQC_ConsoleCommand(string command)
{
int argc = tokenize_console(command);
-
- if(ConsoleCommand_macro_normal(argc))
- {
- return true;
- }
- else if(ConsoleCommand_macro_movement(argc))
- {
- return true;
- }
-
- // Return value should be 1 if CSQC handled the command, otherwise return 0 to have the engine handle it.
-
- return false;
+ string s = strtolower(argv(0));
+ // Return value should be true if CSQC handled the command, otherwise return false to have the engine handle it.
+ return (ConsoleCommand_macro_normal(s, argc)
+ || ConsoleCommand_macro_movement(s, argc)
+ || MUTATOR_CALLHOOK(CSQC_ConsoleCommand, s, argc, command)
+ );
}
--- /dev/null
+#ifndef CLIENT_MUTATORS_EVENTS_H
+#define CLIENT_MUTATORS_EVENTS_H
+
+#include "../../common/mutators/base.qh"
+
+// globals
+
+string cmd_name;
+int cmd_argc;
+string cmd_string;
+
+/**
+ * Called when a client command is parsed
+ * NOTE: hooks MUST start with if (MUTATOR_RETURNVALUE) return false;
+ * NOTE: return true if you handled the command, return false to continue handling
+ * NOTE: THESE HOOKS MUST NEVER EVER CALL tokenize()
+ * // example:
+ * MUTATOR_HOOKFUNCTION(foo, CSQC_ConsoleCommand) {
+ * if (MUTATOR_RETURNVALUE) return false; // command was already handled
+ * if (cmd_name == "echocvar" && cmd_argc >= 2) {
+ * print(cvar_string(argv(1)), "\n");
+ * return true;
+ * }
+ * if (cmd_name == "echostring" && cmd_argc >= 2) {
+ * print(substring(cmd_string, argv_start_index(1), argv_end_index(-1) - argv_start_index(1)), "\n");
+ * return true;
+ * }
+ * return false;
+ * }
+ */
+#define EV_CSQC_ConsoleCommand(i, o) \
+ /** command name */ i(string, cmd_name) \
+ /** also, argv() can be used */ i(int, cmd_argc) \
+ /** whole command, use only if you really have to */ i(string, cmd_string) \
+ /**/
+MUTATOR_HOOKABLE(CSQC_ConsoleCommand, EV_CSQC_ConsoleCommand);
+
+#endif
/**
* called when a client command is parsed
- * NOTE: hooks MUST start with if(MUTATOR_RETURNVALUE) return 0;
- * NOTE: return 1 if you handled the command, return 0 to continue handling
+ * NOTE: hooks MUST start with if (MUTATOR_RETURNVALUE) return false;
+ * NOTE: return true if you handled the command, return false to continue handling
* NOTE: THESE HOOKS MUST NEVER EVER CALL tokenize()
* // example:
* MUTATOR_HOOKFUNCTION(foo_SV_ParseClientCommand)