struct Channel *
find_allowing_channel(struct Client *source_p, struct Client *target_p)
{
- rb_dlink_node *ps = source_p->user->channel.head;
- rb_dlink_node *pt = target_p->user->channel.head;
+ rb_dlink_node *ps, *pt;
+ struct membership *ms, *mt;
+ struct Channel *chptr;
- while (ps && pt)
+ ITER_COMM_CHANNELS(ps, pt, source_p->user->channel.head, target_p->user->channel.head, ms, mt, chptr)
{
- struct membership *ms = ps->data;
- struct membership *mt = pt->data;
- int d;
- if (ms->chptr == mt->chptr)
- {
- if (is_chanop_voiced(ms))
- return ms->chptr;
- ps = ps->next;
- pt = pt->next;
- continue;
- }
- d = irccmp(ms->chptr->chname, mt->chptr->chname);
- if (d < 0)
- ps = ps->next;
- else if (d > 0)
- pt = pt->next;
- else
- assert("different channels can't have equal names" && false);
+ if (ms != NULL && mt != NULL && is_chanop_voiced(ms))
+ return chptr;
}
return NULL;
}