diff --git a/include/modules.h b/include/modules.h index 6d36afac9..7e97b18d0 100644 --- a/include/modules.h +++ b/include/modules.h @@ -702,6 +702,7 @@ extern Command *CommandAdd(Module *module, char *cmd, int (*func)(aClient *cptr, extern void CommandDel(Command *command); extern int CommandExists(char *name); extern Cmdoverride *CmdoverrideAdd(Module *module, char *cmd, int (*func)(Cmdoverride *ovr, aClient *cptr, aClient *sptr, int parc, char *parv[])); +extern Cmdoverride *CmdoverrideAddEx(Module *module, char *name, int priority, int (*func)(Cmdoverride *ovr, aClient *cptr, aClient *sptr, int parc, char *parv[])); extern void CmdoverrideDel(Cmdoverride *ovr); extern int CallCmdoverride(Cmdoverride *ovr, aClient *cptr, aClient *sptr, int parc, char *parv[]); diff --git a/include/struct.h b/include/struct.h index 85f5cb11f..a2809b8b8 100644 --- a/include/struct.h +++ b/include/struct.h @@ -1704,6 +1704,7 @@ struct Command { struct _cmdoverride { Cmdoverride *prev, *next; + int priority; Module *owner; aCommand *command; int (*func)(); diff --git a/src/modules.c b/src/modules.c index a172a25d5..e05bb38b9 100644 --- a/src/modules.c +++ b/src/modules.c @@ -1446,7 +1446,7 @@ Efunction *p, *q; return NULL; } -Cmdoverride *CmdoverrideAdd(Module *module, char *name, iFP function) +Cmdoverride *CmdoverrideAddEx(Module *module, char *name, int priority, iFP function) { aCommand *p; Cmdoverride *ovr; @@ -1469,6 +1469,7 @@ Cmdoverride *CmdoverrideAdd(Module *module, char *name, iFP function) ovr = MyMallocEx(sizeof(Cmdoverride)); ovr->func = function; ovr->owner = module; /* TODO: module objects */ + ovr->priority = priority; if (module) { ModuleObject *cmdoverobj = MyMallocEx(sizeof(ModuleObject)); @@ -1480,7 +1481,7 @@ Cmdoverride *CmdoverrideAdd(Module *module, char *name, iFP function) ovr->command = p; if (!p->overriders) p->overridetail = ovr; - AddListItem(ovr, p->overriders); + AddListItemPrio(ovr, p->overriders, ovr->priority); if (p->friend) { if (!p->friend->overriders) @@ -1490,6 +1491,11 @@ Cmdoverride *CmdoverrideAdd(Module *module, char *name, iFP function) return ovr; } +Cmdoverride *CmdoverrideAdd(Module *module, char *name, iFP function) +{ + return CmdoverrideAddEx(module, name, 0, function); +} + void CmdoverrideDel(Cmdoverride *cmd) { if (!cmd->next)