From 2035e21667b746c346e9f95658109904a86597d3 Mon Sep 17 00:00:00 2001 From: Colin Snover Date: Mon, 26 Sep 2016 10:33:52 -0500 Subject: SCI32: Add workaround for kNumCels This workaround may be able to be vastly simplified in the future since, so far, simply returning the number of cels in loop 0 is enough to make all the scripts with this bug work as expected. --- engines/sci/graphics/celobj32.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'engines/sci/graphics/celobj32.cpp') diff --git a/engines/sci/graphics/celobj32.cpp b/engines/sci/graphics/celobj32.cpp index 5d2d5dd6a6..e5149246e4 100644 --- a/engines/sci/graphics/celobj32.cpp +++ b/engines/sci/graphics/celobj32.cpp @@ -28,6 +28,7 @@ #include "sci/graphics/palette32.h" #include "sci/graphics/remap32.h" #include "sci/graphics/text32.h" +#include "sci/engine/workarounds.h" namespace Sci { #pragma mark CelScaler @@ -819,8 +820,18 @@ int16 CelObjView::getNumCels(const GuiResourceId viewId, const int16 loopNo) { // 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 if (loopNo == loopCount) { - const SciCallOrigin origin = g_sci->getEngineState()->getCurrentCallOrigin(); - error("[CelObjView::getNumCels]: loop number is equal to loop count in method %s::%s (room %d, script %d, localCall %x)", origin.objectName.c_str(), origin.methodName.c_str(), origin.roomNr, origin.scriptNr, origin.localCallOffset); + SciCallOrigin origin; + SciWorkaroundSolution solution = trackOriginAndFindWorkaround(0, kNumCels_workarounds, &origin); + switch (solution.type) { + case WORKAROUND_NONE: + error("[CelObjView::getNumCels]: loop number is equal to loop count in method %s::%s (room %d, script %d, localCall %x)", origin.objectName.c_str(), origin.methodName.c_str(), origin.roomNr, origin.scriptNr, origin.localCallOffset); + case WORKAROUND_FAKE: + return (int16)solution.value; + case WORKAROUND_IGNORE: + return 0; + case WORKAROUND_STILLCALL: + break; + } } if (loopNo > loopCount || loopNo < 0) { -- cgit v1.2.3