Rework update_user_mode()

This commit is contained in:
Kevin Easton
2017-12-04 17:43:47 +11:00
parent 7642e741b9
commit c4ba093ca5
3 changed files with 23 additions and 29 deletions

View File

@@ -29,6 +29,6 @@
void funny_list (char *, char **);
void funny_mode (char *, char **);
void funny_namreply (char *, char **);
void update_user_mode (char *);
void update_user_mode (int, const char *);
#endif /* FUNNY_H_ */

View File

@@ -408,40 +408,34 @@ void funny_mode(char *from, char **ArgList)
}
}
void update_user_mode(char *modes)
void update_user_mode(int server, const char *modes)
{
int onoff = 1;
char *p_umodes = get_possible_umodes(from_server);
const char *p_umodes = get_possible_umodes(server);
const char *p;
for (; *modes; modes++)
{
if (*modes == '-')
onoff = 0;
else if (*modes == '+')
onoff = 1;
char c = *modes;
else if ((*modes >= 'a' && *modes <= 'z')
|| (*modes >= 'A' && *modes <= 'Z'))
switch (c)
{
size_t idx;
int c = *modes;
idx = ccspan(p_umodes, c);
if (p_umodes[idx] == 0)
ircpanic("Invalid user mode referenced");
set_server_flag(from_server, idx, onoff);
if (c == 'o' || c == 'O')
set_server_operator(from_server, onoff);
#if 0
char c = tolower(*modes);
size_t idx = (size_t) (strchr(umodes, c) - umodes);
set_server_flag(from_server, USER_MODE << idx, onoff);
if (c == 'o' || c == 'O')
set_server_operator(from_server, onoff);
#endif
case '-':
onoff = 0;
break;
case '+':
onoff = 1;
break;
case 'o':
case 'O':
set_server_operator(server, onoff);
/* fallthrough */
default:
p = strchr(p_umodes, c);
if (p)
set_server_flag(server, p - p_umodes, onoff);
else
yell("Ignoring invalid user mode '%c' from server", c);
}
}
}

View File

@@ -1536,7 +1536,7 @@ static void p_mode(char *from, char **ArgList)
put_it("%s", convert_output_format(fget_string_var(fset), "%s %s %s %s %s", update_clock(GET_TIME), from, display_uh, target, line));
}
if (!my_stricmp(target, get_server_nickname(from_server)))
update_user_mode(line);
update_user_mode(from_server, line);
logmsg(LOG_MODE_USER, from, 0, "%s %s", target, line);
}
update_all_status(current_window, NULL, 0);