diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/director/director.cpp | 1 | ||||
-rw-r--r-- | engines/director/frame.cpp | 2 | ||||
-rw-r--r-- | engines/director/resource.cpp | 5 | ||||
-rw-r--r-- | engines/director/score.cpp | 23 |
4 files changed, 22 insertions, 9 deletions
diff --git a/engines/director/director.cpp b/engines/director/director.cpp index cc63e5142c..13b86adb25 100644 --- a/engines/director/director.cpp +++ b/engines/director/director.cpp @@ -221,6 +221,7 @@ Common::Error DirectorEngine::run() { _lingo->restartLingo(); delete _currentScore; + _currentScore = nullptr; _currentPath = getPath(_nextMovie.movie, _currentPath); diff --git a/engines/director/frame.cpp b/engines/director/frame.cpp index ad12406a6d..28be1c5fb7 100644 --- a/engines/director/frame.cpp +++ b/engines/director/frame.cpp @@ -610,7 +610,7 @@ void Frame::renderSprites(Graphics::ManagedSurface &surface, bool renderTrail) { } } else { if (!_vm->getCurrentScore()->_loadedCast->contains(_sprites[i]->_castId)) { - if (!_vm->getSharedScore()->_loadedCast->contains(_sprites[i]->_castId)) { + if (!_vm->getSharedScore() || !_vm->getSharedScore()->_loadedCast->contains(_sprites[i]->_castId)) { debugC(1, kDebugImages, "Frame::renderSprites(): Cast id %d not found", _sprites[i]->_castId); continue; } else { diff --git a/engines/director/resource.cpp b/engines/director/resource.cpp index 1123d92e7c..bd8000d68d 100644 --- a/engines/director/resource.cpp +++ b/engines/director/resource.cpp @@ -64,6 +64,9 @@ Archive *DirectorEngine::openMainArchive(const Common::String movie) { _mainArchive = createArchive(); if (!_mainArchive->openFile(movie)) { + delete _mainArchive; + _mainArchive = nullptr; + warning("openMainArchive(): Could not open '%s'", movie.c_str()); return nullptr; } @@ -295,8 +298,6 @@ void DirectorEngine::loadSharedCastsFrom(Common::String filename) { delete shardcst; - _sharedScore = new Score(this); - return; } diff --git a/engines/director/score.cpp b/engines/director/score.cpp index ead93429e0..9cdc069ed2 100644 --- a/engines/director/score.cpp +++ b/engines/director/score.cpp @@ -67,9 +67,9 @@ const char *scriptType2str(ScriptType scr) { Score::Score(DirectorEngine *vm) { _vm = vm; - _surface = new Graphics::ManagedSurface; - _trailSurface = new Graphics::ManagedSurface; - _backSurface = new Graphics::ManagedSurface; + _surface = nullptr; + _trailSurface = nullptr; + _backSurface = nullptr; _lingo = _vm->getLingo(); _soundManager = _vm->getSoundManager(); _currentMouseDownSpriteId = 0; @@ -98,8 +98,8 @@ Score::Score(DirectorEngine *vm) { _movieArchive = nullptr; - _loadedStxts = new Common::HashMap<int, const Stxt *>(); - _loadedCast = new Common::HashMap<int, Cast *>(); + _loadedStxts = nullptr; + _loadedCast = nullptr; } void Score::setArchive(Archive *archive) { @@ -223,6 +223,8 @@ void Score::loadArchive() { } Common::Array<uint16> cast = _movieArchive->getResourceIDList(MKTAG('C', 'A', 'S', 't')); + _loadedCast = new Common::HashMap<int, Cast *>(); + if (cast.size() > 0) { debugC(2, kDebugLoading, "****** Loading %d CASt resources", cast.size()); @@ -255,6 +257,9 @@ void Score::loadArchive() { // Now process STXTs Common::Array<uint16> stxt = _movieArchive->getResourceIDList(MKTAG('S','T','X','T')); debugC(2, kDebugLoading, "****** Loading %d STXT resources", stxt.size()); + + _loadedStxts = new Common::HashMap<int, const Stxt *>(); + for (Common::Array<uint16>::iterator iterator = stxt.begin(); iterator != stxt.end(); ++iterator) { _loadedStxts->setVal(*iterator, new Stxt(*_movieArchive->getResource(MKTAG('S','T','X','T'), *iterator))); @@ -554,6 +559,8 @@ void Score::readVersion(uint32 rid) { void Score::loadCastDataVWCR(Common::SeekableSubReadStreamEndian &stream) { debugC(1, kDebugLoading, "****** Loading Cast rects VWCR. start: %d, end: %d", _castArrayStart, _castArrayEnd); + _loadedCast = new Common::HashMap<int, Cast *>(); + for (uint16 id = _castArrayStart; id <= _castArrayEnd; id++) { byte size = stream.readByte(); if (size == 0) @@ -599,7 +606,7 @@ void Score::setSpriteCasts() { if (castId == 0) continue; - if (_vm->getSharedScore() != nullptr && _vm->getSharedScore()->_loadedCast->contains(castId)) { + if (_vm->getSharedScore() && _vm->getSharedScore()->_loadedCast && _vm->getSharedScore()->_loadedCast->contains(castId)) { _frames[i]->_sprites[j]->_cast = _vm->getSharedScore()->_loadedCast->getVal(castId); } else if (_loadedCast->contains(castId)) { _frames[i]->_sprites[j]->_cast = _loadedCast->getVal(castId); @@ -1314,6 +1321,10 @@ void Score::startLoop() { initGraphics(_movieRect.width(), _movieRect.height()); + _surface = new Graphics::ManagedSurface; + _trailSurface = new Graphics::ManagedSurface; + _backSurface = new Graphics::ManagedSurface; + _surface->create(_movieRect.width(), _movieRect.height()); _trailSurface->create(_movieRect.width(), _movieRect.height()); _backSurface->create(_movieRect.width(), _movieRect.height()); |