summaryrefslogtreecommitdiff
path: root/src/core/cs_akick.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/cs_akick.c')
-rw-r--r--src/core/cs_akick.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/src/core/cs_akick.c b/src/core/cs_akick.c
index 50faad99d..773388b8a 100644
--- a/src/core/cs_akick.c
+++ b/src/core/cs_akick.c
@@ -248,20 +248,15 @@ int do_akick(User * u)
}
}
- for (i = 0; i < ci->akickcount; i++) {
- if (!(ci->akick[i].flags & AK_USED))
- break;
- }
- if (i == ci->akickcount) {
- if (ci->akickcount >= CSAutokickMax) {
- notice_lang(s_ChanServ, u, CHAN_AKICK_REACHED_LIMIT,
- CSAutokickMax);
- return MOD_CONT;
- }
- ci->akickcount++;
- ci->akick =
- srealloc(ci->akick, sizeof(AutoKick) * ci->akickcount);
+ /* All entries should be in use so we don't have to go over
+ * the entire list. We simply add new entries at the end. */
+ if (ci->akickcount >= CSAutokickMax) {
+ notice_lang(s_ChanServ, u, CHAN_AKICK_REACHED_LIMIT, CSAutokickMax);
+ return MOD_CONT;
}
+ ci->akickcount++;
+ ci->akick =
+ srealloc(ci->akick, sizeof(AutoKick) * ci->akickcount);
akick = &ci->akick[i];
akick->flags = AK_USED;
if (nc) {
@@ -468,7 +463,16 @@ int do_akick(User * u)
}
}
}
- ci->akickcount--;
+ /* After reordering only the entries at the end could still be empty.
+ * We ll free the places no longer in use... - Viper */
+ for (i = ci->akickcount - 1; i >= 0; i--) {
+ if (ci->akick[i].flags & AK_USED)
+ break;
+
+ ci->akickcount--;
+ }
+ ci->akick =
+ srealloc(ci->akick,sizeof(AutoKick) * ci->akickcount);
}
} else if (stricmp(cmd, "LIST") == 0) {
int sent_header = 0;