aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTorbjörn Andersson2013-05-27 06:48:23 +0200
committerTorbjörn Andersson2013-05-27 06:48:23 +0200
commit2e4f64066da7c08edcd17b5c66c6463887b836b4 (patch)
tree63b6dfa996e93997c4fb69f79b323483b8bbeb4f
parent5e0e672283aa5c81e906fbe380ea17a35a5e983a (diff)
downloadscummvm-rg350-2e4f64066da7c08edcd17b5c66c6463887b836b4.tar.gz
scummvm-rg350-2e4f64066da7c08edcd17b5c66c6463887b836b4.tar.bz2
scummvm-rg350-2e4f64066da7c08edcd17b5c66c6463887b836b4.zip
NEVERHOOD: Fix invalid memory access in navigation scenes
When a new Smacker is opened, the old Smacker surface is deleted and a new one is created. Therefore, it has to be removed from the scene and the new one has to be added.
-rw-r--r--engines/neverhood/navigationscene.cpp11
-rw-r--r--engines/neverhood/navigationscene.h1
2 files changed, 10 insertions, 2 deletions
diff --git a/engines/neverhood/navigationscene.cpp b/engines/neverhood/navigationscene.cpp
index d802322858..9752ee618c 100644
--- a/engines/neverhood/navigationscene.cpp
+++ b/engines/neverhood/navigationscene.cpp
@@ -69,7 +69,7 @@ int NavigationScene::getNavigationAreaType() {
void NavigationScene::update() {
if (_smackerFileHash != 0) {
showMouse(false);
- _smackerPlayer->open(_smackerFileHash, false);
+ openSmacker(_smackerFileHash, false);
_vm->_screen->clear();
_vm->_screen->setSmackerDecoder(_smackerPlayer->getSmackerDecoder());
_smackerDone = false;
@@ -92,7 +92,7 @@ void NavigationScene::update() {
_vm->_soundMan->setTwoSoundsPlayFlag(false);
_vm->_soundMan->setSoundThreePlayFlag(false);
_smackerDone = false;
- _smackerPlayer->open(navigationItem.fileHash, true);
+ openSmacker(navigationItem.fileHash, true);
_vm->_screen->clear();
_vm->_screen->setSmackerDecoder(_smackerPlayer->getSmackerDecoder());
sendMessage(_parentModule, 0x100A, _navigationIndex);
@@ -101,6 +101,13 @@ 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 &param, Entity *sender) {
switch (messageNum) {
case 0x0000:
diff --git a/engines/neverhood/navigationscene.h b/engines/neverhood/navigationscene.h
index ebe9a3597c..767b3f5d20 100644
--- a/engines/neverhood/navigationscene.h
+++ b/engines/neverhood/navigationscene.h
@@ -50,6 +50,7 @@ protected:
bool _leaveSceneAfter;
const byte *_itemsTypes;
void update();
+ void openSmacker(uint32 fileHash, bool keepLastFrame);
uint32 handleMessage(int messageNum, const MessageParam &param, Entity *sender);
void createMouseCursor();
void handleNavigation(const NPoint &mousePos);