diff options
-rw-r--r-- | engines/neverhood/diskplayerscene.cpp | 7 | ||||
-rw-r--r-- | engines/neverhood/modules/module3000.cpp | 6 | ||||
-rw-r--r-- | engines/neverhood/navigationscene.cpp | 15 | ||||
-rw-r--r-- | engines/neverhood/navigationscene.h | 1 | ||||
-rw-r--r-- | engines/neverhood/smackerplayer.cpp | 36 | ||||
-rw-r--r-- | engines/neverhood/smackerplayer.h | 1 |
6 files changed, 33 insertions, 33 deletions
diff --git a/engines/neverhood/diskplayerscene.cpp b/engines/neverhood/diskplayerscene.cpp index 534b2b9fe0..94a68a7526 100644 --- a/engines/neverhood/diskplayerscene.cpp +++ b/engines/neverhood/diskplayerscene.cpp @@ -354,9 +354,7 @@ DiskplayerScene::DiskplayerScene(NeverhoodEngine *vm, Module *parentModule, int insertPuzzleMouse(0x000408A8, 20, 620); showMouse(false); - _diskSmackerPlayer = new SmackerPlayer(_vm, this, 0x08288103, false, true); - addEntity(_diskSmackerPlayer); - addSurface(_diskSmackerPlayer->getSurface()); + _diskSmackerPlayer = addSmackerPlayer(new SmackerPlayer(_vm, this, 0x08288103, false, true)); _diskSmackerPlayer->setDrawPos(154, 86); _vm->_screen->setSmackerDecoder(_diskSmackerPlayer->getSmackerDecoder()); @@ -474,10 +472,7 @@ uint32 DiskplayerScene::handleMessage(int messageNum, const MessageParam ¶m, } void DiskplayerScene::openSmacker(uint32 fileHash, bool keepLastFrame) { - // The old Smacker surface is deleted when a new Smacker is opened. - removeSurface(_diskSmackerPlayer->getSurface()); _diskSmackerPlayer->open(fileHash, keepLastFrame); - addSurface(_diskSmackerPlayer->getSurface()); _vm->_screen->setSmackerDecoder(_diskSmackerPlayer->getSmackerDecoder()); _palette->usePalette(); } diff --git a/engines/neverhood/modules/module3000.cpp b/engines/neverhood/modules/module3000.cpp index 75e44edbd6..a2c0eb7ec0 100644 --- a/engines/neverhood/modules/module3000.cpp +++ b/engines/neverhood/modules/module3000.cpp @@ -818,16 +818,10 @@ Scene3009::Scene3009(NeverhoodEngine *vm, Module *parentModule, int which) } Scene3009::~Scene3009() { - removeSurface(_cannonSmackerPlayer->getSurface()); - // FIXME: Deleting the player crashes the game when leaving the cannon scene! - //delete _cannonSmackerPlayer; } void Scene3009::openSmacker(uint32 fileHash, bool keepLastFrame) { - // The old Smacker surface is deleted when a new Smacker is opened. - removeSurface(_cannonSmackerPlayer->getSurface()); _cannonSmackerPlayer->open(fileHash, keepLastFrame); - addSurface(_cannonSmackerPlayer->getSurface()); //_vm->_screen->setSmackerDecoder(_cannonSmackerPlayer->getSmackerDecoder()); _palette->usePalette(); } diff --git a/engines/neverhood/navigationscene.cpp b/engines/neverhood/navigationscene.cpp index 9752ee618c..33e2a264a8 100644 --- a/engines/neverhood/navigationscene.cpp +++ b/engines/neverhood/navigationscene.cpp @@ -41,9 +41,7 @@ NavigationScene::NavigationScene(NeverhoodEngine *vm, Module *parentModule, uint SetUpdateHandler(&NavigationScene::update); SetMessageHandler(&NavigationScene::handleMessage); - _smackerPlayer = new SmackerPlayer(_vm, this, (*_navigationList)[_navigationIndex].fileHash, true, true); - addEntity(_smackerPlayer); - addSurface(_smackerPlayer->getSurface()); + _smackerPlayer = addSmackerPlayer(new SmackerPlayer(_vm, this, (*_navigationList)[_navigationIndex].fileHash, true, true)); createMouseCursor(); @@ -69,7 +67,7 @@ int NavigationScene::getNavigationAreaType() { void NavigationScene::update() { if (_smackerFileHash != 0) { showMouse(false); - openSmacker(_smackerFileHash, false); + _smackerPlayer->open(_smackerFileHash, false); _vm->_screen->clear(); _vm->_screen->setSmackerDecoder(_smackerPlayer->getSmackerDecoder()); _smackerDone = false; @@ -92,7 +90,7 @@ void NavigationScene::update() { _vm->_soundMan->setTwoSoundsPlayFlag(false); _vm->_soundMan->setSoundThreePlayFlag(false); _smackerDone = false; - openSmacker(navigationItem.fileHash, true); + _smackerPlayer->open(navigationItem.fileHash, true); _vm->_screen->clear(); _vm->_screen->setSmackerDecoder(_smackerPlayer->getSmackerDecoder()); sendMessage(_parentModule, 0x100A, _navigationIndex); @@ -101,13 +99,6 @@ void NavigationScene::update() { Scene::update(); } -void NavigationScene::openSmacker(uint32 fileHash, bool keepLastFrame) { - // The old Smacker surface is deleted when a new Smacker is opened. - removeSurface(_smackerPlayer->getSurface()); - _smackerPlayer->open(fileHash, keepLastFrame); - addSurface(_smackerPlayer->getSurface()); -} - uint32 NavigationScene::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { switch (messageNum) { case 0x0000: diff --git a/engines/neverhood/navigationscene.h b/engines/neverhood/navigationscene.h index 767b3f5d20..ebe9a3597c 100644 --- a/engines/neverhood/navigationscene.h +++ b/engines/neverhood/navigationscene.h @@ -50,7 +50,6 @@ protected: bool _leaveSceneAfter; const byte *_itemsTypes; void update(); - void openSmacker(uint32 fileHash, bool keepLastFrame); uint32 handleMessage(int messageNum, const MessageParam ¶m, Entity *sender); void createMouseCursor(); void handleNavigation(const NPoint &mousePos); diff --git a/engines/neverhood/smackerplayer.cpp b/engines/neverhood/smackerplayer.cpp index ba89ec3efd..21d8851f48 100644 --- a/engines/neverhood/smackerplayer.cpp +++ b/engines/neverhood/smackerplayer.cpp @@ -51,6 +51,18 @@ void SmackerSurface::setSmackerFrame(const Graphics::Surface *smackerFrame) { _smackerFrame = smackerFrame; } +void SmackerSurface::unsetSmackerFrame() { + _drawRect.x = 0; + _drawRect.y = 0; + _drawRect.width = 0; + _drawRect.height = 0; + _sysRect.x = 0; + _sysRect.y = 0; + _sysRect.width = 0; + _sysRect.height = 0; + _smackerFrame = NULL; +} + // SmackerDoubleSurface SmackerDoubleSurface::SmackerDoubleSurface(NeverhoodEngine *vm) @@ -62,6 +74,8 @@ void SmackerDoubleSurface::draw() { _vm->_screen->drawDoubleSurface2(_smackerFrame, _drawRect); } +// NeverhoodSmackerDecoder + void NeverhoodSmackerDecoder::forceSeekToFrame(uint frame) { if (!isVideoLoaded()) return; @@ -92,11 +106,20 @@ SmackerPlayer::SmackerPlayer(NeverhoodEngine *vm, Scene *scene, uint32 fileHash, _drawX(-1), _drawY(-1) { SetUpdateHandler(&SmackerPlayer::update); + + if (_doubleSurface) { + _smackerSurface = new SmackerDoubleSurface(_vm); + } else { + _smackerSurface = new SmackerSurface(_vm); + } + open(fileHash, flag); } SmackerPlayer::~SmackerPlayer() { close(); + delete _smackerSurface; + _smackerSurface = NULL; } void SmackerPlayer::open(uint32 fileHash, bool keepLastFrame) { @@ -107,12 +130,6 @@ void SmackerPlayer::open(uint32 fileHash, bool keepLastFrame) { close(); - if (_doubleSurface) { - _smackerSurface = new SmackerDoubleSurface(_vm); - } else { - _smackerSurface = new SmackerSurface(_vm); - } - _smackerFirst = true; _stream = _vm->_res->createStream(fileHash); @@ -134,11 +151,10 @@ void SmackerPlayer::close() { delete _smackerDecoder; delete _palette; // NOTE The SmackerDecoder deletes the _stream - delete _smackerSurface; _smackerDecoder = NULL; _palette = NULL; _stream = NULL; - _smackerSurface = NULL; + _smackerSurface->unsetSmackerFrame(); } void SmackerPlayer::gotoFrame(int frameNumber) { @@ -200,6 +216,10 @@ void SmackerPlayer::update() { } void SmackerPlayer::updateFrame() { + + if (!_smackerDecoder || !_smackerSurface) + return; + const Graphics::Surface *smackerFrame = _smackerDecoder->decodeNextFrame(); if (_smackerFirst) { diff --git a/engines/neverhood/smackerplayer.h b/engines/neverhood/smackerplayer.h index 26ebff5d33..f13b653757 100644 --- a/engines/neverhood/smackerplayer.h +++ b/engines/neverhood/smackerplayer.h @@ -37,6 +37,7 @@ public: SmackerSurface(NeverhoodEngine *vm); virtual void draw(); void setSmackerFrame(const Graphics::Surface *smackerFrame); + void unsetSmackerFrame(); protected: const Graphics::Surface *_smackerFrame; }; |