From 978dd4071e31ec00ac62c7e90b21007fa808c05b Mon Sep 17 00:00:00 2001 From: codemastr Date: Thu, 7 Sep 2000 21:10:40 +0000 Subject: [PATCH] Major changes to the way +I works --- Changes | 7 ++++- src/channel.c | 10 ++++++- src/s_user.c | 23 ++++++++------- src/send.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++--- 4 files changed, 105 insertions(+), 16 deletions(-) diff --git a/Changes b/Changes index 7de3ad052..61f259a4d 100644 --- a/Changes +++ b/Changes @@ -597,7 +597,7 @@ - Fixed some more -Wall warnings - ./update now checks when you specify wget if it exists, if not it tries lynx - Cached MOTDs are now dynamically allocated (saves alot of memory) -- Made aClient->passwd dynamically allocated (saves 32bytes per user/server) [may need debugging] +- Made aClient->passwd dynamically allocated (saves 32bytes per user/server) - Fixed a NOTICE crash bug, reported by EJ - Removed a excessive va_end in send.c - Fixed a bug when running the ircd with -h @@ -615,3 +615,8 @@ - Fixed a bug where +K could be set when +i was not (reported by rapta) - Made it so if you set -i on a channel that is +K it sets -iK - Fixed whowas so it no longer reports away messages +- Made major changes to +I (may need debugging) + - When you set +I while on a chan it sends a PART to the rest of the channel + - When you set -I which on a chan it sends a JOIN to the rest of the channel + - Net/TechAdmins now receive a JOIN/PART when you JOIN/PART a channel + - Net/TechAdmins can now see +I users in /names diff --git a/src/channel.c b/src/channel.c index 68fa5504e..068daed4e 100644 --- a/src/channel.c +++ b/src/channel.c @@ -2975,6 +2975,8 @@ int m_join(cptr, sptr, parc, parv) sendto_serv_butone_token(&me, me.name, MSG_SMO, TOK_SMO, "A :[+I] %s invisible joined %s", sptr->name, chptr->chname); + sendto_channel_ntadmins(sptr, chptr, ":%s JOIN :%s", + sptr->name, chptr->chname); } } else if (chptr->mode.mode & MODE_AUDITORIUM) @@ -3110,6 +3112,12 @@ int m_part(cptr, sptr, parc, parv) me.name, MSG_SMO, TOK_SMO, "A :[+I] %s invisible parted %s", sptr->name, chptr->chname); + if (parc < 3) + sendto_channel_ntadmins(sptr, chptr, ":%s PART %s", + sptr->name, chptr->chname); + else + sendto_channel_ntadmins(sptr, chptr, ":%s PART %s :%s", + sptr->name, chptr->chname, comment); } if (MyClient(sptr)) /* awful hack .. */ @@ -4183,7 +4191,7 @@ int m_names(cptr, sptr, parc, parv) acptr = cm->value.cptr; if (IsInvisible(acptr) && !member) continue; - if (IsHiding(acptr) && acptr != sptr) + if (IsHiding(acptr) && acptr != sptr && !(IsNetAdmin(sptr) || IsTechAdmin(sptr))) continue; if (chptr->mode.mode & MODE_AUDITORIUM) if (!is_chan_op(sptr, chptr) diff --git a/src/s_user.c b/src/s_user.c index f991a8067..574de4d30 100644 --- a/src/s_user.c +++ b/src/s_user.c @@ -1574,11 +1574,11 @@ int m_nick(cptr, sptr, parc, parv) * * Generate a random string for them to pong with. */ -#ifndef _WIN32 +#ifndef _WIN32 sptr->nospoof = 1+(int) (9000000.0*random()/(RAND_MAX+80000000.0)); -#else - sptr->nospoof = 1+(int) (9000000.0*rand()/(RAND_MAX+80000000.0)); -#endif +#else + sptr->nospoof = 1+(int) (9000000.0*rand()/(RAND_MAX+80000000.0)); +#endif /* * If on the odd chance it comes out zero, make it something * non-zero. @@ -3474,15 +3474,15 @@ int m_mkpasswd(cptr, sptr, parc, parv) return 0; } srandom(time(0)); -#ifndef _WIN32 +#ifndef _WIN32 salt[0] = saltChars[random() % 64]; salt[1] = saltChars[random() % 64]; salt[2] = 0; -#else - salt[0] = saltChars[rand() % 64]; - salt[1] = saltChars[rand() % 64]; - salt[2] = 0; -#endif +#else + salt[0] = saltChars[rand() % 64]; + salt[1] = saltChars[rand() % 64]; + salt[2] = 0; +#endif if ((strchr(saltChars, salt[0]) == NULL) || (strchr(saltChars, salt[1]) == NULL)) { @@ -4390,6 +4390,7 @@ int m_umode(cptr, sptr, parc, parv) sendto_serv_butone(cptr, ":%s SMO A :[+I] Activated total invisibility mode on %s", me.name, sptr->name); + sendto_channels_inviso_part(sptr); } if (!(sptr->umodes & (UMODE_HIDING))) { @@ -4401,6 +4402,8 @@ int m_umode(cptr, sptr, parc, parv) sendto_serv_butone(cptr, ":%s SMO A :[+I] De-activated total invisibility mode on %s", me.name, sptr->name); + sendto_channels_inviso_join(sptr); + } } } diff --git a/src/send.c b/src/send.c index bb30ef33f..bccf5c401 100644 --- a/src/send.c +++ b/src/send.c @@ -87,13 +87,13 @@ static int dead_link(to, notice) DBufClear(&to->recvQ); DBufClear(&to->sendQ); if (!IsPerson(to) && !IsUnknown(to) && !(to->flags & FLAGS_CLOSING)) - (void)sendto_failops_whoare_opers(notice, get_client_name(to, FALSE), + (void)sendto_failops_whoare_opers(notice, get_client_name(to, FALSE), #ifndef _WIN32 - strerror(errno)); + strerror(errno)); #else - strerror(WSAGetLastError())); + strerror(WSAGetLastError())); #endif - + Debug((DEBUG_ERROR, notice, get_client_name(to, FALSE))); return -1; } @@ -1737,3 +1737,76 @@ void sendto_message_one(aClient *to, aClient *from, char *sender, sendto_prefix_one(to, from, ":%s %s %s :%s", sender, cmd, nick, msg); } + +/* The following functions are for +/-I -- codemastr */ + +void sendto_channels_inviso_join(aClient *user) +{ + Link *channels; + Link *users; + aClient *cptr; + + memset((char *)sentalong, '\0', sizeof(sentalong)); + if (user->fd >= 0) + sentalong[user->fd] = 1; + if (user->user) + for (channels = user->user->channel; channels; channels = channels->next) + for (users = channels->value.chptr->members; users; users = users->next) + { + cptr = users->value.cptr; + if (!MyConnect(cptr) || IsTechAdmin(cptr) || IsNetAdmin(cptr) || sentalong[cptr->fd] || cptr == user) + continue; + sentalong[cptr->fd]++; + sendto_one(cptr, ":%s!%s@%s JOIN :%s", user->name, user->user->username, + (IsHidden(user) ? user->user->virthost : user->user->realhost), channels->value.chptr->chname); + } + return; +} + +void sendto_channels_inviso_part(aClient *user) +{ + Link *channels; + Link *users; + aClient *cptr; + + memset((char *)sentalong, '\0', sizeof(sentalong)); + if (user->fd >= 0) + sentalong[user->fd] = 1; + if (user->user) + for (channels = user->user->channel; channels; channels = channels->next) + for (users = channels->value.chptr->members; users; users = users->next) + { + cptr = users->value.cptr; + if (!MyConnect(cptr) || IsTechAdmin(cptr) || IsNetAdmin(cptr) || sentalong[cptr->fd] || cptr == user) + continue; + sentalong[cptr->fd]++; + sendto_one(cptr, ":%s!%s@%s PART :%s", user->name, user->user->username, (IsHidden(user) ? user->user->virthost : user->user->realhost), channels->value.chptr->chname); + } + return; +} + +void sendto_channel_ntadmins(aClient *from, aChannel *chptr, char *pattern, ...) +{ + va_list vl; + Link *lp; + aClient *acptr; + int i; + + va_start(vl, pattern); + ++sentalong_marker; + for (lp = chptr->members; lp; lp = lp->next) + { + acptr = lp->value.cptr; + if (acptr->from == from || !(IsNetAdmin(acptr) || IsTechAdmin(acptr)) || (IsDeaf(acptr) && !(sendanyways == 1))) + continue; + if (MyConnect(acptr)) /* (It is always a client) */ + vsendto_prefix_one(acptr, from, pattern, vl); + else if (sentalong[(i = acptr->from->fd)] != sentalong_marker) + { + sentalong[i] = sentalong_marker; + vsendto_prefix_one(acptr, from, pattern, vl); + } + } + va_end(vl); + return; +}