Hi
I wrote a patch for the current CVS-snapshot of irssi, including
halfop-support. Halfop was built in as far i could see, but not
displayed in the nicklist and as prefix in the channel.
The attached should fix this.

-- 
PGP Public Key at http://yath.eu.org/~yath/public_key.asc
PGP Key fingerprint = 8D25 C96B 3DE0 C7D0 AE01  6824 BC15 6273 5A13 B048

RTFM: No just an acronym, it's the LAW!
diff -Nur old/src/core/nicklist.c new/src/core/nicklist.c
--- old/src/core/nicklist.c     Fri Oct  5 17:57:41 2001
+++ new/src/core/nicklist.c     Fri Oct  5 17:27:41 2001
@@ -355,17 +355,39 @@
 /* nick record comparision for sort functions */
 int nicklist_compare(NICK_REC *p1, NICK_REC *p2)
 {
+       int status1, status2;
+       
        if (p1 == NULL) return -1;
        if (p2 == NULL) return 1;
 
-       if (p1->op && !p2->op) return -1;
-       if (!p1->op && p2->op) return 1;
+       /* we assign each status (op, halfop, voice, normal) a number
+        * and compare them. this is easier than 100,000 if's and
+        * returns :-)
+        * -- yath */
 
-       if (!p1->op) {
-               if (p1->voice && !p2->voice) return -1;
-               if (!p1->voice && p2->voice) return 1;
-       }
+       if (p1->op)
+               status1 = 4;
+       else if (p1->halfop)
+               status1 = 3;
+       else if (p1->voice)
+               status1 = 2;
+       else
+               status1 = 1;
 
+       if (p2->op)
+               status2 = 4;
+       else if (p2->halfop)
+               status2 = 3;
+       else if (p2->voice)
+               status2 = 2;
+       else
+               status2 = 1;
+       
+       if (status1 < status2)
+               return 1;
+       else if (status1 > status2)
+               return -1;
+       
        return g_strcasecmp(p1->nick, p2->nick);
 }
 
diff -Nur old/src/fe-common/core/fe-channels.c new/src/fe-common/core/fe-channels.c
--- old/src/fe-common/core/fe-channels.c        Fri Oct  5 17:57:42 2001
+++ new/src/fe-common/core/fe-channels.c        Fri Oct  5 17:31:19 2001
@@ -377,8 +377,15 @@
        for (tmp = nicklist; tmp != NULL; tmp = tmp->next) {
                NICK_REC *rec = tmp->data;
 
-               nickmode[0] = rec->op ? '@' : rec->voice ? '+' : ' ';
-
+               if (rec->op)
+                       nickmode[0] = '@';
+               else if (rec->halfop)
+                       nickmode[0] = '%';
+               else if (rec->voice)
+                       nickmode[0] = '+';
+               else
+                       nickmode[0] = ' ';
+               
                if (linebuf_size < columns[col]-item_extra+1) {
                        linebuf_size = (columns[col]-item_extra+1)*2;
                         linebuf = g_realloc(linebuf, linebuf_size);
@@ -419,9 +426,9 @@
 {
        NICK_REC *nick;
        GSList *tmp, *nicklist, *sorted;
-       int nicks, normal, voices, ops;
+       int nicks, normal, voices, halfops, ops;
 
-       nicks = normal = voices = ops = 0;
+       nicks = normal = voices = halfops = ops = 0;
        nicklist = nicklist_getnicks(channel);
        sorted = NULL;
 
@@ -435,6 +442,7 @@
                        if ((flags & CHANNEL_NICKLIST_FLAG_OPS) == 0)
                                 continue;
                } else if (nick->halfop) {
+                       halfops++;
                        if ((flags & CHANNEL_NICKLIST_FLAG_HALFOPS) == 0)
                                continue;
                } else if (nick->voice) {
@@ -462,7 +470,7 @@
 
        printformat(channel->server, channel->name,
                    MSGLEVEL_CRAP, TXT_ENDOFNAMES,
-                   channel->name, nicks, ops, voices, normal);
+                   channel->name, nicks, ops, halfops, voices, normal);
 }
 
 /* SYNTAX: NAMES [-count | -ops -halfops -voices -normal] [<channels> | **] */
diff -Nur old/src/fe-common/core/fe-messages.c new/src/fe-common/core/fe-messages.c
--- old/src/fe-common/core/fe-messages.c        Fri Oct  5 17:57:42 2001
+++ new/src/fe-common/core/fe-messages.c        Fri Oct  5 17:32:53 2001
@@ -126,7 +126,8 @@
        nickrec = channel == NULL ? NULL :
                nicklist_find(channel, nick);
        return nickrec == NULL ? emptystr :
-               (nickrec->op ? "@" : (nickrec->voice ? "+" : emptystr));
+               (nickrec->op ? "@" : (nickrec->halfop ? "%" :
+               (nickrec->voice ? "+" : emptystr)));
 }
 
 static char *channel_get_nickmode_rec(NICK_REC *nickrec)
@@ -139,7 +140,8 @@
         emptystr = settings_get_bool("show_nickmode_empty") ? " " : "";
 
        return nickrec == NULL ? emptystr :
-               (nickrec->op ? "@" : (nickrec->voice ? "+" : emptystr));
+               (nickrec->op ? "@" : (nickrec->halfop ? "%" :
+               (nickrec->voice ? "+" : emptystr)));
 }
 
 static void sig_message_public(SERVER_REC *server, const char *msg,
diff -Nur old/src/fe-common/core/module-formats.c 
new/src/fe-common/core/module-formats.c
--- old/src/fe-common/core/module-formats.c     Fri Oct  5 17:57:42 2001
+++ new/src/fe-common/core/module-formats.c     Fri Oct  5 17:33:53 2001
@@ -101,7 +101,7 @@
        { "current_channel", "Current channel {channel $0}", 1, { 0 } },
        { "names", "{names_users Users {names_channel $0}} $1", 2, { 0, 0 } },
         { "names_nick", "{names_nick $0 $1}", 2, { 0, 0 } },
-        { "endofnames", "{channel $0}: Total of {hilight $1} nicks {comment {hilight 
$2} ops, {hilight $3} voices, {hilight $4} normal}", 5, { 0, 1, 1, 1, 1 } },
+        { "endofnames", "{channel $0}: Total of {hilight $1} nicks {comment {hilight 
+$2} ops, {hilight $3} halfops, {hilight $4} voices, {hilight $5} normal}", 6, { 0, 1, 
+1, 1, 1, 1 } },
        { "chanlist_header", "You are on the following channels:", 0 },
        { "chanlist_line", "{channel $[-10]0} %|+$1 ($2): $3", 4, { 0, 0, 0, 0 } },
        { "chansetup_not_found", "Channel {channel $0} not found", 2, { 0, 0 } },
diff -Nur old/src/irc/core/irc-nicklist.c new/src/irc/core/irc-nicklist.c
--- old/src/irc/core/irc-nicklist.c     Fri Oct  5 17:57:42 2001
+++ new/src/irc/core/irc-nicklist.c     Fri Oct  5 17:36:09 2001
@@ -31,7 +31,7 @@
 
 /* Add new nick to list */
 NICK_REC *irc_nicklist_insert(IRC_CHANNEL_REC *channel, const char *nick,
-                             int op, int voice, int send_massjoin)
+                             int op, int halfop, int voice, int send_massjoin)
 {
        NICK_REC *rec;
 
@@ -42,6 +42,7 @@
        rec->nick = g_strdup(nick);
 
        if (op) rec->op = TRUE;
+       if (halfop) rec->halfop = TRUE;
        if (voice) rec->voice = TRUE;
        rec->send_massjoin = send_massjoin;
 
@@ -106,7 +107,8 @@
                if (*names != '\0') *names++ = '\0';
 
                irc_nicklist_insert(chanrec, ptr+isnickflag(*ptr),
-                                   *ptr == '@', *ptr == '+', FALSE);
+                                   *ptr == '@', *ptr == '%', *ptr == '+',
+                                   FALSE);
        }
 
        g_free(params);
@@ -132,7 +134,7 @@
                        nicks = g_hash_table_size(chanrec->nicks);
                        ownnick = irc_nicklist_insert(chanrec, server->nick,
                                                      nicks == 0, FALSE,
-                                                     FALSE);
+                                                     FALSE, FALSE);
                }
                nicklist_set_own(CHANNEL(chanrec), ownnick);
                 chanrec->chanop = chanrec->ownnick->op;
diff -Nur old/src/irc/core/irc-nicklist.h new/src/irc/core/irc-nicklist.h
--- old/src/irc/core/irc-nicklist.h     Fri Oct  5 17:57:42 2001
+++ new/src/irc/core/irc-nicklist.h     Fri Oct  5 17:36:27 2001
@@ -6,7 +6,7 @@
 
 /* Add new nick to list */
 NICK_REC *irc_nicklist_insert(IRC_CHANNEL_REC *channel, const char *nick,
-                             int op, int voice, int send_massjoin);
+                             int op, int halfop, int voice, int send_massjoin);
 
 /* Remove all "extra" characters from `nick'. Like _nick_ -> nick */
 char *irc_nick_strip(const char *nick);
diff -Nur old/src/irc/core/massjoin.c new/src/irc/core/massjoin.c
--- old/src/irc/core/massjoin.c Fri Oct  5 17:57:42 2001
+++ new/src/irc/core/massjoin.c Fri Oct  5 17:37:11 2001
@@ -58,7 +58,7 @@
        if (chanrec == NULL) return;
 
        /* add user to nicklist */
-       nickrec = irc_nicklist_insert(chanrec, nick, FALSE, FALSE, TRUE);
+       nickrec = irc_nicklist_insert(chanrec, nick, FALSE, FALSE, FALSE, TRUE);
         nicklist_set_host(CHANNEL(chanrec), nickrec, address);
 
        if (chanrec->massjoins == 0) {
diff -Nur old/src/perl/irc/IrcChannel.xs new/src/perl/irc/IrcChannel.xs
--- old/src/perl/irc/IrcChannel.xs      Fri Oct  5 17:57:43 2001
+++ new/src/perl/irc/IrcChannel.xs      Fri Oct  5 17:41:21 2001
@@ -31,14 +31,15 @@
        }
 
 Irssi::Irc::Nick
-irc_nick_insert(channel, nick, op, voice, send_massjoin)
+irc_nick_insert(channel, nick, op, halfop, voice, send_massjoin)
        Irssi::Irc::Channel channel
        char *nick
        int op
+       int halfop
        int voice
        int send_massjoin
 CODE:
-       RETVAL = irc_nicklist_insert(channel, nick, op, voice, send_massjoin);
+       RETVAL = irc_nicklist_insert(channel, nick, op, halfop, voice, send_massjoin);
 OUTPUT:
        RETVAL
 

PGP signature

Reply via email to