From: Michael Poole Date: Sun, 3 Sep 2006 15:21:10 +0000 (+0000) Subject: DelChannelUser call and semantic fixups X-Git-Tag: v1.4.0-rc1~127 X-Git-Url: http://git.pk910.de/?p=srvx.git;a=commitdiff_plain;h=8cb76025c9e5bc7d7f545991299138c85ffc17f2 DelChannelUser call and semantic fixups src/hash.c (DelChannel): Fix type of 'reason' arg to DelChannelUser(). (DelChannelUser): Only send part message if user is local. src/proto-bahamut.c (DelUser): Unswap arguments to DelChannelUser(). (cmd_part): Move to proto-common.c. src/proto-common.c (part_desc): New structure type. (part_helper): Use it to capture user and reason. (cmd_part): New common function. src/proto-p10.c (cmd_part): Move to proto-common.c. (DelUser): Unswap arguments to DelChannelUser(). git-archimport-id: srvx@srvx.net--2006/srvx--devo--1.3--patch-29 --- diff --git a/ChangeLog b/ChangeLog index 4c2dd85..d513265 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,31 @@ # arch-tag: automatic-ChangeLog--srvx@srvx.net--2006/srvx--devo--1.3 # +2006-09-03 15:21:10 GMT Michael Poole patch-29 + + Summary: + DelChannelUser call and semantic fixups + Revision: + srvx--devo--1.3--patch-29 + + src/hash.c (DelChannel): Fix type of 'reason' arg to DelChannelUser(). + (DelChannelUser): Only send part message if user is local. + + src/proto-bahamut.c (DelUser): Unswap arguments to DelChannelUser(). + (cmd_part): Move to proto-common.c. + + src/proto-common.c (part_desc): New structure type. + (part_helper): Use it to capture user and reason. + (cmd_part): New common function. + + src/proto-p10.c (cmd_part): Move to proto-common.c. + (DelUser): Unswap arguments to DelChannelUser(). + + modified files: + ChangeLog src/hash.c src/proto-bahamut.c src/proto-common.c + src/proto-p10.c + + 2006-09-03 15:17:05 GMT Michael Poole patch-28 Summary: diff --git a/src/hash.c b/src/hash.c index 4680865..f08a3c5 100644 --- a/src/hash.c +++ b/src/hash.c @@ -440,7 +440,7 @@ DelChannel(struct chanNode *channel) /* go through all channel members and delete them from the channel */ for (n=channel->members.used; n>0; ) - DelChannelUser(channel->members.list[--n]->user, channel, false, 1); + DelChannelUser(channel->members.list[--n]->user, channel, NULL, 1); /* delete all channel bans */ for (n=channel->banlist.used; n>0; ) @@ -550,7 +550,7 @@ DelChannelUser(struct userNode* user, struct chanNode* channel, const char *reas struct modeNode* mNode; unsigned int n; - if (reason) + if (IsLocal(user) && reason) irc_part(user, channel, reason); mNode = GetUserMode(channel, user); diff --git a/src/proto-bahamut.c b/src/proto-bahamut.c index d63aef0..d493744 100644 --- a/src/proto-bahamut.c +++ b/src/proto-bahamut.c @@ -210,7 +210,7 @@ DelUser(struct userNode* user, struct userNode *killer, int announce, const char unsigned int nn; for (nn=user->channels.used; nn>0;) { - DelChannelUser(user, user->channels.list[--nn]->channel, false, 0); + DelChannelUser(user, user->channels.list[--nn]->channel, NULL, false); } for (nn=duf_used; nn>0; ) duf_list[--nn](user, killer, why); user->uplink->clients--; @@ -892,12 +892,6 @@ static CMD_FUNC(cmd_topic) { return 1; } -static CMD_FUNC(cmd_part) { - if (argc < 2) return 0; - parse_foreach(argv[1], part_helper, NULL, NULL, NULL, GetUserH(origin)); - return 1; -} - static CMD_FUNC(cmd_away) { struct userNode *un; diff --git a/src/proto-common.c b/src/proto-common.c index bd392e0..a8b2888 100644 --- a/src/proto-common.c +++ b/src/proto-common.c @@ -464,10 +464,30 @@ privmsg_invalid(char *name, void *data) irc_numeric(pd->user, ERR_NOSUCHNICK, "%s@%s :No such nick", name, self->name); } +struct part_desc { + struct userNode *user; + const char *text; +}; + static void part_helper(struct chanNode *cn, void *data) { - DelChannelUser(data, cn, false, 0); + struct part_desc *desc = data; + DelChannelUser(desc->user, cn, desc->text, false); +} + +static CMD_FUNC(cmd_part) +{ + struct part_desc desc; + + if (argc < 2) + return 0; + desc.user = GetUserH(origin); + if (!desc.user) + return 0; + desc.text = (argc > 2) ? argv[argc - 1] : NULL; + parse_foreach(argv[1], part_helper, NULL, NULL, NULL, &desc); + return 1; } void diff --git a/src/proto-p10.c b/src/proto-p10.c index 595bd14..35e5a09 100644 --- a/src/proto-p10.c +++ b/src/proto-p10.c @@ -1388,19 +1388,6 @@ static CMD_FUNC(cmd_kill) return 1; } -static CMD_FUNC(cmd_part) -{ - struct userNode *user; - - if (argc < 2) - return 0; - user = GetUserH(origin); - if (!user) - return 0; - parse_foreach(argv[1], part_helper, NULL, NULL, NULL, user); - return 1; -} - static CMD_FUNC(cmd_kick) { if (argc < 3) @@ -2056,7 +2043,7 @@ DelUser(struct userNode* user, struct userNode *killer, int announce, const char /* remove user from all channels */ while (user->channels.used > 0) - DelChannelUser(user, user->channels.list[user->channels.used-1]->channel, false, 0); + DelChannelUser(user, user->channels.list[user->channels.used-1]->channel, NULL, false); /* Call these in reverse order so ChanServ can update presence information before NickServ nukes the handle_info. */