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
This commit is contained in:
Jilles Tjoelker 2008-11-28 00:16:51 +00:00 committed by jilles
commit 89cd47bf3a
15 changed files with 110 additions and 88 deletions

View file

@ -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;*/

View file

@ -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->prefixes[0] == p2->prefixes[0])
return g_strcasecmp(p1->nick, p2->nick);
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])
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);
}

View file

@ -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"
};

View file

@ -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);
}