From fe4c5abe286b81238d8a5757ba888ff495c04766 Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Sat, 13 Dec 2008 21:42:42 +0000 Subject: Preserve op/halfop/voice when /upgrading from before the prefixes change (r4922). This also restores them when /upgrading from a revision between r4922 and this one. Note that other prefixes are still lost when /upgrading from pre-r4922 irssi. git-svn-id: file:///var/www/svn.irssi.org/SVN/irssi/trunk@4968 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- src/irc/core/irc-session.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/irc/core/irc-session.c b/src/irc/core/irc-session.c index 5cd5cc43..21fc5fc7 100644 --- a/src/irc/core/irc-session.c +++ b/src/irc/core/irc-session.c @@ -113,9 +113,11 @@ static void sig_session_restore_server(IRC_SERVER_REC *server, static void sig_session_restore_nick(IRC_CHANNEL_REC *channel, CONFIG_NODE *node) { - const char *nick; + const char *nick, *prefixes; int op, halfop, voice; NICK_REC *nickrec; + char newprefixes[MAX_USER_PREFIXES + 1]; + int i; if (!IS_IRC_CHANNEL(channel)) return; @@ -128,8 +130,24 @@ static void sig_session_restore_nick(IRC_CHANNEL_REC *channel, voice = config_node_get_bool(node, "voice", FALSE); halfop = config_node_get_bool(node, "halfop", FALSE); nickrec = irc_nicklist_insert(channel, nick, op, halfop, voice, FALSE); + prefixes = config_node_get_str(node, "prefixes", NULL); + if (prefixes == NULL || *prefixes == '\0') { + /* upgrading from old irssi or from an in-between + * version that did not imply non-present prefixes from + * op/voice/halfop, restore prefixes + */ + i = 0; + if (op) + newprefixes[i++] = '@'; + if (halfop) + newprefixes[i++] = '%'; + if (voice) + newprefixes[i++] = '+'; + newprefixes[i] = '\0'; + prefixes = newprefixes; + } strocpy(nickrec->prefixes, - config_node_get_str(node, "prefixes", ""), + prefixes, sizeof(nickrec->prefixes)); } -- cgit v1.2.3