From a2ee5d67f33ef65aa69f23014390695d29a02185 Mon Sep 17 00:00:00 2001 From: Bram Matthys Date: Fri, 7 Jun 2019 15:05:10 +0200 Subject: [PATCH] Update a few hooks to include mtags, more will follow later. This fixes inconsistent mtags accross server links with delayjoin. --- include/modules.h | 23 ++++++++-------- src/modules/chanmodes/censor.c | 4 +-- src/modules/chanmodes/delayjoin.c | 27 ++++++++++--------- src/modules/chanmodes/floodprot.c | 8 +++--- src/modules/chanmodes/nocolor.c | 4 +-- src/modules/chanmodes/noctcp.c | 4 +-- src/modules/chanmodes/stripcolor.c | 4 +-- src/modules/extbans/textban.c | 4 +-- src/modules/m_message.c | 13 ++++++--- src/modules/m_mode.c | 43 ++++++++++++++++++------------ src/modules/nocodes.c | 4 +-- 11 files changed, 78 insertions(+), 60 deletions(-) diff --git a/include/modules.h b/include/modules.h index 6d20f4671..c96dcabdc 100644 --- a/include/modules.h +++ b/include/modules.h @@ -728,13 +728,14 @@ extern void HooktypeDel(Hooktype *hooktype, Module *module); } \ } -#define RunHookReturnVoid(hooktype,x,ret) do { Hook *h; for (h = Hooks[hooktype]; h; h = h->next) if((*(h->func.intfunc))(x) ret) return; } while(0) -#define RunHook2(hooktype,x,y) do { Hook *h; for (h = Hooks[hooktype]; h; h = h->next) (*(h->func.intfunc))(x,y); } while(0) -#define RunHook3(hooktype,a,b,c) do { Hook *h; for (h = Hooks[hooktype]; h; h = h->next) (*(h->func.intfunc))(a,b,c); } while(0) -#define RunHook4(hooktype,a,b,c,d) do { Hook *h; for (h = Hooks[hooktype]; h; h = h->next) (*(h->func.intfunc))(a,b,c,d); } while(0) -#define RunHook5(hooktype,a,b,c,d,e) do { Hook *h; for (h = Hooks[hooktype]; h; h = h->next) (*(h->func.intfunc))(a,b,c,d,e); } while(0) -#define RunHook6(hooktype,a,b,c,d,e,f) do { Hook *h; for (h = Hooks[hooktype]; h; h = h->next) (*(h->func.intfunc))(a,b,c,d,e,f); } while(0) -#define RunHook7(hooktype,a,b,c,d,e,f,g) do { Hook *h; for (h = Hooks[hooktype]; h; h = h->next) (*(h->func.intfunc))(a,b,c,d,e,f,g); } while(0) +#define RunHookReturnVoid(hooktype,x,ret) do { Hook *hook; for (hook = Hooks[hooktype]; hook; hook = hook->next) if((*(hook->func.intfunc))(x) ret) return; } while(0) +#define RunHook2(hooktype,x,y) do { Hook *hook; for (hook = Hooks[hooktype]; hook; hook = hook->next) (*(hook->func.intfunc))(x,y); } while(0) +#define RunHook3(hooktype,a,b,c) do { Hook *hook; for (hook = Hooks[hooktype]; hook; hook = hook->next) (*(hook->func.intfunc))(a,b,c); } while(0) +#define RunHook4(hooktype,a,b,c,d) do { Hook *hook; for (hook = Hooks[hooktype]; hook; hook = hook->next) (*(hook->func.intfunc))(a,b,c,d); } while(0) +#define RunHook5(hooktype,a,b,c,d,e) do { Hook *hook; for (hook = Hooks[hooktype]; hook; hook = hook->next) (*(hook->func.intfunc))(a,b,c,d,e); } while(0) +#define RunHook6(hooktype,a,b,c,d,e,f) do { Hook *hook; for (hook = Hooks[hooktype]; hook; hook = hook->next) (*(hook->func.intfunc))(a,b,c,d,e,f); } while(0) +#define RunHook7(hooktype,a,b,c,d,e,f,g) do { Hook *hook; for (hook = Hooks[hooktype]; hook; hook = hook->next) (*(hook->func.intfunc))(a,b,c,d,e,f,g); } while(0) +#define RunHook8(hooktype,a,b,c,d,e,f,g,h) do { Hook *hook; for (hook = Hooks[hooktype]; hook; hook = hook->next) (*(hook->func.intfunc))(a,b,c,d,e,f,g,h); } while(0) #define CallbackAdd(cbtype, func) CallbackAddMain(NULL, cbtype, func, NULL, NULL) #define CallbackAddEx(module, cbtype, func) CallbackAddMain(module, cbtype, func, NULL, NULL) @@ -898,7 +899,7 @@ int hooktype_local_join(aClient *cptr, aClient *sptr, aChannel *chptr, char *par int hooktype_configtest(ConfigFile *cfptr, ConfigEntry *ce, int section, int *errors); int hooktype_configrun(ConfigFile *cfptr, ConfigEntry *ce, int section); int hooktype_usermsg(aClient *sptr, aClient *to, char *text, int notice); -int hooktype_chanmsg(aClient *sptr, aChannel *chptr, char *text, int notice); +int hooktype_chanmsg(aClient *sptr, aChannel *chptr, MessageTag *mtags, char *text, int notice); int hooktype_local_part(aClient *cptr, aClient *sptr, aChannel *chptr, char *comment); int hooktype_local_kick(aClient *cptr, aClient *sptr, aClient *victim, aChannel *chptr, char *comment); int hooktype_local_chanmode(aClient *cptr, aClient *sptr, aChannel *chptr, char *modebuf, char *parabuf, time_t sendts, int samode); @@ -940,7 +941,7 @@ int hooktype_can_send(aClient *sptr, aChannel *chptr, char *text, Membership *me int hooktype_can_kick(aClient *sptr, aClient *victim, aChannel *chptr, char *comment, long sptr_flags, long victim_flags, char **error); int hooktype_free_client(aClient *acptr); int hooktype_free_user(anUser *user, aClient *acptr); -char *hooktype_pre_chanmsg(aClient *sptr, aChannel *chptr, char *text, int notice); +char *hooktype_pre_chanmsg(aClient *sptr, aChannel *chptr, MessageTag *mtags, char *text, int notice); char *hooktype_pre_usermsg(aClient *sptr, aClient *to, char *text, int notice); int hooktype_knock(aClient *sptr, aChannel *chptr); int hooktype_modechar_del(aChannel *chptr, int modechar); @@ -948,8 +949,8 @@ int hooktype_modechar_add(aChannel *chptr, int modechar); int hooktype_exit_one_client(aClient *sptr); int hooktype_can_join_limitexceeded(aClient *sptr, aChannel *chptr, char *key, char *parv[]); int hooktype_visible_in_channel(aClient *sptr, aChannel *chptr); -int hooktype_pre_local_chanmode(aClient *cptr, aClient *sptr, aChannel *chptr, char *modebuf, char *parabuf, time_t sendts, int samode); -int hooktype_pre_remote_chanmode(aClient *cptr, aClient *sptr, aChannel *chptr, char *modebuf, char *parabuf, time_t sendts, int samode); +int hooktype_pre_local_chanmode(aClient *cptr, aClient *sptr, aChannel *chptr, MessageTag *mtags, char *modebuf, char *parabuf, time_t sendts, int samode); +int hooktype_pre_remote_chanmode(aClient *cptr, aClient *sptr, aChannel *chptr, MessageTag *mtags, char *modebuf, char *parabuf, time_t sendts, int samode); int hooktype_join_data(aClient *who, aChannel *chptr); int hooktype_pre_knock(aClient *sptr, aChannel *chptr); int hooktype_pre_invite(aClient *sptr, aClient *acptr, aChannel *chptr, int *override); diff --git a/src/modules/chanmodes/censor.c b/src/modules/chanmodes/censor.c index 34ea944d8..03a14c4de 100644 --- a/src/modules/chanmodes/censor.c +++ b/src/modules/chanmodes/censor.c @@ -20,7 +20,7 @@ Cmode_t EXTMODE_CENSOR = 0L; #define IsCensored(x) ((x)->mode.extmode & EXTMODE_CENSOR) -char *censor_pre_chanmsg(aClient *sptr, aChannel *chptr, char *text, int notice); +char *censor_pre_chanmsg(aClient *sptr, aChannel *chptr, MessageTag *mtags, char *text, int notice); char *censor_pre_local_part(aClient *sptr, aChannel *chptr, char *text); char *censor_pre_local_quit(aClient *sptr, char *text); @@ -253,7 +253,7 @@ char *stripbadwords_channel(char *str, int *blocked) return stripbadwords(str, conf_badword_channel, blocked); } -char *censor_pre_chanmsg(aClient *sptr, aChannel *chptr, char *text, int notice) +char *censor_pre_chanmsg(aClient *sptr, aChannel *chptr, MessageTag *mtags, char *text, int notice) { int blocked; Hook *h; diff --git a/src/modules/chanmodes/delayjoin.c b/src/modules/chanmodes/delayjoin.c index 19666bedd..63c61df1c 100644 --- a/src/modules/chanmodes/delayjoin.c +++ b/src/modules/chanmodes/delayjoin.c @@ -29,8 +29,8 @@ int moded_join(aClient *cptr, aChannel *chptr); int moded_part(aClient *cptr, aClient *sptr, aChannel *chptr, char *comment); int deny_all(aClient *cptr, aChannel *chptr, char mode, char *para, int checkt, int what); int moded_chanmode(aClient *cptr, aClient *sptr, aChannel *chptr, - char *modebuf, char *parabuf, time_t sendts, int samode); -char *moded_prechanmsg(aClient *sptr, aChannel *chptr, char *text, int notice); + MessageTag *mtags, char *modebuf, char *parabuf, time_t sendts, int samode); +char *moded_prechanmsg(aClient *sptr, aChannel *chptr, MessageTag *mtags, char *text, int notice); char *moded_serialize(ModData *m); void moded_unserialize(char *str, ModData *m); @@ -201,9 +201,10 @@ void clear_user_invisible(aChannel *chptr, aClient *sptr) } } -void clear_user_invisible_announce(aChannel *chptr, aClient *sptr) +void clear_user_invisible_announce(aChannel *chptr, aClient *sptr, MessageTag *recv_mtags) { Member *i; + MessageTag *mtags = NULL; char joinbuf[512]; char exjoinbuf[512]; long CAP_EXTENDED_JOIN = ClientCapabilityBit("extended-join"); @@ -218,17 +219,19 @@ void clear_user_invisible_announce(aChannel *chptr, aClient *sptr) !isdigit(*sptr->user->svid) ? sptr->user->svid : "*", sptr->info); + new_message_special(sptr, recv_mtags, &mtags, ":%s JOIN %s", sptr->name, chptr->chname); for (i = chptr->members; i; i = i->next) { aClient *acptr = i->cptr; if (!is_skochanop(acptr,chptr) && acptr != sptr && MyConnect(acptr)) { if (HasCapabilityFast(acptr, CAP_EXTENDED_JOIN)) - sendbufto_one(acptr, exjoinbuf, 0); + sendto_one(acptr, mtags, "%s", exjoinbuf); else - sendbufto_one(acptr, joinbuf, 0); + sendto_one(acptr, mtags, "%s", joinbuf); } } + free_mtags(mtags); } void set_user_invisible(aChannel *chptr, aClient *sptr) @@ -277,7 +280,7 @@ int moded_part(aClient *cptr, aClient *sptr, aChannel *chptr, char *comment) } int moded_chanmode(aClient *cptr, aClient *sptr, aChannel *chptr, - char *modebuf, char *parabuf, time_t sendts, int samode) + MessageTag *recv_mtags, char *modebuf, char *parabuf, time_t sendts, int samode) { long CAP_EXTENDED_JOIN = ClientCapabilityBit("extended-join"); @@ -301,7 +304,7 @@ int moded_chanmode(aClient *cptr, aClient *sptr, aChannel *chptr, continue; if (moded_user_invisible(user,chptr)) - clear_user_invisible_announce(chptr,user); + clear_user_invisible_announce(chptr, user, recv_mtags); if (pm.modechar == 'v' || !MyConnect(user)) continue; @@ -314,7 +317,7 @@ int moded_chanmode(aClient *cptr, aClient *sptr, aChannel *chptr, if (moded_user_invisible(i->cptr,chptr)) { MessageTag *mtags = NULL; - new_message(i->cptr, NULL, &mtags); + new_message_special(i->cptr, recv_mtags, &mtags, ":%s JOIN %s", i->cptr->name, chptr->chname); if (HasCapabilityFast(user, CAP_EXTENDED_JOIN)) { sendto_one(user, mtags, ":%s!%s@%s JOIN %s %s :%s", @@ -338,7 +341,7 @@ int moded_chanmode(aClient *cptr, aClient *sptr, aChannel *chptr, continue; if (moded_user_invisible(user,chptr)) - clear_user_invisible_announce(chptr,user); + clear_user_invisible_announce(chptr, user, recv_mtags); if (pm.modechar == 'v' || !MyConnect(user)) continue; @@ -351,7 +354,7 @@ int moded_chanmode(aClient *cptr, aClient *sptr, aChannel *chptr, if (moded_user_invisible(i->cptr,chptr)) { MessageTag *mtags = NULL; - new_message(i->cptr, NULL, &mtags); + new_message_special(i->cptr, recv_mtags, &mtags, ":%s PART %s", i->cptr->name, chptr->chname); sendto_one(user, mtags, ":%s!%s@%s PART :%s", i->cptr->name, i->cptr->user->username, GetHost(i->cptr), chptr->chname); free_mtags(mtags); } @@ -364,11 +367,11 @@ int moded_chanmode(aClient *cptr, aClient *sptr, aChannel *chptr, return 0; } -char *moded_prechanmsg(aClient *sptr, aChannel *chptr, char *text, int notice) +char *moded_prechanmsg(aClient *sptr, aChannel *chptr, MessageTag *mtags, char *text, int notice) { if ((channel_is_delayed(chptr) || channel_is_post_delayed(chptr)) && (moded_user_invisible(sptr,chptr))) - clear_user_invisible_announce(chptr,sptr); + clear_user_invisible_announce(chptr, sptr, mtags); return text; } diff --git a/src/modules/chanmodes/floodprot.c b/src/modules/chanmodes/floodprot.c index 6314a9ddd..079033552 100644 --- a/src/modules/chanmodes/floodprot.c +++ b/src/modules/chanmodes/floodprot.c @@ -100,8 +100,8 @@ int cmodef_sjoin_check(aChannel *chptr, void *ourx, void *theirx); int floodprot_join(aClient *cptr, aClient *sptr, aChannel *chptr, char *parv[]); EVENT(modef_event); int cmodef_channel_destroy(aChannel *chptr, int *should_destroy); -char *floodprot_pre_chanmsg(aClient *sptr, aChannel *chptr, char *text, int notice); -int floodprot_post_chanmsg(aClient *sptr, aChannel *chptr, char *text, int notice); +char *floodprot_pre_chanmsg(aClient *sptr, aChannel *chptr, MessageTag *mtags, char *text, int notice); +int floodprot_post_chanmsg(aClient *sptr, aChannel *chptr, MessageTag *mtags, char *text, int notice); int floodprot_knock(aClient *sptr, aChannel *chptr); int floodprot_local_nickchange(aClient *sptr, char *oldnick); int floodprot_remote_nickchange(aClient *cptr, aClient *sptr, char *oldnick); @@ -1020,14 +1020,14 @@ char *channel_modef_string(ChanFloodProt *x, char *retbuf) return retbuf; } -char *floodprot_pre_chanmsg(aClient *sptr, aChannel *chptr, char *text, int notice) +char *floodprot_pre_chanmsg(aClient *sptr, aChannel *chptr, MessageTag *mtags, char *text, int notice) { if (MyClient(sptr) && (check_for_chan_flood(sptr, chptr) == 1)) return NULL; /* don't send it */ return text; } -int floodprot_post_chanmsg(aClient *sptr, aChannel *chptr, char *text, int notice) +int floodprot_post_chanmsg(aClient *sptr, aChannel *chptr, MessageTag *mtags, char *text, int notice) { if (!IsFloodLimit(chptr) || is_skochanop(sptr, chptr) || IsULine(sptr)) return 0; diff --git a/src/modules/chanmodes/nocolor.c b/src/modules/chanmodes/nocolor.c index 26ed7c4b1..83472c236 100644 --- a/src/modules/chanmodes/nocolor.c +++ b/src/modules/chanmodes/nocolor.c @@ -34,7 +34,7 @@ Cmode_t EXTCMODE_NOCOLOR; #define IsNoColor(chptr) (chptr->mode.extmode & EXTCMODE_NOCOLOR) -char *nocolor_prechanmsg(aClient *sptr, aChannel *chptr, char *text, int notice); +char *nocolor_prechanmsg(aClient *sptr, aChannel *chptr, MessageTag *mtags, char *text, int notice); char *nocolor_prelocalpart(aClient *sptr, aChannel *chptr, char *comment); char *nocolor_prelocalquit(aClient *sptr, char *comment); @@ -84,7 +84,7 @@ static int IsUsingColor(char *s) return 0; } -char *nocolor_prechanmsg(aClient *sptr, aChannel *chptr, char *text, int notice) +char *nocolor_prechanmsg(aClient *sptr, aChannel *chptr, MessageTag *mtags, char *text, int notice) { Hook *h; int i; diff --git a/src/modules/chanmodes/noctcp.c b/src/modules/chanmodes/noctcp.c index 66445124e..9ab4522a0 100644 --- a/src/modules/chanmodes/noctcp.c +++ b/src/modules/chanmodes/noctcp.c @@ -34,7 +34,7 @@ Cmode_t EXTCMODE_NOCTCP; #define IsNoCTCP(chptr) (chptr->mode.extmode & EXTCMODE_NOCTCP) -char *noctcp_prechanmsg(aClient *sptr, aChannel *chptr, char *text, int notice); +char *noctcp_prechanmsg(aClient *sptr, aChannel *chptr, MessageTag *mtags, char *text, int notice); MOD_TEST(noctcp) { @@ -78,7 +78,7 @@ static int IsACTCP(char *s) return 0; } -char *noctcp_prechanmsg(aClient *sptr, aChannel *chptr, char *text, int notice) +char *noctcp_prechanmsg(aClient *sptr, aChannel *chptr, MessageTag *mtags, char *text, int notice) { if (MyClient(sptr) && IsNoCTCP(chptr) && IsACTCP(text)) { diff --git a/src/modules/chanmodes/stripcolor.c b/src/modules/chanmodes/stripcolor.c index a4e7f698d..e516541cc 100644 --- a/src/modules/chanmodes/stripcolor.c +++ b/src/modules/chanmodes/stripcolor.c @@ -34,7 +34,7 @@ Cmode_t EXTCMODE_STRIPCOLOR; #define IsStripColor(chptr) (chptr->mode.extmode & EXTCMODE_STRIPCOLOR) -char *stripcolor_prechanmsg(aClient *sptr, aChannel *chptr, char *text, int notice); +char *stripcolor_prechanmsg(aClient *sptr, aChannel *chptr, MessageTag *mtags, char *text, int notice); char *stripcolor_prelocalpart(aClient *sptr, aChannel *chptr, char *comment); char *stripcolor_prelocalquit(aClient *sptr, char *comment); @@ -72,7 +72,7 @@ MOD_UNLOAD(stripcolor) return MOD_SUCCESS; } -char *stripcolor_prechanmsg(aClient *sptr, aChannel *chptr, char *text, int notice) +char *stripcolor_prechanmsg(aClient *sptr, aChannel *chptr, MessageTag *mtags, char *text, int notice) { Hook *h; int i; diff --git a/src/modules/extbans/textban.c b/src/modules/extbans/textban.c index f415addce..ac74dc21c 100644 --- a/src/modules/extbans/textban.c +++ b/src/modules/extbans/textban.c @@ -83,7 +83,7 @@ ModuleHeader MOD_HEADER(textban) char *extban_modeT_conv_param(char *para_in); int extban_modeT_is_banned(aClient *sptr, aChannel *chptr, char *ban, int type); int extban_modeT_is_ok(aClient *sptr, aChannel *chptr, char *para, int checkt, int what, int what2); -char *textban_chanmsg(aClient *, aChannel *, char *, int); +char *textban_chanmsg(aClient *, aChannel *, MessageTag *, char *, int); MOD_INIT(textban) { @@ -383,7 +383,7 @@ char *o = buf; #endif /* Channel message callback */ -char *textban_chanmsg(aClient *sptr, aChannel *chptr, char *text, int notice) +char *textban_chanmsg(aClient *sptr, aChannel *chptr, MessageTag *mtags, char *text, int notice) { static char filtered[512]; /* temp buffer */ Ban *ban; diff --git a/src/modules/m_message.c b/src/modules/m_message.c index e308e01a4..9e335ccce 100644 --- a/src/modules/m_message.c +++ b/src/modules/m_message.c @@ -356,23 +356,28 @@ int m_message(aClient *cptr, aClient *sptr, MessageTag *recv_mtags, int parc, ch return ret; } + new_message(sptr, recv_mtags, &mtags); + for (tmphook = Hooks[HOOKTYPE_PRE_CHANMSG]; tmphook; tmphook = tmphook->next) { - text = (*(tmphook->func.pcharfunc))(sptr, chptr, text, notice); + text = (*(tmphook->func.pcharfunc))(sptr, chptr, mtags, text, notice); if (!text) break; } if (!text) + { + free_mtags(mtags); continue; + } - new_message(sptr, recv_mtags, &mtags); sendto_channel(chptr, sptr, sptr, prefix, 0, sendflags, mtags, notice ? ":%s NOTICE %s :%s" : ":%s PRIVMSG %s :%s", sptr->name, nick, text); - free_mtags(mtags); - RunHook4(HOOKTYPE_CHANMSG, sptr, chptr, text, notice); + RunHook5(HOOKTYPE_CHANMSG, sptr, chptr, mtags, text, notice); + + free_mtags(mtags); continue; } diff --git a/src/modules/m_mode.c b/src/modules/m_mode.c index 45ac7df0d..cef1d04bc 100644 --- a/src/modules/m_mode.c +++ b/src/modules/m_mode.c @@ -402,6 +402,10 @@ void _do_mode(aChannel *chptr, aClient *cptr, aClient *sptr, MessageTag *recv_mt char tschange = 0, isbounce = 0; /* fwd'ing bounce */ MessageTag *mtags = NULL; + new_message(sptr, recv_mtags, &mtags); + + /* IMPORTANT: if you return, don't forget to free mtags!! */ + if (**parv == '&') isbounce = 1; @@ -411,10 +415,9 @@ void _do_mode(aChannel *chptr, aClient *cptr, aClient *sptr, MessageTag *recv_mt samode_in_progress = 0; if (MyConnect(sptr)) - RunHook7(HOOKTYPE_PRE_LOCAL_CHANMODE, cptr, sptr, chptr, modebuf, parabuf, sendts, samode); - else - RunHook7(HOOKTYPE_PRE_REMOTE_CHANMODE, cptr, sptr, chptr, modebuf, parabuf, sendts, samode); - + RunHook8(HOOKTYPE_PRE_LOCAL_CHANMODE, cptr, sptr, chptr, mtags, modebuf, parabuf, sendts, samode); + else + RunHook8(HOOKTYPE_PRE_REMOTE_CHANMODE, cptr, sptr, chptr, mtags, modebuf, parabuf, sendts, samode); if (IsServer(sptr)) { @@ -423,11 +426,6 @@ void _do_mode(aChannel *chptr, aClient *cptr, aClient *sptr, MessageTag *recv_mt if (!chptr->creationtime || sendts < chptr->creationtime) { tschange = 1; -/* - if (chptr->creationtime != 0) - sendto_snomask(SNO_EYES, "*** TS fix for %s - %lu(ours) %lu(theirs)", - chptr->chname, chptr->creationtime, sendts); - */ chptr->creationtime = sendts; if (sendts < 750000) { @@ -452,19 +450,26 @@ void _do_mode(aChannel *chptr, aClient *cptr, aClient *sptr, MessageTag *recv_mt if (sendts == -1 && chptr->creationtime) sendts = chptr->creationtime; } + if (*modebuf == '\0' || (*(modebuf + 1) == '\0' && (*modebuf == '+' || *modebuf == '-'))) { - if (tschange || isbounce) { /* relay bounce time changes */ + if (tschange || isbounce) + { + /* relay bounce time changes */ if (chptr->creationtime) + { sendto_server(cptr, 0, 0, NULL, ":%s MODE %s %s+ %lu", me.name, chptr->chname, isbounce ? "&" : "", chptr->creationtime); - else + } else { sendto_server(cptr, 0, 0, NULL, ":%s MODE %s %s+", me.name, chptr->chname, isbounce ? "&" : ""); - return; /* nothing to send */ + } + free_mtags(mtags); + return; /* nothing to send */ } } + /* opermode for twimodesystem --sts */ #ifndef NO_OPEROVERRIDE if (opermode == 1) @@ -488,7 +493,11 @@ void _do_mode(aChannel *chptr, aClient *cptr, aClient *sptr, MessageTag *recv_mt /* Should stop null modes */ if (*(modebuf + 1) == '\0') + { + free_mtags(mtags); return; + } + if (IsPerson(sptr) && samode && MyClient(sptr)) { sendto_umode_global(UMODE_OPER, "%s used SAMODE %s (%s%s%s)", @@ -497,8 +506,6 @@ void _do_mode(aChannel *chptr, aClient *cptr, aClient *sptr, MessageTag *recv_mt sendts = 0; } - new_message(sptr, recv_mtags, &mtags); - sendto_channel(chptr, sptr, NULL, 0, 0, SEND_LOCAL, mtags, ":%s MODE %s %s %s", sptr->name, chptr->chname, modebuf, parabuf); @@ -524,13 +531,15 @@ void _do_mode(aChannel *chptr, aClient *cptr, aClient *sptr, MessageTag *recv_mt ** is a number. */ } - free_mtags(mtags); - if (MyConnect(sptr)) RunHook7(HOOKTYPE_LOCAL_CHANMODE, cptr, sptr, chptr, modebuf, parabuf, sendts, samode); else RunHook7(HOOKTYPE_REMOTE_CHANMODE, cptr, sptr, chptr, modebuf, parabuf, sendts, samode); - /* After this, don't touch 'chptr' anymore! As permanent module may destroy the channel. */ + + /* After this, don't touch 'chptr' anymore! As permanent module may have destroyed the channel. */ + + free_mtags(mtags); + } /* make_mode_str -- written by binary * Reconstructs the mode string, to make it look clean. mode_buf will diff --git a/src/modules/nocodes.c b/src/modules/nocodes.c index bb0d233b8..a8e8c229c 100644 --- a/src/modules/nocodes.c +++ b/src/modules/nocodes.c @@ -31,7 +31,7 @@ ModuleHeader MOD_HEADER(nocodes) NULL }; -char *nocodes_pre_chanmsg(aClient *sptr, aChannel *chptr, char *text, int notice); +char *nocodes_pre_chanmsg(aClient *sptr, aChannel *chptr, MessageTag *mtags, char *text, int notice); MOD_INIT(nocodes) { @@ -59,7 +59,7 @@ static int has_controlcodes(char *p) return 0; } -char *nocodes_pre_chanmsg(aClient *sptr, aChannel *chptr, char *text, int notice) +char *nocodes_pre_chanmsg(aClient *sptr, aChannel *chptr, MessageTag *mtags, char *text, int notice) { static char retbuf[4096]; Hook *h;