aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2018-02-17 21:48:36 -0500
committerPaul Gilbert2018-02-17 21:48:36 -0500
commit9ce8d4f446a5b4b1e4c992d4830a7a5c4bafcc68 (patch)
tree1f4450a86683133e3c36d2de528c72a2045a984d
parente6de89d2441b6c60139195449b5f056a7407fbff (diff)
downloadscummvm-rg350-9ce8d4f446a5b4b1e4c992d4830a7a5c4bafcc68.tar.gz
scummvm-rg350-9ce8d4f446a5b4b1e4c992d4830a7a5c4bafcc68.tar.bz2
scummvm-rg350-9ce8d4f446a5b4b1e4c992d4830a7a5c4bafcc68.zip
XEEN: Cleanup of giveTake give case 66 - give item
-rw-r--r--engines/xeen/character.cpp4
-rw-r--r--engines/xeen/character.h2
-rw-r--r--engines/xeen/party.cpp65
-rw-r--r--engines/xeen/party.h5
4 files changed, 23 insertions, 53 deletions
diff --git a/engines/xeen/character.cpp b/engines/xeen/character.cpp
index 456e12477f..7fc17a5e84 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 1e13c36260..bf4966c348 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 dc70bc2089..37e6d46dc0 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 cb7bfd9d7b..372e373676 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 {