1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-07-07 08:43:13 +02:00

Pass ClientContext in CMD_FUNC() and friends. So extra arg. Breaking change.

It now passes 'clictx' which at the moment only has clictx->cmd which
points to the command handler. So only useful in very few cases where
you have like a generic command handler and thus have no idea for which
command you are being called. In the future, with this new ClientContext
struct, we can simply add new fields to the struct without breaking
things in the core and in (third party) modules.

If you use the magic functions in your modules CMD_FUNC(cmd_mycmd),
OVERRIDE_FUNC(myoverride), CALL_NEXT_COMMAND_OVERRIDE() and such then
you shouldn't have any compile errors as these will use the correct
prototypes and variable names automatically. In a few cases you can't
use these, in which case you will need to update your modules.
This commit is contained in:
Bram Matthys
2025-03-21 15:35:21 +01:00
parent 5d733d50e5
commit d15c82346e
17 changed files with 62 additions and 41 deletions
+4 -1
View File
@@ -194,6 +194,7 @@ void CommandDel(Command *command)
void do_cmd(Client *client, MessageTag *mtags, const char *cmd, int parc, const char *parv[])
{
RealCommand *cmptr;
ClientContext clictx;
cmptr = find_command_simple(cmd);
if (cmptr)
@@ -201,7 +202,9 @@ void do_cmd(Client *client, MessageTag *mtags, const char *cmd, int parc, const
int gen_mtags = (mtags == NULL) ? 1 : 0;
if (gen_mtags)
new_message(client, NULL, &mtags);
(*cmptr->func) (client, mtags, parc, parv);
memset(&clictx, 0, sizeof(clictx));
clictx.cmd = cmptr;
(*cmptr->func) (&clictx, client, mtags, parc, parv);
if (gen_mtags)
free_message_tags(mtags);
}