From 1b7508c510aae8906fdcd7309da47c97b2804184 Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Thu, 13 Aug 2009 13:48:30 -0600 Subject: Change sending of hair style and color Send them together in overloaded change looks packets (twice for older clients). This lets newer clients be more flexible with their handling of hair. --- src/map/clif.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/map/clif.c') diff --git a/src/map/clif.c b/src/map/clif.c index 908e9ff..e734efe 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -2388,6 +2388,35 @@ int clif_changelook_towards(struct block_list *bl,int type,int val, struct map_s return 0; } +int clif_changehair(struct block_list *bl, int hairStyle, int hairColor) +{ + unsigned char buf[32]; + struct map_session_data *sd = NULL; + + nullpo_retr(0, bl); + + if(bl->type == BL_PC) + sd = (struct map_session_data *)bl; + + if(sd && sd->disguise > 23 && sd->disguise < 4001) // mob disguises [Valaris] + return 0; + + if (sd && sd->status.option & OPTION_INVISIBILITY) + return 0; + + WBUFW(buf,0)=0x1d7; + WBUFL(buf,2)=bl->id; + WBUFB(buf,6)=LOOK_HAIR; + WBUFW(buf,7)=hairStyle; + WBUFW(buf,9)=hairColor; + clif_send(buf, packet_len_table[0x1d7], bl, AREA); + + WBUFB(buf,6)=LOOK_HAIR_COLOR; + WBUFW(buf,7)=hairColor; + WBUFW(buf,9)=hairStyle; + clif_send(buf, packet_len_table[0x1d7], bl, AREA); +} + /*========================================== * *------------------------------------------ -- cgit v1.2.3-70-g09d2 From 70faeb3733a9a5c39acb75c2c8765e8c2acd1dd5 Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Fri, 14 Aug 2009 08:39:50 -0600 Subject: Revert "Change sending of hair style and color" This reverts commit 1b7508c510aae8906fdcd7309da47c97b2804184. After talking on IRC, this change is no longer needed. --- src/map/clif.c | 29 ----------------------------- src/map/clif.h | 1 - src/map/pc.c | 6 +----- 3 files changed, 1 insertion(+), 35 deletions(-) (limited to 'src/map/clif.c') diff --git a/src/map/clif.c b/src/map/clif.c index e734efe..908e9ff 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -2388,35 +2388,6 @@ int clif_changelook_towards(struct block_list *bl,int type,int val, struct map_s return 0; } -int clif_changehair(struct block_list *bl, int hairStyle, int hairColor) -{ - unsigned char buf[32]; - struct map_session_data *sd = NULL; - - nullpo_retr(0, bl); - - if(bl->type == BL_PC) - sd = (struct map_session_data *)bl; - - if(sd && sd->disguise > 23 && sd->disguise < 4001) // mob disguises [Valaris] - return 0; - - if (sd && sd->status.option & OPTION_INVISIBILITY) - return 0; - - WBUFW(buf,0)=0x1d7; - WBUFL(buf,2)=bl->id; - WBUFB(buf,6)=LOOK_HAIR; - WBUFW(buf,7)=hairStyle; - WBUFW(buf,9)=hairColor; - clif_send(buf, packet_len_table[0x1d7], bl, AREA); - - WBUFB(buf,6)=LOOK_HAIR_COLOR; - WBUFW(buf,7)=hairColor; - WBUFW(buf,9)=hairStyle; - clif_send(buf, packet_len_table[0x1d7], bl, AREA); -} - /*========================================== * *------------------------------------------ diff --git a/src/map/clif.h b/src/map/clif.h index 0816093..198bbff 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -63,7 +63,6 @@ int clif_damage(struct block_list *,struct block_list *,unsigned int,int,int,int #define clif_takeitem(src,dst) clif_damage(src,dst,0,0,0,0,0,1,0) int clif_changelook(struct block_list *,int,int); // area int clif_changelook_towards(struct block_list *,int,int, struct map_session_data *dst); // area or target -int clif_changehair(struct block_list *,int,int); void clif_changelook_accessories(struct block_list *bl, struct map_session_data *dst); // area or target; list gloves, boots etc. int clif_arrowequip(struct map_session_data *sd,int val); //self int clif_arrow_fail(struct map_session_data *sd,int type); //self diff --git a/src/map/pc.c b/src/map/pc.c index 1310743..e0b4c89 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -5763,11 +5763,7 @@ int pc_changelook(struct map_session_data *sd,int type,int val) case LOOK_SHOES: break; } - - if (type == LOOK_HAIR || type == LOOK_HAIR_COLOR) - clif_changehair(&sd->bl,sd->status.hair,sd->status.hair_color); - else - clif_changelook(&sd->bl,type,val); + clif_changelook(&sd->bl,type,val); return 0; } -- cgit v1.2.3-70-g09d2 From 4fcb38d69d1b61cc79b6b9af06918e5c228b242b Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Sun, 16 Aug 2009 09:57:14 -0600 Subject: Send GM flag to clients --- src/map/clif.c | 6 ++---- src/map/pc.c | 3 +++ 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'src/map/clif.c') diff --git a/src/map/clif.c b/src/map/clif.c index 908e9ff..050c1c9 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -756,8 +756,7 @@ static int clif_set0078(struct map_session_data *sd, unsigned char *buf) { WBUFB(buf,45)=sd->sex; WBUFPOS(buf,46,sd->bl.x,sd->bl.y); WBUFB(buf,48)|=sd->dir&0x0f; - WBUFB(buf,49)=5; - WBUFB(buf,50)=5; + WBUFW(buf,49)=pc_isGM(sd) >= 60 ? 0x80 : 0; WBUFB(buf,51)=sd->state.dead_sit; WBUFW(buf,52)=((level = battle_get_lv(&sd->bl)) > battle_config.max_lv) ? battle_config.max_lv : level; @@ -830,8 +829,7 @@ static int clif_set007b(struct map_session_data *sd,unsigned char *buf) { WBUFB(buf,48)=sd->status.karma; WBUFB(buf,49)=sd->sex; WBUFPOS2(buf,50,sd->bl.x,sd->bl.y,sd->to_x,sd->to_y); - WBUFB(buf,55)=0; - WBUFB(buf,56)=5; + WBUFW(buf,55)=pc_isGM(sd) >= 60 ? 0x80 : 0; WBUFB(buf,57)=5; WBUFW(buf,58)=(sd->status.base_level>battle_config.max_lv)?battle_config.max_lv:sd->status.base_level; diff --git a/src/map/pc.c b/src/map/pc.c index e0b4c89..7aec359 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -790,7 +790,10 @@ int pc_authok(int id, int login_id2, time_t connect_until_time, short tmw_versio pc_calcstatus(sd,1); if (pc_isGM(sd)) + { printf("Connection accepted: character '%s' (account: %d; GM level %d).\n", sd->status.name, sd->status.account_id, pc_isGM(sd)); + clif_updatestatus(sd, SP_GM); + } else printf("Connection accepted: Character '%s' (account: %d).\n", sd->status.name, sd->status.account_id); -- cgit v1.2.3-70-g09d2 From d54b91582b6f8ba1a2c26411dd122d80930f3b02 Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Sun, 16 Aug 2009 11:07:10 -0600 Subject: Adjust auto ban code and add sit spam handling All three ban types can now either ban or just ingore new packets. Trade and sit spam default to ignore. Chat spam defaults to 1hr ban. --- src/map/battle.c | 35 ++++++++++++++++++++++++++++++++--- src/map/battle.h | 5 +++++ src/map/clif.c | 11 ++++++++--- src/map/map.h | 3 +++ src/map/pc.c | 2 ++ src/map/tmw.c | 43 +++++++++++++++++++++++++++++++++++++++++-- src/map/tmw.h | 1 + 7 files changed, 92 insertions(+), 8 deletions(-) (limited to 'src/map/clif.c') diff --git a/src/map/battle.c b/src/map/battle.c index c9f1b59..c21d69c 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -4524,8 +4524,13 @@ int battle_config_read(const char *cfgName) battle_config.trade_spam_threshold = 10; battle_config.trade_spam_flood = 10; - battle_config.trade_spam_ban = 1; + battle_config.trade_spam_ban = 0; battle_config.trade_spam_warn = 8; + + battle_config.sit_spam_threshold = 1; + battle_config.sit_spam_flood = 15; + battle_config.sit_spam_ban = 0; + battle_config.sit_spam_warn = 3; } fp = fopen_(cfgName,"r"); @@ -4737,7 +4742,11 @@ int battle_config_read(const char *cfgName) { "trade_spam_threshold", &battle_config.trade_spam_threshold }, { "trade_spam_flood", &battle_config.trade_spam_flood }, { "trade_spam_ban", &battle_config.trade_spam_ban }, - { "trade_spam_warn", &battle_config.trade_spam_warn } + { "trade_spam_warn", &battle_config.trade_spam_warn }, + { "sit_spam_threshold", &battle_config.sit_spam_threshold }, + { "sit_spam_flood", &battle_config.sit_spam_flood }, + { "sit_spam_ban", &battle_config.sit_spam_ban }, + { "sit_spam_warn", &battle_config.sit_spam_warn } }; if (line[0] == '/' && line[1] == '/') @@ -4896,7 +4905,27 @@ int battle_config_read(const char *cfgName) if (battle_config.trade_spam_threshold < 0) battle_config.trade_spam_threshold = 0; else if (battle_config.trade_spam_threshold > 32767) - battle_config.trade_spam_threshold = 32767; + battle_config.trade_spam_threshold = 32767; + + if (battle_config.sit_spam_ban < 0) + battle_config.sit_spam_ban = 0; + else if (battle_config.sit_spam_ban > 32767) + battle_config.sit_spam_ban = 32767; + + if (battle_config.sit_spam_flood < 0) + battle_config.sit_spam_flood = 0; + else if (battle_config.sit_spam_flood > 32767) + battle_config.sit_spam_flood = 32767; + + if (battle_config.sit_spam_warn < 0) + battle_config.sit_spam_warn = 0; + else if (battle_config.sit_spam_warn > 32767) + battle_config.sit_spam_warn = 32767; + + if (battle_config.sit_spam_threshold < 0) + battle_config.sit_spam_threshold = 0; + else if (battle_config.sit_spam_threshold > 32767) + battle_config.sit_spam_threshold = 32767; // at least 1 client must be accepted if ((battle_config.packet_ver_flag & 63) == 0) // added by [Yor] diff --git a/src/map/battle.h b/src/map/battle.h index cdce770..b58e80c 100644 --- a/src/map/battle.h +++ b/src/map/battle.h @@ -323,6 +323,11 @@ extern struct Battle_Config { int trade_spam_flood; int trade_spam_ban; int trade_spam_warn; + + int sit_spam_threshold; + int sit_spam_flood; + int sit_spam_ban; + int sit_spam_warn; int drop_pickup_safety_zone; // [Fate] Max. distance to an object dropped by a kill by self in which dropsteal protection works diff --git a/src/map/clif.c b/src/map/clif.c index 050c1c9..14f2770 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -6503,7 +6503,8 @@ void clif_parse_GlobalMessage(int fd, struct map_session_data *sd) { // S 008c < memcpy(WBUFP(buf,8), RFIFOP(fd,4), RFIFOW(fd,2) - 4); if (malformed || !magic_message(sd, buf, msg_len)) { - tmw_CheckChatSpam(sd, RFIFOP(fd,4)); + if (tmw_CheckChatSpam(sd, RFIFOP(fd,4))) + return; if ((malformed)||(pc_isdead(sd))) { free(buf); @@ -6674,6 +6675,8 @@ void clif_parse_ActionRequest(int fd, struct map_session_data *sd) { break; case 0x02: // sitdown if (battle_config.basic_skill_check == 0 || pc_checkskill(sd, NV_BASIC) >= 3) { + if (tmw_CheckSitSpam(sd)) + break; pc_stop_walking(sd, 1); skill_gangsterparadise(sd, 1); // �M�����O�X�^�[�p���_�C�X�ݒ� pc_setsit(sd); @@ -6748,7 +6751,8 @@ void clif_parse_Wis(int fd, struct map_session_data *sd) { // S 0096 .w = battle_config.chat_maxline) return; @@ -7082,7 +7086,8 @@ void clif_parse_TradeRequest(int fd,struct map_session_data *sd) nullpo_retv(sd); if(battle_config.basic_skill_check == 0 || pc_checkskill(sd,NV_BASIC) >= 1){ - tmw_CheckTradeSpam(sd); + if (tmw_CheckTradeSpam(sd)) + return; trade_traderequest(sd,RFIFOL(sd->fd,2)); } else clif_skill_fail(sd,1,0,0); diff --git a/src/map/map.h b/src/map/map.h index 1c49293..ad6575a 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -361,6 +361,9 @@ struct map_session_data { time_t trade_reset_due; int trades_in; + + time_t sit_reset_due; + int sits_in; }; struct npc_timerevent_list { diff --git a/src/map/pc.c b/src/map/pc.c index 7aec359..6f1cc86 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -820,6 +820,8 @@ int pc_authok(int id, int login_id2, time_t connect_until_time, short tmw_versio sd->chat_lastmsg[0] = '\0'; sd->trade_reset_due = sd->trades_in = 0; + + sd->sit_reset_due = sd->sits_in = 0; // message of the limited time of the account if (connect_until_time != 0) { // don't display if it's unlimited or unknow value diff --git a/src/map/tmw.c b/src/map/tmw.c index 5d4c991..2331a23 100644 --- a/src/map/tmw.c +++ b/src/map/tmw.c @@ -64,15 +64,17 @@ int tmw_CheckChatSpam(struct map_session_data *sd, char* message) { if (sd->chat_lines_in >= battle_config.chat_spam_flood) { sd->chat_lines_in = 0; - tmw_GmHackMsg("Spam detected from character '%s' (account: %d)", sd->status.name, sd->status.account_id); if (battle_config.chat_spam_ban > 0) { + tmw_GmHackMsg("Spam detected from character '%s' (account: %d)", sd->status.name, sd->status.account_id); clif_displaymessage(sd->fd, "You have been banned for spamming. Please do not spam."); tmw_GmHackMsg("This player has been banned for %d hour(s).", battle_config.chat_spam_ban); chrif_char_ask_name(-1, sd->status.name, 2, 0, 0, 0, battle_config.chat_spam_ban, 0, 0); // type: 2 - ban (year, month, day, hour, minute, second) clif_setwaitclose(sd->fd); } + + return 1; } if (battle_config.chat_spam_ban && sd->chat_lines_in >= battle_config.chat_spam_warn) { @@ -132,15 +134,17 @@ int tmw_CheckTradeSpam(struct map_session_data *sd) { if (sd->trades_in >= battle_config.trade_spam_flood) { sd->trades_in = 0; - tmw_GmHackMsg("Trade spam detected from character '%s' (account: %d)", sd->status.name, sd->status.account_id); if (battle_config.trade_spam_ban > 0) { + tmw_GmHackMsg("Trade spam detected from character '%s' (account: %d)", sd->status.name, sd->status.account_id); clif_displaymessage(sd->fd, "You have been banned for trade spamming. Please do not trade spam."); tmw_GmHackMsg("This player has been banned for %d hour(s).", battle_config.trade_spam_ban); chrif_char_ask_name(-1, sd->status.name, 2, 0, 0, 0, battle_config.trade_spam_ban, 0, 0); // type: 2 - ban (year, month, day, hour, minute, second) clif_setwaitclose(sd->fd); } + + return 1; } if (battle_config.trade_spam_ban && sd->trades_in >= battle_config.trade_spam_warn) { @@ -149,3 +153,38 @@ int tmw_CheckTradeSpam(struct map_session_data *sd) { return 0; } + +int tmw_CheckSitSpam(struct map_session_data *sd) { + nullpo_retr(1, sd); + time_t now = time(NULL); + + if (pc_isGM(sd)) return 0; + + if (now > sd->sit_reset_due) { + sd->sit_reset_due = now + battle_config.sit_spam_threshold; + sd->sits_in = 0; + } + + sd->sits_in++; + + if (sd->sits_in >= battle_config.sit_spam_flood) { + sd->sits_in = 0; + + if (battle_config.sit_spam_ban > 0) { + tmw_GmHackMsg("Sit spam detected from character '%s' (account: %d)", sd->status.name, sd->status.account_id); + clif_displaymessage(sd->fd, "You have been banned for sit spamming. Please do not sit spam."); + tmw_GmHackMsg("This player has been banned for %d hour(s).", battle_config.sit_spam_ban); + + chrif_char_ask_name(-1, sd->status.name, 2, 0, 0, 0, battle_config.sit_spam_ban, 0, 0); // type: 2 - ban (year, month, day, hour, minute, second) + clif_setwaitclose(sd->fd); + } + + return 1; + } + + if (battle_config.sit_spam_ban && sd->sits_in >= battle_config.sit_spam_warn) { + clif_displaymessage(sd->fd, "WARNING : You are about to be automaticly banned for sit spam!"); + } + + return 0; +} diff --git a/src/map/tmw.h b/src/map/tmw.h index 92bcaf4..8580810 100644 --- a/src/map/tmw.h +++ b/src/map/tmw.h @@ -6,3 +6,4 @@ int tmw_CheckChatSpam(struct map_session_data *sd, char* message); int tmw_CheckChatLameness(struct map_session_data *sd, char *message); void tmw_GmHackMsg(const char *fmt, ...); int tmw_CheckTradeSpam(struct map_session_data *sd); +int tmw_CheckSitSpam(struct map_session_data *sd); -- cgit v1.2.3-70-g09d2