channels: replace Member's six parallel prefix bools (oprefix/owner/admin/op/halfop/voice) with a single u8 bitfield (PFX_*) + inline bool accessors/mutators — same semantics, one byte instead of six, no more risk of the flags drifting out of sync; all call sites go through op()/set_op()-style methods
This commit is contained in:
parent
16fae5b23c
commit
1aa02a08b9
6 changed files with 129 additions and 76 deletions
|
|
@ -105,19 +105,19 @@ impl Command for ExtJwt {
|
|||
let cmodes = member
|
||||
.map(|m| {
|
||||
let mut v = Vec::new();
|
||||
if m.owner {
|
||||
if m.owner() {
|
||||
v.push('q');
|
||||
}
|
||||
if m.admin {
|
||||
if m.admin() {
|
||||
v.push('a');
|
||||
}
|
||||
if m.op {
|
||||
if m.op() {
|
||||
v.push('o');
|
||||
}
|
||||
if m.halfop {
|
||||
if m.halfop() {
|
||||
v.push('h');
|
||||
}
|
||||
if m.voice {
|
||||
if m.voice() {
|
||||
v.push('v');
|
||||
}
|
||||
v
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@ fn set(s: &mut Server, uid: Uid, key: &str, on: bool) {
|
|||
return;
|
||||
};
|
||||
let changed = match s.channels.get_mut(key).and_then(|c| c.members.get_mut(&uid)) {
|
||||
Some(m) if m.oprefix != on => {
|
||||
m.oprefix = on;
|
||||
Some(m) if m.oprefix() != on => {
|
||||
m.set_oprefix(on);
|
||||
true
|
||||
}
|
||||
_ => false,
|
||||
|
|
|
|||
|
|
@ -10,11 +10,11 @@ use crate::server::{now, Server};
|
|||
fn prefixes(m: &crate::channels::Member) -> String {
|
||||
let mut p = String::new();
|
||||
for (has, ch) in [
|
||||
(m.owner, '~'),
|
||||
(m.admin, '&'),
|
||||
(m.op, '@'),
|
||||
(m.halfop, '%'),
|
||||
(m.voice, '+'),
|
||||
(m.owner(), '~'),
|
||||
(m.admin(), '&'),
|
||||
(m.op(), '@'),
|
||||
(m.halfop(), '%'),
|
||||
(m.voice(), '+'),
|
||||
] {
|
||||
if has {
|
||||
p.push(ch);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue