diff options
author | Paul Gilbert | 2014-05-16 18:30:41 -0400 |
---|---|---|
committer | Paul Gilbert | 2014-05-16 18:30:41 -0400 |
commit | d590ca39d139136cf616d80beb525ff3a07acca2 (patch) | |
tree | 1aa1a6263e04b28e21a440f856154aa5479da023 /engines/mads/inventory.cpp | |
parent | 3af6bbb397ae94bfbfceeaeab9979613d1047cbb (diff) | |
download | scummvm-rg350-d590ca39d139136cf616d80beb525ff3a07acca2.tar.gz scummvm-rg350-d590ca39d139136cf616d80beb525ff3a07acca2.tar.bz2 scummvm-rg350-d590ca39d139136cf616d80beb525ff3a07acca2.zip |
MADS: Properly implemented object quality code
Diffstat (limited to 'engines/mads/inventory.cpp')
-rw-r--r-- | engines/mads/inventory.cpp | 54 |
1 files changed, 35 insertions, 19 deletions
diff --git a/engines/mads/inventory.cpp b/engines/mads/inventory.cpp index 79a8e87b2a..434d284244 100644 --- a/engines/mads/inventory.cpp +++ b/engines/mads/inventory.cpp @@ -31,16 +31,46 @@ void InventoryObject::synchronize(Common::Serializer &s) { s.syncAsUint16LE(_roomNumber); s.syncAsByte(_article); s.syncAsByte(_vocabCount); + s.syncAsByte(_qualitiesCount); + s.skip(1); - for (int i = 0; i < 3; ++i) { + for (int i = 0; i < MAX_VOCAB; ++i) { + s.syncAsUint16LE(_vocabList[i]._vocabId); s.syncAsByte(_vocabList[i]._verbType); s.syncAsByte(_vocabList[i]._prepType); - s.syncAsUint16LE( _vocabList[i]._vocabId); } - s.skip(4); // field12 - s.syncBytes((byte *)&_mutilateString[0], 10); - s.skip(16); + for (int i = 0; i < MAX_QUALITIES; ++i) + s.syncAsByte(_qualityId[i]); + for (int i = 0; i < MAX_QUALITIES; ++i) + s.syncAsSint32LE(_qualityValue[i]); +} + +bool InventoryObject::hasQuality(int qualityId) const { + for (int i = 0; i < _qualitiesCount; ++i) { + if (_qualityId[i] == qualityId) + return true; + } + + return false; +} + +void InventoryObject::setQuality(int qualityId, int qualityValue) { + for (int i = 0; i < _qualitiesCount; ++i) { + if (_qualityId[i] == qualityId) { + _qualityValue[i] = qualityValue; + } + } +} + +int InventoryObject::getQuality(int qualityId) const { + for (int i = 0; i < _qualitiesCount; ++i) { + if (_qualityId[i] == qualityId) { + return _qualityValue[i]; + } + } + + return 0; } /*------------------------------------------------------------------------*/ @@ -92,20 +122,6 @@ void InventoryObjects::synchronize(Common::Serializer &s) { } } -void InventoryObjects::setQuality(int objIndex, int id, const byte *p) { - // TODO: This whole method seems weird. Check it out more thoroughly once - // more of the engine is implemented - for (int i = 0; i < (int)size(); ++i) { - InventoryObject &obj = (*this)[i]; - if (obj._vocabList[0]._verbType <= i) - break; - - if (obj._mutilateString[6 + i] == id) { - (*this)[objIndex]._objFolder = p; - } - } -} - void InventoryObjects::setRoom(int objectId, int sceneNumber) { InventoryObject &obj = (*this)[objectId]; |