X-Git-Url: https://jfr.im/git/solanum.git/blobdiff_plain/6c639159b0e1acb5bc0d2e9e9d439218c4190028..81e41406f4027dfef50dcd5ef33403661bea5995:/extensions/helpops.c?ds=sidebyside diff --git a/extensions/helpops.c b/extensions/helpops.c index 5633420e..95932744 100644 --- a/extensions/helpops.c +++ b/extensions/helpops.c @@ -108,17 +108,31 @@ do_dehelper(struct Client *source_p, struct Client *target_p) static int _modinit(void) { + rb_dlink_node *ptr; + user_modes[UMODECHAR_HELPOPS] = find_umode_slot(); construct_umodebuf(); + RB_DLINK_FOREACH (ptr, global_client_list.head) + { + struct Client *client_p = ptr->data; + if (IsPerson(client_p) && (client_p->umodes & user_modes[UMODECHAR_HELPOPS])) + helper_add(client_p); + } + return 0; } static void _moddeinit(void) { + rb_dlink_node *n, *tn; + user_modes[UMODECHAR_HELPOPS] = 0; construct_umodebuf(); + + RB_DLINK_FOREACH_SAFE(n, tn, helper_list.head) + rb_dlinkDestroy(n, &helper_list); } static void @@ -206,8 +220,7 @@ h_hdl_umode_changed(hook_data_umode_changed *hdata) struct Client *source_p = hdata->client; /* didn't change +H umode, we don't need to do anything */ - if (!((hdata->oldumodes ^ source_p->umodes) & user_modes[UMODECHAR_HELPOPS])) - return; + bool changed = (hdata->oldumodes ^ source_p->umodes) & user_modes[UMODECHAR_HELPOPS]; if (source_p->umodes & user_modes[UMODECHAR_HELPOPS]) { @@ -215,13 +228,19 @@ h_hdl_umode_changed(hook_data_umode_changed *hdata) { source_p->umodes &= ~user_modes[UMODECHAR_HELPOPS]; sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "usermode:helpops"); + /* they didn't ask for +H so we must be removing it */ + if (!changed) + helper_delete(source_p); return; } - helper_add(source_p); + if (changed) + helper_add(source_p); } - else if (!(source_p->umodes & user_modes[UMODECHAR_HELPOPS])) + else if (changed) + { helper_delete(source_p); + } } static void