]> jfr.im git - irc/evilnet/x3.git/commitdiff
Updated ChanServ.netinfo oper count to only include opers who do not have user modes...
authorMatthew Beeching <redacted>
Wed, 16 Jul 2014 21:30:18 +0000 (22:30 +0100)
committerMatthew Beeching <redacted>
Wed, 16 Jul 2014 21:30:18 +0000 (22:30 +0100)
src/chanserv.c
src/hash.c
src/hash.h
src/proto-p10.c

index e8b349d8d4c76a3ee16fcd8403da3514d72a07ca..5c54290d9e7fd096dbca76f5c3ff0f7419f537f5 100644 (file)
@@ -5534,7 +5534,7 @@ static CHANSERV_FUNC(cmd_netinfo)
     reply("CSMSG_NETWORK_INFO");
     reply("CSMSG_NETWORK_SERVERS", dict_size(servers));
     reply("CSMSG_NETWORK_USERS", dict_size(clients));
-    reply("CSMSG_NETWORK_OPERS", curr_opers.used);
+    reply("CSMSG_NETWORK_OPERS", count_opers);
     reply("CSMSG_NETWORK_CHANNELS", registered_channels);
     reply("CSMSG_NETWORK_LAMERS", banCount);
     reply("CSMSG_NETWORK_CHANUSERS", userCount);
@@ -5579,14 +5579,14 @@ send_staff_list(struct userNode *to, struct userList *list, int skip_flags)
 static CHANSERV_FUNC(cmd_ircops)
 {
     reply("CSMSG_STAFF_OPERS");
-    send_staff_list(user, &curr_opers, FLAGS_SERVICE);
+    send_staff_list(user, &curr_opers, FLAGS_SERVICE | FLAGS_BOT);
     return 1;
 }
 
 static CHANSERV_FUNC(cmd_helpers)
 {
     reply("CSMSG_STAFF_HELPERS");
-    send_staff_list(user, &curr_helpers, FLAGS_OPER);
+    send_staff_list(user, &curr_helpers, FLAGS_OPER | FLAGS_SERVICE | FLAGS_BOT);
     return 1;
 }
 
index 1adfeca56b61b6f935e48a81f689f1e224011298..492599dcdd3e5dfd1513888caada727833f95b7d 100644 (file)
@@ -38,6 +38,7 @@ dict_t servers;
 unsigned int max_clients, invis_clients;
 time_t max_clients_time;
 struct userList curr_opers;
+unsigned int count_opers;
 
 static void hash_cleanup(void *extra);
 
@@ -47,6 +48,7 @@ void init_structs(void)
     clients = dict_new();
     servers = dict_new();
     userList_init(&curr_opers);
+    count_opers = 0;
     reg_exit_func(hash_cleanup, NULL);
 }
 
@@ -1056,6 +1058,7 @@ hash_cleanup(UNUSED_ARG(void *extra))
     dict_delete(clients);
     dict_delete(servers);
     userList_clean(&curr_opers);
+    count_opers = 0;
 
     free(slf_list);
     free(slf_list_extra);
index 66e9419ee4f2d2bd32d5ccd39637170ba0e402ee..2e81f256de35a66d1d5eb0806fedc4e7054ee550 100644 (file)
@@ -392,6 +392,8 @@ extern unsigned int max_clients, invis_clients;
 extern time_t max_clients_time;
 extern struct userList curr_opers, curr_helpers;
 
+extern unsigned int count_opers;
+
 struct server* GetServerH(const char *name); /* using full name */
 struct userNode* GetUserH(const char *nick);   /* using nick */
 struct chanNode* GetChannel(const char *name);
index ff115bafea173562154d00fe1e0674c6bdaead89..c36a920bf61189ab66d91e9b196cc7658cf225b5 100644 (file)
@@ -3250,8 +3250,11 @@ DelUser(struct userNode* user, struct userNode *killer, int announce, const char
 
     user->uplink->clients--;
     user->uplink->users[user->num_local] = NULL;
-    if (IsOper(user))
+    if (IsOper(user)) {
         userList_remove(&curr_opers, user);
+        if (count_opers > 0 && !IsBotM(user) && !IsService(user) && !IsHideOper(user))
+          count_opers--;
+    }
     /* remove from global dictionary, but not if after a collide */
     if (user == dict_find(clients, user->nick, NULL))
         dict_remove(clients, user->nick);
@@ -3316,6 +3319,8 @@ static void call_oper_funcs(struct userNode *user);
 
 void mod_usermode(struct userNode *user, const char *mode_change) {
     int add = 1;
+    long setmodes = 0;
+    int donemodes = 0;
     const char *word = mode_change;
 
     if (!user || !mode_change)
@@ -3323,12 +3328,16 @@ void mod_usermode(struct userNode *user, const char *mode_change) {
 
     call_user_mode_funcs(user, mode_change);
 
+    setmodes = user->modes;
+
     while (*word != ' ' && *word) word++;
     while (*word == ' ') word++;
-    while (1) {
+    while (!donemodes) {
 #define do_user_mode(FLAG) do { if (add) user->modes |= FLAG; else user->modes &= ~FLAG; } while (0)
        switch (*mode_change++) {
-       case 0: case ' ': return;
+       case 0: case ' ':
+            donemodes = 1;
+            break;
        case '+': add = 1; break;
        case '-': add = 0; break;
        case 'o':
@@ -3431,6 +3440,37 @@ void mod_usermode(struct userNode *user, const char *mode_change) {
        }
 #undef do_user_mode
     }
+
+    // Set user mode +o
+    if (!(setmodes & FLAGS_OPER) && IsOper(user)) {
+        if (!IsBotM(user) && !IsService(user) && !IsHideOper(user))
+            count_opers++;
+    }
+
+    // Set user mode -o
+    if ((setmodes & FLAGS_OPER) && !IsOper(user)) {
+        if (count_opers > 1 && !(setmodes & FLAGS_BOT) &&
+            !(setmodes & FLAGS_SERVICE) && !(setmodes & FLAGS_HIDEOPER))
+            count_opers--;
+    }
+
+    // Set +H, +k or +B
+    if (!(setmodes & FLAGS_HIDEOPER) &&
+        !(setmodes & FLAGS_SERVICE) &&
+        !(setmodes & FLAGS_BOT) &&
+        (IsHideOper(user) || IsService(user) || IsBotM(user))) {
+        if ((setmodes & FLAGS_OPER) && IsOper(user) && count_opers > 0)
+              count_opers--;
+    }
+
+    // Set -H, -k or -B
+    if (((setmodes & FLAGS_HIDEOPER) ||
+         (setmodes & FLAGS_SERVICE) ||
+         (setmodes & FLAGS_BOT)) &&
+        !IsHideOper(user) && !IsService(user) && !IsBotM(user)) {
+        if ((setmodes & FLAGS_OPER) && IsOper(user))
+            count_opers++;
+    }
 }
 
 static int