From 19cc5798002c7bf7003cab336d1540c1745ec285 Mon Sep 17 00:00:00 2001 From: MadCamel Date: Fri, 5 Feb 2010 01:15:27 -0500 Subject: Spellcasting will no longer trigger spam bans I ran this by fate and he had no objections. If there are problems with flooding/resource consumption we can put some rate limits in the packet handlers. (That's on my TODO) --- src/map/clif.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/src/map/clif.c b/src/map/clif.c index 86be79c..a09b929 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -7145,43 +7145,34 @@ void clif_parse_GetCharNameRequest (int fd, struct map_session_data *sd) */ void clif_parse_GlobalMessage (int fd, struct map_session_data *sd) { // S 008c .w .?B - int malformed = 0; - nullpo_retv (sd); - if ((is_atcommand (fd, sd, RFIFOP (fd, 4), 0) != AtCommand_None) || (sd->sc_data && (sd->sc_data[SC_BERSERK].timer != -1 || //�o�[�T�[�N���͉��b���s�� - sd->sc_data[SC_NOCHAT].timer != -1))) //�`���b�g�֎~ - { + if ((is_atcommand (fd, sd, RFIFOP (fd, 4), 0) != AtCommand_None) || (sd->sc_data && (sd->sc_data[SC_BERSERK].timer != -1 || + sd->sc_data[SC_NOCHAT].timer != -1))) return; - } if (strlen (RFIFOP (fd, 4)) >= battle_config.chat_maxline) - malformed = 1; + return; // Simply ignore messages with spoofed/incorrect source names. if (strncmp (RFIFOP (fd, 4), sd->status.name, strlen (sd->status.name)) != 0) - malformed = 1; + return; char *buf = (char *) malloc (RFIFOW (fd, 2) + 4); int msg_len = RFIFOW (fd, 2) + 4; // len of message - 4 + 8 + // Prepare to send message to others WBUFW (buf, 0) = 0x8d; WBUFW (buf, 2) = msg_len; WBUFL (buf, 4) = sd->bl.id; memcpy (WBUFP (buf, 8), RFIFOP (fd, 4), RFIFOW (fd, 2) - 4); - - if (malformed || !magic_message (sd, buf, msg_len)) + + if (magic_message(sd, buf, msg_len) == 0) { if (tmw_CheckChatSpam (sd, RFIFOP (fd, 4))) return; - if (malformed) - { - free (buf); - return; - } - clif_send (buf, WBUFW (buf, 2), &sd->bl, sd->chatID ? CHAT_WOS : AREA_CHAT_WOC); } -- cgit v1.2.3-60-g2f50