diff options
author | Timo Sirainen <cras@irssi.org> | 2001-12-09 17:13:48 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2001-12-09 17:13:48 +0000 |
commit | 15e815e8d3ff84683c2429f59738f6625d3e4f9b (patch) | |
tree | d09ad892780db823466c9a36b102fe2de3882154 /src/core | |
parent | a8419ed5b93af2c063ca90a4f34ffe36d88458a2 (diff) | |
download | irssi-15e815e8d3ff84683c2429f59738f6625d3e4f9b.zip |
Better support for halfops, patch by yathen@web.de
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2228 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/nicklist.c | 38 |
1 files changed, 30 insertions, 8 deletions
diff --git a/src/core/nicklist.c b/src/core/nicklist.c index 24ad0d1a..66b58ffb 100644 --- a/src/core/nicklist.c +++ b/src/core/nicklist.c @@ -356,17 +356,39 @@ GSList *nicklist_get_same_unique(SERVER_REC *server, void *id) /* 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; - - if (!p1->op) { - if (p1->voice && !p2->voice) return -1; - if (!p1->voice && p2->voice) 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) + 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); } |