summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2005-05-07 06:56:01 +0000
committerSebastien Helleu <flashcode@flashtux.org>2005-05-07 06:56:01 +0000
commite7c899014c3e0b0850fa2b12627d1207998a2bdd (patch)
treeb0331fc8528d358e4762b18b0c2face50b4ae651
parentAllow only server (with blank channel) for buffer search (for print & command functions) (diff)
downloadweechat-e7c899014c3e0b0850fa2b12627d1207998a2bdd.tar.xz
weechat-e7c899014c3e0b0850fa2b12627d1207998a2bdd.zip
Fixed nicklist sort mode: now modes are not cumulated any more (so for example all op will be sorted together)
-rw-r--r--src/irc/irc-nick.c26
-rw-r--r--weechat/src/irc/irc-nick.c26
2 files changed, 44 insertions, 8 deletions
diff --git a/src/irc/irc-nick.c b/src/irc/irc-nick.c
index 03c511947..af845e3f2 100644
--- a/src/irc/irc-nick.c
+++ b/src/irc/irc-nick.c
@@ -52,6 +52,26 @@ nick_find_color (t_irc_nick *nick)
}
/*
+ * nick_score_for_sort: return score for sorting nick, according to privileges
+ */
+
+int
+nick_score_for_sort (t_irc_nick *nick)
+{
+ if (nick->is_chanowner)
+ return -32;
+ if (nick->is_chanadmin)
+ return -16;
+ if (nick->is_op)
+ return -8;
+ if (nick->is_halfop)
+ return -4;
+ if (nick->has_voice)
+ return -2;
+ return 0;
+}
+
+/*
* nick_compare: compare two nicks
* return: -1 is nick1 < nick2
* 0 if nick1 = nick2
@@ -64,10 +84,8 @@ nick_compare (t_irc_nick *nick1, t_irc_nick *nick2)
{
int score1, score2, comp;
- score1 = - ( (nick1->is_chanowner * 32) + (nick1->is_chanadmin * 16) +
- (nick1->is_op * 8) + (nick1->is_halfop * 4) + (nick1->has_voice * 2) );
- score2 = - ( (nick2->is_chanowner * 32) + (nick2->is_chanadmin * 16) +
- (nick2->is_op * 8) + (nick2->is_halfop * 4) + (nick2->has_voice * 2) );
+ score1 = nick_score_for_sort (nick1);
+ score2 = nick_score_for_sort (nick2);
comp = strcasecmp(nick1->nick, nick2->nick);
if (comp > 0)
diff --git a/weechat/src/irc/irc-nick.c b/weechat/src/irc/irc-nick.c
index 03c511947..af845e3f2 100644
--- a/weechat/src/irc/irc-nick.c
+++ b/weechat/src/irc/irc-nick.c
@@ -52,6 +52,26 @@ nick_find_color (t_irc_nick *nick)
}
/*
+ * nick_score_for_sort: return score for sorting nick, according to privileges
+ */
+
+int
+nick_score_for_sort (t_irc_nick *nick)
+{
+ if (nick->is_chanowner)
+ return -32;
+ if (nick->is_chanadmin)
+ return -16;
+ if (nick->is_op)
+ return -8;
+ if (nick->is_halfop)
+ return -4;
+ if (nick->has_voice)
+ return -2;
+ return 0;
+}
+
+/*
* nick_compare: compare two nicks
* return: -1 is nick1 < nick2
* 0 if nick1 = nick2
@@ -64,10 +84,8 @@ nick_compare (t_irc_nick *nick1, t_irc_nick *nick2)
{
int score1, score2, comp;
- score1 = - ( (nick1->is_chanowner * 32) + (nick1->is_chanadmin * 16) +
- (nick1->is_op * 8) + (nick1->is_halfop * 4) + (nick1->has_voice * 2) );
- score2 = - ( (nick2->is_chanowner * 32) + (nick2->is_chanadmin * 16) +
- (nick2->is_op * 8) + (nick2->is_halfop * 4) + (nick2->has_voice * 2) );
+ score1 = nick_score_for_sort (nick1);
+ score2 = nick_score_for_sort (nick2);
comp = strcasecmp(nick1->nick, nick2->nick);
if (comp > 0)