diff options
author | Torbjörn Andersson | 2008-10-13 18:41:12 +0000 |
---|---|---|
committer | Torbjörn Andersson | 2008-10-13 18:41:12 +0000 |
commit | c2066b9c20930af2e01953f6bf97f147fb2673e3 (patch) | |
tree | 83855b2ca8db12e8494e42c370fe7eee04a980f0 | |
parent | ffdbb474c4cab2f26645b8624acc3bc8ce3196d9 (diff) | |
download | scummvm-rg350-c2066b9c20930af2e01953f6bf97f147fb2673e3.tar.gz scummvm-rg350-c2066b9c20930af2e01953f6bf97f147fb2673e3.tar.bz2 scummvm-rg350-c2066b9c20930af2e01953f6bf97f147fb2673e3.zip |
Fixed crash after using cutscene subtitles. (Now I *know* no one has used that
feature before. :-)
svn-id: r34796
-rw-r--r-- | engines/sword1/animation.cpp | 11 | ||||
-rw-r--r-- | engines/sword1/text.cpp | 7 | ||||
-rw-r--r-- | engines/sword1/text.h | 2 |
3 files changed, 13 insertions, 7 deletions
diff --git a/engines/sword1/animation.cpp b/engines/sword1/animation.cpp index 608274179f..a033abbc3d 100644 --- a/engines/sword1/animation.cpp +++ b/engines/sword1/animation.cpp @@ -278,7 +278,7 @@ void MoviePlayer::play(void) { _textSpriteBuf = (byte *)calloc(_textHeight, _textWidth); } if (_currentFrame == _movieTexts[0]->_endFrame) { - _textMan->releaseText(2); + _textMan->releaseText(2, false); free(_textSpriteBuf); _textSpriteBuf = NULL; delete _movieTexts.remove_at(0); @@ -309,10 +309,15 @@ void MoviePlayer::play(void) { if (terminated) _snd->stopHandle(_bgSoundHandle); - while (!_movieTexts.empty()) { - delete _movieTexts.remove_at(_movieTexts.size() - 1); + if (_textSpriteBuf) { + _textMan->releaseText(2, false); + free(_textSpriteBuf); + _textSpriteBuf = NULL; } + while (!_movieTexts.empty()) + delete _movieTexts.remove_at(_movieTexts.size() - 1); + while (_snd->isSoundHandleActive(_bgSoundHandle)) _system->delayMillis(100); diff --git a/engines/sword1/text.cpp b/engines/sword1/text.cpp index 4758028522..499133dd97 100644 --- a/engines/sword1/text.cpp +++ b/engines/sword1/text.cpp @@ -89,7 +89,7 @@ void Text::makeTextSprite(uint8 slot, uint8 *text, uint16 maxWidth, uint8 pen) { assert(!_textBlocks[slot]); // if this triggers, the speechDriver failed to call Text::releaseText. _textBlocks[slot] = (FrameHeader*)malloc(sprSize + sizeof(FrameHeader)); - memcpy( _textBlocks[slot]->runTimeComp, "Nu ", 4); + memcpy(_textBlocks[slot]->runTimeComp, "Nu ", 4); _textBlocks[slot]->compSize = 0; _textBlocks[slot]->width = _resMan->toUint16(sprWidth); _textBlocks[slot]->height = _resMan->toUint16(sprHeight); @@ -179,13 +179,14 @@ FrameHeader *Text::giveSpriteData(uint32 textTarget) { return _textBlocks[textTarget]; } -void Text::releaseText(uint32 id) { +void Text::releaseText(uint32 id, bool updateCount) { id &= ITM_ID; assert(id < MAX_TEXT_OBS); if (_textBlocks[id]) { free(_textBlocks[id]); _textBlocks[id] = NULL; - _textCount--; + if (updateCount) + _textCount--; } } diff --git a/engines/sword1/text.h b/engines/sword1/text.h index 59b42fa67d..6a15585148 100644 --- a/engines/sword1/text.h +++ b/engines/sword1/text.h @@ -52,7 +52,7 @@ public: FrameHeader *giveSpriteData(uint32 textTarget); uint32 lowTextManager(uint8 *text, int32 width, uint8 pen); void makeTextSprite(uint8 slot, uint8 *text, uint16 maxWidth, uint8 pen); - void releaseText(uint32 id); + void releaseText(uint32 id, bool updateCount = true); private: uint16 analyzeSentence(uint8 *text, uint16 maxWidth, LineInfo *info); |