[Scummvm-git-logs] scummvm master -> b6fc3fd99195f2cbc1e17ea6827175855df8f8cc

dreammaster dreammaster at scummvm.org
Sun Apr 1 00:39:44 CEST 2018


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
b6fc3fd991 XEEN: Change many item Id checks to use empty() function


Commit: b6fc3fd99195f2cbc1e17ea6827175855df8f8cc
    https://github.com/scummvm/scummvm/commit/b6fc3fd99195f2cbc1e17ea6827175855df8f8cc
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2018-03-31T18:39:42-04:00

Commit Message:
XEEN: Change many item Id checks to use empty() function

Changed paths:
    engines/xeen/combat.cpp
    engines/xeen/dialogs/dialogs_items.cpp
    engines/xeen/item.cpp
    engines/xeen/party.cpp


diff --git a/engines/xeen/combat.cpp b/engines/xeen/combat.cpp
index bec9942..b1ecd77 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 f844964..0ea835e 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 3fe2896..a79efc0 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 f60c532..a3bb674 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);





More information about the Scummvm-git-logs mailing list