summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--src/game.cpp11
-rw-r--r--src/net/tradehandler.cpp15
-rw-r--r--src/net/tradehandler.h18
4 files changed, 48 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 8dda0d11..71a248b3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -553,6 +553,12 @@
strings for item effects.
* po/POTFILES.in: Marked effect strings as translatable.
+2007-10-18 Bjørn Lindeijer <bjorn@lindeijer.nl>
+
+ * src/game.cpp, src/net/tradehandler.h, src/net/tradehandler.cpp:
+ Implemented automatic denying of trade requests based on a patch
+ submitted by Quiche_on_a_leash.
+
2007-10-15 Bjørn Lindeijer <bjorn@lindeijer.nl>
* src/gui/viewport.h, src/gui/viewport.cpp: Put drawing of debug path
diff --git a/src/game.cpp b/src/game.cpp
index 1ad99268..9455e47a 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -613,6 +613,17 @@ void Game::handleInput()
viewport->toggleDebugPath();
used = true;
break;
+
+ case SDLK_t:
+ // Toggle accepting of incoming trade requests
+ {
+ TradeHandler *th = static_cast<TradeHandler*>(
+ mTradeHandler.get());
+ th->setAcceptTradeRequests(
+ !th->acceptTradeRequests());
+ }
+ used = true;
+ break;
}
// Emotions
diff --git a/src/net/tradehandler.cpp b/src/net/tradehandler.cpp
index b659f8a4..d75350bc 100644
--- a/src/net/tradehandler.cpp
+++ b/src/net/tradehandler.cpp
@@ -55,7 +55,8 @@ namespace {
} listener;
}
-TradeHandler::TradeHandler()
+TradeHandler::TradeHandler():
+ mAcceptTradeRequests(true)
{
static const Uint16 _messages[] = {
GPMSG_TRADE_REQUEST,
@@ -70,6 +71,16 @@ TradeHandler::TradeHandler()
handledMessages = _messages;
}
+void TradeHandler::setAcceptTradeRequests(bool acceptTradeRequests)
+{
+ mAcceptTradeRequests = acceptTradeRequests;
+ if (mAcceptTradeRequests) {
+ chatWindow->chatLog("Accepting incoming trade requests", BY_SERVER);
+ } else {
+ chatWindow->chatLog("Ignoring incoming trade requests", BY_SERVER);
+ }
+}
+
void TradeHandler::handleMessage(MessageIn &msg)
{
switch (msg.getId())
@@ -77,7 +88,7 @@ void TradeHandler::handleMessage(MessageIn &msg)
case GPMSG_TRADE_REQUEST:
{
Being *being = beingManager->findBeing(msg.readInt16());
- if (!being)
+ if (!being || !mAcceptTradeRequests)
{
Net::GameServer::Player::acceptTrade(false);
break;
diff --git a/src/net/tradehandler.h b/src/net/tradehandler.h
index 1ab3c2e4..33dddf05 100644
--- a/src/net/tradehandler.h
+++ b/src/net/tradehandler.h
@@ -32,6 +32,24 @@ class TradeHandler : public MessageHandler
TradeHandler();
void handleMessage(MessageIn &msg);
+
+ /**
+ * Returns whether trade requests are accepted.
+ *
+ * @see setAcceptTradeRequests
+ */
+ bool acceptTradeRequests() const
+ { return mAcceptTradeRequests; }
+
+ /**
+ * Sets whether trade requests are accepted. When set to false, trade
+ * requests are automatically denied. When true, a popup will ask the
+ * player whether he wants to trade.
+ */
+ void setAcceptTradeRequests(bool acceptTradeRequests);
+
+ private:
+ bool mAcceptTradeRequests;
};
#endif