[Scummvm-git-logs] scummvm master -> 9ce8d4f446a5b4b1e4c992d4830a7a5c4bafcc68

dreammaster dreammaster at scummvm.org
Sun Feb 18 03:48:33 CET 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:
9ce8d4f446 XEEN: Cleanup of giveTake give case 66 - give item


Commit: 9ce8d4f446a5b4b1e4c992d4830a7a5c4bafcc68
    https://github.com/scummvm/scummvm/commit/9ce8d4f446a5b4b1e4c992d4830a7a5c4bafcc68
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2018-02-17T21:48:36-05:00

Commit Message:
XEEN: Cleanup of giveTake give case 66 - give item

Changed paths:
    engines/xeen/character.cpp
    engines/xeen/character.h
    engines/xeen/party.cpp
    engines/xeen/party.h


diff --git a/engines/xeen/character.cpp b/engines/xeen/character.cpp
index 456e124..7fc17a5 100644
--- a/engines/xeen/character.cpp
+++ b/engines/xeen/character.cpp
@@ -1525,12 +1525,12 @@ int Character::getNumAwards() const {
 	return total;
 }
 
-int Character::makeItem(int p1, int itemIndex, int p3) {
+ItemCategory Character::makeItem(int p1, int itemIndex, int p3) {
 	XeenEngine *vm = Party::_vm;
 	Scripts &scripts = *vm->_scripts;
 
 	if (!p1)
-		return 0;
+		return CATEGORY_WEAPON;
 
 	int itemId = 0;
 	int v4 = vm->getRandomNumber(100);
diff --git a/engines/xeen/character.h b/engines/xeen/character.h
index 1e13c36..bf4966c 100644
--- a/engines/xeen/character.h
+++ b/engines/xeen/character.h
@@ -503,7 +503,7 @@ public:
 	/**
 	 * Creates an item and adds it to the inventory
 	 */
-	int makeItem(int p1, int itemIndex, int p3);
+	ItemCategory makeItem(int p1, int itemIndex, int p3);
 
 	/**
 	 * Add hit points to a character
diff --git a/engines/xeen/party.cpp b/engines/xeen/party.cpp
index dc70bc2..37e6d46 100644
--- a/engines/xeen/party.cpp
+++ b/engines/xeen/party.cpp
@@ -622,7 +622,7 @@ void Party::giveTreasure() {
 			}
 
 			// If there's no treasure item to be distributed, skip to next slot
-			if (!_treasure._categories[categoryNum][itemNum]._id)
+			if (!_treasure[categoryNum][itemNum]._id)
 				continue;
 
 			int charIndex = scripts._whoWill - 1;
@@ -1255,8 +1255,7 @@ bool Party::giveTake(int takeMode, uint takeVal, int giveMode, uint giveVal, int
 		_food += giveVal;
 		break;
 	case 66: {
-		warning("TODO: Verify case 66");
-		Character &c = _itemsCharacter;
+		Character &tempChar = _itemsCharacter;
 		int idx = -1;
 		if (scripts._itemType != 0) {
 			for (idx = 0; idx < 10 && _treasure._misc[idx]._material; ++idx);
@@ -1264,55 +1263,21 @@ bool Party::giveTake(int takeMode, uint takeVal, int giveMode, uint giveVal, int
 				return true;
 		}
 
-		int result = ps.makeItem(giveVal, 0, (idx == -1) ? 12 : 0);
-		switch (result) {
-		case 0:
-			for (idx = 0; idx < 10 && _treasure._weapons[idx]._id; ++idx);
-			if (idx == 10)
-				return true;
-
-			ps._weapons[idx]._material = c._weapons[0]._material;
-			ps._weapons[idx]._id = c._weapons[0]._id;
-			ps._weapons[idx]._bonusFlags = c._weapons[0]._bonusFlags;
-			_treasure._hasItems = true;
-			break;
-
-		case 1:
-			for (idx = 0; idx < 10 && _treasure._armor[idx]._id; ++idx);
-			if (idx == 10)
-				return true;
-
-			ps._armor[idx]._material = c._armor[0]._material;
-			ps._armor[idx]._id = c._armor[0]._id;
-			ps._armor[idx]._bonusFlags = c._armor[0]._bonusFlags;
-			_treasure._hasItems = true;
-			break;
-
-		case 2:
-			for (idx = 0; idx < 10 && _treasure._accessories[idx]._id; ++idx);
-			if (idx == 10)
-				return true;
-
-			ps._accessories[idx]._material = c._accessories[0]._material;
-			ps._accessories[idx]._id = c._accessories[0]._id;
-			ps._accessories[idx]._bonusFlags = c._accessories[0]._bonusFlags;
-			_treasure._hasItems = true;
-			break;
+		// Create the item and it's category
+		ItemCategory itemCat = tempChar.makeItem(giveVal, 0, (idx == -1) ? 12 : 0);
+		XeenItem &srcItem = _treasure[itemCat][0];
+		XeenItem *trItems = _treasure[itemCat];
 
-		case 3:
-			for (idx = 0; idx < 10 && _treasure._misc[idx]._material; ++idx);
-			if (idx == 10)
-				return true;
-
-			ps._misc[idx]._material = c._misc[0]._material;
-			ps._misc[idx]._id = c._misc[0]._id;
-			ps._misc[idx]._bonusFlags = c._misc[0]._bonusFlags;
-			_treasure._hasItems = true;
-			break;
-
-		default:
+		// Check for a free treasure slot
+		for (idx = 0; idx < 10 && trItems[idx]._id; ++idx);
+		if (idx == 10)
 			return true;
-		}
+
+		// Found a free slot, so copy the created item into it
+		trItems[idx]._material = srcItem._material;
+		trItems[idx]._id = srcItem._id;
+		trItems[idx]._bonusFlags = srcItem._bonusFlags;
+		_treasure._hasItems = true;
 		break;
 	}
 	case 69:
diff --git a/engines/xeen/party.h b/engines/xeen/party.h
index cb7bfd9..372e373 100644
--- a/engines/xeen/party.h
+++ b/engines/xeen/party.h
@@ -77,6 +77,11 @@ public:
 	int _gems, _gold;
 public:
 	Treasure();
+
+	/**
+	 * Returns a particular category's array
+	 */
+	XeenItem *operator[](int category) { return _categories[category]; }
 };
 
 class Party {





More information about the Scummvm-git-logs mailing list