diff --git a/src/channel.c b/src/channel.c index be35bed9c..47e848d8a 100644 --- a/src/channel.c +++ b/src/channel.c @@ -242,12 +242,16 @@ int identical_ban(const char *one, const char *two) /** Add a listmode (+beI) with the specified banid to * the specified channel. (Extended version with * set by nick and set on timestamp) + * @retval 1 Added + * @retval 0 Updated + * @retval -1 Ban list full */ int add_listmode_ex(Ban **list, Client *client, Channel *channel, const char *banid, const char *setby, time_t seton) { Ban *ban; int cnt = 0, len; int do_not_add = 0; + char isnew = 0; //if (MyUser(client)) // collapse(banid); @@ -294,6 +298,7 @@ int add_listmode_ex(Ban **list, Client *client, Channel *channel, const char *ba ban = make_ban(); ban->next = *list; *list = ban; + isnew = 1; } if ((ban->when > 0) && (seton >= ban->when)) @@ -308,7 +313,7 @@ int add_listmode_ex(Ban **list, Client *client, Channel *channel, const char *ba safe_strdup(ban->banstr, banid); /* cAsE may differ, use oldest version of it */ safe_strdup(ban->who, setby); ban->when = seton; - return 0; + return isnew ? 1 : 0; } /** Add a listmode (+beI) with the specified banid to diff --git a/src/modules/chanmodes/floodprot.c b/src/modules/chanmodes/floodprot.c index 0348ccf4e..a8e32b4c6 100644 --- a/src/modules/chanmodes/floodprot.c +++ b/src/modules/chanmodes/floodprot.c @@ -1407,7 +1407,7 @@ int floodprot_can_send_to_channel(Client *client, Channel *channel, Membership * } else { snprintf(mask, sizeof(mask), "*!*@%s", GetHost(client)); } - if (add_listmode(&channel->banlist, &me, channel, mask) == 0) + if (add_listmode(&channel->banlist, &me, channel, mask) == 1) { mtags = NULL; new_message(&me, NULL, &mtags); @@ -1415,7 +1415,7 @@ int floodprot_can_send_to_channel(Client *client, Channel *channel, Membership * sendto_channel(channel, &me, NULL, 0, 0, SEND_LOCAL, mtags, ":%s MODE %s +b %s", me.name, channel->name, mask); free_message_tags(mtags); - } /* else.. ban list is full */ + } /* else.. ban list is full or already exists */ } mtags = NULL; kick_user(NULL, channel, &me, client, errbuf); @@ -1777,7 +1777,7 @@ int do_floodprot_action_alternative(Channel *channel, int what, FloodType *flood floodtype->alternative_ban_action); /* Add the ban internally */ - if (add_listmode(&channel->banlist, &me, channel, ban) == -1) + if (add_listmode(&channel->banlist, &me, channel, ban) != 1) return 0; /* ban list full (or ban already exists) */ /* First the notice to the chanops */ diff --git a/src/modules/mode.c b/src/modules/mode.c index 2dbadc48a..11850ad4c 100644 --- a/src/modules/mode.c +++ b/src/modules/mode.c @@ -593,10 +593,10 @@ const char *mode_ban_handler(Client *client, Channel *channel, const char *param } } - if ( (what == MODE_ADD && add_listmode(banlist, client, channel, tmpstr)) || + if ( (what == MODE_ADD && (add_listmode(banlist, client, channel, tmpstr) != 1)) || (what == MODE_DEL && del_listmode(banlist, channel, tmpstr))) { - return NULL; /* already exists */ + return NULL; /* ban to be added already exists, or ban to be deleted does not exist */ } return tmpstr; diff --git a/src/modules/sjoin.c b/src/modules/sjoin.c index 5d5cadf84..bc19e0efb 100644 --- a/src/modules/sjoin.c +++ b/src/modules/sjoin.c @@ -531,21 +531,21 @@ CMD_FUNC(cmd_sjoin) /* Adding of list modes */ if (*item_modes == 'b') { - if (add_listmode_ex(&channel->banlist, client, channel, item, setby, setat) != -1) + if (add_listmode_ex(&channel->banlist, client, channel, item, setby, setat) == 1) { Addit('b', item); } } if (*item_modes == 'e') { - if (add_listmode_ex(&channel->exlist, client, channel, item, setby, setat) != -1) + if (add_listmode_ex(&channel->exlist, client, channel, item, setby, setat) == 1) { Addit('e', item); } } if (*item_modes == 'I') { - if (add_listmode_ex(&channel->invexlist, client, channel, item, setby, setat) != -1) + if (add_listmode_ex(&channel->invexlist, client, channel, item, setby, setat) == 1) { Addit('I', item); }