summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-04-11 01:09:29 +0300
committerAndrei Karas <akaras@inbox.ru>2013-04-11 01:09:29 +0300
commit9ce9d5563195bf9d7d22356252f38bc95b247527 (patch)
tree984014cbb799fefaa62d3e8f8c7820ed2b6407c1 /src
parentfc199c3ae60d4c4cf76236c7f4891113daa3cbc4 (diff)
downloadmv-9ce9d5563195bf9d7d22356252f38bc95b247527.tar.gz
mv-9ce9d5563195bf9d7d22356252f38bc95b247527.tar.bz2
mv-9ce9d5563195bf9d7d22356252f38bc95b247527.tar.xz
mv-9ce9d5563195bf9d7d22356252f38bc95b247527.zip
imporve tradehandler class.
Diffstat (limited to 'src')
-rw-r--r--src/net/ea/tradehandler.cpp11
-rw-r--r--src/net/ea/tradehandler.h2
-rw-r--r--src/net/eathena/tradehandler.cpp14
-rw-r--r--src/net/eathena/tradehandler.h16
-rw-r--r--src/net/tmwa/tradehandler.cpp14
-rw-r--r--src/net/tmwa/tradehandler.h16
-rw-r--r--src/net/tradehandler.h18
7 files changed, 47 insertions, 44 deletions
diff --git a/src/net/ea/tradehandler.cpp b/src/net/ea/tradehandler.cpp
index 961f8ff62..b4aca1041 100644
--- a/src/net/ea/tradehandler.cpp
+++ b/src/net/ea/tradehandler.cpp
@@ -67,7 +67,8 @@ TradeHandler::TradeHandler()
confirmDlg = nullptr;
}
-void TradeHandler::removeItem(int slotNum A_UNUSED, int amount A_UNUSED)
+void TradeHandler::removeItem(const int slotNum A_UNUSED,
+ const int amount A_UNUSED) const
{
// TODO
}
@@ -87,7 +88,7 @@ void TradeHandler::processTradeRequest(Net::MessageIn &msg)
{
if (PlayerInfo::isTrading() || confirmDlg)
{
- Net::getTradeHandler()->respond(false);
+ respond(false);
return;
}
@@ -106,13 +107,13 @@ void TradeHandler::processTradeRequest(Net::MessageIn &msg)
}
else
{
- Net::getTradeHandler()->respond(true);
+ respond(true);
}
}
}
else
{
- Net::getTradeHandler()->respond(false);
+ respond(false);
return;
}
}
@@ -123,7 +124,7 @@ void TradeHandler::processTradeResponse(Net::MessageIn &msg)
|| !player_relations.hasPermission(tradePartnerName,
PlayerRelation::TRADE))
{
- Net::getTradeHandler()->respond(false);
+ respond(false);
return;
}
diff --git a/src/net/ea/tradehandler.h b/src/net/ea/tradehandler.h
index 7253f4e0a..b7be2704e 100644
--- a/src/net/ea/tradehandler.h
+++ b/src/net/ea/tradehandler.h
@@ -37,7 +37,7 @@ class TradeHandler : public Net::TradeHandler
A_DELETE_COPY(TradeHandler)
- void removeItem(int slotNum, int amount);
+ void removeItem(const int slotNum, const int amount) const override;
void processTradeRequest(Net::MessageIn &msg);
diff --git a/src/net/eathena/tradehandler.cpp b/src/net/eathena/tradehandler.cpp
index 6db01aa67..aa11b1233 100644
--- a/src/net/eathena/tradehandler.cpp
+++ b/src/net/eathena/tradehandler.cpp
@@ -93,7 +93,7 @@ void TradeHandler::handleMessage(Net::MessageIn &msg)
}
}
-void TradeHandler::request(const Being *const being)
+void TradeHandler::request(const Being *const being) const
{
if (!being)
return;
@@ -102,7 +102,7 @@ void TradeHandler::request(const Being *const being)
outMsg.writeInt32(being->getId());
}
-void TradeHandler::respond(bool accept)
+void TradeHandler::respond(const bool accept) const
{
if (!accept)
PlayerInfo::setTrading(false);
@@ -111,7 +111,7 @@ void TradeHandler::respond(bool accept)
outMsg.writeInt8(accept ? 3 : 4);
}
-void TradeHandler::addItem(Item *item, int amount)
+void TradeHandler::addItem(const Item *const item, const int amount) const
{
if (!item)
return;
@@ -122,24 +122,24 @@ void TradeHandler::addItem(Item *item, int amount)
outMsg.writeInt32(amount);
}
-void TradeHandler::setMoney(int amount)
+void TradeHandler::setMoney(const int amount) const
{
MessageOut outMsg(CMSG_TRADE_ITEM_ADD_REQUEST);
outMsg.writeInt16(0);
outMsg.writeInt32(amount);
}
-void TradeHandler::confirm()
+void TradeHandler::confirm() const
{
MessageOut outMsg(CMSG_TRADE_ADD_COMPLETE);
}
-void TradeHandler::finish()
+void TradeHandler::finish() const
{
MessageOut outMsg(CMSG_TRADE_OK);
}
-void TradeHandler::cancel()
+void TradeHandler::cancel() const
{
MessageOut outMsg(CMSG_TRADE_CANCEL_REQUEST);
}
diff --git a/src/net/eathena/tradehandler.h b/src/net/eathena/tradehandler.h
index 0cd826ca2..290a0fd92 100644
--- a/src/net/eathena/tradehandler.h
+++ b/src/net/eathena/tradehandler.h
@@ -40,21 +40,21 @@ class TradeHandler final : public MessageHandler, public Ea::TradeHandler
A_DELETE_COPY(TradeHandler)
- void handleMessage(Net::MessageIn &msg);
+ void handleMessage(Net::MessageIn &msg) override;
- void request(const Being *const being);
+ void request(const Being *const being) const override;
- void respond(bool accept);
+ void respond(const bool accept) const override;
- void addItem(Item *item, int amount);
+ void addItem(const Item *const item, int amount) const override;
- void setMoney(int amount);
+ void setMoney(const int amount) const override;
- void confirm();
+ void confirm() const override;
- void finish();
+ void finish() const override;
- void cancel();
+ void cancel() const override;
};
} // namespace EAthena
diff --git a/src/net/tmwa/tradehandler.cpp b/src/net/tmwa/tradehandler.cpp
index a05f28401..4f413fdaf 100644
--- a/src/net/tmwa/tradehandler.cpp
+++ b/src/net/tmwa/tradehandler.cpp
@@ -95,7 +95,7 @@ void TradeHandler::handleMessage(Net::MessageIn &msg)
BLOCK_END("TradeHandler::handleMessage")
}
-void TradeHandler::request(const Being *const being)
+void TradeHandler::request(const Being *const being) const
{
if (!being)
return;
@@ -104,7 +104,7 @@ void TradeHandler::request(const Being *const being)
outMsg.writeInt32(being->getId());
}
-void TradeHandler::respond(bool accept)
+void TradeHandler::respond(const bool accept) const
{
if (!accept)
PlayerInfo::setTrading(false);
@@ -113,7 +113,7 @@ void TradeHandler::respond(bool accept)
outMsg.writeInt8(static_cast<int8_t>(accept ? 3 : 4));
}
-void TradeHandler::addItem(Item *item, int amount)
+void TradeHandler::addItem(const Item *const item, const int amount) const
{
if (!item)
return;
@@ -124,24 +124,24 @@ void TradeHandler::addItem(Item *item, int amount)
outMsg.writeInt32(amount);
}
-void TradeHandler::setMoney(int amount)
+void TradeHandler::setMoney(const int amount) const
{
MessageOut outMsg(CMSG_TRADE_ITEM_ADD_REQUEST);
outMsg.writeInt16(0);
outMsg.writeInt32(amount);
}
-void TradeHandler::confirm()
+void TradeHandler::confirm() const
{
MessageOut outMsg(CMSG_TRADE_ADD_COMPLETE);
}
-void TradeHandler::finish()
+void TradeHandler::finish() const
{
MessageOut outMsg(CMSG_TRADE_OK);
}
-void TradeHandler::cancel()
+void TradeHandler::cancel() const
{
MessageOut outMsg(CMSG_TRADE_CANCEL_REQUEST);
}
diff --git a/src/net/tmwa/tradehandler.h b/src/net/tmwa/tradehandler.h
index dfa5840b0..7a88c61be 100644
--- a/src/net/tmwa/tradehandler.h
+++ b/src/net/tmwa/tradehandler.h
@@ -40,21 +40,21 @@ class TradeHandler final : public MessageHandler, public Ea::TradeHandler
A_DELETE_COPY(TradeHandler)
- void handleMessage(Net::MessageIn &msg);
+ void handleMessage(Net::MessageIn &msg) override;
- void request(const Being *const being);
+ void request(const Being *const being) const override;
- void respond(bool accept);
+ void respond(const bool accept) const override;
- void addItem(Item *item, int amount);
+ void addItem(const Item *const item, const int amount) const override;
- void setMoney(int amount);
+ void setMoney(const int amount) const override;
- void confirm();
+ void confirm() const override;
- void finish();
+ void finish() const override;
- void cancel();
+ void cancel() const override;
};
} // namespace TmwAthena
diff --git a/src/net/tradehandler.h b/src/net/tradehandler.h
index 2eeaaf635..3adc3265f 100644
--- a/src/net/tradehandler.h
+++ b/src/net/tradehandler.h
@@ -37,28 +37,30 @@ class TradeHandler
virtual ~TradeHandler()
{ }
- virtual void request(const Being *const being A_UNUSED)
+ virtual void request(const Being *const being A_UNUSED) const
{ }
- virtual void respond(bool accept A_UNUSED)
+ virtual void respond(const bool accept A_UNUSED) const
{ }
- virtual void addItem(Item *item A_UNUSED, int amount A_UNUSED)
+ virtual void addItem(const Item *const item A_UNUSED,
+ const int amount A_UNUSED) const
{ }
- virtual void removeItem(int slotNum A_UNUSED, int amount A_UNUSED)
+ virtual void removeItem(const int slotNum A_UNUSED,
+ const int amount A_UNUSED) const
{ }
- virtual void setMoney(int amount A_UNUSED)
+ virtual void setMoney(const int amount A_UNUSED) const
{ }
- virtual void confirm()
+ virtual void confirm() const
{ }
- virtual void finish()
+ virtual void finish() const
{ }
- virtual void cancel()
+ virtual void cancel() const
{ }
};
}