From 2c273a20b2cd3e1628840f2d87df16f0cce9ad33 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 1 Feb 2017 00:43:24 +0300 Subject: Set currency to buy dialog based on selected npc type id. For now this type never set. --- src/net/eathena/buysellrecv.cpp | 30 ++++++++++++++++++++++++++++-- src/net/eathena/cashshoprecv.cpp | 27 ++++++++++++++++++++++++++- src/net/eathena/marketrecv.cpp | 28 +++++++++++++++++++++++++++- src/net/eathena/npcrecv.cpp | 4 ++++ src/net/eathena/npcrecv.h | 4 ++++ src/net/eathena/vendingrecv.cpp | 4 +++- 6 files changed, 92 insertions(+), 5 deletions(-) (limited to 'src/net/eathena') 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"); -- cgit v1.2.3-70-g09d2