aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/graphics/celobj32.cpp
diff options
context:
space:
mode:
authorColin Snover2016-10-29 19:50:35 -0500
committerColin Snover2016-11-02 15:43:07 -0500
commite8c429832f7b6393f853fd6d9ce8ba2e62f6a93c (patch)
treef9a8cbf4f2dea3f1a3ce34012aaa8e18b7006ee7 /engines/sci/graphics/celobj32.cpp
parentc42e74c562c3a55cb72901e8ecb56da600bfcb42 (diff)
downloadscummvm-rg350-e8c429832f7b6393f853fd6d9ce8ba2e62f6a93c.tar.gz
scummvm-rg350-e8c429832f7b6393f853fd6d9ce8ba2e62f6a93c.tar.bz2
scummvm-rg350-e8c429832f7b6393f853fd6d9ce8ba2e62f6a93c.zip
SCI32: Automate kNumCels workaround
Diffstat (limited to 'engines/sci/graphics/celobj32.cpp')
-rw-r--r--engines/sci/graphics/celobj32.cpp28
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) {