summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-07-06 14:33:43 -0600
committerJared Adams <jaxad0127@gmail.com>2009-07-06 14:33:43 -0600
commit03b5e644857f80a23bd8b856b78a10cf0a564a66 (patch)
tree1f557d75211e3408cbac740b95258e5a3f92f35d
parent2855e018b8e177878ca0d83c61e4442ddf3e505c (diff)
downloadtmwa-03b5e644857f80a23bd8b856b78a10cf0a564a66.tar.gz
tmwa-03b5e644857f80a23bd8b856b78a10cf0a564a66.tar.bz2
tmwa-03b5e644857f80a23bd8b856b78a10cf0a564a66.tar.xz
tmwa-03b5e644857f80a23bd8b856b78a10cf0a564a66.zip
Add a new trade spam system
-rw-r--r--src/map/battle.c40
-rw-r--r--src/map/battle.h5
-rw-r--r--src/map/clif.c2
-rw-r--r--src/map/map.h3
-rw-r--r--src/map/pc.c2
-rw-r--r--src/map/tmw.c33
-rw-r--r--src/map/tmw.h1
7 files changed, 79 insertions, 7 deletions
diff --git a/src/map/battle.c b/src/map/battle.c
index 45524e5..94d64de 100644
--- a/src/map/battle.c
+++ b/src/map/battle.c
@@ -4520,6 +4520,11 @@ int battle_config_read(const char *cfgName)
battle_config.chat_spam_ban = 1;
battle_config.chat_spam_warn = 8;
battle_config.chat_maxline = 255;
+
+ battle_config.trade_spam_threshold = 10;
+ battle_config.trade_spam_flood = 10;
+ battle_config.trade_spam_ban = 1;
+ battle_config.trade_spam_warn = 8;
}
fp = fopen(cfgName,"r");
@@ -4722,12 +4727,16 @@ int battle_config_read(const char *cfgName)
{ "castrate_dex_scale", &battle_config.castrate_dex_scale }, // added by [MouseJstr]
{ "area_size", &battle_config.area_size }, // added by [MouseJstr]
{ "muting_players", &battle_config.muting_players}, // added by [Apple]
- { "chat_lame_penalty", &battle_config.chat_lame_penalty },
- { "chat_spam_threshold", &battle_config.chat_spam_threshold },
- { "chat_spam_flood", &battle_config.chat_spam_flood },
- { "chat_spam_ban", &battle_config.chat_spam_ban },
- { "chat_spam_warn", &battle_config.chat_spam_warn },
- { "chat_maxline", &battle_config.chat_maxline }
+ { "chat_lame_penalty", &battle_config.chat_lame_penalty },
+ { "chat_spam_threshold", &battle_config.chat_spam_threshold },
+ { "chat_spam_flood", &battle_config.chat_spam_flood },
+ { "chat_spam_ban", &battle_config.chat_spam_ban },
+ { "chat_spam_warn", &battle_config.chat_spam_warn },
+ { "chat_maxline", &battle_config.chat_maxline },
+ { "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 }
};
if (line[0] == '/' && line[1] == '/')
@@ -4868,6 +4877,25 @@ int battle_config_read(const char *cfgName)
else if (battle_config.chat_maxline > 512)
battle_config.chat_maxline = 512;
+ if (battle_config.trade_spam_ban < 0)
+ battle_config.trade_spam_ban = 0;
+ else if (battle_config.trade_spam_ban > 32767)
+ battle_config.trade_spam_ban = 32767;
+
+ if (battle_config.trade_spam_flood < 0)
+ battle_config.trade_spam_flood = 0;
+ else if (battle_config.trade_spam_flood > 32767)
+ battle_config.trade_spam_flood = 32767;
+
+ if (battle_config.trade_spam_warn < 0)
+ battle_config.trade_spam_warn = 0;
+ else if (battle_config.trade_spam_warn > 32767)
+ battle_config.trade_spam_warn = 32767;
+
+ 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;
// 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 3c46586..cdce770 100644
--- a/src/map/battle.h
+++ b/src/map/battle.h
@@ -318,6 +318,11 @@ extern struct Battle_Config {
int chat_spam_ban;
int chat_spam_warn;
int chat_maxline;
+
+ int trade_spam_threshold;
+ int trade_spam_flood;
+ int trade_spam_ban;
+ int trade_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 d10effb..1f88ed8 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -7084,7 +7084,7 @@ 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_CheckChatSpam(sd, NULL);
+ tmw_CheckTradeSpam(sd);
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 7275734..1c49293 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -358,6 +358,9 @@ struct map_session_data {
time_t chat_reset_due;
int chat_lines_in;
char chat_lastmsg[513];
+
+ time_t trade_reset_due;
+ int trades_in;
};
struct npc_timerevent_list {
diff --git a/src/map/pc.c b/src/map/pc.c
index 630a15b..b3626df 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -815,6 +815,8 @@ int pc_authok(int id, int login_id2, time_t connect_until_time, short tmw_versio
sd->chat_reset_due = sd->chat_lines_in = 0;
sd->chat_lastmsg[0] = '\0';
+
+ sd->trade_reset_due = sd->trades_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 ba02189..5d4c991 100644
--- a/src/map/tmw.c
+++ b/src/map/tmw.c
@@ -116,3 +116,36 @@ void tmw_GmHackMsg(const char *fmt, ...) {
intif_wis_message_to_gm(wisp_server_name, battle_config.hack_info_GM_level, outbuf, strlen(outbuf) + 1);
}
+
+int tmw_CheckTradeSpam(struct map_session_data *sd) {
+ nullpo_retr(1, sd);
+ time_t now = time(NULL);
+
+ if (pc_isGM(sd)) return 0;
+
+ if (now > sd->trade_reset_due) {
+ sd->trade_reset_due = now + battle_config.trade_spam_threshold;
+ sd->trades_in = 0;
+ }
+
+ sd->trades_in++;
+
+ 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) {
+ 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);
+ }
+ }
+
+ if (battle_config.trade_spam_ban && sd->trades_in >= battle_config.trade_spam_warn) {
+ clif_displaymessage(sd->fd, "WARNING : You are about to be automaticly banned for trade spam!");
+ }
+
+ return 0;
+}
diff --git a/src/map/tmw.h b/src/map/tmw.h
index 87066d9..92bcaf4 100644
--- a/src/map/tmw.h
+++ b/src/map/tmw.h
@@ -5,3 +5,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);