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 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'src/net/eathena/buysellrecv.cpp') 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)); -- cgit v1.2.3-70-g09d2