diff options
author | Paul Gilbert | 2018-03-22 18:31:18 -0400 |
---|---|---|
committer | Paul Gilbert | 2018-03-22 18:31:18 -0400 |
commit | d725d78ec5e58d84433634ce1d6171c722df46bc (patch) | |
tree | 93995c7717f5a071d1cf9c421ad77f0ad1089e00 | |
parent | d623ec2c38e62567525cc84554a3fd7c4e3bfef4 (diff) | |
download | scummvm-rg350-d725d78ec5e58d84433634ce1d6171c722df46bc.tar.gz scummvm-rg350-d725d78ec5e58d84433634ce1d6171c722df46bc.tar.bz2 scummvm-rg350-d725d78ec5e58d84433634ce1d6171c722df46bc.zip |
XEEN: Fix implementation of breakAllItems
-rw-r--r-- | engines/xeen/character.cpp | 3 | ||||
-rw-r--r-- | engines/xeen/character.h | 2 | ||||
-rw-r--r-- | engines/xeen/item.cpp | 35 | ||||
-rw-r--r-- | engines/xeen/item.h | 5 |
4 files changed, 22 insertions, 23 deletions
diff --git a/engines/xeen/character.cpp b/engines/xeen/character.cpp index ba81852c50..47d43d806f 100644 --- a/engines/xeen/character.cpp +++ b/engines/xeen/character.cpp @@ -38,8 +38,7 @@ void AttributePair::synchronize(Common::Serializer &s) { /*------------------------------------------------------------------------*/ Character::Character(): - _weapons(this), _armor(this), _accessories(this), _misc(this), - _items(_weapons, _armor, _accessories, _misc) { + _weapons(this), _armor(this), _accessories(this), _misc(this), _items(this) { clear(); _faceSprites = nullptr; _rosterId = -1; diff --git a/engines/xeen/character.h b/engines/xeen/character.h index 9a757b56e2..c169e6c769 100644 --- a/engines/xeen/character.h +++ b/engines/xeen/character.h @@ -130,11 +130,11 @@ public: bool _hasSpells; int8 _currentSpell; QuickAction _quickOption; - InventoryItemsGroup _items; WeaponItems _weapons; ArmorItems _armor; AccessoryItems _accessories; MiscItems _misc; + InventoryItemsGroup _items; int _lloydSide; AttributePair _fireResistence; AttributePair _coldResistence; diff --git a/engines/xeen/item.cpp b/engines/xeen/item.cpp index b722d9152d..fe9e4ab052 100644 --- a/engines/xeen/item.cpp +++ b/engines/xeen/item.cpp @@ -629,30 +629,31 @@ Common::String MiscItems::getAttributes(XeenItem &item, const Common::String &cl } /*------------------------------------------------------------------------*/ -InventoryItemsGroup::InventoryItemsGroup(InventoryItems &weapons, InventoryItems &armor, - InventoryItems &accessories, InventoryItems &misc) { - _itemSets[0] = &weapons; - _itemSets[1] = &armor; - _itemSets[2] = &accessories; - _itemSets[3] = &misc; -} - InventoryItems &InventoryItemsGroup::operator[](ItemCategory category) { - return *_itemSets[category]; + switch (category) { + case CATEGORY_WEAPON: + return _owner->_weapons; + case CATEGORY_ARMOR: + return _owner->_armor; + case CATEGORY_ACCESSORY: + return _owner->_accessories; + default: + return _owner->_misc; + } } void InventoryItemsGroup::breakAllItems() { for (int idx = 0; idx < INV_ITEMS_TOTAL; ++idx) { - if ((*_itemSets[0])[idx]._id != 34) { - (*_itemSets[0])[idx]._bonusFlags |= ITEMFLAG_BROKEN; - (*_itemSets[0])[idx]._frame = 0; + if (_owner->_weapons[idx]._id != 34) { + _owner->_weapons[idx]._bonusFlags |= ITEMFLAG_BROKEN; + _owner->_weapons[idx]._frame = 0; } - (*_itemSets[1])[idx]._bonusFlags |= ITEMFLAG_BROKEN; - (*_itemSets[2])[idx]._bonusFlags |= ITEMFLAG_BROKEN; - (*_itemSets[3])[idx]._bonusFlags |= ITEMFLAG_BROKEN; - (*_itemSets[1])[idx]._frame = 0; - (*_itemSets[2])[idx]._frame = 0; + _owner->_armor[idx]._bonusFlags |= ITEMFLAG_BROKEN; + _owner->_accessories[idx]._bonusFlags |= ITEMFLAG_BROKEN; + _owner->_misc[idx]._bonusFlags |= ITEMFLAG_BROKEN; + _owner->_armor[idx]._frame = 0; + _owner->_accessories[idx]._frame = 0; } } diff --git a/engines/xeen/item.h b/engines/xeen/item.h index 871bd1c919..c79de0c282 100644 --- a/engines/xeen/item.h +++ b/engines/xeen/item.h @@ -259,10 +259,9 @@ public: class InventoryItemsGroup { private: - InventoryItems *_itemSets[4]; + Character *_owner; public: - InventoryItemsGroup(InventoryItems &weapons, InventoryItems &armor, - InventoryItems &accessories, InventoryItems &misc); + InventoryItemsGroup(Character *owner) : _owner(owner) {} /** * Returns the inventory items for a given category |