diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2008-06-12 09:06:01 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2008-06-12 09:06:01 +0000 |
commit | 2f8ee95fbacb71e7cbca85fcc11e6f9f7e36c258 (patch) | |
tree | 8d256ac1a38932aaf0db7b55ed178e4212616555 /src/gui/buy.cpp | |
parent | eb019ab915998a3ec247b33dad4b23f763d7a29a (diff) | |
download | mana-2f8ee95fbacb71e7cbca85fcc11e6f9f7e36c258.tar.gz mana-2f8ee95fbacb71e7cbca85fcc11e6f9f7e36c258.tar.bz2 mana-2f8ee95fbacb71e7cbca85fcc11e6f9f7e36c258.tar.xz mana-2f8ee95fbacb71e7cbca85fcc11e6f9f7e36c258.zip |
Merged revisions 3738 via svnmerge from
https://themanaworld.svn.sourceforge.net/svnroot/themanaworld/tmw/trunk
........
r3738 | b_lindeijer | 2007-11-16 00:44:01 +0100 (Fri, 16 Nov 2007) | 3 lines
Moved item icon from ItemInfo class to the Item class, so that it can be loaded
on demand. Results in faster startup time and reduced memory usage.
........
Diffstat (limited to 'src/gui/buy.cpp')
-rw-r--r-- | src/gui/buy.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp index 17e5dba7..259fcfd9 100644 --- a/src/gui/buy.cpp +++ b/src/gui/buy.cpp @@ -33,8 +33,6 @@ #include "../npc.h" -#include "../resources/itemdb.h" - #include "../net/messageout.h" #include "../net/protocol.h" @@ -170,7 +168,7 @@ void BuyDialog::action(const gcn::ActionEvent &event) outMsg.writeInt16(CMSG_NPC_BUY_REQUEST); outMsg.writeInt16(8); outMsg.writeInt16(mAmountItems); - outMsg.writeInt16(mShopItems->at(selectedItem).id); + outMsg.writeInt16(mShopItems->at(selectedItem)->getId()); // Reset selection mAmountItems = 1; @@ -179,7 +177,8 @@ void BuyDialog::action(const gcn::ActionEvent &event) // Update money and adjust the max number of items that can be bought mMaxItems -= mAmountItems; - setMoney(mMoney - mAmountItems * mShopItems->at(selectedItem).price); + setMoney(mMoney - + mAmountItems * mShopItems->at(selectedItem)->getPrice()); } } @@ -246,20 +245,22 @@ BuyDialog::updateButtonsAndLabels() if (selectedItem > -1) { - const ItemInfo &info = ItemDB::get(mShopItems->at(selectedItem).id); + const ItemInfo &info = mShopItems->at(selectedItem)->getInfo(); mItemDescLabel->setCaption("Description: " + info.getDescription()); mItemEffectLabel->setCaption("Effect: " + info.getEffect()); + int itemPrice = mShopItems->at(selectedItem)->getPrice(); + // Calculate how many the player can afford - mMaxItems = mMoney / mShopItems->at(selectedItem).price; + mMaxItems = mMoney / itemPrice; if (mAmountItems > mMaxItems) { mAmountItems = mMaxItems; } // Calculate price of pending purchase - price = mAmountItems * mShopItems->at(selectedItem).price; + price = mAmountItems * itemPrice; } else { |