From e7c899014c3e0b0850fa2b12627d1207998a2bdd Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Sat, 7 May 2005 06:56:01 +0000 Subject: Fixed nicklist sort mode: now modes are not cumulated any more (so for example all op will be sorted together) --- src/irc/irc-nick.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'src/irc') 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 @@ -51,6 +51,26 @@ nick_find_color (t_irc_nick *nick) return COLOR_WIN_NICK_FIRST + color; } +/* + * 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 @@ -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) -- cgit v1.2.3