diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-02-01 23:48:15 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-02-02 22:48:03 +0300 |
commit | 6dc1f5e0b68cf390f7938329b50a9b28bd187862 (patch) | |
tree | 29e30e48cc03d95aeff278f6842f3a15de8f4106 /src/gui/windows/buydialog.cpp | |
parent | c8c51d7550adf9c952a4be54398df7e7a6f341a8 (diff) | |
download | plus-6dc1f5e0b68cf390f7938329b50a9b28bd187862.tar.gz plus-6dc1f5e0b68cf390f7938329b50a9b28bd187862.tar.bz2 plus-6dc1f5e0b68cf390f7938329b50a9b28bd187862.tar.xz plus-6dc1f5e0b68cf390f7938329b50a9b28bd187862.zip |
Set correct vending status to local player.
Allow buy from vending shop.
Diffstat (limited to 'src/gui/windows/buydialog.cpp')
-rw-r--r-- | src/gui/windows/buydialog.cpp | 41 |
1 files changed, 29 insertions, 12 deletions
diff --git a/src/gui/windows/buydialog.cpp b/src/gui/windows/buydialog.cpp index b0564eb52..068440c65 100644 --- a/src/gui/windows/buydialog.cpp +++ b/src/gui/windows/buydialog.cpp @@ -22,6 +22,7 @@ #include "gui/windows/buydialog.h" +#include "actormanager.h" #include "configuration.h" #include "shopitem.h" #include "units.h" @@ -48,6 +49,8 @@ #include "net/cashshophandler.h" #include "net/markethandler.h" #include "net/npchandler.h" +#include "net/serverfeatures.h" +#include "net/vendinghandler.h" #include "resources/iteminfo.h" @@ -336,14 +339,15 @@ void BuyDialog::reset() setMoney(0); } -void BuyDialog::addItem(const int id, - const int type, - const unsigned char color, - const int amount, - const int price) +ShopItem *BuyDialog::addItem(const int id, + const int type, + const unsigned char color, + const int amount, + const int price) { - mShopItems->addItem(id, type, color, amount, price); + ShopItem *const item = mShopItems->addItem(id, type, color, amount, price); mShopItemList->adjustSize(); + return item; } void BuyDialog::sort() @@ -478,14 +482,27 @@ void BuyDialog::action(const ActionEvent &event) mSlider->setScale(1, mMaxItems); mSlider->setValue(1); } - else if (tradeWindow) + else if (mNpcId == Nick) { - if (item) + if (serverFeatures->haveVending()) { - buySellHandler->sendBuyRequest(mNick, - item, mAmountItems); - tradeWindow->addAutoMoney(mNick, - item->getPrice() * mAmountItems); + Being *const being = actorManager->findBeingByName(mNick); + if (being) + { + vendingHandler->buy(being, + item->getInvIndex(), + mAmountItems); + } + } + else if (tradeWindow) + { + if (item) + { + buySellHandler->sendBuyRequest(mNick, + item, mAmountItems); + tradeWindow->addAutoMoney(mNick, + item->getPrice() * mAmountItems); + } } } } |