Remove 'type' argument of flood_prot()
All callers of flood_prot() were supplying { get_flood_types(flood_type), flood_type } as the second and third arguments,
except one that supplied { get_flood_types(CTCP_FLOOD), CTCP_ACTION_FLOOD }.
Hardwiring this logic in to flood_prot() lets us remove the 'type' argument without changing the behaviour.
This commit is contained in:
@@ -7,10 +7,10 @@
|
|||||||
#ifndef __flood_h_
|
#ifndef __flood_h_
|
||||||
#define __flood_h_
|
#define __flood_h_
|
||||||
|
|
||||||
int BX_check_flooding (char *, int, char *, char *);
|
int BX_check_flooding(char *, int, char *, char *);
|
||||||
int BX_is_other_flood (ChannelList *, NickList *, int, int *);
|
int BX_is_other_flood(ChannelList *, NickList *, int, int *);
|
||||||
int BX_flood_prot (char *, char *, char *, int, int, char *);
|
int BX_flood_prot(char *nick, char *userhost, int flood_type, int ignoretime, char *channel);
|
||||||
void clean_flood_list (void);
|
void clean_flood_list(void);
|
||||||
|
|
||||||
#define MSG_FLOOD 0x0001
|
#define MSG_FLOOD 0x0001
|
||||||
#define PUBLIC_FLOOD 0x0002
|
#define PUBLIC_FLOOD 0x0002
|
||||||
|
|||||||
@@ -596,7 +596,7 @@ extern Function_ptr *global;
|
|||||||
/* flood.c */
|
/* flood.c */
|
||||||
#define is_other_flood (*(int (*)(ChannelList *, NickList *, int, int *))global[IS_OTHER_FLOOD])
|
#define is_other_flood (*(int (*)(ChannelList *, NickList *, int, int *))global[IS_OTHER_FLOOD])
|
||||||
#define check_flooding (*(int (*)(char *, int , char *, char *))global[CHECK_FLOODING])
|
#define check_flooding (*(int (*)(char *, int , char *, char *))global[CHECK_FLOODING])
|
||||||
#define flood_prot (*(int (*)(char *, char *, char *, int , int , char *))global[FLOOD_PROT])
|
#define flood_prot (*(int (*)(char *, char *, int , int , char *))global[FLOOD_PROT])
|
||||||
|
|
||||||
/* expr.c */
|
/* expr.c */
|
||||||
#define next_unit (*(char *(*)(char *, const char *, int *, int ))global[NEXT_UNIT])
|
#define next_unit (*(char *(*)(char *, const char *, int *, int ))global[NEXT_UNIT])
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ extern int from_server;
|
|||||||
#define NO_RESET 0
|
#define NO_RESET 0
|
||||||
#define RESET 1
|
#define RESET 1
|
||||||
|
|
||||||
char *get_flood_types(unsigned int type)
|
static char *get_flood_types(unsigned int type)
|
||||||
{
|
{
|
||||||
int x = 0;
|
int x = 0;
|
||||||
while (type)
|
while (type)
|
||||||
@@ -440,13 +440,11 @@ int BX_check_flooding(char *nick, int type, char *line, char *channel)
|
|||||||
case NOTICE_FLOOD:
|
case NOTICE_FLOOD:
|
||||||
case CDCC_FLOOD:
|
case CDCC_FLOOD:
|
||||||
case CTCP_FLOOD:
|
case CTCP_FLOOD:
|
||||||
if (flood_prot(nick, FromUserHost, get_flood_types(type), type, get_int_var(IGNORE_TIME_VAR), channel))
|
case CTCP_ACTION_FLOOD:
|
||||||
|
if (flood_prot(nick, FromUserHost, type, get_int_var(IGNORE_TIME_VAR), channel))
|
||||||
return 0;
|
return 0;
|
||||||
break;
|
break;
|
||||||
case CTCP_ACTION_FLOOD:
|
default: /* INVITE_FLOOD and WALLOP_FLOOD - not clear if this is intentional */
|
||||||
if (flood_prot(nick, FromUserHost, get_flood_types(CTCP_FLOOD), type, get_int_var(IGNORE_TIME_VAR), channel))
|
|
||||||
return 0;
|
|
||||||
default:
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (get_int_var(FLOOD_WARNING_VAR))
|
if (get_int_var(FLOOD_WARNING_VAR))
|
||||||
@@ -489,22 +487,23 @@ ChannelList *chan = NULL;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int BX_flood_prot (char *nick, char *userhost, char *type, int ctcp_type, int ignoretime, char *channel)
|
int BX_flood_prot(char *nick, char *userhost, int flood_type, int ignoretime, char *channel)
|
||||||
{
|
{
|
||||||
ChannelList *chan;
|
ChannelList *chan;
|
||||||
NickList *Nick;
|
NickList *Nick;
|
||||||
char tmp[BIG_BUFFER_SIZE+1];
|
char tmp[BIG_BUFFER_SIZE+1];
|
||||||
char *uh;
|
char *uh;
|
||||||
int old_window_display;
|
int old_window_display;
|
||||||
int kick_on_flood = 1;
|
int kick_on_flood = 1;
|
||||||
|
char *type = get_flood_types(flood_type);
|
||||||
|
|
||||||
if ((ctcp_type == CDCC_FLOOD || ctcp_type == CTCP_FLOOD || ctcp_type == CTCP_ACTION_FLOOD) && !get_int_var(CTCP_FLOOD_PROTECTION_VAR))
|
if ((flood_type == CDCC_FLOOD || flood_type == CTCP_FLOOD || flood_type == CTCP_ACTION_FLOOD) && !get_int_var(CTCP_FLOOD_PROTECTION_VAR))
|
||||||
return 0;
|
return 0;
|
||||||
else if (!get_int_var(FLOOD_PROTECTION_VAR))
|
else if (!get_int_var(FLOOD_PROTECTION_VAR))
|
||||||
return 0;
|
return 0;
|
||||||
else if (!my_stricmp(nick, get_server_nickname(from_server)))
|
else if (!my_stricmp(nick, get_server_nickname(from_server)))
|
||||||
return 0;
|
return 0;
|
||||||
switch (ctcp_type)
|
switch (flood_type)
|
||||||
{
|
{
|
||||||
case WALL_FLOOD:
|
case WALL_FLOOD:
|
||||||
case MSG_FLOOD:
|
case MSG_FLOOD:
|
||||||
@@ -549,7 +548,7 @@ int kick_on_flood = 1;
|
|||||||
snprintf(tmp, sizeof tmp, "*!*%s", uh);
|
snprintf(tmp, sizeof tmp, "*!*%s", uh);
|
||||||
old_window_display = window_display;
|
old_window_display = window_display;
|
||||||
window_display = 0;
|
window_display = 0;
|
||||||
ignore_nickname(tmp, ignore_type(type, strlen(type)), 0);
|
ignore_nickname(tmp, flood_type == CTCP_ACTION_FLOOD ? IGNORE_CTCPS : ignore_type(type, strlen(type)), 0);
|
||||||
window_display = old_window_display;
|
window_display = old_window_display;
|
||||||
snprintf(tmp, sizeof tmp, "%d ^IGNORE *!*%s NONE", ignoretime, uh);
|
snprintf(tmp, sizeof tmp, "%d ^IGNORE *!*%s NONE", ignoretime, uh);
|
||||||
timercmd("TIMER", tmp, NULL, NULL);
|
timercmd("TIMER", tmp, NULL, NULL);
|
||||||
|
|||||||
@@ -607,7 +607,7 @@ static void p_privmsg(char *from, char **Args)
|
|||||||
if (is_other_flood(channel, tmpnick, PUBLIC_FLOOD, &blah))
|
if (is_other_flood(channel, tmpnick, PUBLIC_FLOOD, &blah))
|
||||||
{
|
{
|
||||||
no_flood = 0;
|
no_flood = 0;
|
||||||
flood_prot(tmpnick->nick, FromUserHost, "PUBLIC", flood_type, get_cset_int_var(channel->csets, PUBFLOOD_IGNORE_TIME_CSET), channel->channel);
|
flood_prot(tmpnick->nick, FromUserHost, flood_type, get_cset_int_var(channel->csets, PUBFLOOD_IGNORE_TIME_CSET), channel->channel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user