From b6fc3fd99195f2cbc1e17ea6827175855df8f8cc Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 31 Mar 2018 18:39:42 -0400 Subject: XEEN: Change many item Id checks to use empty() function --- engines/xeen/combat.cpp | 8 ++++---- engines/xeen/dialogs/dialogs_items.cpp | 2 +- engines/xeen/item.cpp | 4 ++-- engines/xeen/party.cpp | 8 ++++---- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/engines/xeen/combat.cpp b/engines/xeen/combat.cpp index bec9942767..b1ecd7776d 100644 --- a/engines/xeen/combat.cpp +++ b/engines/xeen/combat.cpp @@ -1527,7 +1527,7 @@ void Combat::attack2(int damage, RangeType rangeType) { switch (category) { case CATEGORY_WEAPON: for (int idx = 0; idx < MAX_TREASURE_ITEMS; ++idx) { - if (party._treasure._weapons[idx]._id == 0) { + if (party._treasure._weapons[idx].empty()) { party._treasure._weapons[idx] = tempChar._weapons[0]; party._treasure._hasItems = true; break; @@ -1536,7 +1536,7 @@ void Combat::attack2(int damage, RangeType rangeType) { break; case CATEGORY_ARMOR: for (int idx = 0; idx < MAX_TREASURE_ITEMS; ++idx) { - if (party._treasure._armor[idx]._id == 0) { + if (party._treasure._armor[idx].empty()) { party._treasure._armor[idx] = tempChar._armor[0]; party._treasure._hasItems = true; break; @@ -1545,7 +1545,7 @@ void Combat::attack2(int damage, RangeType rangeType) { break; case CATEGORY_ACCESSORY: for (int idx = 0; idx < MAX_TREASURE_ITEMS; ++idx) { - if (party._treasure._accessories[idx]._id == 0) { + if (party._treasure._accessories[idx].empty()) { party._treasure._accessories[idx] = tempChar._accessories[0]; party._treasure._hasItems = true; break; @@ -1554,7 +1554,7 @@ void Combat::attack2(int damage, RangeType rangeType) { break; case CATEGORY_MISC: for (int idx = 0; idx < MAX_TREASURE_ITEMS; ++idx) { - if (party._treasure._accessories[idx]._id == 0) { + if (party._treasure._accessories[idx].empty()) { party._treasure._accessories[idx] = tempChar._accessories[0]; party._treasure._hasItems = true; break; diff --git a/engines/xeen/dialogs/dialogs_items.cpp b/engines/xeen/dialogs/dialogs_items.cpp index f844964396..0ea835e121 100644 --- a/engines/xeen/dialogs/dialogs_items.cpp +++ b/engines/xeen/dialogs/dialogs_items.cpp @@ -904,7 +904,7 @@ int ItemsDialog::doItemOptions(Character &c, int actionIndex, int itemIndex, Ite } case ITEMMODE_RECHARGE: - if (category != CATEGORY_MISC || item._material > 9 || item._id == 53 || item._id == 0) { + if (category != CATEGORY_MISC || item.empty() || item._material > 9 || item._id == 53) { sound.playFX(21); ErrorScroll::show(_vm, Common::String::format(Res.NOT_RECHARGABLE, Res.SPELL_FAILED)); } else { diff --git a/engines/xeen/item.cpp b/engines/xeen/item.cpp index 3fe2896583..a79efc085d 100644 --- a/engines/xeen/item.cpp +++ b/engines/xeen/item.cpp @@ -217,7 +217,7 @@ bool InventoryItems::discardItem(int itemIndex) { void InventoryItems::sort() { for (uint idx = 0; idx < size(); ++idx) { - if (operator[](idx)._id == 0) { + if (operator[](idx).empty()) { // Found empty slot operator[](idx).clear(); @@ -272,7 +272,7 @@ void InventoryItems::enchantItem(int itemIndex, int amount) { bool InventoryItems::isFull() const { assert(size() == INV_ITEMS_TOTAL); - return operator[](size() - 1)._id != 0; + return !operator[](size() - 1).empty(); } void InventoryItems::capitalizeItem(Common::String &name) { diff --git a/engines/xeen/party.cpp b/engines/xeen/party.cpp index f60c532872..a3bb674093 100644 --- a/engines/xeen/party.cpp +++ b/engines/xeen/party.cpp @@ -799,10 +799,10 @@ bool Party::arePacksFull() const { uint total = 0; for (uint idx = 0; idx < _activeParty.size(); ++idx) { const Character &c = _activeParty[idx]; - total += (c._weapons[INV_ITEMS_TOTAL - 1]._id != 0 ? 1 : 0) - + (c._armor[INV_ITEMS_TOTAL - 1]._id != 0 ? 1 : 0) - + (c._accessories[INV_ITEMS_TOTAL - 1]._id != 0 ? 1 : 0) - + (c._misc[INV_ITEMS_TOTAL - 1]._id != 0 ? 1 : 0); + total += (c._weapons[INV_ITEMS_TOTAL - 1].empty() ? 0 : 1) + + (c._armor[INV_ITEMS_TOTAL - 1].empty() ? 0 : 1) + + (c._accessories[INV_ITEMS_TOTAL - 1].empty() ? 0 : 1) + + (c._misc[INV_ITEMS_TOTAL - 1].empty() ? 0 : 1); } return total == (_activeParty.size() * NUM_ITEM_CATEGORIES); -- cgit v1.2.3