Index: libgaim/protocols/irc/irc.h =================================================================== --- libgaim/protocols/irc/irc.h (revision 17817) +++ libgaim/protocols/irc/irc.h (working copy) @@ -54,6 +54,9 @@ guint timer; GHashTable *buddies; + guint rotation_current; + GArray *rotation_counts; + char *inbuf; int inbuflen; int inbufused; @@ -89,6 +92,8 @@ char *name; gboolean online; gboolean flag; + guint rotation; + struct irc_conn *irc; }; typedef int (*IRCCmdCallback) (struct irc_conn *irc, const char *cmd, const char *target, const char **args); Index: libgaim/protocols/irc/msgs.c =================================================================== --- libgaim/protocols/irc/msgs.c (revision 17817) +++ libgaim/protocols/irc/msgs.c (working copy) @@ -487,6 +487,8 @@ if(b->account == gc->account) { struct irc_buddy *ib = g_new0(struct irc_buddy, 1); ib->name = g_strdup(b->name); + ib->rotation = G_MAXUINT; + ib->irc = irc; g_hash_table_insert(irc->buddies, ib->name, ib); } } @@ -649,12 +651,15 @@ if (!gc || !buddy) return; - if (ib->online && !ib->flag) { - gaim_prpl_got_user_status(irc->account, name, "offline", NULL); - ib->online = FALSE; - } else if (!ib->online && ib->flag) { - gaim_prpl_got_user_status(irc->account, name, "available", NULL); - ib->online = TRUE; + if (ib->rotation == ib->irc->rotation_current) + { + if (ib->online && !ib->flag) { + gaim_prpl_got_user_status(irc->account, name, "offline", NULL); + ib->online = FALSE; + } else if (!ib->online && ib->flag) { + gaim_prpl_got_user_status(irc->account, name, "available", NULL); + ib->online = TRUE; + } } } Index: libgaim/protocols/irc/irc.c =================================================================== --- libgaim/protocols/irc/irc.c (revision 17817) +++ libgaim/protocols/irc/irc.c (working copy) @@ -184,6 +184,9 @@ GString *string = g_string_sized_new(512); char *list, *buf; + if (++irc->rotation_current == irc->rotation_counts->len) + irc->rotation_current = 0; + g_hash_table_foreach(irc->buddies, (GHFunc)irc_buddy_append, (gpointer)string); list = g_string_free(string, FALSE); @@ -202,8 +205,24 @@ static void irc_buddy_append(char *name, struct irc_buddy *ib, GString *string) { - ib->flag = FALSE; - g_string_append_printf(string, "%s ", name); + if (ib->rotation == G_MAXUINT) + { + guint len = strlen(name) + 1; + GArray *rotation_counts = ib->irc->rotation_counts; + + if (g_array_index(rotation_counts, guint, rotation_counts->len - 1) + len > 497) + g_array_append_val(rotation_counts, len); + else + g_array_index(rotation_counts, guint, rotation_counts->len - 1) += len; + + ib->rotation = rotation_counts->len - 1; + } + + if (ib->rotation == ib->irc->rotation_current) + { + ib->flag = FALSE; + g_string_append_printf(string, "%s ", name); + } } static void irc_ison_one(struct irc_conn *irc, struct irc_buddy *ib) @@ -319,6 +338,11 @@ irc->server = g_strdup(userparts[1]); g_strfreev(userparts); + irc->rotation_current = 0; + irc->rotation_counts = g_array_new(FALSE, TRUE, sizeof(guint)); + + g_array_set_size(irc->rotation_counts, 1); + irc->buddies = g_hash_table_new_full((GHashFunc)irc_nick_hash, (GEqualFunc)irc_nick_equal, NULL, (GDestroyNotify)irc_buddy_free); irc->cmds = g_hash_table_new(g_str_hash, g_str_equal); @@ -533,6 +557,8 @@ struct irc_conn *irc = (struct irc_conn *)gc->proto_data; struct irc_buddy *ib = g_new0(struct irc_buddy, 1); ib->name = g_strdup(buddy->name); + ib->rotation = G_MAXUINT; + ib->irc = irc; g_hash_table_insert(irc->buddies, ib->name, ib); /* if the timer isn't set, this is during signon, so we don't want to flood