diff options
author | Thomas Fach-Pedersen | 2016-10-22 18:30:46 +0200 |
---|---|---|
committer | Thomas Fach-Pedersen | 2016-10-22 18:46:28 +0200 |
commit | 669e6be4380f058cf097c686e0edaa75ae500576 (patch) | |
tree | 06c163627a447e1d9acee7820ae6e90713768dc5 | |
parent | 41e6a5d2a64bbecd37d47a1dc87b4135c2149f4a (diff) | |
download | scummvm-rg350-669e6be4380f058cf097c686e0edaa75ae500576.tar.gz scummvm-rg350-669e6be4380f058cf097c686e0edaa75ae500576.tar.bz2 scummvm-rg350-669e6be4380f058cf097c686e0edaa75ae500576.zip |
BLADERUNNER: Fix uninitialized variable accesses
Fixes a couple of issues reported by valgrind and clang
sanitizers.
In particular, the initialization of Actor::_inCombat means that McCoy
no longer randomly has his gun out at the beginning of the game. In
SliceRenderer::drawInWorld, the assert of _sliceFramePtr has been
moved to after the call to setupFrameInWorld which is the method that
initializes the field. This misplaced assert caused the game to crash
for several people.
-rw-r--r-- | engines/bladerunner/actor.cpp | 2 | ||||
-rw-r--r-- | engines/bladerunner/bladerunner.cpp | 12 | ||||
-rw-r--r-- | engines/bladerunner/script/rc01.cpp | 2 | ||||
-rw-r--r-- | engines/bladerunner/script/script.cpp | 2 | ||||
-rw-r--r-- | engines/bladerunner/slice_renderer.cpp | 2 |
5 files changed, 15 insertions, 5 deletions
diff --git a/engines/bladerunner/actor.cpp b/engines/bladerunner/actor.cpp index 7509bb9575..c778a6dee0 100644 --- a/engines/bladerunner/actor.cpp +++ b/engines/bladerunner/actor.cpp @@ -78,7 +78,9 @@ void Actor::setup(int actorId) { _fps = 15; _frame_ms = 1000 / _fps; + _isMoving = false; _isTargetable = false; + _inCombat = false; _isInvisible = false; _isImmuneToObstacles = false; diff --git a/engines/bladerunner/bladerunner.cpp b/engines/bladerunner/bladerunner.cpp index 9cd0e0ddc2..6fe66d02bc 100644 --- a/engines/bladerunner/bladerunner.cpp +++ b/engines/bladerunner/bladerunner.cpp @@ -80,6 +80,14 @@ BladeRunnerEngine::BladeRunnerEngine(OSystem *syst) _obstacles = new Obstacles(this); _itemPickup = new ItemPickup(this); + _playerActorIdle = false; + _playerDead = false; + _speechSkipped = false; + _gameOver = false; + _gameAutoSave = 0; + _gameIsLoading = false; + _sceneIsLoading = false; + _walkSoundId = -1; _walkSoundVolume = 0; _walkSoundBalance = 0; @@ -342,7 +350,7 @@ void BladeRunnerEngine::initChapterAndScene() { _aiScripts->Initialize(i); for (int i = 0, end = _gameInfo->getActorCount(); i != end; ++i) - _actors[i]->changeAnimationMode(i); + _actors[i]->changeAnimationMode(0); _settings->setChapter(1); _settings->setNewSetAndScene(_gameInfo->getInitialSetId(), _gameInfo->getInitialSceneId()); @@ -507,7 +515,7 @@ bool BladeRunnerEngine::loadSplash() { _system->copyRectToScreen(_surface1.getPixels(), _surface1.pitch, 0, 0, _surface1.w, _surface1.h); _system->updateScreen(); - return false; + return true; } bool BladeRunnerEngine::init2() { diff --git a/engines/bladerunner/script/rc01.cpp b/engines/bladerunner/script/rc01.cpp index d94f104403..f3a7748c57 100644 --- a/engines/bladerunner/script/rc01.cpp +++ b/engines/bladerunner/script/rc01.cpp @@ -388,7 +388,7 @@ bool ScriptRC01::ClickedOnExit(int exitId) { if (!Loop_Actor_Walk_To_XYZ(0, -151.98f, -0.3f, 318.15f, 0, 1, false, 0)) { Player_Loses_Control(); Actor_Set_Immunity_To_Obstacles(0, true); - Loop_Actor_Walk_To_XYZ(0, -151.98f, -0.3f, 318.15f, 0, 0, false, 0); + Loop_Actor_Walk_To_XYZ(0, -10.98f, -0.3f, 318.15f, 0, 0, false, 0); if (Game_Flag_Query(486) && !Game_Flag_Query(660)) { Actor_Voice_Over(4310, 99); Actor_Voice_Over(4320, 99); diff --git a/engines/bladerunner/script/script.cpp b/engines/bladerunner/script/script.cpp index 2870e31636..060f8778d4 100644 --- a/engines/bladerunner/script/script.cpp +++ b/engines/bladerunner/script/script.cpp @@ -436,7 +436,7 @@ void ScriptBase::Actor_Voice_Over(int sentenceId, int actorId) { _vm->loopActorSpeaking(); _vm->_adq->flush(1, true); - Actor *actor = _vm->_actors[actorId]; + Actor *actor = (actorId == 99) ? _vm->_voiceoverActor : _vm->_actors[actorId]; actor->speechPlay(sentenceId, true); Player_Loses_Control(); diff --git a/engines/bladerunner/slice_renderer.cpp b/engines/bladerunner/slice_renderer.cpp index 8e299f7c0b..4f2d52c0b8 100644 --- a/engines/bladerunner/slice_renderer.cpp +++ b/engines/bladerunner/slice_renderer.cpp @@ -334,12 +334,12 @@ static void setupLookupTable(int t[256], int inc) { } void SliceRenderer::drawInWorld(int animationId, int animationFrame, Vector3 position, float facing, float scale, Graphics::Surface &surface, uint16 *zbuffer) { - assert(_sliceFramePtr); assert(_lights); assert(_setEffects); //assert(_view); _vm->_sliceRenderer->setupFrameInWorld(animationId, animationFrame, position, facing); + assert(_sliceFramePtr); SliceLineIterator sliceLineIterator; sliceLineIterator.setup( |