diff options
author | Filippos Karapetis | 2011-10-12 02:43:08 +0300 |
---|---|---|
committer | Filippos Karapetis | 2011-10-12 02:44:16 +0300 |
commit | 4af034a7a991d12ea062b90548fd4c7339d5b527 (patch) | |
tree | 60a82c8ca1a08912841ddbb7cd15247e692ce931 /engines/sci/graphics | |
parent | 271a1018993c30ad7ba74fa5a1d7d6dd78ed7869 (diff) | |
download | scummvm-rg350-4af034a7a991d12ea062b90548fd4c7339d5b527.tar.gz scummvm-rg350-4af034a7a991d12ea062b90548fd4c7339d5b527.tar.bz2 scummvm-rg350-4af034a7a991d12ea062b90548fd4c7339d5b527.zip |
SCI: Added proper handling of duplicate items in kAddScreenItem
- Items that are being readded to the scene should be updated instead
- Added a findScreenItem() call to simplify the code slightly
Diffstat (limited to 'engines/sci/graphics')
-rw-r--r-- | engines/sci/graphics/frameout.cpp | 55 | ||||
-rw-r--r-- | engines/sci/graphics/frameout.h | 1 |
2 files changed, 33 insertions, 23 deletions
diff --git a/engines/sci/graphics/frameout.cpp b/engines/sci/graphics/frameout.cpp index 17b4b015d5..9d15c8233f 100644 --- a/engines/sci/graphics/frameout.cpp +++ b/engines/sci/graphics/frameout.cpp @@ -235,36 +235,45 @@ void GfxFrameout::kernelUpdateScreenItem(reg_t object) { if (!_segMan->isObject(object)) return; - for (FrameoutList::iterator listIterator = _screenItems.begin(); listIterator != _screenItems.end(); listIterator++) { - FrameoutEntry *itemEntry = *listIterator; - - if (itemEntry->object == object) { - itemEntry->viewId = readSelectorValue(_segMan, object, SELECTOR(view)); - itemEntry->loopNo = readSelectorValue(_segMan, object, SELECTOR(loop)); - itemEntry->celNo = readSelectorValue(_segMan, object, SELECTOR(cel)); - itemEntry->x = readSelectorValue(_segMan, object, SELECTOR(x)); - itemEntry->y = readSelectorValue(_segMan, object, SELECTOR(y)); - itemEntry->z = readSelectorValue(_segMan, object, SELECTOR(z)); - itemEntry->priority = readSelectorValue(_segMan, object, SELECTOR(priority)); - if (readSelectorValue(_segMan, object, SELECTOR(fixPriority)) == 0) - itemEntry->priority = itemEntry->y; - - itemEntry->signal = readSelectorValue(_segMan, object, SELECTOR(signal)); - itemEntry->scaleX = readSelectorValue(_segMan, object, SELECTOR(scaleX)); - itemEntry->scaleY = readSelectorValue(_segMan, object, SELECTOR(scaleY)); - return; - } + FrameoutEntry *itemEntry = findScreenItem(object); + if (!itemEntry) { + warning("kernelUpdateScreenItem: invalid object %04x:%04x", PRINT_REG(object)); + return; } + + itemEntry->viewId = readSelectorValue(_segMan, object, SELECTOR(view)); + itemEntry->loopNo = readSelectorValue(_segMan, object, SELECTOR(loop)); + itemEntry->celNo = readSelectorValue(_segMan, object, SELECTOR(cel)); + itemEntry->x = readSelectorValue(_segMan, object, SELECTOR(x)); + itemEntry->y = readSelectorValue(_segMan, object, SELECTOR(y)); + itemEntry->z = readSelectorValue(_segMan, object, SELECTOR(z)); + itemEntry->priority = readSelectorValue(_segMan, object, SELECTOR(priority)); + if (readSelectorValue(_segMan, object, SELECTOR(fixPriority)) == 0) + itemEntry->priority = itemEntry->y; + + itemEntry->signal = readSelectorValue(_segMan, object, SELECTOR(signal)); + itemEntry->scaleX = readSelectorValue(_segMan, object, SELECTOR(scaleX)); + itemEntry->scaleY = readSelectorValue(_segMan, object, SELECTOR(scaleY)); } void GfxFrameout::kernelDeleteScreenItem(reg_t object) { + FrameoutEntry *itemEntry = findScreenItem(object); + if (!itemEntry) { + warning("kernelDeleteScreenItem: invalid object %04x:%04x", PRINT_REG(object)); + return; + } + + _screenItems.remove(itemEntry); +} + +FrameoutEntry *GfxFrameout::findScreenItem(reg_t object) { for (FrameoutList::iterator listIterator = _screenItems.begin(); listIterator != _screenItems.end(); listIterator++) { FrameoutEntry *itemEntry = *listIterator; - if (itemEntry->object == object) { - _screenItems.remove(itemEntry); - return; - } + if (itemEntry->object == object) + return itemEntry; } + + return NULL; } int16 GfxFrameout::kernelGetHighPlanePri() { diff --git a/engines/sci/graphics/frameout.h b/engines/sci/graphics/frameout.h index 4e0f312a4b..3176db25fd 100644 --- a/engines/sci/graphics/frameout.h +++ b/engines/sci/graphics/frameout.h @@ -93,6 +93,7 @@ public: void kernelAddScreenItem(reg_t object); void kernelUpdateScreenItem(reg_t object); void kernelDeleteScreenItem(reg_t object); + FrameoutEntry *findScreenItem(reg_t object); int16 kernelGetHighPlanePri(); void kernelAddPicAt(reg_t planeObj, GuiResourceId pictureId, int16 pictureX, int16 pictureY); void kernelFrameout(); |