From 3996783c885d056b812b90e699f635685c2781dd Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 1 Sep 2019 10:14:28 -0700 Subject: XEEN: Fix searches resulting in misc items --- engines/xeen/character.cpp | 18 ++++++++++-------- engines/xeen/character.h | 2 ++ engines/xeen/party.cpp | 4 +++- engines/xeen/scripts.cpp | 4 +--- engines/xeen/scripts.h | 1 - 5 files changed, 16 insertions(+), 13 deletions(-) (limited to 'engines') diff --git a/engines/xeen/character.cpp b/engines/xeen/character.cpp index 982ffd88ad..8a5fa94737 100644 --- a/engines/xeen/character.cpp +++ b/engines/xeen/character.cpp @@ -48,6 +48,8 @@ int CharacterArray::indexOf(const Character &c) { /*------------------------------------------------------------------------*/ +int Character::_itemType; + Character::Character(): _weapons(this), _armor(this), _accessories(this), _misc(this), _items(this) { clear(); _faceSprites = nullptr; @@ -969,7 +971,6 @@ int Character::getNumAwards() const { ItemCategory Character::makeItem(int p1, int itemIndex, int p3) { XeenEngine *vm = Party::_vm; - Scripts &scripts = *vm->_scripts; int itemOffset = vm->getGameID() == GType_Swords ? 6 : 0; if (!p1) @@ -983,18 +984,18 @@ ItemCategory Character::makeItem(int p1, int itemIndex, int p3) { // Randomly pick a category and item Id if (p3 == 12) { - if (scripts._itemType < (35 + itemOffset)) { + if (_itemType < (35 + itemOffset)) { category = CATEGORY_WEAPON; - itemId = scripts._itemType; - } else if (scripts._itemType < (49 + itemOffset)) { + itemId = _itemType; + } else if (_itemType < (49 + itemOffset)) { category = CATEGORY_ARMOR; - itemId = scripts._itemType - (35 + itemOffset); - } else if (scripts._itemType < (60 + itemOffset)) { + itemId = _itemType - (35 + itemOffset); + } else if (_itemType < (60 + itemOffset)) { category = CATEGORY_ACCESSORY; - itemId = scripts._itemType - (49 + itemOffset); + itemId = _itemType - (49 + itemOffset); } else { category = CATEGORY_MISC; - itemId = scripts._itemType - (60 + itemOffset); + itemId = _itemType - (60 + itemOffset); } } else { switch (p3) { @@ -1104,6 +1105,7 @@ ItemCategory Character::makeItem(int p1, int itemIndex, int p3) { break; case CATEGORY_MISC: + newItem._material = itemId; v8 = 4; break; diff --git a/engines/xeen/character.h b/engines/xeen/character.h index 47312efe66..07d93b2d45 100644 --- a/engines/xeen/character.h +++ b/engines/xeen/character.h @@ -154,6 +154,8 @@ public: SpriteResource *_faceSprites; int _rosterId; +public: + static int _itemType; public: /** * Constructor diff --git a/engines/xeen/party.cpp b/engines/xeen/party.cpp index 6f9868b282..48100310c5 100644 --- a/engines/xeen/party.cpp +++ b/engines/xeen/party.cpp @@ -257,6 +257,8 @@ Party::Party(XeenEngine *vm) { _fallMaze = 0; _fallDamage = 0; _dead = false; + + Character::_itemType = 0; } void Party::synchronize(Common::Serializer &s) { @@ -1359,7 +1361,7 @@ bool Party::giveTake(int takeMode, uint takeVal, int giveMode, uint giveVal, int case 66: { Character &tempChar = _itemsCharacter; int idx = -1; - if (scripts._itemType != 0) { + if (Character::_itemType != 0) { for (idx = 0; idx < 10 && _treasure._misc[idx]._material; ++idx) {} if (idx == 10) return true; diff --git a/engines/xeen/scripts.cpp b/engines/xeen/scripts.cpp index 81af063f2f..a781086238 100644 --- a/engines/xeen/scripts.cpp +++ b/engines/xeen/scripts.cpp @@ -115,7 +115,6 @@ bool MirrorEntry::synchronize(Common::SeekableReadStream &s) { Scripts::Scripts(XeenEngine *vm) : _vm(vm) { _whoWill = 0; - _itemType = 0; _treasureItems = 0; _lineNum = 0; _charIndex = 0; @@ -144,7 +143,6 @@ int Scripts::checkEvents() { int ccNum = files._ccNum; _refreshIcons = false; - _itemType = 0; _scriptExecuted = false; _dirFlag = false; _whoWill = 0; @@ -1313,7 +1311,7 @@ bool Scripts::cmdGiveEnchanted(ParamsIterator ¶ms) { } bool Scripts::cmdItemType(ParamsIterator ¶ms) { - _itemType = params.readByte(); + Character::_itemType = params.readByte(); return true; } diff --git a/engines/xeen/scripts.h b/engines/xeen/scripts.h index 89b6bda250..d1236fb464 100644 --- a/engines/xeen/scripts.h +++ b/engines/xeen/scripts.h @@ -554,7 +554,6 @@ public: bool _eventSkipped; int _whoWill; DamageType _nEdamageType; - int _itemType; Common::Array _mirror; Common::String _message; public: -- cgit v1.2.3