diff options
author | Dmitry Iskrich | 2016-06-29 19:24:12 +0300 |
---|---|---|
committer | Eugene Sandulenko | 2016-08-03 23:40:36 +0200 |
commit | b208b8e5fffc6a13277987d98400488c4d59d9c1 (patch) | |
tree | d989483eefaf6aa749714c523a8c075ac7770abe /engines/director | |
parent | aaf8448cbc0a282a1c28f0ef4d7c738c8b87ab3b (diff) | |
download | scummvm-rg350-b208b8e5fffc6a13277987d98400488c4d59d9c1.tar.gz scummvm-rg350-b208b8e5fffc6a13277987d98400488c4d59d9c1.tar.bz2 scummvm-rg350-b208b8e5fffc6a13277987d98400488c4d59d9c1.zip |
DIRECTOR: Fix memory corruption
Diffstat (limited to 'engines/director')
-rw-r--r-- | engines/director/director.cpp | 8 | ||||
-rw-r--r-- | engines/director/director.h | 15 | ||||
-rw-r--r-- | engines/director/score.cpp | 8 |
3 files changed, 16 insertions, 15 deletions
diff --git a/engines/director/director.cpp b/engines/director/director.cpp index 10db492e59..9a22e675cb 100644 --- a/engines/director/director.cpp +++ b/engines/director/director.cpp @@ -395,14 +395,14 @@ void DirectorEngine::loadSharedCastsFrom(Common::String filename) { Common::SeekableSubReadStreamEndian *castStream = shardcst->getResource(MKTAG('V','W','C','R'), 1024); castScore->loadCastData(*castStream); - _sharedCasts = castScore->_casts; + *_sharedCasts = castScore->_casts; Common::Array<uint16> dib = shardcst->getResourceIDList(MKTAG('D','I','B',' ')); if (dib.size() != 0) { Common::Array<uint16>::iterator iterator; for (iterator = dib.begin(); iterator != dib.end(); ++iterator) { - _sharedDIB[*iterator] = shardcst->getResource(MKTAG('D','I','B',' '), *iterator); + _sharedDIB->setVal(*iterator, shardcst->getResource(MKTAG('D','I','B',' '), *iterator)); } } @@ -411,7 +411,7 @@ void DirectorEngine::loadSharedCastsFrom(Common::String filename) { if (stxt.size() != 0) { Common::Array<uint16>::iterator iterator; for (iterator = stxt.begin(); iterator != stxt.end(); ++iterator) { - _sharedSTXT[*iterator] = shardcst->getResource(MKTAG('S','T','X','T'), *iterator); + _sharedSTXT->setVal(*iterator, shardcst->getResource(MKTAG('S','T','X','T'), *iterator)); } } @@ -420,7 +420,7 @@ void DirectorEngine::loadSharedCastsFrom(Common::String filename) { if (stxt.size() != 0) { Common::Array<uint16>::iterator iterator; for (iterator = sound.begin(); iterator != sound.end(); ++iterator) { - _sharedSTXT[*iterator] = shardcst->getResource(MKTAG('S','N','D',' '), *iterator); + _sharedSound->setVal(*iterator, shardcst->getResource(MKTAG('S','N','D',' '), *iterator)); } } } diff --git a/engines/director/director.h b/engines/director/director.h index 82c43fd90c..a3e0ad0dbb 100644 --- a/engines/director/director.h +++ b/engines/director/director.h @@ -24,6 +24,7 @@ #define DIRECTOR_DIRECTOR_H #include "common/scummsys.h" +#include "common/substream.h" #include "common/str.h" #include "common/hashmap.h" @@ -67,9 +68,9 @@ public: const byte *getPalette() const { return _currentPalette; } uint16 getPaletteColorCount() const { return _currentPaletteLength; } void loadSharedCastsFrom(Common::String filename); - Common::HashMap<int, Common::SeekableReadStream *> getSharedDIB() const { return _sharedDIB; } - Common::HashMap<int, Common::SeekableReadStream *> getSharedSTXT() const { return _sharedSTXT; } - Common::HashMap<int, Cast *> getSharedCasts() const { return _sharedCasts; } + Common::HashMap<int, Common::SeekableSubReadStreamEndian *> *getSharedDIB() const { return _sharedDIB; } + Common::HashMap<int, Common::SeekableSubReadStreamEndian *> *getSharedSTXT() const { return _sharedSTXT; } + Common::HashMap<int, Cast *> *getSharedCasts() const { return _sharedCasts; } Common::HashMap<Common::String, Score *> *_movies; Score *_currentScore; @@ -93,10 +94,10 @@ private: Common::String readPascalString(Common::SeekableReadStream &stream); Common::String _sharedMMM; - Common::HashMap<int, Cast *> _sharedCasts; - Common::HashMap<int, Common::SeekableReadStream *> _sharedDIB; - Common::HashMap<int, Common::SeekableReadStream *> _sharedSTXT; - Common::HashMap<int, Common::SeekableReadStream *> _sharedSound; + Common::HashMap<int, Cast *> *_sharedCasts; + Common::HashMap<int, Common::SeekableSubReadStreamEndian *> *_sharedDIB; + Common::HashMap<int, Common::SeekableSubReadStreamEndian *> *_sharedSTXT; + Common::HashMap<int, Common::SeekableSubReadStreamEndian *> *_sharedSound; Archive *_mainArchive; Common::MacResManager *_macBinary; diff --git a/engines/director/score.cpp b/engines/director/score.cpp index ff324c59c4..59b37ececf 100644 --- a/engines/director/score.cpp +++ b/engines/director/score.cpp @@ -1129,11 +1129,11 @@ void Frame::renderSprites(Graphics::ManagedSurface &surface, bool renderTrail) { Cast *cast; if (!_vm->_currentScore->_casts.contains(_sprites[i]->_castId)) { - if (!_vm->getSharedCasts().contains(_sprites[i]->_castId)) { + if (!_vm->getSharedCasts()->contains(_sprites[i]->_castId)) { warning("Cast id %d not found", _sprites[i]->_castId); continue; } else { - cast = _vm->getSharedCasts().getVal(_sprites[i]->_castId); + cast = _vm->getSharedCasts()->getVal(_sprites[i]->_castId); } } else { cast = _vm->_currentScore->_casts[_sprites[i]->_castId]; @@ -1148,11 +1148,11 @@ void Frame::renderSprites(Graphics::ManagedSurface &surface, bool renderTrail) { uint32 imgId = 1024 + _sprites[i]->_castId; if (!_vm->_currentScore->getArchive()->hasResource(MKTAG('D', 'I', 'B', ' '), imgId)) { - if (!_vm->getSharedDIB().contains(imgId)) { + if (!_vm->getSharedDIB()->contains(imgId)) { warning("DIB id %d not found", imgId); continue; } else { - img.loadStream(*_vm->getSharedDIB().getVal(imgId)); + img.loadStream(*_vm->getSharedDIB()->getVal(imgId)); } } else { img.loadStream(*_vm->_currentScore->getArchive()->getResource(MKTAG('D', 'I', 'B', ' '), imgId)); |