From 01dffdfa46fdff9631712312797b9192b4316dd9 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Mon, 20 May 2013 19:37:43 +0000 Subject: [PATCH] - Extend HOOKTYPE_CHANNEL_DESTROY to allow cancelling the destroy event. --- src/channel.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/channel.c b/src/channel.c index d8b25398b..797738543 100644 --- a/src/channel.c +++ b/src/channel.c @@ -1310,14 +1310,20 @@ void sub1_from_channel(aChannel *chptr) { Ban *ban; Link *lp; + bool should_destroy = true; - /* if (--chptr->users <= 0) */ - if (chptr->users == 0 || --chptr->users == 0) + --chptr->users; + if (chptr->users <= 0) { + chptr->users = 0; + /* * Now, find all invite links from channel structure */ - RunHook(HOOKTYPE_CHANNEL_DESTROY, chptr); + RunHook2(HOOKTYPE_CHANNEL_DESTROY, chptr, &should_destroy); + if (!should_destroy) + return; + while ((lp = chptr->invites)) del_invite(lp->value.cptr, chptr);