summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/net/ea/tradehandler.cpp90
-rw-r--r--src/net/ea/tradehandler.h4
-rw-r--r--src/net/eathena/tradehandler.cpp5
-rw-r--r--src/net/eathena/tradehandler.h3
-rw-r--r--src/net/tmwa/tradehandler.cpp5
-rw-r--r--src/net/tmwa/tradehandler.h3
6 files changed, 59 insertions, 51 deletions
diff --git a/src/net/ea/tradehandler.cpp b/src/net/ea/tradehandler.cpp
index d6715d4f6..5f507a01a 100644
--- a/src/net/ea/tradehandler.cpp
+++ b/src/net/ea/tradehandler.cpp
@@ -69,55 +69,6 @@ void TradeHandler::removeItem(const int slotNum A_UNUSED,
{
}
-void TradeHandler::processTradeRequest(Net::MessageIn &msg) const
-{
- // If a trade window or request window is already open, send a
- // trade cancel to any other trade request.
- //
- // Note that it would be nice if the server would prevent this
- // situation, and that the requesting player would get a
- // special message about the player being occupied.
- std::string tradePartnerNameTemp = msg.readString(24);
-
- if (player_relations.hasPermission(tradePartnerNameTemp,
- PlayerRelation::TRADE))
- {
- if (PlayerInfo::isTrading() || confirmDlg)
- {
- respond(false);
- return;
- }
-
- tradePartnerName = tradePartnerNameTemp;
- PlayerInfo::setTrading(true);
- if (tradeWindow)
- {
- if (tradePartnerName.empty() || tradeWindow->getAutoTradeNick()
- != tradePartnerName)
- {
- tradeWindow->clear();
- // TRANSLATORS: trade message
- confirmDlg = new ConfirmDialog(_("Request for Trade"),
- // TRANSLATORS: trade message
- strprintf(_("%s wants to trade with you, do"
- " you accept?"), tradePartnerName.c_str()),
- SOUND_REQUEST, true);
- confirmDlg->postInit();
- confirmDlg->addActionListener(&listener);
- }
- else
- {
- respond(true);
- }
- }
- }
- else
- {
- respond(false);
- return;
- }
-}
-
void TradeHandler::processTradeResponse(Net::MessageIn &msg) const
{
if (confirmDlg || tradePartnerName.empty()
@@ -281,4 +232,45 @@ void TradeHandler::processTradeComplete(Net::MessageIn &msg A_UNUSED)
PlayerInfo::setTrading(false);
}
+void TradeHandler::processTradeRequestContinue(const std::string &partner) const
+{
+ if (player_relations.hasPermission(partner,
+ PlayerRelation::TRADE))
+ {
+ if (PlayerInfo::isTrading() || confirmDlg)
+ {
+ respond(false);
+ return;
+ }
+
+ tradePartnerName = partner;
+ PlayerInfo::setTrading(true);
+ if (tradeWindow)
+ {
+ if (tradePartnerName.empty() || tradeWindow->getAutoTradeNick()
+ != tradePartnerName)
+ {
+ tradeWindow->clear();
+ // TRANSLATORS: trade message
+ confirmDlg = new ConfirmDialog(_("Request for Trade"),
+ // TRANSLATORS: trade message
+ strprintf(_("%s wants to trade with you, do"
+ " you accept?"), tradePartnerName.c_str()),
+ SOUND_REQUEST, true);
+ confirmDlg->postInit();
+ confirmDlg->addActionListener(&listener);
+ }
+ else
+ {
+ respond(true);
+ }
+ }
+ }
+ else
+ {
+ respond(false);
+ return;
+ }
+}
+
} // namespace Ea
diff --git a/src/net/ea/tradehandler.h b/src/net/ea/tradehandler.h
index a11941d5d..cbf19919e 100644
--- a/src/net/ea/tradehandler.h
+++ b/src/net/ea/tradehandler.h
@@ -43,8 +43,6 @@ class TradeHandler notfinal : public Net::TradeHandler
void removeItem(const int slotNum,
const int amount) const override final;
- void processTradeRequest(Net::MessageIn &msg) const;
-
void processTradeResponse(Net::MessageIn &msg) const;
static void processTradeItemAdd(Net::MessageIn &msg);
@@ -56,6 +54,8 @@ class TradeHandler notfinal : public Net::TradeHandler
static void processTradeCancel(Net::MessageIn &msg);
static void processTradeComplete(Net::MessageIn &msg);
+
+ void processTradeRequestContinue(const std::string &partner) const;
};
} // namespace Ea
diff --git a/src/net/eathena/tradehandler.cpp b/src/net/eathena/tradehandler.cpp
index 1e71d4a43..1d9fabaa0 100644
--- a/src/net/eathena/tradehandler.cpp
+++ b/src/net/eathena/tradehandler.cpp
@@ -146,4 +146,9 @@ void TradeHandler::cancel() const
MessageOut outMsg(CMSG_TRADE_CANCEL_REQUEST);
}
+void TradeHandler::processTradeRequest(Net::MessageIn &msg) const
+{
+ processTradeRequestContinue(msg.readString(24, "name"));
+}
+
} // namespace EAthena
diff --git a/src/net/eathena/tradehandler.h b/src/net/eathena/tradehandler.h
index 16a7669e2..eb50d65c0 100644
--- a/src/net/eathena/tradehandler.h
+++ b/src/net/eathena/tradehandler.h
@@ -53,6 +53,9 @@ class TradeHandler final : public MessageHandler, public Ea::TradeHandler
void finish() const override final;
void cancel() const override final;
+
+ protected:
+ void processTradeRequest(Net::MessageIn &msg) const;
};
} // namespace EAthena
diff --git a/src/net/tmwa/tradehandler.cpp b/src/net/tmwa/tradehandler.cpp
index 0cc768c5a..0a67a9202 100644
--- a/src/net/tmwa/tradehandler.cpp
+++ b/src/net/tmwa/tradehandler.cpp
@@ -148,4 +148,9 @@ void TradeHandler::cancel() const
MessageOut outMsg(CMSG_TRADE_CANCEL_REQUEST);
}
+void TradeHandler::processTradeRequest(Net::MessageIn &msg) const
+{
+ processTradeRequestContinue(msg.readString(24, "name"));
+}
+
} // namespace TmwAthena
diff --git a/src/net/tmwa/tradehandler.h b/src/net/tmwa/tradehandler.h
index 28f43cb0a..39222e7ba 100644
--- a/src/net/tmwa/tradehandler.h
+++ b/src/net/tmwa/tradehandler.h
@@ -53,6 +53,9 @@ class TradeHandler final : public MessageHandler, public Ea::TradeHandler
void finish() const override final;
void cancel() const override final;
+
+ protected:
+ void processTradeRequest(Net::MessageIn &msg) const;
};
} // namespace TmwAthena