[Scummvm-cvs-logs] SF.net SVN: scummvm:[52351] scummvm/trunk/engines/sci/graphics/palette.cpp

m_kiewitz at users.sourceforge.net m_kiewitz at users.sourceforge.net
Tue Aug 24 19:22:05 CEST 2010


Revision: 52351
          http://scummvm.svn.sourceforge.net/scummvm/?rev=52351&view=rev
Author:   m_kiewitz
Date:     2010-08-24 17:22:05 +0000 (Tue, 24 Aug 2010)

Log Message:
-----------
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)

Modified Paths:
--------------
    scummvm/trunk/engines/sci/graphics/palette.cpp

Modified: scummvm/trunk/engines/sci/graphics/palette.cpp
===================================================================
--- scummvm/trunk/engines/sci/graphics/palette.cpp	2010-08-24 17:17:13 UTC (rev 52350)
+++ scummvm/trunk/engines/sci/graphics/palette.cpp	2010-08-24 17:22:05 UTC (rev 52351)
@@ -614,9 +614,18 @@
 		_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 @@
 	_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();
 }
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list