summaryrefslogtreecommitdiff
path: root/src/net/tmwa
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2018-11-27 21:51:59 +0300
committerAndrei Karas <akaras@inbox.ru>2018-11-27 21:51:59 +0300
commitd33ffd2ac6230059cce68ecae862d3bdc813b93d (patch)
tree1e30c7373c78c6d968bc9697ad72a71df4d84e46 /src/net/tmwa
parent2734f4a788dad6faf960d53de00da74ebff69bd5 (diff)
downloadplus-d33ffd2ac6230059cce68ecae862d3bdc813b93d.tar.gz
plus-d33ffd2ac6230059cce68ecae862d3bdc813b93d.tar.bz2
plus-d33ffd2ac6230059cce68ecae862d3bdc813b93d.tar.xz
plus-d33ffd2ac6230059cce68ecae862d3bdc813b93d.zip
Avoid shop spam in legacy server.
Diffstat (limited to 'src/net/tmwa')
-rw-r--r--src/net/tmwa/buysellhandler.cpp5
-rw-r--r--src/net/tmwa/chatrecv.cpp17
-rw-r--r--src/net/tmwa/chatrecv.h2
3 files changed, 23 insertions, 1 deletions
diff --git a/src/net/tmwa/buysellhandler.cpp b/src/net/tmwa/buysellhandler.cpp
index 23bef65de..787b9ef33 100644
--- a/src/net/tmwa/buysellhandler.cpp
+++ b/src/net/tmwa/buysellhandler.cpp
@@ -31,6 +31,8 @@
#include "net/ea/buysellrecv.h"
+#include "net/tmwa/chatrecv.h"
+
#include "utils/timer.h"
#include "debug.h"
@@ -57,6 +59,7 @@ void BuySellHandler::requestSellList(const std::string &nick) const
const std::string data("!selllist " + toString(tick_time));
shopWindow->setAcceptPlayer(nick);
+ ChatRecv::mShopRequestName = nick;
if (config.getBoolValue("hideShopMessages"))
{
chatHandler->privateMessage(nick, data);
@@ -75,7 +78,7 @@ void BuySellHandler::requestBuyList(const std::string &nick) const
const std::string data("!buylist " + toString(tick_time));
shopWindow->setAcceptPlayer(nick);
-
+ ChatRecv::mShopRequestName = nick;
if (config.getBoolValue("hideShopMessages"))
{
chatHandler->privateMessage(nick, data);
diff --git a/src/net/tmwa/chatrecv.cpp b/src/net/tmwa/chatrecv.cpp
index e044d5877..b9dd73af5 100644
--- a/src/net/tmwa/chatrecv.cpp
+++ b/src/net/tmwa/chatrecv.cpp
@@ -44,11 +44,18 @@
#include "net/tmwa/guildmanager.h"
+#include "utils/gettext.h"
+
#include "debug.h"
namespace TmwAthena
{
+namespace ChatRecv
+{
+ std::string mShopRequestName;
+} // namespace ChatRecv
+
void ChatRecv::processChat(Net::MessageIn &msg)
{
BLOCK_START("ChatRecv::processChat")
@@ -248,6 +255,16 @@ void ChatRecv::processWhisperContinue(const std::string &nick,
&& chatMsg.find("\302\202") == 0)
{
chatMsg = chatMsg.erase(0, 2);
+ if (mShopRequestName != nick)
+ {
+ debugMsg(strprintf(
+ // TRANSLATORS: message about spam player
+ _("Detected spam from: %s"),
+ nick.c_str()));
+ BLOCK_END("ChatRecv::processWhisper")
+ return;
+ }
+ mShopRequestName.clear();
if (showMsg && chatWindow != nullptr)
{
chatWindow->addWhisper(nick,
diff --git a/src/net/tmwa/chatrecv.h b/src/net/tmwa/chatrecv.h
index c896f1337..2c5e6a084 100644
--- a/src/net/tmwa/chatrecv.h
+++ b/src/net/tmwa/chatrecv.h
@@ -34,6 +34,8 @@ namespace TmwAthena
{
namespace ChatRecv
{
+ extern std::string mShopRequestName;
+
void processChat(Net::MessageIn &msg);
void processChatContinue(std::string chatMsg);
void processGmChat(Net::MessageIn &msg);