aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/graphics
diff options
context:
space:
mode:
authorMartin Kiewitz2010-08-24 17:22:05 +0000
committerMartin Kiewitz2010-08-24 17:22:05 +0000
commit3e6fb233ac33d74e7045fc8e172e4ac86f5f682c (patch)
tree4dfe45b6926a6f0af75414a55b3b2422d530edae /engines/sci/graphics
parentd48e173da1e8c278123353694ef23de024e3c850 (diff)
downloadscummvm-rg350-3e6fb233ac33d74e7045fc8e172e4ac86f5f682c.tar.gz
scummvm-rg350-3e6fb233ac33d74e7045fc8e172e4ac86f5f682c.tar.bz2
scummvm-rg350-3e6fb233ac33d74e7045fc8e172e4ac86f5f682c.zip
SCI: fix race condition in sierra kPalVary code
we are loading pictures very fast, this results in a kPalVary race condition, because sierra set timer to 1 tick, when it was getting called with 0 ticks and required the timer to occur before the transition. Fixes freddy pharkas nighttime being daytime during transitions (bug #3051905) svn-id: r52351
Diffstat (limited to 'engines/sci/graphics')
-rw-r--r--engines/sci/graphics/palette.cpp22
1 files changed, 18 insertions, 4 deletions
diff --git a/engines/sci/graphics/palette.cpp b/engines/sci/graphics/palette.cpp
index 2135adcc62..346a4c075c 100644
--- a/engines/sci/graphics/palette.cpp
+++ b/engines/sci/graphics/palette.cpp
@@ -614,9 +614,18 @@ bool GfxPalette::kernelPalVaryInit(GuiResourceId resourceId, uint16 ticks, uint1
_palVaryStepStop = stepStop;
_palVaryDirection = direction;
// if no ticks are given, jump directly to destination
- if (!_palVaryTicks)
+ if (!_palVaryTicks) {
_palVaryDirection = stepStop;
- palVaryInstallTimer();
+ // sierra sci set the timer to 1 tick instead of calling it directly
+ // we have to change this to prevent a race condition to happen in
+ // at least freddy pharkas during nighttime. In that case kPalVary is
+ // called right before that and because we load pictures much faster
+ // the 1 tick won't pass sometimes resulting in the palette being
+ // daytime instead of nighttime during the transition.
+ palVaryProcess(1, true);
+ } else {
+ palVaryInstallTimer();
+ }
return true;
}
return false;
@@ -633,9 +642,14 @@ int16 GfxPalette::kernelPalVaryReverse(int16 ticks, uint16 stepStop, int16 direc
_palVaryStepStop = stepStop;
_palVaryDirection = direction != -1 ? -direction : -_palVaryDirection;
- if (!_palVaryTicks)
+ if (!_palVaryTicks) {
_palVaryDirection = _palVaryStepStop - _palVaryStep;
- palVaryInstallTimer();
+ // ffs. see palVaryInit right above, we fix the code here as well
+ // just in case
+ palVaryProcess(1, true);
+ } else {
+ palVaryInstallTimer();
+ }
return kernelPalVaryGetCurrentStep();
}