aboutsummaryrefslogtreecommitdiff
path: root/engines/xeen/dialogs/dialogs_items.cpp
diff options
context:
space:
mode:
authorPaul Gilbert2018-03-14 20:08:52 -0400
committerPaul Gilbert2018-03-14 20:08:52 -0400
commit0b802f25d0513cc026b6c25b6d9755adc0f446e2 (patch)
tree2ee8c783ab3c633b3d99f834a3eb41f8699b8458 /engines/xeen/dialogs/dialogs_items.cpp
parent30ed738a7f206424854d69b05d1f0c2031131881 (diff)
downloadscummvm-rg350-0b802f25d0513cc026b6c25b6d9755adc0f446e2.tar.gz
scummvm-rg350-0b802f25d0513cc026b6c25b6d9755adc0f446e2.tar.bz2
scummvm-rg350-0b802f25d0513cc026b6c25b6d9755adc0f446e2.zip
XEEN: Fix transfer of bought items to character inventory
Diffstat (limited to 'engines/xeen/dialogs/dialogs_items.cpp')
-rw-r--r--engines/xeen/dialogs/dialogs_items.cpp24
1 files changed, 9 insertions, 15 deletions
diff --git a/engines/xeen/dialogs/dialogs_items.cpp b/engines/xeen/dialogs/dialogs_items.cpp
index 07e2b87cfe..38529f6832 100644
--- a/engines/xeen/dialogs/dialogs_items.cpp
+++ b/engines/xeen/dialogs/dialogs_items.cpp
@@ -631,10 +631,8 @@ int ItemsDialog::calcItemCost(Character *c, int itemIndex, ItemsMode mode,
int amount1 = 0, amount2 = 0, amount3 = 0, amount4 = 0;
int result = 0;
int level = skillLevel & 0x7f;
+ XeenItem &i = c->_items[category][itemIndex];
- InventoryItems *invGroups[4] = {
- &c->_weapons, &c->_armor, &c->_accessories, &c->_misc
- };
const int *BASE_COSTS[4] = {
Res.WEAPON_BASE_COSTS, Res.ARMOR_BASE_COSTS, Res.ACCESSORY_BASE_COSTS, Res.MISC_BASE_COSTS
};
@@ -660,8 +658,7 @@ int ItemsDialog::calcItemCost(Character *c, int itemIndex, ItemsMode mode,
switch (category) {
case CATEGORY_WEAPON:
case CATEGORY_ARMOR:
- case CATEGORY_ACCESSORY: {
- XeenItem &i = (*invGroups[category])[itemIndex];
+ case CATEGORY_ACCESSORY:
amount1 = (BASE_COSTS[category])[i._id];
if (i._material > 36 && i._material < 59) {
@@ -703,11 +700,9 @@ int ItemsDialog::calcItemCost(Character *c, int itemIndex, ItemsMode mode,
break;
}
break;
- }
- case CATEGORY_MISC: {
+ case CATEGORY_MISC:
// Misc
- XeenItem &i = c->_misc[itemIndex];
amount1 = Res.MISC_MATERIAL_COSTS[i._material];
amount4 = Res.MISC_BASE_COSTS[i._id];
@@ -725,7 +720,6 @@ int ItemsDialog::calcItemCost(Character *c, int itemIndex, ItemsMode mode,
break;
}
break;
- }
default:
break;
@@ -865,12 +859,12 @@ int ItemsDialog::doItemOptions(Character &c, int actionIndex, int itemIndex, Ite
case ITEMMODE_BLACKSMITH: {
InventoryItems &invItems = _oldCharacter->_items[category];
- if (invItems[INV_ITEMS_TOTAL - 1]._id) {
- // If the last slot is in use, it means the list is full
+ if (invItems.isFull()) {
+ // Character's inventory for that category is already full
ErrorScroll::show(_vm, Common::String::format(Res.BACKPACK_IS_FULL,
_oldCharacter->_name.c_str()));
} else {
- int cost = calcItemCost(_oldCharacter, itemIndex, mode, 0, category);
+ int cost = calcItemCost(&c, itemIndex, mode, 0, category);
Common::String desc = c._items[category].getFullDescription(itemIndex);
if (Confirm::show(_vm, Common::String::format(Res.BUY_X_FOR_Y_GOLD,
desc.c_str(), cost))) {
@@ -881,9 +875,9 @@ int ItemsDialog::doItemOptions(Character &c, int actionIndex, int itemIndex, Ite
}
// Add entry to the end of the list
- _oldCharacter->_items[category][8] = c._items[category][itemIndex];
- _oldCharacter->_items[category][8]._frame = 0;
- c._items[category].clear();
+ XeenItem &bsItem = c._items[category][itemIndex];
+ _oldCharacter->_items[category][INV_ITEMS_TOTAL - 1] = bsItem;
+ bsItem.clear();
c._items[category].sort();
_oldCharacter->_items[category].sort();
}