diff options
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/battle.c | 35 | ||||
-rw-r--r-- | src/map/battle.h | 5 | ||||
-rw-r--r-- | src/map/clif.c | 17 | ||||
-rw-r--r-- | src/map/magic-stmt.c | 2 | ||||
-rw-r--r-- | src/map/map.h | 3 | ||||
-rw-r--r-- | src/map/npc.c | 9 | ||||
-rw-r--r-- | src/map/pc.c | 29 | ||||
-rw-r--r-- | src/map/pc.h | 1 | ||||
-rw-r--r-- | src/map/tmw.c | 43 | ||||
-rw-r--r-- | src/map/tmw.h | 1 | ||||
-rw-r--r-- | src/map/trade.c | 1 |
11 files changed, 125 insertions, 21 deletions
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 908e9ff..14f2770 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; @@ -6505,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); @@ -6676,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); @@ -6750,7 +6751,8 @@ void clif_parse_Wis(int fd, struct map_session_data *sd) { // S 0096 <len>.w <ni return; } - tmw_CheckChatSpam(sd, RFIFOP(fd,28)); + if (tmw_CheckChatSpam(sd, RFIFOP(fd,28))) + return; if (strlen(RFIFOP(fd,28)) >= battle_config.chat_maxline) return; @@ -7084,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/magic-stmt.c b/src/map/magic-stmt.c index e488c2b..4c866ca 100644 --- a/src/map/magic-stmt.c +++ b/src/map/magic-stmt.c @@ -249,7 +249,7 @@ local_spell_effect(int m, int x, int y, int effect, int tdelay) { int delay = 30000; /* 1 minute should be enough for all interesting spell effects, I hope */ struct npc_data *effect_npc = npc_spawn_text(m, x, y, - INVISIBLE_NPC, "", NULL); + INVISIBLE_NPC, "", "?"); int effect_npc_id = effect_npc->bl.id; entity_effect(&effect_npc->bl, effect, tdelay); 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/npc.c b/src/map/npc.c index 5fe190b..a24a458 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -836,7 +836,10 @@ int npc_click(struct map_session_data *sd,int id) break; case MESSAGE: if (nd->u.message) + { clif_scriptmes(sd, id, nd->u.message); + clif_scriptclose(sd, id); + } break; } @@ -941,7 +944,10 @@ int npc_buylist(struct map_session_data *sd,int n,unsigned short *item_list) case ADDITEM_EXIST: break; case ADDITEM_NEW: - new++; + if (itemdb_isequip) + new += item_list[i*2]; + else + new++; break; case ADDITEM_OVERAMOUNT: return 2; @@ -949,6 +955,7 @@ int npc_buylist(struct map_session_data *sd,int n,unsigned short *item_list) w+=itemdb_weight(item_list[i*2+1]) * item_list[i*2]; } + if (z > (double)sd->status.zeny) return 1; // zeny�s�� if (w+sd->weight > sd->max_weight) diff --git a/src/map/pc.c b/src/map/pc.c index 570ceb6..6f1cc86 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); @@ -817,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 @@ -2948,7 +2953,6 @@ int pc_delitem(struct map_session_data *sd,int n,int amount,int type) */ int pc_dropitem(struct map_session_data *sd,int n,int amount) { - int i; nullpo_retr(1, sd); if (sd->trade_partner != 0 || sd->npc_id != 0 || sd->state.storage_flag) @@ -2960,12 +2964,7 @@ int pc_dropitem(struct map_session_data *sd,int n,int amount) if(amount <= 0) return 0; - for (i = 0; i < 11; i++) { - if (equip_pos[i] > 0 && sd->equip_index[i] == n) { //Slot taken, remove item from there. - pc_unequipitem(sd, sd->equip_index[i], 1); - sd->equip_index[i] = -1; - } - } + pc_unequipinvyitem(sd, n, 1); if (sd->status.inventory[n].nameid <= 0 || @@ -6507,6 +6506,22 @@ int pc_unequipitem(struct map_session_data *sd,int n,int type) return 0; } +int pc_unequipinvyitem(struct map_session_data* sd, int n, int type) +{ + int i; + + nullpo_retr(1, sd); + + for (i = 0; i < 11; i++) { + if (equip_pos[i] > 0 && sd->equip_index[i] == n) { //Slot taken, remove item from there. + pc_unequipitem(sd, sd->equip_index[i], type); + sd->equip_index[i] = -1; + } + } + + return 0; +} + /*========================================== * �A�C�e����index�ԍ����l�߂��� * �� ���i�̑����\�`�F�b�N���s�Ȃ� diff --git a/src/map/pc.h b/src/map/pc.h index 0af9a20..31d8c8a 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -126,6 +126,7 @@ int pc_resetstate(struct map_session_data*); int pc_resetskill(struct map_session_data*); int pc_equipitem(struct map_session_data*,int,int); int pc_unequipitem(struct map_session_data*,int,int); +int pc_unequipinvyitem(struct map_session_data*,int,int); int pc_checkitem(struct map_session_data*); int pc_useitem(struct map_session_data*,int); 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); diff --git a/src/map/trade.c b/src/map/trade.c index 8880629..67ac257 100644 --- a/src/map/trade.c +++ b/src/map/trade.c @@ -147,6 +147,7 @@ void trade_tradeadditem(struct map_session_data *sd,int index,int amount) return; } } + pc_unequipinvyitem(sd, index - 2, 1); sd->deal_item_index[trade_i] =index; sd->deal_item_amount[trade_i]+=amount; clif_tradeitemok(sd,index,amount,0); //success to add item |