diff options
Diffstat (limited to 'engines/sci/graphics/celobj32.cpp')
-rw-r--r-- | engines/sci/graphics/celobj32.cpp | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/engines/sci/graphics/celobj32.cpp b/engines/sci/graphics/celobj32.cpp index 430500ce1e..09ea05bd59 100644 --- a/engines/sci/graphics/celobj32.cpp +++ b/engines/sci/graphics/celobj32.cpp @@ -800,7 +800,7 @@ int16 CelObjView::getNumLoops(const GuiResourceId viewId) { return resource->data[2]; } -int16 CelObjView::getNumCels(const GuiResourceId viewId, const int16 loopNo) { +int16 CelObjView::getNumCels(const GuiResourceId viewId, int16 loopNo) { const Resource *const resource = g_sci->getResMan()->findResource(ResourceId(kResourceTypeView, viewId), false); if (!resource) { @@ -813,25 +813,15 @@ int16 CelObjView::getNumCels(const GuiResourceId viewId, const int16 loopNo) { // Every version of SCI32 has a logic error in this function that causes // random memory to be read if a script requests the cel count for one - // past the maximum loop index. At least GK1 room 800 does this, and gets - // stuck in an infinite loop because the game script expects this method - // to return a non-zero value. - // The scope of this bug means it is likely to pop up in other games, so we - // explicitly trap the bad condition here and report it so that any other - // game scripts relying on this broken behavior can be fixed as well + // past the maximum loop index. For example, GK1 room 808 does this, and + // gets stuck in an infinite loop because the game script expects this + // method to return a non-zero value. + // This bug is triggered in basically every SCI32 game and appears to be + // universally fixable simply by always using the next lowest loop instead. if (loopNo == loopCount) { - SciCallOrigin origin; - SciWorkaroundSolution solution = trackOriginAndFindWorkaround(0, kNumCels_workarounds, &origin); - switch (solution.type) { - case WORKAROUND_NONE: - error("[CelObjView::getNumCels]: loop number %d is equal to loop count in view %u, %s", loopNo, viewId, origin.toString().c_str()); - case WORKAROUND_FAKE: - return (int16)solution.value; - case WORKAROUND_IGNORE: - return 0; - case WORKAROUND_STILLCALL: - break; - } + const SciCallOrigin origin = g_sci->getEngineState()->getCurrentCallOrigin(); + debugC(kDebugLevelWorkarounds, "Workaround: kNumCels loop %d -> loop %d in view %u, %s", loopNo, loopNo - 1, viewId, origin.toString().c_str()); + --loopNo; } if (loopNo > loopCount || loopNo < 0) { |