diff options
| author | Nakidai <nakidai@disroot.org> | 2026-02-06 17:04:09 +0300 |
|---|---|---|
| committer | Nakidai <nakidai@disroot.org> | 2026-02-06 17:04:09 +0300 |
| commit | 9ae659fd6c792407f3d80ea4d313bf850c2332ec (patch) | |
| tree | 9bd14003e61c4d6a66216e50f4deddb266898118 /writef.c | |
| parent | b7e7843214ba36ca06289d1925c05e6586acac41 (diff) | |
| download | libreircd-9ae659fd6c792407f3d80ea4d313bf850c2332ec.tar.gz libreircd-9ae659fd6c792407f3d80ea4d313bf850c2332ec.zip | |
Change way to deal with modes in channels
I thought it'd be fine to store modes as an array. But using this is awful experience. Take a look at simple NAMES command: it just needs to check whether some user is oper or voice or not, and with that approach it will need to iterate over an array of users, and for each user iterate over an array of modes. Or it is possible to optimize it, saving all interesting modes to a local buffer and then iterating over it. But those are attempts to fix broken design So, instead of array of modes there'll be lots of fields regarding each mode or kind of mode From now on (struct Channel).peers is not a simple array of peers, but the one with metainformation. This is done by making an array of structures, so there are renames throughout the code Also, I didn't like that it was users and not peers and this is a nice opportunity to rename it: in first place this was done to avoid thing that compiler somehow could silently ignore type change, but this is also a stylistic change reflecting my view on naming
Diffstat (limited to 'writef.c')
| -rw-r--r-- | writef.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/writef.c b/writef.c index 51346d9..a2283b9 100644 --- a/writef.c +++ b/writef.c @@ -59,9 +59,9 @@ writechanf(const struct Peer *except, const struct Channel *channel, const char va_end(args); count = 0; - for (i = 0; i < channel->users_c; ++i) - if (!except || channel->users[i]->fd != except->fd) - count += write(channel->users[i]->fd, buf, written) == written; + for (i = 0; i < channel->peers_c; ++i) + if (!except || channel->peers[i].p->fd != except->fd) + count += write(channel->peers[i].p->fd, buf, written) == written; return count; } @@ -83,8 +83,8 @@ announce(struct Peer *peer, const char *fmt, ...) } for (i = 0; i < peer->channels_c; ++i) - for (j = 0; j < peer->channels[i]->users_c; ++j) - peer->channels[i]->users[j]->flags |= ANNOUNCE; + for (j = 0; j < peer->channels[i]->peers_c; ++j) + peer->channels[i]->peers[j].p->flags |= ANNOUNCE; for (i = 0; i < peers_c; ++i) if (peers[i].flags & ANNOUNCE) |