From 2e9c7b5342290005c92f30bcce35401c91fcd175 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Thu, 22 Sep 2011 10:53:53 -0400 Subject: [PATCH] PEGASUS: Don't allow for seeking beyond the ends of the movie --- engines/pegasus/movie.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/engines/pegasus/movie.cpp b/engines/pegasus/movie.cpp index 9d9c18994fc..2bf852a496e 100755 --- a/engines/pegasus/movie.cpp +++ b/engines/pegasus/movie.cpp @@ -81,6 +81,9 @@ void Movie::redrawMovieWorld() { if (_video) { const Graphics::Surface *frame = _video->decodeNextFrame(); + if (!frame) + return; + if (_directDraw) { // Copy to the screen Common::Rect bounds; @@ -117,8 +120,16 @@ void Movie::setVolume(uint16 volume) { void Movie::setTime(const TimeValue time, const TimeScale scale) { if (_video) { - _video->seekToTime(Audio::Timestamp(0, time, ((scale == 0) ? getScale() : scale))); - _time = Common::Rational(time, ((scale == 0) ? getScale() : scale)); + // Don't go past the ends of the movie + Common::Rational timeFrac = Common::Rational(time, ((scale == 0) ? getScale() : scale)); + + if (timeFrac < Common::Rational(_startTime, _startScale)) + timeFrac = Common::Rational(_startTime, _startScale); + else if (timeFrac >= Common::Rational(_stopTime, _stopScale)) + return; + + _video->seekToTime(Audio::Timestamp(0, timeFrac.getNumerator(), timeFrac.getDenominator())); + _time = timeFrac; } }