aboutsummaryrefslogtreecommitdiff
path: root/engines/bladerunner/scene.cpp
diff options
context:
space:
mode:
authorPeter Kohaut2016-09-29 21:00:36 +0200
committerEugene Sandulenko2016-09-29 22:33:42 +0200
commitaf70a90cbc239f820f6c33ac54c207829fd8847a (patch)
tree9d4893f45df39345ee78ab09ecc4c82e380a21ce /engines/bladerunner/scene.cpp
parentf5d5f3302f59d2073c15985f8ffb3058bad7d014 (diff)
downloadscummvm-rg350-af70a90cbc239f820f6c33ac54c207829fd8847a.tar.gz
scummvm-rg350-af70a90cbc239f820f6c33ac54c207829fd8847a.tar.bz2
scummvm-rg350-af70a90cbc239f820f6c33ac54c207829fd8847a.zip
BLADERUNNER: fixed loading of new set/scene, fixed memoryleak in lights
Diffstat (limited to 'engines/bladerunner/scene.cpp')
-rw-r--r--engines/bladerunner/scene.cpp56
1 files changed, 42 insertions, 14 deletions
diff --git a/engines/bladerunner/scene.cpp b/engines/bladerunner/scene.cpp
index 29d73f3070..65efe1306b 100644
--- a/engines/bladerunner/scene.cpp
+++ b/engines/bladerunner/scene.cpp
@@ -32,7 +32,6 @@
#include "bladerunner/slice_renderer.h"
#include "common/str.h"
-#include "common/stream.h"
namespace BladeRunner {
@@ -44,7 +43,7 @@ bool Scene::open(int setId, int sceneId, bool isLoadingGame) {
_setId = setId;
_sceneId = sceneId;
- const Common::String setName = _vm->_gameInfo->getSetName(_sceneId);
+ const Common::String setName = _vm->_gameInfo->getSceneName(_sceneId);
if (isLoadingGame) {
// TODO: Set up overlays
@@ -70,10 +69,15 @@ bool Scene::open(int setId, int sceneId, bool isLoadingGame) {
vqaName = Common::String::format("%s_%d.VQA", setName.c_str(), MIN(currentResourceId, 3));
}
- if (!_vqaPlayer.open(vqaName))
+ if (_vqaPlayer != nullptr)
+ delete _vqaPlayer;
+
+ _vqaPlayer = new VQAPlayer(_vm);
+
+ if (!_vqaPlayer->open(vqaName))
return false;
- Common::String sceneName = _vm->_gameInfo->getSetName(sceneId);
+ Common::String sceneName = _vm->_gameInfo->getSceneName(sceneId);
if (!_vm->_script->open(sceneName))
return false;
@@ -124,20 +128,44 @@ bool Scene::open(int setId, int sceneId, bool isLoadingGame) {
// TODO: add all items to scene
// TODO: calculate walking obstacles??
- // if (_playerWalkedIn) { // TODO: Not _playerWalkedIn
- // _vm->_script->PlayerWalkedIn();
- // }
+ if (_specialLoopMode) {
+ _vm->_script->PlayerWalkedIn();
+ }
return true;
}
+bool Scene::close(bool isLoadingGame) {
+ bool result = true;
+ if (getSetId() == -1) {
+ return true;
+ }
+
+ //_vm->_policeMaze->clear(!isLoadingGame);
+ if (isLoadingGame) {
+ _vm->_script->PlayerWalkedOut();
+ }
+// if (SceneScript_isLoaded() && !SceneScript_unload()) {
+// result = false;
+// }
+ if (_vqaPlayer != nullptr) {
+ //_vqaPlayer->stop();
+ delete _vqaPlayer;
+ _vqaPlayer = nullptr;
+ }
+ _sceneId = -1;
+ _setId = -1;
+
+ return result;
+}
+
int Scene::advanceFrame(Graphics::Surface &surface, uint16 *&zBuffer) {
- int frame = _vqaPlayer.update();
+ int frame = _vqaPlayer->update();
if (frame >= 0) {
- surface.copyFrom(*_vqaPlayer.getSurface());
- memcpy(zBuffer, _vqaPlayer.getZBuffer(), 640*480*2);
- _vqaPlayer.updateView(_vm->_view);
- _vqaPlayer.updateLights(_vm->_lights);
+ surface.copyFrom(*_vqaPlayer->getSurface());
+ memcpy(zBuffer, _vqaPlayer->getZBuffer(), 640*480*2);
+ _vqaPlayer->updateView(_vm->_view);
+ _vqaPlayer->updateLights(_vm->_lights);
}
if (frame < 0) {
@@ -145,12 +173,12 @@ int Scene::advanceFrame(Graphics::Surface &surface, uint16 *&zBuffer) {
}
_frame = frame;
- if (_specialLoopMode == 0 && frame == _vqaPlayer.getLoopEndFrame(_specialLoop)) {
+ if (_specialLoopMode == 0 && frame == _vqaPlayer->getLoopEndFrame(_specialLoop)) {
_playerWalkedIn = true;
_specialLoopMode = -1;
}
if (_specialLoopMode == 0 && !_defaultLoopSet) {
- _vqaPlayer.setLoop(_defaultLoop + 1);
+ _vqaPlayer->setLoop(_defaultLoop + 1);
_defaultLoopSet = true;
}