diff options
author | Paul Gilbert | 2017-12-29 21:29:40 -0500 |
---|---|---|
committer | Paul Gilbert | 2017-12-29 21:29:40 -0500 |
commit | 8f8166236c7aa9c37868131ccf0fb77e40655d4b (patch) | |
tree | 3884c47160f7bed11692aa677ada8a8b334805e9 | |
parent | d0c04053dd2acce2a9afa675099d304cbf7c9a70 (diff) | |
download | scummvm-rg350-8f8166236c7aa9c37868131ccf0fb77e40655d4b.tar.gz scummvm-rg350-8f8166236c7aa9c37868131ccf0fb77e40655d4b.tar.bz2 scummvm-rg350-8f8166236c7aa9c37868131ccf0fb77e40655d4b.zip |
XEEN: Simplify itemScan method
-rw-r--r-- | engines/xeen/character.cpp | 125 |
1 files changed, 59 insertions, 66 deletions
diff --git a/engines/xeen/character.cpp b/engines/xeen/character.cpp index 67760cee67..e68cb192ae 100644 --- a/engines/xeen/character.cpp +++ b/engines/xeen/character.cpp @@ -1125,87 +1125,80 @@ uint Character::getCurrentLevel() const { int Character::itemScan(int itemId) const { int result = 0; - for (int accessIdx = 0; accessIdx < 3; ++accessIdx) { - switch (accessIdx) { - case 0: - for (int idx = 0; idx < INV_ITEMS_TOTAL; ++idx) { - const XeenItem &item = _weapons[idx]; + // Weapons + for (int idx = 0; idx < INV_ITEMS_TOTAL; ++idx) { + const XeenItem &item = _weapons[idx]; - if (item._frame && !(item._bonusFlags & 0xC0) && itemId < 11 - && itemId != 3 && item._material >= 59 && item._material <= 130) { - int mIndex = (int)item.getAttributeCategory(); - if (mIndex > PERSONALITY) - ++mIndex; + if (item._frame && !(item._bonusFlags & 0xC0) && itemId < 11 + && itemId != 3 && item._material >= 59 && item._material <= 130) { + int mIndex = (int)item.getAttributeCategory(); + if (mIndex > PERSONALITY) + ++mIndex; - if (mIndex == itemId) - result += Res.ATTRIBUTE_BONUSES[item._material - 59]; - } + if (mIndex == itemId) + result += Res.ATTRIBUTE_BONUSES[item._material - 59]; + } + } + + // Armor + for (int idx = 0; idx < INV_ITEMS_TOTAL; ++idx) { + const XeenItem &item = _armor[idx]; + + if (item._frame && !(item._bonusFlags & 0xC0)) { + if (itemId < 11 && itemId != 3 && item._material >= 59 && item._material <= 130) { + int mIndex = (int)item.getAttributeCategory(); + if (mIndex > PERSONALITY) + ++mIndex; + + if (mIndex == itemId) + result += Res.ATTRIBUTE_BONUSES[item._material - 59]; } - break; - case 1: - for (int idx = 0; idx < INV_ITEMS_TOTAL; ++idx) { - const XeenItem &item = _armor[idx]; + if (itemId > 10 && item._material < 37) { + int mIndex = item.getElementalCategory() + 11; - if (item._frame && !(item._bonusFlags & 0xC0)) { - if (itemId < 11 && itemId != 3 && item._material >= 59 && item._material <= 130) { - int mIndex = (int)item.getAttributeCategory(); - if (mIndex > PERSONALITY) - ++mIndex; + if (mIndex == itemId) { + result += Res.ELEMENTAL_RESISTENCES[item._material]; + } + } - if (mIndex == itemId) - result += Res.ATTRIBUTE_BONUSES[item._material - 59]; - } + if (itemId == 9) { + result += Res.ARMOR_STRENGTHS[item._id]; - if (itemId > 10 && item._material < 37) { - int mIndex = item.getElementalCategory() + 11; + if (item._material >= 37 && item._material <= 58) + result += Res.METAL_LAC[item._material - 37]; + } + } + } - if (mIndex == itemId) { - result += Res.ELEMENTAL_RESISTENCES[item._material]; - } - } + // Accessories + for (int idx = 0; idx < INV_ITEMS_TOTAL; ++idx) { + const XeenItem &item = _accessories[idx]; - if (itemId == 9) { - result += Res.ARMOR_STRENGTHS[item._id]; + if (item._frame && !(item._bonusFlags & 0xC0)) { + if (itemId < 11 && itemId != 3 && item._material >= 59 && item._material <= 130) { + int mIndex = (int)item.getAttributeCategory(); + if (mIndex > PERSONALITY) + ++mIndex; - if (item._material >= 37 && item._material <= 58) - result += Res.METAL_LAC[item._material - 37]; - } + if (mIndex == itemId) { + result += Res.ATTRIBUTE_BONUSES[item._material - 59]; } } - break; - case 2: - for (int idx = 0; idx < INV_ITEMS_TOTAL; ++idx) { - const XeenItem &item = _accessories[idx]; - - if (item._frame && !(item._bonusFlags & 0xC0)) { - if (itemId < 11 && itemId != 3 && item._material >= 59 && item._material <= 130) { - int mIndex = (int)item.getAttributeCategory(); - if (mIndex > PERSONALITY) - ++mIndex; - - if (mIndex == itemId) { - result += Res.ATTRIBUTE_BONUSES[item._material - 59]; - } - } - - if (itemId > 10 && item._material < 37) { - int mIndex = item.getElementalCategory() + 11; - - if (mIndex == itemId) - result += Res.ELEMENTAL_RESISTENCES[item._material]; - } - - if (itemId == 9) { - result += Res.ARMOR_STRENGTHS[item._id]; - if (item._material >= 37 && item._material <= 58) { - result += Res.METAL_LAC[item._material - 37]; - } - } + if (itemId > 10 && item._material < 37) { + int mIndex = item.getElementalCategory() + 11; + + if (mIndex == itemId) + result += Res.ELEMENTAL_RESISTENCES[item._material]; + } + + if (itemId == 9) { + result += Res.ARMOR_STRENGTHS[item._id]; + if (item._material >= 37 && item._material <= 58) { + result += Res.METAL_LAC[item._material - 37]; } } - break; } } |