diff --git a/include/h.h b/include/h.h index 33db10332..15274d9dc 100644 --- a/include/h.h +++ b/include/h.h @@ -315,8 +315,7 @@ extern int check_registered_user(aClient *); extern char *get_client_name(aClient *, int); extern char *get_client_host(aClient *); extern char *myctime(time_t), *date(time_t); -extern int exit_client(aClient *, aClient *, aClient *, char *); -extern int exit_client2(aClient *, aClient *, aClient *, MessageTag *, char *); +extern int exit_client(aClient *cptr, aClient *sptr, aClient *from, MessageTag *recv_mtags, char *comment); extern void initstats(), tstats(aClient *, char *); extern char *check_string(char *); extern char *make_nick_user_host(char *, char *, char *); diff --git a/src/s_misc.c b/src/s_misc.c index cff19899e..201b651c2 100644 --- a/src/s_misc.c +++ b/src/s_misc.c @@ -53,7 +53,7 @@ extern ircstats IRCstats; extern char *me_hash; -static void exit_one_client(aClient *, const char *); +static void exit_one_client(aClient *, MessageTag *mtags_i, const char *); static char *months[] = { "January", "February", "March", "April", @@ -442,9 +442,8 @@ int found; * clients. A server needs the client QUITs if it does not support NOQUIT. * - kaniini */ -static void -recurse_send_quits(aClient *cptr, aClient *sptr, aClient *from, aClient *to, - const char *comment, const char *splitstr) +static void recurse_send_quits(aClient *cptr, aClient *sptr, aClient *from, aClient *to, + const char *comment, const char *splitstr) { aClient *acptr, *next; @@ -480,8 +479,7 @@ recurse_send_quits(aClient *cptr, aClient *sptr, aClient *from, aClient *to, * and servers before the server itself; exit_one_client takes care of * actually removing things off llists. tweaked from +CSr31 -orabidoo */ -static void -recurse_remove_clients(aClient *sptr, const char *comment) +static void recurse_remove_clients(aClient *sptr, MessageTag *mtags, const char *comment) { aClient *acptr, *next; @@ -490,7 +488,7 @@ recurse_remove_clients(aClient *sptr, const char *comment) if (acptr->srvptr != sptr) continue; - exit_one_client(acptr, comment); + exit_one_client(acptr, mtags, comment); } list_for_each_entry_safe(acptr, next, &global_server_list, client_node) @@ -498,8 +496,8 @@ recurse_remove_clients(aClient *sptr, const char *comment) if (acptr->srvptr != sptr) continue; - recurse_remove_clients(acptr, comment); - exit_one_client(acptr, comment); + recurse_remove_clients(acptr, mtags, comment); + exit_one_client(acptr, mtags, comment); } } @@ -508,15 +506,14 @@ recurse_remove_clients(aClient *sptr, const char *comment) ** all necessary QUITs and SQUITs. source_p itself is still on the lists, ** and its SQUITs have been sent except for the upstream one -orabidoo */ -static void -remove_dependents(aClient *sptr, aClient *from, const char *comment, const char *splitstr) +static void remove_dependents(aClient *sptr, aClient *from, MessageTag *mtags, const char *comment, const char *splitstr) { aClient *acptr; list_for_each_entry(acptr, &global_server_list, client_node) recurse_send_quits(sptr, sptr, from, acptr, comment, splitstr); - recurse_remove_clients(sptr, splitstr); + recurse_remove_clients(sptr, mtags, splitstr); } /* @@ -525,7 +522,7 @@ remove_dependents(aClient *sptr, aClient *from, const char *comment, const char */ /* DANGER: Ugly hack follows. */ /* Yeah :/ */ -static void exit_one_client(aClient *sptr, const char *comment) +static void exit_one_client(aClient *sptr, MessageTag *mtags_i, const char *comment) { Link *lp; Membership *mp; @@ -534,13 +531,14 @@ static void exit_one_client(aClient *sptr, const char *comment) if (IsClient(sptr)) { - if (!MyClient(sptr)) - { - RunHook2(HOOKTYPE_REMOTE_QUIT, sptr, comment); - } + MessageTag *mtags_o = NULL; - // FIXME: mtags - sendto_local_common_channels(sptr, NULL, 0, NULL, ":%s QUIT :%s", sptr->name, comment); + if (!MyClient(sptr)) + RunHook2(HOOKTYPE_REMOTE_QUIT, sptr, comment); + + new_message_special(sptr, mtags_i, &mtags_o, ":%s QUIT", sptr->name); + sendto_local_common_channels(sptr, NULL, 0, mtags_o, ":%s QUIT :%s", sptr->name, comment); + free_mtags(mtags_o); /* This hook may or may not be redundant */ RunHook(HOOKTYPE_EXIT_ONE_CLIENT, sptr); @@ -595,13 +593,7 @@ static void exit_one_client(aClient *sptr, const char *comment) * FLUSH_BUFFER if (cptr == sptr) * 0 if (cptr != sptr) */ -int exit_client(aClient *cptr, aClient *sptr, aClient *from, char *comment) -{ - return exit_client2(cptr, sptr, from, NULL, comment); -} - -/** See exit_client() */ -int exit_client2(aClient *cptr, aClient *sptr, aClient *from, MessageTag *recv_mtags, char *comment) +int exit_client(aClient *cptr, aClient *sptr, aClient *from, MessageTag *recv_mtags, char *comment) { time_t on_for; ConfigItem_listen *listen_conf; @@ -726,25 +718,20 @@ int exit_client2(aClient *cptr, aClient *sptr, aClient *from, MessageTag *recv_m else ircsnprintf(splitstr, sizeof splitstr, "%s %s", sptr->srvptr->name, sptr->name); - remove_dependents(sptr, cptr, comment, splitstr); + remove_dependents(sptr, cptr, recv_mtags, comment, splitstr); RunHook(HOOKTYPE_SERVER_QUIT, sptr); } else if (IsClient(sptr) && !(sptr->flags & FLAGS_KILLED)) { - MessageTag *mtags = NULL; - new_message(sptr, recv_mtags, &mtags); - sendto_server(cptr, PROTO_SID, 0, mtags, - ":%s QUIT :%s", ID(sptr), comment); - sendto_server(cptr, 0, PROTO_SID, mtags, - ":%s QUIT :%s", sptr->name, comment); - free_mtags(mtags); + sendto_server(cptr, PROTO_SID, 0, recv_mtags, ":%s QUIT :%s", ID(sptr), comment); + sendto_server(cptr, 0, PROTO_SID, recv_mtags, ":%s QUIT :%s", sptr->name, comment); } /* * Finally, clear out the server we lost itself */ - exit_one_client(sptr, comment); + exit_one_client(sptr, recv_mtags, comment); return cptr == sptr ? FLUSH_BUFFER : 0; } @@ -1222,7 +1209,7 @@ int banned_client(aClient *acptr, char *bantype, char *reason, int global, int n if (noexit != NO_EXIT_CLIENT) { - return exit_client(acptr, acptr, acptr, buf); + return exit_client(acptr, acptr, acptr, NULL, buf); } else { /* Special handling for direct Z-line code */ send_raw_direct(acptr, "ERROR :Closing Link: [%s] (%s)",