summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-12-24 19:28:46 +0300
committerAndrei Karas <akaras@inbox.ru>2014-12-24 19:28:46 +0300
commit8764d8fed61e7f0148ede9a6a836b402145578aa (patch)
treed19a68662f801fcabd378f4b966b048778878e5c
parent81020303571b9421b3ef1c8d2ec5f5d36599540d (diff)
downloadmanaplus-8764d8fed61e7f0148ede9a6a836b402145578aa.tar.gz
manaplus-8764d8fed61e7f0148ede9a6a836b402145578aa.tar.bz2
manaplus-8764d8fed61e7f0148ede9a6a836b402145578aa.tar.xz
manaplus-8764d8fed61e7f0148ede9a6a836b402145578aa.zip
eathena: add support for buy from cash shop.
-rw-r--r--src/gui/windows/buydialog.cpp20
-rw-r--r--src/net/cashshophandler.h8
-rw-r--r--src/net/eathena/cashshophandler.cpp8
-rw-r--r--src/net/eathena/cashshophandler.h8
-rw-r--r--src/net/tmwa/cashshophandler.cpp8
-rw-r--r--src/net/tmwa/cashshophandler.h8
6 files changed, 34 insertions, 26 deletions
diff --git a/src/gui/windows/buydialog.cpp b/src/gui/windows/buydialog.cpp
index 33e3932bc..ec83e610c 100644
--- a/src/gui/windows/buydialog.cpp
+++ b/src/gui/windows/buydialog.cpp
@@ -45,6 +45,7 @@
#include "net/adminhandler.h"
#include "net/buysellhandler.h"
+#include "net/cashshophandler.h"
#include "net/markethandler.h"
#include "net/npchandler.h"
@@ -442,21 +443,28 @@ void BuyDialog::action(const ActionEvent &event)
}
else if (mNpcId != Nick)
{
- if (mNpcId != Market)
+ if (mNpcId == Market)
{
- npcHandler->buyItem(mNpcId,
+ marketHandler->buyItem(item->getId(),
+ item->getType(),
+ item->getColor(),
+ mAmountItems);
+ item->increaseQuantity(-mAmountItems);
+ item->update();
+ }
+ else if (mNpcId == Cash)
+ {
+ cashShopHandler->buyItem(item->getPrice(),
item->getId(),
item->getColor(),
mAmountItems);
}
else
{
- marketHandler->buyItem(item->getId(),
- item->getType(),
+ npcHandler->buyItem(mNpcId,
+ item->getId(),
item->getColor(),
mAmountItems);
- item->increaseQuantity(-mAmountItems);
- item->update();
}
// Update money and adjust the max number of items
diff --git a/src/net/cashshophandler.h b/src/net/cashshophandler.h
index 5ca5fd8af..ed01779fd 100644
--- a/src/net/cashshophandler.h
+++ b/src/net/cashshophandler.h
@@ -34,10 +34,10 @@ class CashShopHandler notfinal
virtual ~CashShopHandler()
{ }
- virtual void buy(const int points,
- const int itemId,
- const unsigned char color,
- const int amount) const = 0;
+ virtual void buyItem(const int points,
+ const int itemId,
+ const unsigned char color,
+ const int amount) const = 0;
};
diff --git a/src/net/eathena/cashshophandler.cpp b/src/net/eathena/cashshophandler.cpp
index 63cd03a04..b04eec445 100644
--- a/src/net/eathena/cashshophandler.cpp
+++ b/src/net/eathena/cashshophandler.cpp
@@ -96,10 +96,10 @@ void CashShopHandler::processCashShopBuyAck(Net::MessageIn &msg)
msg.readInt16("error");
}
-void CashShopHandler::buy(const int points,
- const int itemId,
- const unsigned char color A_UNUSED,
- const int amount) const
+void CashShopHandler::buyItem(const int points,
+ const int itemId,
+ const unsigned char color A_UNUSED,
+ const int amount) const
{
createOutPacket(CMSG_NPC_CASH_SHOP_BUY);
outMsg.writeInt16(10 + 4, "len");
diff --git a/src/net/eathena/cashshophandler.h b/src/net/eathena/cashshophandler.h
index ae99d8e9e..2c7f0b56e 100644
--- a/src/net/eathena/cashshophandler.h
+++ b/src/net/eathena/cashshophandler.h
@@ -39,10 +39,10 @@ class CashShopHandler final : public MessageHandler,
void handleMessage(Net::MessageIn &msg) override final;
- void buy(const int points,
- const int itemId,
- const unsigned char color,
- const int amount) const override final;
+ void buyItem(const int points,
+ const int itemId,
+ const unsigned char color,
+ const int amount) const override final;
protected:
static void processCashShopOpen(Net::MessageIn &msg);
diff --git a/src/net/tmwa/cashshophandler.cpp b/src/net/tmwa/cashshophandler.cpp
index 7eab823df..991aad5aa 100644
--- a/src/net/tmwa/cashshophandler.cpp
+++ b/src/net/tmwa/cashshophandler.cpp
@@ -42,10 +42,10 @@ void CashShopHandler::handleMessage(Net::MessageIn &msg A_UNUSED)
{
}
-void CashShopHandler::buy(const int points A_UNUSED,
- const int itemId A_UNUSED,
- const unsigned char color A_UNUSED,
- const int amount A_UNUSED) const
+void CashShopHandler::buyItem(const int points A_UNUSED,
+ const int itemId A_UNUSED,
+ const unsigned char color A_UNUSED,
+ const int amount A_UNUSED) const
{
}
diff --git a/src/net/tmwa/cashshophandler.h b/src/net/tmwa/cashshophandler.h
index cbd558d9d..6f79c8480 100644
--- a/src/net/tmwa/cashshophandler.h
+++ b/src/net/tmwa/cashshophandler.h
@@ -38,10 +38,10 @@ class CashShopHandler final : public MessageHandler,
void handleMessage(Net::MessageIn &msg) override final;
- void buy(const int points,
- const int itemId,
- const unsigned char color,
- const int amount) const override final;
+ void buyItem(const int points,
+ const int itemId,
+ const unsigned char color,
+ const int amount) const override final;
};
} // namespace TmwAthena