mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-07 18:31:37 +00:00
BLADERUNNER: fixed loading of new set/scene, fixed memoryleak in lights
This commit is contained in:
parent
f5d5f3302f
commit
af70a90cbc
@ -95,7 +95,8 @@ int AudStream::readBuffer(int16 *buffer, const int numSamples) {
|
|||||||
samplesRead += 2 * bytesConsumed;
|
samplesRead += 2 * bytesConsumed;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
assert(0 && "readBuffer: Unimplemented");
|
//assert(0 && "readBuffer: Unimplemented");
|
||||||
|
warning("AudStream::readBuffer unknown compression type %d", _compressionType);
|
||||||
}
|
}
|
||||||
|
|
||||||
return samplesRead;
|
return samplesRead;
|
||||||
|
@ -613,7 +613,7 @@ void BladeRunnerEngine::gameTick() {
|
|||||||
_walkSoundId = -1;
|
_walkSoundId = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0 //_DEBUG
|
#if _DEBUG
|
||||||
//draw scene objects
|
//draw scene objects
|
||||||
int count = _sceneObjects->_count;
|
int count = _sceneObjects->_count;
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
@ -667,6 +667,19 @@ void BladeRunnerEngine::gameTick() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < (int)_lights->_lights.size(); i++) {
|
||||||
|
Light *light = _lights->_lights[i];
|
||||||
|
Matrix4x3 m = light->_matrix;
|
||||||
|
Vector3 pos = Vector3(m(0, 3), m(1, 3), m(2, 3));
|
||||||
|
Vector3 size = Vector3(5.0f, 5.0f, 5.0f);
|
||||||
|
int colorR = (light->_color.r * 31.0f);
|
||||||
|
int colorG = (light->_color.g * 31.0f);
|
||||||
|
int colorB = (light->_color.b * 31.0f);
|
||||||
|
int color = (colorR << 10) + (colorG << 5) + colorB;
|
||||||
|
drawBBox(pos-size, pos+size, _view, &_surface2, color);
|
||||||
|
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
_system->copyRectToScreen((const byte *)_surface2.getBasePtr(0, 0), _surface2.pitch, 0, 0, 640, 480);
|
_system->copyRectToScreen((const byte *)_surface2.getBasePtr(0, 0), _surface2.pitch, 0, 0, 640, 480);
|
||||||
|
@ -32,14 +32,14 @@ namespace BladeRunner {
|
|||||||
GameInfo::GameInfo(BladeRunnerEngine *vm)
|
GameInfo::GameInfo(BladeRunnerEngine *vm)
|
||||||
: _vm(vm)
|
: _vm(vm)
|
||||||
{
|
{
|
||||||
_set_names = nullptr;
|
_scene_names = nullptr;
|
||||||
_sfx_tracks = nullptr;
|
_sfx_tracks = nullptr;
|
||||||
_music_tracks = nullptr;
|
_music_tracks = nullptr;
|
||||||
_outtakes = nullptr;
|
_outtakes = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameInfo::~GameInfo() {
|
GameInfo::~GameInfo() {
|
||||||
delete[] _set_names;
|
delete[] _scene_names;
|
||||||
delete[] _sfx_tracks;
|
delete[] _sfx_tracks;
|
||||||
delete[] _music_tracks;
|
delete[] _music_tracks;
|
||||||
delete[] _outtakes;
|
delete[] _outtakes;
|
||||||
@ -73,9 +73,9 @@ bool GameInfo::open(const Common::String &name) {
|
|||||||
|
|
||||||
(void)unk;
|
(void)unk;
|
||||||
|
|
||||||
_set_names = new char[_set_names_count][5];
|
_scene_names = new char[_set_names_count][5];
|
||||||
for (uint32 i = 0; i != _set_names_count; ++i)
|
for (uint32 i = 0; i != _set_names_count; ++i)
|
||||||
s->read(_set_names[i], 5);
|
s->read(_scene_names[i], 5);
|
||||||
|
|
||||||
_sfx_tracks = new char[_sfx_track_count][13];
|
_sfx_tracks = new char[_sfx_track_count][13];
|
||||||
for (uint32 i = 0; i != _sfx_track_count; ++i)
|
for (uint32 i = 0; i != _sfx_track_count; ++i)
|
||||||
@ -97,7 +97,7 @@ bool GameInfo::open(const Common::String &name) {
|
|||||||
|
|
||||||
if (false) {
|
if (false) {
|
||||||
for (uint32 i = 0; i != _set_names_count; ++i)
|
for (uint32 i = 0; i != _set_names_count; ++i)
|
||||||
debug("%3d: %s", i, _set_names[i]);
|
debug("%3d: %s", i, _scene_names[i]);
|
||||||
for (uint32 i = 0; i != _sfx_track_count; ++i)
|
for (uint32 i = 0; i != _sfx_track_count; ++i)
|
||||||
debug("%3d: %s", i, _sfx_tracks[i]);
|
debug("%3d: %s", i, _sfx_tracks[i]);
|
||||||
for (uint32 i = 0; i != _music_track_count; ++i)
|
for (uint32 i = 0; i != _music_track_count; ++i)
|
||||||
|
@ -49,7 +49,7 @@ class GameInfo {
|
|||||||
uint32 _cover_waypoint_count;
|
uint32 _cover_waypoint_count;
|
||||||
uint32 _flee_waypoint_count;
|
uint32 _flee_waypoint_count;
|
||||||
|
|
||||||
char (*_set_names)[5];
|
char (*_scene_names)[5];
|
||||||
char (*_sfx_tracks)[13];
|
char (*_sfx_tracks)[13];
|
||||||
char (*_music_tracks)[13];
|
char (*_music_tracks)[13];
|
||||||
char (*_outtakes)[13];
|
char (*_outtakes)[13];
|
||||||
@ -75,7 +75,7 @@ public:
|
|||||||
uint32 getCoverWaypointCount() { return _cover_waypoint_count; }
|
uint32 getCoverWaypointCount() { return _cover_waypoint_count; }
|
||||||
uint32 getFleeWaypointCount() { return _flee_waypoint_count; }
|
uint32 getFleeWaypointCount() { return _flee_waypoint_count; }
|
||||||
|
|
||||||
const char *getSetName(int i) { return _set_names[i]; }
|
const char *getSceneName(int i) { return _scene_names[i]; }
|
||||||
const char *getSfxTrack(int i) { return _sfx_tracks[i]; }
|
const char *getSfxTrack(int i) { return _sfx_tracks[i]; }
|
||||||
const char *getMusicTrack(int i) { return _music_tracks[i]; }
|
const char *getMusicTrack(int i) { return _music_tracks[i]; }
|
||||||
const char *getOuttake(int i) { return _outtakes[i]; }
|
const char *getOuttake(int i) { return _outtakes[i]; }
|
||||||
|
@ -9,7 +9,6 @@ Lights::Lights(BladeRunnerEngine *vm) {
|
|||||||
_ambientLightColor.g = 0.0;
|
_ambientLightColor.g = 0.0;
|
||||||
_ambientLightColor.b = 0.0;
|
_ambientLightColor.b = 0.0;
|
||||||
|
|
||||||
_lightsCount = 0;
|
|
||||||
_lights.clear();
|
_lights.clear();
|
||||||
_frame = 0;
|
_frame = 0;
|
||||||
}
|
}
|
||||||
@ -23,9 +22,8 @@ void Lights::read(Common::ReadStream *stream, int framesCount) {
|
|||||||
_ambientLightColor.g = stream->readFloatLE();
|
_ambientLightColor.g = stream->readFloatLE();
|
||||||
_ambientLightColor.b = stream->readFloatLE();
|
_ambientLightColor.b = stream->readFloatLE();
|
||||||
|
|
||||||
_lightsCount = stream->readUint32LE();
|
uint _lightsCount = stream->readUint32LE();
|
||||||
int i;
|
for (uint i = 0; i < _lightsCount; i++) {
|
||||||
for (i = 0; i < _lightsCount; i++) {
|
|
||||||
Light *light;
|
Light *light;
|
||||||
int type = stream->readUint32LE();
|
int type = stream->readUint32LE();
|
||||||
switch (type) {
|
switch (type) {
|
||||||
@ -54,7 +52,7 @@ void Lights::read(Common::ReadStream *stream, int framesCount) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Lights::removeAnimated() {
|
void Lights::removeAnimated() {
|
||||||
for (int i = (int)(_lights.size() - 1); i > 0; i--) {
|
for (int i = (int)(_lights.size() - 1); i >= 0; i--) {
|
||||||
if (_lights[i]->_animated) {
|
if (_lights[i]->_animated) {
|
||||||
delete _lights.remove_at(i);
|
delete _lights.remove_at(i);
|
||||||
}
|
}
|
||||||
@ -106,7 +104,7 @@ void Lights::setupFrame(int frame) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Lights::reset() {
|
void Lights::reset() {
|
||||||
for (int i = (int)(_lights.size() - 1); i > 0; i--) {
|
for (int i = (int)(_lights.size() - 1); i >= 0; i--) {
|
||||||
delete _lights.remove_at(i);
|
delete _lights.remove_at(i);
|
||||||
}
|
}
|
||||||
_lights.clear();
|
_lights.clear();
|
||||||
|
@ -39,12 +39,9 @@ class Lights {
|
|||||||
|
|
||||||
BladeRunnerEngine *_vm;
|
BladeRunnerEngine *_vm;
|
||||||
|
|
||||||
Color _ambientLightColor;
|
Color _ambientLightColor;
|
||||||
|
|
||||||
int _lightsCount;
|
|
||||||
Common::Array<Light*> _lights;
|
Common::Array<Light*> _lights;
|
||||||
|
int _frame;
|
||||||
int _frame;
|
|
||||||
//char gap[28];
|
//char gap[28];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -32,7 +32,6 @@
|
|||||||
#include "bladerunner/slice_renderer.h"
|
#include "bladerunner/slice_renderer.h"
|
||||||
|
|
||||||
#include "common/str.h"
|
#include "common/str.h"
|
||||||
#include "common/stream.h"
|
|
||||||
|
|
||||||
namespace BladeRunner {
|
namespace BladeRunner {
|
||||||
|
|
||||||
@ -44,7 +43,7 @@ bool Scene::open(int setId, int sceneId, bool isLoadingGame) {
|
|||||||
_setId = setId;
|
_setId = setId;
|
||||||
_sceneId = sceneId;
|
_sceneId = sceneId;
|
||||||
|
|
||||||
const Common::String setName = _vm->_gameInfo->getSetName(_sceneId);
|
const Common::String setName = _vm->_gameInfo->getSceneName(_sceneId);
|
||||||
|
|
||||||
if (isLoadingGame) {
|
if (isLoadingGame) {
|
||||||
// TODO: Set up overlays
|
// 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));
|
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;
|
return false;
|
||||||
|
|
||||||
Common::String sceneName = _vm->_gameInfo->getSetName(sceneId);
|
Common::String sceneName = _vm->_gameInfo->getSceneName(sceneId);
|
||||||
if (!_vm->_script->open(sceneName))
|
if (!_vm->_script->open(sceneName))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -124,20 +128,44 @@ bool Scene::open(int setId, int sceneId, bool isLoadingGame) {
|
|||||||
// TODO: add all items to scene
|
// TODO: add all items to scene
|
||||||
// TODO: calculate walking obstacles??
|
// TODO: calculate walking obstacles??
|
||||||
|
|
||||||
// if (_playerWalkedIn) { // TODO: Not _playerWalkedIn
|
if (_specialLoopMode) {
|
||||||
// _vm->_script->PlayerWalkedIn();
|
_vm->_script->PlayerWalkedIn();
|
||||||
// }
|
}
|
||||||
|
|
||||||
return true;
|
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 Scene::advanceFrame(Graphics::Surface &surface, uint16 *&zBuffer) {
|
||||||
int frame = _vqaPlayer.update();
|
int frame = _vqaPlayer->update();
|
||||||
if (frame >= 0) {
|
if (frame >= 0) {
|
||||||
surface.copyFrom(*_vqaPlayer.getSurface());
|
surface.copyFrom(*_vqaPlayer->getSurface());
|
||||||
memcpy(zBuffer, _vqaPlayer.getZBuffer(), 640*480*2);
|
memcpy(zBuffer, _vqaPlayer->getZBuffer(), 640*480*2);
|
||||||
_vqaPlayer.updateView(_vm->_view);
|
_vqaPlayer->updateView(_vm->_view);
|
||||||
_vqaPlayer.updateLights(_vm->_lights);
|
_vqaPlayer->updateLights(_vm->_lights);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (frame < 0) {
|
if (frame < 0) {
|
||||||
@ -145,12 +173,12 @@ int Scene::advanceFrame(Graphics::Surface &surface, uint16 *&zBuffer) {
|
|||||||
}
|
}
|
||||||
_frame = frame;
|
_frame = frame;
|
||||||
|
|
||||||
if (_specialLoopMode == 0 && frame == _vqaPlayer.getLoopEndFrame(_specialLoop)) {
|
if (_specialLoopMode == 0 && frame == _vqaPlayer->getLoopEndFrame(_specialLoop)) {
|
||||||
_playerWalkedIn = true;
|
_playerWalkedIn = true;
|
||||||
_specialLoopMode = -1;
|
_specialLoopMode = -1;
|
||||||
}
|
}
|
||||||
if (_specialLoopMode == 0 && !_defaultLoopSet) {
|
if (_specialLoopMode == 0 && !_defaultLoopSet) {
|
||||||
_vqaPlayer.setLoop(_defaultLoop + 1);
|
_vqaPlayer->setLoop(_defaultLoop + 1);
|
||||||
_defaultLoopSet = true;
|
_defaultLoopSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ public:
|
|||||||
Set *_set;
|
Set *_set;
|
||||||
int _setId;
|
int _setId;
|
||||||
int _sceneId;
|
int _sceneId;
|
||||||
VQAPlayer _vqaPlayer;
|
VQAPlayer *_vqaPlayer;
|
||||||
|
|
||||||
int _defaultLoop;
|
int _defaultLoop;
|
||||||
int _defaultLoopSet;
|
int _defaultLoopSet;
|
||||||
@ -69,7 +69,7 @@ public:
|
|||||||
_set(new Set(vm)),
|
_set(new Set(vm)),
|
||||||
_setId(-1),
|
_setId(-1),
|
||||||
_sceneId(-1),
|
_sceneId(-1),
|
||||||
_vqaPlayer(vm),
|
_vqaPlayer(nullptr),
|
||||||
_defaultLoop(0),
|
_defaultLoop(0),
|
||||||
_nextSetId(-1),
|
_nextSetId(-1),
|
||||||
_nextSceneId(-1),
|
_nextSceneId(-1),
|
||||||
@ -83,9 +83,13 @@ public:
|
|||||||
delete _set;
|
delete _set;
|
||||||
delete _regions;
|
delete _regions;
|
||||||
delete _exits;
|
delete _exits;
|
||||||
|
if (_vqaPlayer != nullptr) {
|
||||||
|
delete _vqaPlayer;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool open(int setId, int sceneId, bool isLoadingGame);
|
bool open(int setId, int sceneId, bool isLoadingGame);
|
||||||
|
bool close(bool isLoadingGame);
|
||||||
int advanceFrame(Graphics::Surface &surface, uint16 *&zBuffer);
|
int advanceFrame(Graphics::Surface &surface, uint16 *&zBuffer);
|
||||||
void setActorStart(Vector3 position, int facing);
|
void setActorStart(Vector3 position, int facing);
|
||||||
|
|
||||||
|
@ -57,6 +57,9 @@ bool Settings::openNewScene() {
|
|||||||
|
|
||||||
if (_startingGame) {
|
if (_startingGame) {
|
||||||
// Stop ambient audio and music
|
// Stop ambient audio and music
|
||||||
|
// ambient::removeAllNonLoopingSounds(Ambient, 1);
|
||||||
|
// ambient::removeAllLoopingSounds(Ambient, 1);
|
||||||
|
// music::stop(Music, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
int currentSet = _vm->_scene->_setId;
|
int currentSet = _vm->_scene->_setId;
|
||||||
@ -65,7 +68,9 @@ bool Settings::openNewScene() {
|
|||||||
|
|
||||||
_newSet = -1;
|
_newSet = -1;
|
||||||
_newScene = -1;
|
_newScene = -1;
|
||||||
|
if (currentSet != -1) {
|
||||||
|
_vm->_scene->close(!_loadingGame && !_startingGame);
|
||||||
|
}
|
||||||
if (_chapterChanged) {
|
if (_chapterChanged) {
|
||||||
if (_vm->_chapters->hasOpenResources())
|
if (_vm->_chapters->hasOpenResources())
|
||||||
_vm->_chapters->closeResources();
|
_vm->_chapters->closeResources();
|
||||||
|
@ -65,7 +65,6 @@ int VQAPlayer::update() {
|
|||||||
queueAudioFrame(_decoder.decodeAudioFrame());
|
queueAudioFrame(_decoder.decodeAudioFrame());
|
||||||
_surface = _decoder.decodeVideoFrame();
|
_surface = _decoder.decodeVideoFrame();
|
||||||
_zBuffer = _decoder.decodeZBuffer();
|
_zBuffer = _decoder.decodeZBuffer();
|
||||||
//_view = _decoder.getView();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_decodedFrame = calcNextFrame(_curFrame);
|
_decodedFrame = calcNextFrame(_curFrame);
|
||||||
@ -89,7 +88,6 @@ int VQAPlayer::update() {
|
|||||||
if (_curFrame >= 0) {
|
if (_curFrame >= 0) {
|
||||||
_surface = _decoder.decodeVideoFrame();
|
_surface = _decoder.decodeVideoFrame();
|
||||||
_zBuffer = _decoder.decodeZBuffer();
|
_zBuffer = _decoder.decodeZBuffer();
|
||||||
//_view = _decoder.getView();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_decodedFrame = calcNextFrame(_curFrame);
|
_decodedFrame = calcNextFrame(_curFrame);
|
||||||
|
Loading…
Reference in New Issue
Block a user