From 506ed95cdcf11523efb06f8816c4f99a32a6a243 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 1 Apr 2018 14:41:23 +0200 Subject: BLADERUNNER: Fix chapter switching with CDFRAMES.DAT --- engines/bladerunner/slice_animations.cpp | 12 ++++++++++-- engines/bladerunner/slice_animations.h | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/engines/bladerunner/slice_animations.cpp b/engines/bladerunner/slice_animations.cpp index 411e6a07a1..f452947f2f 100644 --- a/engines/bladerunner/slice_animations.cpp +++ b/engines/bladerunner/slice_animations.cpp @@ -103,13 +103,15 @@ bool SliceAnimations::openFrames(int fileNumber) { } } + warning("opening: %d", fileNumber); + if (_framesPageFile._fileNumber == 0) // HDFRAMES.DAT return true; if (_framesPageFile._fileNumber == fileNumber) return true; - _framesPageFile._fileNumber = fileNumber; + _framesPageFile.close(); if (fileNumber == 1 && _framesPageFile.open("CDFRAMES.DAT")) // For Chapter1 we try both CDFRAMES.DAT and CDFRAMES1.DAT return true; @@ -139,11 +141,17 @@ bool SliceAnimations::PageFile::open(const Common::String &name) { _pageOffsets[pageNumber] = dataOffset + i * _sliceAnimations->_pageSize; } - debug("PageFile::Open: page file \"%s\" opened with %d pages", name.c_str(), pageCount); + debug(5, "PageFile::Open: page file \"%s\" opened with %d pages", name.c_str(), pageCount); return true; } +void SliceAnimations::PageFile::close() { + if (_file.isOpen()) { + _file.close(); + } +} + void *SliceAnimations::PageFile::loadPage(uint32 pageNumber) { if (_pageOffsets[pageNumber] == -1) return nullptr; diff --git a/engines/bladerunner/slice_animations.h b/engines/bladerunner/slice_animations.h index eafba1bb14..0732e596ea 100644 --- a/engines/bladerunner/slice_animations.h +++ b/engines/bladerunner/slice_animations.h @@ -72,6 +72,7 @@ class SliceAnimations { PageFile(SliceAnimations *sliceAnimations) : _sliceAnimations(sliceAnimations), _fileNumber(-1) {} bool open(const Common::String &name); + void close(); void *loadPage(uint32 page); }; -- cgit v1.2.3