1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-06-29 23:36:38 +02:00

De-duplicate code. Make sendto_serv_butone_nickcmd() use sendto_one_nickcmd(). Fixes bug reported by Adam.

This commit is contained in:
Bram Matthys
2015-09-12 11:16:02 +02:00
parent af88bc7e19
commit 69a121278f
3 changed files with 23 additions and 44 deletions
+1 -3
View File
@@ -255,9 +255,7 @@ extern void *MyMallocEx(size_t size);
extern int advanced_check(char *userhost, int ipstat);
extern int send_queued(aClient *);
extern void sendto_connectnotice(aClient *sptr, int disconnect, char *comment);
extern void sendto_serv_butone_nickcmd(aClient *one, aClient *sptr, char *nick, int hopcount,
long lastnick, char *username, char *realhost, char *server, char *svid, char *info, char *umodes,
char *virthost);
extern void sendto_serv_butone_nickcmd(aClient *one, aClient *sptr, char *umodes);
extern void sendto_message_one(aClient *to, aClient *from, char *sender,
char *cmd, char *nick, char *msg);
#define PREFIX_ALL 0
+1 -5
View File
@@ -1517,11 +1517,7 @@ int _register_user(aClient *cptr, aClient *sptr, char *nick, char *username, cha
send_umode(NULL, sptr, 0, SEND_UMODES|UMODE_SERVNOTICE, buf);
/* NICKv2 Servers ! */
sendto_serv_butone_nickcmd(cptr, sptr, nick,
sptr->hopcount + 1, sptr->lastnick, user->username, user->realhost,
user->server, user->svid, sptr->info,
(*buf == '\0' ? "+" : buf),
sptr->umodes & UMODE_SETHOST ? sptr->user->virthost : NULL);
sendto_serv_butone_nickcmd(cptr, sptr, (*buf == '\0' ? "+" : buf));
if (MyConnect(sptr))
{
+21 -36
View File
@@ -1270,51 +1270,36 @@ void sendto_fconnectnotice(aClient *acptr, int disconnect, char *comment)
}
}
/*
* sendto_server_butone_nickcmd
*
* Send a message to all connected servers except the client 'one'.
/** Introduce user to NICKv2-capable and SID-capable servers.
* @param cptr Server to skip
* @param sptr Client to introduce
* @param umodes User modes of client
*/
void sendto_serv_butone_nickcmd(aClient *one, aClient *sptr,
char *nick, int hopcount,
long lastnick, char *username, char *realhost, char *server,
char *svid, char *info, char *umodes, char *virthost)
void sendto_serv_butone_nickcmd(aClient *one, aClient *sptr, char *umodes)
{
aClient *cptr;
char *vhost;
if (!*umodes)
if (BadPtr(umodes))
umodes = "+";
if (IsHidden(sptr))
vhost = sptr->user->virthost;
else
vhost = sptr->user->realhost;
if (*sptr->id)
list_for_each_entry(cptr, &server_list, special_node)
{
sendto_server(one, PROTO_SID, 0,
":%s UID %s %d %ld %s %s %s %s %s %s %s %s :%s",
sptr->srvptr->id, nick, hopcount, lastnick, username,
realhost, sptr->id, svid, umodes, vhost, getcloak(sptr),
encode_ip(sptr->ip), info);
}
va_list vl;
/* Hmmm this code had PROTO_NICKv2|PROTO_VHP as 2nd argument which
* caused NICK messages not to be sent to non-SID servers.
* I removed PROTO_VHP here seeing nenolod already ripped out the
* SupportVHP() check ~20 lines up. Double check if this is OK?
*/
sendto_server(one, PROTO_NICKv2, *sptr->id ? PROTO_SID : 0,
"NICK %s %d %ld %s %s %s %s %s %s %s %s :%s",
nick, hopcount, lastnick, username,
realhost, server, svid, umodes, vhost, getcloak(sptr),
encode_ip(sptr->ip), info);
if (one && cptr == one->from)
continue;
if (!CHECKPROTO(cptr, PROTO_SID) && !CHECKPROTO(cptr, PROTO_NICKv2))
continue;
sendto_one_nickcmd(cptr, sptr, umodes);
}
}
/*
* sendto_one_nickcmd
*
/** Introduce user to NICKv2-capable and SID-capable servers.
* @param cptr Server to send to (locally connected!)
* @param sptr Client to introduce
* @param umodes User modes of client
*/
void sendto_one_nickcmd(aClient *cptr, aClient *sptr, char *umodes)
{