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.
This commit is contained in:
Thomas Fach-Pedersen 2016-10-22 18:30:46 +02:00
parent 41e6a5d2a6
commit 669e6be438
5 changed files with 15 additions and 5 deletions

View File

@ -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;

View File

@ -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() {

View File

@ -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);

View File

@ -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();

View File

@ -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(