From 60c36631425755cbb9d7b06637b129b0e9b4a9da Mon Sep 17 00:00:00 2001 From: Colin Snover Date: Sat, 9 Jul 2016 19:37:18 -0500 Subject: SCI32: Fix incorrect logic of cycler overflow --- engines/sci/graphics/palette32.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'engines/sci/graphics') diff --git a/engines/sci/graphics/palette32.cpp b/engines/sci/graphics/palette32.cpp index 4ee33bdd38..9d1cc655b9 100644 --- a/engines/sci/graphics/palette32.cpp +++ b/engines/sci/graphics/palette32.cpp @@ -651,18 +651,15 @@ void GfxPalette32::setCycle(const uint8 fromColor, const uint8 toColor, const in // SCI engine overrides the first oldest cycler that it finds where // “oldest” is determined by the difference between the tick and now if (cycler == nullptr) { - int maxUpdateDelta = -1; - // Optimization: Unlike actual SCI (SQ6) engine, we call - // getTickCount only once and store it, instead of calling it - // twice on each iteration through the loop const uint32 now = g_sci->getTickCount(); + uint32 minUpdateDelta = 0xFFFFFFFF; for (cyclerIndex = 0; cyclerIndex < numCyclers; ++cyclerIndex) { PalCycler *candidate = _cyclers[cyclerIndex]; - const int32 updateDelta = now - candidate->lastUpdateTick; - if (updateDelta >= maxUpdateDelta) { - maxUpdateDelta = updateDelta; + const uint32 updateDelta = now - candidate->lastUpdateTick; + if (updateDelta < minUpdateDelta) { + minUpdateDelta = updateDelta; cycler = candidate; } } -- cgit v1.2.3