summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorJilles Tjoelker <jilles@irssi.org>2008-11-28 00:16:51 +0000
committerjilles <jilles@dbcabf3a-b0e7-0310-adc4-f8d773084564>2008-11-28 00:16:51 +0000
commit89cd47bf3a937c3077acdc95d98cc4b389e30608 (patch)
treee96f73aa452cc2fbec41f45f973cfaf42acacb3a /src/core
parentaefa7b47c14f2bd8801b233907a84de4f6eee3b8 (diff)
downloadirssi-89cd47bf3a937c3077acdc95d98cc4b389e30608.zip
Allow storing multiple "other" prefixes such as +q and +a.
Original patch by JasonX, somewhat changed by exg and me. git-svn-id: file:///var/www/svn.irssi.org/SVN/irssi/trunk@4922 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/core')
-rw-r--r--src/core/nick-rec.h2
-rw-r--r--src/core/nicklist.c50
-rw-r--r--src/core/nicklist.h2
-rw-r--r--src/core/session.c5
4 files changed, 22 insertions, 37 deletions
diff --git a/src/core/nick-rec.h b/src/core/nick-rec.h
index aaedded9..1463f9f3 100644
--- a/src/core/nick-rec.h
+++ b/src/core/nick-rec.h
@@ -19,7 +19,7 @@ unsigned int send_massjoin:1; /* Waiting to be sent in massjoin signal */
unsigned int op:1;
unsigned int halfop:1;
unsigned int voice:1;
-char other;
+char prefixes[MAX_USER_PREFIXES+1];
/*GHashTable *module_data;*/
diff --git a/src/core/nicklist.c b/src/core/nicklist.c
index 28665ddd..9f67f20b 100644
--- a/src/core/nicklist.c
+++ b/src/core/nicklist.c
@@ -359,45 +359,31 @@ 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, const char *nick_prefix)
{
- int status1, status2;
+ int i;
if (p1 == NULL) return -1;
if (p2 == NULL) 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->other) {
- const char *other = (nick_prefix == NULL) ? NULL : strchr(nick_prefix, p1->other);
- status1 = (other == NULL) ? 5 : 1000 - (other - nick_prefix);
- } else if (p1->op)
- status1 = 4;
- else if (p1->halfop)
- status1 = 3;
- else if (p1->voice)
- status1 = 2;
- else
- status1 = 1;
-
- if (p2->other) {
- const char *other = (nick_prefix == NULL) ? NULL : strchr(nick_prefix, p2->other);
- status2 = (other == NULL) ? 5 : 1000 - (other - nick_prefix);
- } else if (p2->op)
- status2 = 4;
- else if (p2->halfop)
- status2 = 3;
- else if (p2->voice)
- status2 = 2;
- else
- status2 = 1;
-
- if (status1 < status2)
+ if (p1->prefixes[0] == p2->prefixes[0])
+ return g_strcasecmp(p1->nick, p2->nick);
+
+ if (!p1->prefixes[0])
return 1;
- else if (status1 > status2)
+ if (!p2->prefixes[0])
return -1;
+ /* They aren't equal. We've taken care of that already.
+ * The first one we encounter in this list is the greater.
+ */
+
+ for (i = 0; nick_prefix[i] != '\0'; i++) {
+ if (p1->prefixes[0] == nick_prefix[i])
+ return -1;
+ if (p2->prefixes[0] == nick_prefix[i])
+ return 1;
+ }
+
+ /* we should never have gotten here... */
return g_strcasecmp(p1->nick, p2->nick);
}
diff --git a/src/core/nicklist.h b/src/core/nicklist.h
index 7712af65..55dfd5ef 100644
--- a/src/core/nicklist.h
+++ b/src/core/nicklist.h
@@ -8,6 +8,8 @@
#define IS_NICK(server) \
(NICK(server) ? TRUE : FALSE)
+#define MAX_USER_PREFIXES 7 /* Max prefixes kept for any user-in-chan. 7+1 is a memory unit */
+
struct _NICK_REC {
#include "nick-rec.h"
};
diff --git a/src/core/session.c b/src/core/session.c
index 75b44b3d..5eb5270b 100644
--- a/src/core/session.c
+++ b/src/core/session.c
@@ -91,7 +91,6 @@ static void cmd_upgrade(const char *data)
static void session_save_nick(CHANNEL_REC *channel, NICK_REC *nick,
CONFIG_REC *config, CONFIG_NODE *node)
{
- static char other[2];
node = config_node_section(node, NULL, NODE_TYPE_BLOCK);
config_node_set_str(config, node, "nick", nick->nick);
@@ -99,9 +98,7 @@ static void session_save_nick(CHANNEL_REC *channel, NICK_REC *nick,
config_node_set_bool(config, node, "halfop", nick->halfop);
config_node_set_bool(config, node, "voice", nick->voice);
- other[0] = nick->other;
- other[1] = '\0';
- config_node_set_str(config, node, "other", other);
+ config_node_set_str(config, node, "prefixes", nick->prefixes);
signal_emit("session save nick", 4, channel, nick, config, node);
}