Skip to content

Commit

Permalink
SHERLOCK: RT: Fix drawing last frame of animations
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Aug 9, 2015
1 parent 41e1320 commit d5af7b7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
13 changes: 10 additions & 3 deletions engines/sherlock/image_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1026,6 +1026,7 @@ StreamingImageFile::StreamingImageFile() {
_scaleVal = 0;
_zPlacement = 0;
_compressed = false;
_active = false;
}

StreamingImageFile::~StreamingImageFile() {
Expand All @@ -1036,18 +1037,22 @@ void StreamingImageFile::load(Common::SeekableReadStream *stream, bool compresse
_stream = stream;
_compressed = compressed;
_frameNumber = -1;
_active = true;
}

void StreamingImageFile::close() {
delete _stream;
_stream = nullptr;
_frameNumber = -1;
_active = false;
}

void StreamingImageFile::getNextFrame() {
bool StreamingImageFile::getNextFrame() {
// Don't proceed if we're already at the end of the stream
if (_stream->pos() >= _stream->size())
return;
if (_stream->pos() >= _stream->size()) {
_active = false;
return false;
}

// Increment frame number
++_frameNumber;
Expand Down Expand Up @@ -1080,6 +1085,8 @@ void StreamingImageFile::getNextFrame() {
_imageFrame.decompressFrame(_buffer + 11, true);
delete[] data;
}

return true;
}

} // End of namespace Sherlock
7 changes: 4 additions & 3 deletions engines/sherlock/image_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,9 @@ class StreamingImageFile {
private:
int _frameNumber;
Common::SeekableReadStream *_stream;
bool _compressed;
byte _buffer[STREAMING_BUFFER_SIZE];
bool _compressed;
bool _active;
public:
ImageFrame _imageFrame;

Expand Down Expand Up @@ -189,12 +190,12 @@ class StreamingImageFile {
/**
* Get the next frame of the file
*/
void getNextFrame();
bool getNextFrame();

/**
* Returns whether there are any remaining frames or not
*/
bool active() const { return _stream != nullptr && _stream->pos() < _stream->size(); }
bool active() const { return _active; }

/**
* Return the current frame number
Expand Down
5 changes: 3 additions & 2 deletions engines/sherlock/tattoo/tattoo_scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -663,9 +663,10 @@ int TattooScene::startCAnim(int cAnimNum, int playRate) {

_activeCAnim.load(animStream, _compressed);

while (_activeCAnim.active() && !_vm->shouldQuit()) {
while (!_vm->shouldQuit()) {
// Get the next frame
_activeCAnim.getNextFrame();
if (!_activeCAnim.getNextFrame())
break;

// Draw the frame
doBgAnim();
Expand Down

0 comments on commit d5af7b7

Please sign in to comment.