make sure all ways to join a channel trigger a namesreply

This commit is contained in:
pandaemonium 2007-08-05 17:56:45 +00:00
parent 15fafea294
commit 46482992c4
4 changed files with 54 additions and 39 deletions

View file

@ -795,8 +795,6 @@ static int _handle_join_command(t_connection * conn, int numparams, char ** para
irc_send(conn,RPL_NOTOPIC,":No topic is set");
irc_send_rpl_namreply(conn,channel);
irc_send(conn,RPL_ENDOFNAMES,":End of NAMES list");
}
}
}

View file

@ -880,10 +880,10 @@ static int _handle_quit_command(t_connection * conn, int numparams, char ** para
static int _handle_part_command(t_connection * conn, int numparams, char ** params, char * text)
{
if ((conn_wol_get_ingame(conn) == 1)) {
conn_wol_set_ingame(conn,0);
if ((conn_wol_get_ingame(conn) == 1)) {
conn_wol_set_ingame(conn,0);
}
conn_set_channel(conn, NULL); /* In WOL we disconecting from the channel */
conn_set_channel(conn, NULL);
return 0;
}
@ -1304,10 +1304,6 @@ static int _handle_joingame_command(t_connection * conn, int numparams, char **
irc_send_rpl_namreply(conn,channel);
if ((std::strlen(wolname)+1+std::strlen(":End of NAMES list")+1)<MAX_IRC_MESSAGE_LEN) {
snprintf(temp, sizeof(temp), "%s :End of NAMES list",wolname);
irc_send(conn,RPL_ENDOFNAMES,temp);
}
}
else {
irc_send(conn,ERR_NOSUCHCHANNEL,":JOINGAME failed");
@ -1390,10 +1386,6 @@ static int _handle_joingame_command(t_connection * conn, int numparams, char **
irc_send_rpl_namreply(conn,channel);
if ((std::strlen(wolname)+1+std::strlen(":End of NAMES list")+1)<MAX_IRC_MESSAGE_LEN) {
snprintf(temp, sizeof(temp), "%s :End of NAMES list", wolname);
irc_send(conn,RPL_ENDOFNAMES,temp);
}
}
}
if (old_channel_name) xfree((void *)old_channel_name);

View file

@ -681,6 +681,7 @@ extern int irc_message_format(t_packet * packet, t_message_type type, t_connecti
else
msg = irc_message_preformat(&from,"JOIN","\r",irc_convert_channel(channel));
conn_unget_chatname(me,from.nick);
irc_send_rpl_namreply(me,channel);
break;
}
else
@ -879,21 +880,17 @@ extern int irc_message_format(t_packet * packet, t_message_type type, t_connecti
return -1;
}
extern int irc_send_rpl_namreply(t_connection * c, t_channel const * channel)
{
int irc_send_rpl_namreply_internal(t_connection * c, t_channel const * channel){
char temp[MAX_IRC_MESSAGE_LEN];
char const * ircname;
int first = 1;
t_connection * m;
if (!c) {
eventlog(eventlog_level_error,__FUNCTION__,"got NULL connection");
return -1;
}
if (!channel) {
eventlog(eventlog_level_error,__FUNCTION__,"got NULL channel");
eventlog(eventlog_level_error,__FUNCTION__,"got NULL channel");
return -1;
}
std::memset(temp,0,sizeof(temp));
ircname = irc_convert_channel(channel);
if (!ircname) {
@ -958,6 +955,37 @@ extern int irc_send_rpl_namreply(t_connection * c, t_channel const * channel)
conn_unget_chatname(m,name);
}
irc_send(c,RPL_NAMREPLY,temp);
}
extern int irc_send_rpl_namreply(t_connection * c, t_channel const * channel)
{
char temp[MAX_IRC_MESSAGE_LEN];
char const * ircname;
if (!c) {
eventlog(eventlog_level_error,__FUNCTION__,"got NULL connection");
return -1;
}
if (channel) {
ircname = irc_convert_channel(channel);
if (!ircname) {
eventlog(eventlog_level_error,__FUNCTION__,"channel has NULL ircname");
return -1;
}
irc_send_rpl_namreply_internal(c, channel);
std:sprintf(temp, "%32s :End of NAMES list", ircname);
} else {
t_elem const * curr;
LIST_TRAVERSE_CONST(channellist(),curr)
{
channel = (t_channel*)elem_get_data(curr);
irc_send_rpl_namreply_internal(c, channel);
}
std::sprintf(temp, "* :End of NAMES list", ircname);
}
irc_send(c, RPL_ENDOFNAMES, temp);
return 0;
}
@ -1211,25 +1239,12 @@ extern int _handle_names_command(t_connection * conn, int numparams, char ** par
if (!channel)
continue; /* channel doesn't exist */
irc_send_rpl_namreply(conn,channel);
ircname=irc_convert_channel(channel);
if ((std::strlen(ircname)+1+std::strlen(":End of NAMES list")+1)<MAX_IRC_MESSAGE_LEN) {
snprintf(temp, sizeof(temp), "%s :End of NAMES list",ircname);
irc_send(conn,RPL_ENDOFNAMES,temp);
}
else
irc_send(conn,RPL_ENDOFNAMES,":End of NAMES list");
}
if (e)
irc_unget_listelems(e);
}
else if (numparams==0) {
t_elem const * curr;
LIST_TRAVERSE_CONST(channellist(),curr)
{
channel = (t_channel*)elem_get_data(curr);
irc_send_rpl_namreply(conn,channel);
}
irc_send(conn,RPL_ENDOFNAMES,"* :End of NAMES list");
irc_send_rpl_namreply(conn, NULL);
}
return 0;
}

View file

@ -344,7 +344,9 @@ static int message_telnet_format(t_packet * packet, t_message_type type, t_conne
eventlog(eventlog_level_error,__FUNCTION__,"got NULL connection for %s",message_type_get_str(type));
return -1;
}
if (me!=dst)
if (me==dst)
return -1;
else
{
char const * tname;
@ -721,7 +723,9 @@ static int message_bot_format(t_packet * packet, t_message_type type, t_connecti
eventlog(eventlog_level_error,__FUNCTION__,"got NULL connection for %s",message_type_get_str(type));
return -1;
}
if (me!=dst)
if (me==dst)
return -1;
else
{
char const * tname;
@ -737,7 +741,9 @@ static int message_bot_format(t_packet * packet, t_message_type type, t_connecti
eventlog(eventlog_level_error,__FUNCTION__,"got NULL connection for %s",message_type_get_str(type));
return -1;
}
if (me!=dst)
if (me==dst)
return -1;
else
{
char const * tname;
@ -987,7 +993,9 @@ static int message_bnet_format(t_packet * packet, t_message_type type, t_connect
bn_int_set(&packet->u.server_message.type,SERVER_MESSAGE_TYPE_JOIN);
bn_int_set(&packet->u.server_message.flags,conn_get_flags(me)|dstflags);
bn_int_set(&packet->u.server_message.latency,conn_get_latency(me));
if (me!=dst)
if (me==dst)
return -1;
else
{
char const * tname;
char const * playerinfo;
@ -1013,7 +1021,9 @@ static int message_bnet_format(t_packet * packet, t_message_type type, t_connect
bn_int_set(&packet->u.server_message.type,SERVER_MESSAGE_TYPE_PART);
bn_int_set(&packet->u.server_message.flags,conn_get_flags(me)|dstflags);
bn_int_set(&packet->u.server_message.latency,conn_get_latency(me));
if (me!=dst)
if (me==dst)
return -1;
else
{
char const * tname;