Cleanup remove_channel()

remove_channel() is only called in direct response to a message from a server,
so it always acts on from_server - remove the unnecessary server argument.

The channel argument is always non-NULL - remove the dead code that removed all
channels if a NULL channel was passed.
This commit is contained in:
Kevin Easton
2017-04-16 16:19:55 +10:00
parent 53f3a34ca5
commit 1ccd082cd2
5 changed files with 23 additions and 41 deletions

View File

@@ -427,7 +427,7 @@ extern Function_ptr *global;
#define get_channel_bans (*(char *(*)(char *, int , int ))global[GET_CHANNEL_BANS])
#define get_channel_mode (*(char *(*)(char *, int ))global[GET_CHANNEL_MODE])
#define clear_bans (*(void (*)(ChannelList *))global[CLEAR_BANS])
#define remove_channel (*(void (*)(char *, int ))global[REMOVE_CHANNEL])
#define remove_channel (*(void (*)(const char *))global[REMOVE_CHANNEL])
#define remove_from_channel (*(void (*)(char *, char *, int , int , char *))global[REMOVE_FROM_CHANNEL])
#define rename_nick (*(void (*)(char *, char *, int ))global[RENAME_NICK])
#define get_channel_oper (*(int (*)(char *, int ))global[GET_CHANNEL_OPER])

View File

@@ -61,7 +61,7 @@ void set_channel_mode (char *, int, char *);
#endif /* INCLUDE_UNUSED_FUNCTIONS */
ChannelList * BX_add_channel (char *, int, int);
ChannelList * BX_add_to_channel (char *, char *, int, int, int, char *, char *, char *, int, int);
void BX_remove_channel (char *, int);
void BX_remove_channel (const char *);
void BX_remove_from_channel (char *, char *, int, int, char *);
int BX_is_on_channel (char *, int, char *);
void list_channels (void);

View File

@@ -1207,48 +1207,30 @@ void BX_clear_bans(ChannelList *channel)
channel->exemptbans = NULL;
}
/*
* remove_channel: removes the named channel from the
* server_list[server].chan_list. If the channel is not on the
* server_list[server].chan_list, nothing happens. If the channel was
* the current channel, this will select the top of the
* server_list[server].chan_list to be the current_channel, or 0 if the
* list is empty.
/* remove_channel()
*
* Removes the named channel from the channel list for the current context
* server. If the channel was the current channel for a window, this will
* select a new current channel if possible.
*
* Should be called in direct response to a message from the server indicating
* that we are no longer on the channel.
*/
void BX_remove_channel (char *channel, int server)
void BX_remove_channel(const char *channel)
{
ChannelList *tmp;
int old_from_server = from_server;
if (channel)
{
if (*channel == '*')
return;
from_server = server;
from_server = old_from_server;
if ((tmp = lookup_channel(channel, server, CHAN_UNLINK)))
if ((tmp = lookup_channel(channel, from_server, CHAN_UNLINK)))
{
clear_bans(tmp);
clear_channel(tmp);
add_to_whowas_chan_buffer(tmp);
}
if (is_current_channel(channel, server, 1))
if (is_current_channel(channel, from_server, 1))
switch_channels(0, NULL);
}
else
{
ChannelList *next;
for (tmp = get_server_channels(server); tmp; tmp = next)
{
next = tmp->next;
clear_channel(tmp);
clear_bans(tmp);
add_to_whowas_chan_buffer(tmp);
}
set_server_channels(server, NULL);
}
xterm_settitle();
update_all_windows();
}

View File

@@ -316,7 +316,7 @@ static void not_valid_channel(char *from, char **ArgList)
if (!my_stricmp(from, get_server_itsname(from_server)))
{
if (strcmp(channel, "*"))
remove_channel(channel, from_server);
remove_channel(channel);
put_it("%s", convert_output_format(fget_string_var(FORMAT_SERVER_MSG2_FSET), "%s %s %s", update_clock(GET_TIME), channel, ArgList[1]));
}
}
@@ -343,7 +343,7 @@ static void cannot_join_channel(char *from, char **ArgList)
remove_from_join_list(chan, from_server);
if (!is_on_channel(chan, from_server, get_server_nickname(from_server)))
remove_channel(chan, from_server);
remove_channel(chan);
else
return;

View File

@@ -1719,7 +1719,7 @@ static void p_kick(char *from, char **ArgList)
new_free(&chankey);
if (do_hook(KICK_LIST, "%s %s %s %s", who, from, channel, comment?comment:empty_string))
put_it("%s",convert_output_format(fget_string_var(FORMAT_KICK_USER_FSET),"%s %s %s %s %s",update_clock(GET_TIME),from, channel, who, comment));
remove_channel(channel, from_server);
remove_channel(channel);
update_all_status(window ? window : current_window, NULL, 0);
update_input(UPDATE_ALL);
logmsg(LOG_KICK_USER, from, 0, "%s %s %s %s", FromUserHost, who, channel, comment);
@@ -1784,7 +1784,7 @@ static void p_part(char *from, char **ArgList)
put_it("%s",convert_output_format(fget_string_var(FORMAT_LEAVE_FSET), "%s %s %s %s %s", update_clock(GET_TIME), from, FromUserHost, channel, ArgList[1]?ArgList[1]:empty_string));
if (!my_stricmp(from, get_server_nickname(from_server)))
{
remove_channel(channel, from_server);
remove_channel(channel);
remove_from_mode_list(channel, from_server);
remove_from_join_list(channel, from_server);
set_input_prompt(current_window, get_string_var(INPUT_PROMPT_VAR), 0);