diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-02-01 00:43:24 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-02-01 00:45:05 +0300 |
commit | 2c273a20b2cd3e1628840f2d87df16f0cce9ad33 (patch) | |
tree | 853d172e0fd05117d84eda712912ba2843bb87e2 /src/net | |
parent | 35481061f62111f916a39ce3cac6a314579418f9 (diff) | |
download | plus-2c273a20b2cd3e1628840f2d87df16f0cce9ad33.tar.gz plus-2c273a20b2cd3e1628840f2d87df16f0cce9ad33.tar.bz2 plus-2c273a20b2cd3e1628840f2d87df16f0cce9ad33.tar.xz plus-2c273a20b2cd3e1628840f2d87df16f0cce9ad33.zip |
Set currency to buy dialog based on selected npc type id.
For now this type never set.
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/eathena/buysellrecv.cpp | 30 | ||||
-rw-r--r-- | src/net/eathena/cashshoprecv.cpp | 27 | ||||
-rw-r--r-- | src/net/eathena/marketrecv.cpp | 28 | ||||
-rw-r--r-- | src/net/eathena/npcrecv.cpp | 4 | ||||
-rw-r--r-- | src/net/eathena/npcrecv.h | 4 | ||||
-rw-r--r-- | src/net/eathena/vendingrecv.cpp | 4 | ||||
-rw-r--r-- | src/net/tmwa/buysellrecv.cpp | 7 |
7 files changed, 98 insertions, 6 deletions
diff --git a/src/net/eathena/buysellrecv.cpp b/src/net/eathena/buysellrecv.cpp index f817813c6..2984eac97 100644 --- a/src/net/eathena/buysellrecv.cpp +++ b/src/net/eathena/buysellrecv.cpp @@ -26,15 +26,23 @@ #include "being/playerinfo.h" +#include "const/resources/currency.h" + #include "enums/resources/notifytypes.h" #include "gui/windows/buydialog.h" #include "gui/widgets/createwidget.h" +#include "net/messagein.h" + #include "net/ea/buysellrecv.h" -#include "net/messagein.h" +#include "net/eathena/npcrecv.h" + +#include "resources/beinginfo.h" + +#include "resources/db/npcdb.h" #include "debug.h" @@ -46,8 +54,26 @@ void BuySellRecv::processNpcBuy(Net::MessageIn &msg) msg.readInt16("len"); const int sz = 11; const int n_items = (msg.getLength() - 4) / sz; + + const BeingTypeId npcId = NpcRecv::mNpcTypeId; + std::string currency; + + if (npcId != BeingTypeId_zero) + { + const BeingInfo *info = NPCDB::get(npcId); + if (info) + currency = info->getCurrency(); + else + currency = DEFAULT_CURRENCY; + } + else + { + currency = DEFAULT_CURRENCY; + } + CREATEWIDGETV(Ea::BuySellRecv::mBuyDialog, BuyDialog, - Ea::BuySellRecv::mNpcId); + Ea::BuySellRecv::mNpcId, + currency); Ea::BuySellRecv::mBuyDialog->setMoney( PlayerInfo::getAttribute(Attributes::MONEY)); diff --git a/src/net/eathena/cashshoprecv.cpp b/src/net/eathena/cashshoprecv.cpp index e051f8ba0..fefe422f1 100644 --- a/src/net/eathena/cashshoprecv.cpp +++ b/src/net/eathena/cashshoprecv.cpp @@ -24,6 +24,8 @@ #include "being/playerinfo.h" +#include "const/resources/currency.h" + #include "enums/resources/notifytypes.h" #include "gui/windows/buydialog.h" @@ -32,6 +34,12 @@ #include "net/messagein.h" +#include "net/eathena/npcrecv.h" + +#include "resources/beinginfo.h" + +#include "resources/db/npcdb.h" + #include "debug.h" extern int packetVersion; @@ -52,7 +60,24 @@ void CashShopRecv::processCashShopOpen(Net::MessageIn &msg) else count = (msg.readInt16("len") - 8) / 11; - CREATEWIDGETV(mBuyDialog, BuyDialog, fromInt(BuyDialog::Cash, BeingId)); + const BeingTypeId npcId = NpcRecv::mNpcTypeId; + std::string currency; + + if (npcId != BeingTypeId_zero) + { + const BeingInfo *info = NPCDB::get(npcId); + if (info) + currency = info->getCurrency(); + else + currency = DEFAULT_CURRENCY; + } + else + { + currency = DEFAULT_CURRENCY; + } + CREATEWIDGETV(mBuyDialog, BuyDialog, + fromInt(BuyDialog::Cash, BeingId), + currency); const int points = msg.readInt32("cash points"); mBuyDialog->setMoney(points); diff --git a/src/net/eathena/marketrecv.cpp b/src/net/eathena/marketrecv.cpp index c3ac370ff..82775acff 100644 --- a/src/net/eathena/marketrecv.cpp +++ b/src/net/eathena/marketrecv.cpp @@ -24,6 +24,8 @@ #include "being/playerinfo.h" +#include "const/resources/currency.h" + #include "enums/resources/notifytypes.h" #include "gui/windows/buydialog.h" @@ -32,6 +34,12 @@ #include "net/messagein.h" +#include "net/eathena/npcrecv.h" + +#include "resources/beinginfo.h" + +#include "resources/db/npcdb.h" + #include "debug.h" namespace EAthena @@ -47,7 +55,25 @@ void MarketRecv::processMarketOpen(Net::MessageIn &msg) { const int len = (msg.readInt16("len") - 4) / 13; - CREATEWIDGETV(mBuyDialog, BuyDialog, fromInt(BuyDialog::Market, BeingId)); + const BeingTypeId npcId = NpcRecv::mNpcTypeId; + std::string currency; + + if (npcId != BeingTypeId_zero) + { + const BeingInfo *info = NPCDB::get(npcId); + if (info) + currency = info->getCurrency(); + else + currency = DEFAULT_CURRENCY; + } + else + { + currency = DEFAULT_CURRENCY; + } + + CREATEWIDGETV(mBuyDialog, BuyDialog, + fromInt(BuyDialog::Market, BeingId), + currency); mBuyDialog->setMoney(PlayerInfo::getAttribute(Attributes::MONEY)); for (int f = 0; f < len; f ++) diff --git a/src/net/eathena/npcrecv.cpp b/src/net/eathena/npcrecv.cpp index d67c4f880..c23d9d11b 100644 --- a/src/net/eathena/npcrecv.cpp +++ b/src/net/eathena/npcrecv.cpp @@ -37,6 +37,10 @@ namespace EAthena { +namespace NpcRecv +{ + BeingTypeId mNpcTypeId = BeingTypeId_zero; +} // namespace NpcRecv void NpcRecv::processNpcCutin(Net::MessageIn &msg) { diff --git a/src/net/eathena/npcrecv.h b/src/net/eathena/npcrecv.h index 2cdd42719..c89d5f2f0 100644 --- a/src/net/eathena/npcrecv.h +++ b/src/net/eathena/npcrecv.h @@ -21,6 +21,8 @@ #ifndef NET_EATHENA_NPCRECV_H #define NET_EATHENA_NPCRECV_H +#include "enums/simpletypes/beingtypeid.h" + namespace Net { class MessageIn; @@ -30,6 +32,8 @@ namespace EAthena { namespace NpcRecv { + extern BeingTypeId mNpcTypeId; + void processNpcCutin(Net::MessageIn &msg); void processNpcViewPoint(Net::MessageIn &msg); void processNpcShowProgressBar(Net::MessageIn &msg); diff --git a/src/net/eathena/vendingrecv.cpp b/src/net/eathena/vendingrecv.cpp index f5168abac..6d583bca6 100644 --- a/src/net/eathena/vendingrecv.cpp +++ b/src/net/eathena/vendingrecv.cpp @@ -24,6 +24,8 @@ #include "itemcolormanager.h" #include "notifymanager.h" +#include "const/resources/currency.h" + #include "being/localplayer.h" #include "being/playerinfo.h" @@ -109,7 +111,7 @@ void VendingRecv::processItemsList(Net::MessageIn &msg) if (!being) return; int cards[maxCards]; - CREATEWIDGETV(mBuyDialog, BuyDialog, being); + CREATEWIDGETV(mBuyDialog, BuyDialog, being, DEFAULT_CURRENCY); mBuyDialog->setMoney(PlayerInfo::getAttribute(Attributes::MONEY)); if (msg.getVersion() >= 20100105) msg.readInt32("vender id"); diff --git a/src/net/tmwa/buysellrecv.cpp b/src/net/tmwa/buysellrecv.cpp index 6a30f7bc6..7f4ed9de8 100644 --- a/src/net/tmwa/buysellrecv.cpp +++ b/src/net/tmwa/buysellrecv.cpp @@ -26,6 +26,8 @@ #include "being/playerinfo.h" +#include "const/resources/currency.h" + #include "enums/resources/notifytypes.h" #include "gui/windows/buydialog.h" @@ -36,6 +38,8 @@ #include "net/ea/buysellrecv.h" +#include "resources/db/npcdb.h" + #include "debug.h" namespace TmwAthena @@ -46,7 +50,8 @@ void BuySellRecv::processNpcBuy(Net::MessageIn &msg) msg.readInt16("len"); const unsigned int n_items = (msg.getLength() - 4U) / 11; CREATEWIDGETV(Ea::BuySellRecv::mBuyDialog, BuyDialog, - Ea::BuySellRecv::mNpcId); + Ea::BuySellRecv::mNpcId, + DEFAULT_CURRENCY); Ea::BuySellRecv::mBuyDialog->setMoney( PlayerInfo::getAttribute(Attributes::MONEY)); |