Skip to content
This repository was archived by the owner on Jun 6, 2021. It is now read-only.

Commit 57b2b63

Browse files
Ryan Schoppmeyerkaniini
Ryan Schoppmeyer
authored andcommitted
Add a field to channel structure to track the number of internal clients in the channel. This will make it easier to determine if removing a user will cause the channel to become empty (since, in practice, services users will often part channels when the last normal user leaves)
1 parent e83a3b2 commit 57b2b63

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

Diff for: include/channels.h

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ struct channel_
2525
char **extmodes; /* non-standard simple modes with param eg +j */
2626

2727
unsigned int nummembers;
28+
unsigned int numsvcmembers;
2829

2930
time_t ts;
3031

Diff for: libathemecore/channels.c

+6
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ void channel_delete(channel_t *c)
174174
cnt.chanuser--;
175175
}
176176
c->nummembers = 0;
177+
c->numsvcmembers = 0;
177178

178179
hook_call_channel_delete(c);
179180

@@ -400,6 +401,8 @@ chanuser_t *chanuser_add(channel_t *chan, const char *nick)
400401
cu->modes = flags;
401402

402403
chan->nummembers++;
404+
if (is_internal_client(u))
405+
chan->numsvcmembers++;
403406

404407
mowgli_node_add(cu, &cu->cnode, &chan->members);
405408
mowgli_node_add(cu, &cu->unode, &u->channels);
@@ -459,6 +462,9 @@ void chanuser_delete(channel_t *chan, user_t *user)
459462
chan->nummembers--;
460463
cnt.chanuser--;
461464

465+
if (is_internal_client(user))
466+
chan->numsvcmembers--;
467+
462468
if (chan->nummembers == 0 && !(chan->modes & ircd->perm_mode))
463469
{
464470
/* empty channels die */

0 commit comments

Comments
 (0)