diff options
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | src/gui/buydialog.cpp | 14 |
2 files changed, 14 insertions, 1 deletions
@@ -28,6 +28,7 @@ - Enabled whispers in tabs by default - Made pickup notifications to appear as particle instead of text by default - Custom mouse cursor is now rendered by the system +- Limit shop's Max button to available carry weight - Fixed performance issue in BrowserBox (especially update/news window) - Fixed handling of non-consecutive emote IDs - Fixed securing of names in files created by chat logger diff --git a/src/gui/buydialog.cpp b/src/gui/buydialog.cpp index 56c3c261..1ac5cdaa 100644 --- a/src/gui/buydialog.cpp +++ b/src/gui/buydialog.cpp @@ -239,7 +239,8 @@ void BuyDialog::updateButtonsAndLabels() if (selectedItem > -1) { - int itemPrice = mShopItems->at(selectedItem)->getPrice(); + const ShopItem *shopItem = mShopItems->at(selectedItem); + const int itemPrice = shopItem->getPrice(); // Calculate how many the player can afford if (itemPrice > 0) @@ -253,6 +254,17 @@ void BuyDialog::updateButtonsAndLabels() mMaxItems = 1; } + // Calculate how many the player can carry + const int itemWeight = shopItem->getInfo().getWeight(); + if (itemWeight > 0) + { + const int myTotalWeight = PlayerInfo::getAttribute(TOTAL_WEIGHT); + const int myMaxWeight = PlayerInfo::getAttribute(MAX_WEIGHT); + const int myFreeWeight = myMaxWeight - myTotalWeight; + const int canCarry = myFreeWeight / itemWeight; + mMaxItems = std::min(mMaxItems, canCarry); + } + if (mAmountItems > mMaxItems) mAmountItems = mMaxItems; |