summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/map/battle.c35
-rw-r--r--src/map/battle.h5
-rw-r--r--src/map/clif.c11
-rw-r--r--src/map/map.h3
-rw-r--r--src/map/pc.c2
-rw-r--r--src/map/tmw.c43
-rw-r--r--src/map/tmw.h1
7 files changed, 92 insertions, 8 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 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 <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;
@@ -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);