From 0b9e3607a01f4c3b2820b2017240adf073669820 Mon Sep 17 00:00:00 2001 From: Dmitry Iskrich Date: Tue, 28 Jun 2016 18:03:21 +0300 Subject: DIRECTOR: Using shared casts for rendering --- engines/director/director.h | 3 +++ engines/director/score.cpp | 24 ++++++++++++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/engines/director/director.h b/engines/director/director.h index 566bb2ee9a..0e76cd9ea8 100644 --- a/engines/director/director.h +++ b/engines/director/director.h @@ -67,6 +67,9 @@ public: const byte *getPalette() const { return _currentPalette; } uint16 getPaletteColorCount() const { return _currentPaletteLength; } void loadSharedCastsFrom(Common::String filename); + Common::HashMap getSharedDIB() const { return _sharedDIB; } + Common::HashMap getSharedSTXT() const { return _sharedSTXT; } + Common::HashMap getSharedCasts() const { return _sharedCasts; } Common::HashMap *_movies; Score *_currentScore; diff --git a/engines/director/score.cpp b/engines/director/score.cpp index 285577d478..0a4aed49b6 100644 --- a/engines/director/score.cpp +++ b/engines/director/score.cpp @@ -1118,7 +1118,18 @@ void Frame::renderSprites(Graphics::ManagedSurface &surface, bool renderTrail) { if ((_sprites[i]->_trails == 0 && renderTrail) || (_sprites[i]->_trails == 1 && !renderTrail)) continue; - Cast *cast = _vm->_currentScore->_casts[_sprites[i]->_castId]; + Cast *cast; + if (!_vm->_currentScore->_casts.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); + } + } else { + cast = _vm->_currentScore->_casts[_sprites[i]->_castId]; + } + if (cast->type == kCastText) { renderText(surface, i); continue; @@ -1128,11 +1139,16 @@ void Frame::renderSprites(Graphics::ManagedSurface &surface, bool renderTrail) { uint32 imgId = 1024 + _sprites[i]->_castId; if (!_vm->_currentScore->getArchive()->hasResource(MKTAG('D', 'I', 'B', ' '), imgId)) { - continue; + if (!_vm->getSharedDIB().contains(imgId)) { + warning("DIB id %d not found", imgId); + continue; + } else { + img.loadStream(*_vm->getSharedDIB().getVal(imgId)); + } + } else { + img.loadStream(*_vm->_currentScore->getArchive()->getResource(MKTAG('D', 'I', 'B', ' '), imgId)); } - img.loadStream(*_vm->_currentScore->getArchive()->getResource(MKTAG('D', 'I', 'B', ' '), imgId)); - uint32 regX = static_cast(_sprites[i]->_cast)->regX; uint32 regY = static_cast(_sprites[i]->_cast)->regY; uint32 rectLeft = static_cast(_sprites[i]->_cast)->initialRect.left; -- cgit v1.2.3