diff options
23 files changed, 262 insertions, 193 deletions
diff --git a/engines/bladerunner/actor.cpp b/engines/bladerunner/actor.cpp index 1c592267e0..4d66d74f5e 100644 --- a/engines/bladerunner/actor.cpp +++ b/engines/bladerunner/actor.cpp @@ -48,44 +48,21 @@ Actor::Actor(BladeRunnerEngine *vm, int actorId) { _vm = vm; _id = actorId; - _walkInfo = new ActorWalk(vm); + _walkInfo = new ActorWalk(vm); _movementTrack = new MovementTrack(); - _clues = new ActorClues(vm, (actorId && actorId != 99) ? 2 : 4); - _bbox = new BoundingBox(); - _combatInfo = new ActorCombat(vm); + _clues = new ActorClues(vm, (actorId && actorId != 99) ? 2 : 4); + _bbox = new BoundingBox(); + _combatInfo = new ActorCombat(vm); - _friendlinessToOther = new int[_vm->_gameInfo->getActorCount()]; + _friendlinessToOther.resize(_vm->_gameInfo->getActorCount()); - _isMoving = false; - _isTargetable = false; - _inCombat = false; - _isInvisible = false; - _isImmuneToObstacles = false; + _inWalkLoop = false; _damageAnimIfMoving = false; - _movementTrackPaused = false; - _movementTrackNextWaypointId = -1; - _movementTrackNextDelay = -1; - _movementTrackNextAngle = -1; - _movementTrackNextRunning = false; - _movementTrackWalkingToWaypointId = -1; - _movementTrackDelayOnNextWaypoint = -1; - _width = 0; - _height = 0; - _animationMode = -1; - _animationModeCombatIdle = -1; - _animationModeCombatWalk = -1; - _animationModeCombatRun = -1; - _fps = 0; - _frame_ms = 0; - _animationId = 0; - _animationFrame = 0; - _retiredWidth = 0; - _retiredHeight = 0; - _scale = 0.0f; + + setup(actorId); } Actor::~Actor() { - delete[] _friendlinessToOther; delete _combatInfo; delete _bbox; delete _clues; @@ -94,31 +71,31 @@ Actor::~Actor() { } void Actor::setup(int actorId) { - _id = actorId; + _id = actorId; _setId = -1; - _position = Vector3(0.0, 0.0, 0.0); - _facing = 512; + _position = Vector3(0.0, 0.0, 0.0); + _facing = 512; _targetFacing = -1; - _walkboxId = -1; + _walkboxId = -1; - _animationId = 0; + _animationId = 0; _animationFrame = 0; - _fps = 15; - _frame_ms = 1000 / _fps; + _fps = 15; + _frame_ms = 1000 / _fps; - _isMoving = false; - _isTargetable = false; - _inCombat = false; - _isInvisible = false; + _isMoving = false; + _isTargetable = false; + _inCombat = false; + _isInvisible = false; _isImmuneToObstacles = false; + _isRetired = false; - _isRetired = false; - - _width = 0; - _height = 0; - _retiredWidth = 0; + _width = 0; + _height = 0; + _retiredWidth = 0; _retiredHeight = 0; + _scale = 1.0f; _movementTrackWalkingToWaypointId = -1; _movementTrackDelayOnNextWaypoint = -1; @@ -128,30 +105,28 @@ void Actor::setup(int actorId) { _timersStart[i] = _vm->getTotalPlayTime(); } - _scale = 1.0f; - - _honesty = 50; - _intelligence = 50; + _honesty = 50; + _intelligence = 50; _combatAggressiveness = 50; - _stability = 50; + _stability = 50; - _currentHP = 50; - _maxHP = 50; + _currentHP = 50; + _maxHP = 50; _goalNumber = -1; - _movementTrackPaused = false; + _movementTrackPaused = false; _movementTrackNextWaypointId = -1; - _movementTrackNextDelay = -1; - _movementTrackNextAngle = -1; - _movementTrackNextRunning = false; + _movementTrackNextDelay = -1; + _movementTrackNextAngle = -1; + _movementTrackNextRunning = false; _timersRemain[4] = 60000; - _animationMode = -1; + _animationMode = -1; _screenRectangle = Common::Rect(-1, -1, -1, -1); _animationModeCombatIdle = kAnimationModeCombatIdle; _animationModeCombatWalk = kAnimationModeCombatWalk; - _animationModeCombatRun = kAnimationModeCombatRun; + _animationModeCombatRun = kAnimationModeCombatRun; int actorCount = (int)_vm->_gameInfo->getActorCount(); for (int i = 0; i != actorCount; ++i) @@ -426,12 +401,10 @@ bool Actor::loopWalk(const Vector3 &destination, int destinationOffset, bool int return false; } - if (async) { - return false; - } if (_id != kActorMcCoy) { _vm->_mouse->disable(); } + if (interruptible) { _vm->_isWalkingInterruptible = 1; _vm->_interruptWalking = 0; diff --git a/engines/bladerunner/actor.h b/engines/bladerunner/actor.h index 4fd513103a..b160ca3238 100644 --- a/engines/bladerunner/actor.h +++ b/engines/bladerunner/actor.h @@ -25,6 +25,7 @@ #include "bladerunner/vector.h" +#include "common/array.h" #include "common/rect.h" namespace BladeRunner { @@ -50,12 +51,12 @@ private: ActorWalk *_walkInfo; ActorCombat *_combatInfo; - int _honesty; - int _intelligence; - int _stability; - int _combatAggressiveness; - int _goalNumber; - int *_friendlinessToOther; + int _honesty; + int _intelligence; + int _stability; + int _combatAggressiveness; + int _goalNumber; + Common::Array<int> _friendlinessToOther; int _currentHP; int _maxHP; diff --git a/engines/bladerunner/bladerunner.cpp b/engines/bladerunner/bladerunner.cpp index df657065f7..8435e751fa 100644 --- a/engines/bladerunner/bladerunner.cpp +++ b/engines/bladerunner/bladerunner.cpp @@ -85,21 +85,24 @@ BladeRunnerEngine::BladeRunnerEngine(OSystem *syst, const ADGameDescription *des _rnd("bladerunner") { _windowIsActive = true; - _gameIsRunning = true; + _gameIsRunning = true; + _playerLosesControlCounter = 0; _playerActorIdle = false; - _playerDead = false; - _speechSkipped = false; - _gameOver = false; - _gameAutoSave = 0; - _gameIsLoading = false; - _sceneIsLoading = false; - - _walkingActorId = -1; - - _walkSoundId = -1; - _walkSoundVolume = 0; + _playerDead = false; + _speechSkipped = false; + _gameOver = false; + _gameAutoSave = 0; + _gameIsLoading = false; + _sceneIsLoading = false; + + _walkingActorId = -1; + _isWalkingInterruptible = false; + _interruptWalking = false; + + _walkSoundId = -1; + _walkSoundVolume = 0; _walkSoundBalance = 0; _crimesDatabase = nullptr; @@ -164,6 +167,8 @@ BladeRunnerEngine::BladeRunnerEngine(OSystem *syst, const ADGameDescription *des _spinner = nullptr; _elevator = nullptr; _mainFont = nullptr; + _esper = nullptr; + _vk = nullptr; _mouse = nullptr; _sliceAnimations = nullptr; _sliceRenderer = nullptr; @@ -456,7 +461,6 @@ void BladeRunnerEngine::initChapterAndScene() { _settings->setChapter(1); _settings->setNewSetAndScene(_gameInfo->getInitialSetId(), _gameInfo->getInitialSceneId()); -// _settings->setNewSetAndScene(52, 52); } void BladeRunnerEngine::shutdown() { @@ -804,7 +808,7 @@ void BladeRunnerEngine::gameTick() { } if (_settings->getNewScene() == -1 || _sceneScript->isInsideScript() || _aiScripts->isInsideScript()) { - _sliceRenderer->setView(*_view); + _sliceRenderer->setView(_view); // Tick and draw all actors in current set int setId = _scene->getSetId(); diff --git a/engines/bladerunner/bladerunner.h b/engines/bladerunner/bladerunner.h index 40ac1df3bf..2257df6319 100644 --- a/engines/bladerunner/bladerunner.h +++ b/engines/bladerunner/bladerunner.h @@ -149,8 +149,6 @@ public: Actor *_actors[kActorCount]; Actor *_playerActor; - int in_script_counter; - Graphics::Surface _surfaceFront; Graphics::Surface _surfaceBack; Graphics::Surface _surface4; diff --git a/engines/bladerunner/dialogue_menu.cpp b/engines/bladerunner/dialogue_menu.cpp index 9f43f5542a..6f7ff38491 100644 --- a/engines/bladerunner/dialogue_menu.cpp +++ b/engines/bladerunner/dialogue_menu.cpp @@ -166,7 +166,6 @@ int DialogueMenu::queryInput() { if (answer == -1) { int agenda = _vm->_settings->getPlayerAgenda(); - agenda = kPlayerAgendaUserChoice; if (agenda == kPlayerAgendaUserChoice) { _waitingForInput = true; do { diff --git a/engines/bladerunner/scene.cpp b/engines/bladerunner/scene.cpp index f9f49f3589..f20c0be0ef 100644 --- a/engines/bladerunner/scene.cpp +++ b/engines/bladerunner/scene.cpp @@ -123,7 +123,7 @@ bool Scene::open(int setId, int sceneId, bool isLoadingGame) { return false; } - _vm->_sliceRenderer->setView(*_vm->_view); + _vm->_sliceRenderer->setView(_vm->_view); if (isLoadingGame) { // TODO: Advance VQA frame diff --git a/engines/bladerunner/script/scene/hf01.cpp b/engines/bladerunner/script/scene/hf01.cpp index 67f538f12e..6944854ee1 100644 --- a/engines/bladerunner/script/scene/hf01.cpp +++ b/engines/bladerunner/script/scene/hf01.cpp @@ -125,7 +125,7 @@ bool SceneScriptHF01::ClickedOnActor(int actorId) { } return false; } - if (actorId == v1) { + if (v1 != -1 && actorId == v1) { if (!Loop_Actor_Walk_To_Actor(kActorMcCoy, actorId, 28, 1, false)) { if (Actor_Query_Goal_Number(v1) == 599) { Actor_Says(kActorMcCoy, 8630, 13); diff --git a/engines/bladerunner/script/scene/kp05.cpp b/engines/bladerunner/script/scene/kp05.cpp index 6ac4d1f1e0..9b080aceb0 100644 --- a/engines/bladerunner/script/scene/kp05.cpp +++ b/engines/bladerunner/script/scene/kp05.cpp @@ -132,7 +132,7 @@ void SceneScriptKP05::PlayerWalkedIn() { Game_Flag_Reset(574); } else { Loop_Actor_Walk_To_XYZ(kActorMcCoy, -846.0f, 0.0f, 972.0f, 0, 0, false, 0); - Game_Flag_Query(419); + Game_Flag_Query(419); // bug in game? } if (Actor_Query_Goal_Number(kActorMaggie) == 411) { Actor_Set_Goal_Number(kActorMaggie, 412); diff --git a/engines/bladerunner/script/scene/ma02.cpp b/engines/bladerunner/script/scene/ma02.cpp index 98887ed67e..bd4407ada0 100644 --- a/engines/bladerunner/script/scene/ma02.cpp +++ b/engines/bladerunner/script/scene/ma02.cpp @@ -240,11 +240,7 @@ void SceneScriptMA02::sub_402044() { if (Game_Flag_Query(171) && Game_Flag_Query(170)) { arr[i++] = 4; } - if (i == 0) { - Global_Variable_Set(52, -1); - } else { - Global_Variable_Set(52, arr[Random_Query(0, i - 1)]); - } + Global_Variable_Set(52, arr[Random_Query(0, i - 1)]); } } // End of namespace BladeRunner diff --git a/engines/bladerunner/script/scene/nr04.cpp b/engines/bladerunner/script/scene/nr04.cpp index 2ef114a3e6..18583f0d75 100644 --- a/engines/bladerunner/script/scene/nr04.cpp +++ b/engines/bladerunner/script/scene/nr04.cpp @@ -320,7 +320,7 @@ void SceneScriptNR04::sub_402860(int frame) { 0.0f, 0.0f, 1.0f, 0.5f, 0.0f, 0.8f}; - float v3 = (frame - 60) / 10; + float v3 = (frame - 60) * 0.1f; float v4 = (frame % 10) * 0.1f; float coef = 1.0f; if (frame > 100) { diff --git a/engines/bladerunner/script/scene/ps05.cpp b/engines/bladerunner/script/scene/ps05.cpp index a0bb9a7135..e2aa7e8c4b 100644 --- a/engines/bladerunner/script/scene/ps05.cpp +++ b/engines/bladerunner/script/scene/ps05.cpp @@ -177,12 +177,7 @@ void SceneScriptPS05::sub_401B34() { if (Game_Flag_Query(171) && Game_Flag_Query(170)) { arr[i++] = 4; } - if (i == 0) { - Global_Variable_Set(52, -1); - } - else { - Global_Variable_Set(52, arr[Random_Query(0, i - 1)]); - } + Global_Variable_Set(52, arr[Random_Query(0, i - 1)]); } void SceneScriptPS05::sub_401C30() { diff --git a/engines/bladerunner/script/scene/ug05.cpp b/engines/bladerunner/script/scene/ug05.cpp index e2f83c6fc3..e02b6ed1a7 100644 --- a/engines/bladerunner/script/scene/ug05.cpp +++ b/engines/bladerunner/script/scene/ug05.cpp @@ -208,7 +208,7 @@ void SceneScriptUG05::PlayerWalkedIn() { } } if (Game_Flag_Query(663)) { - Game_Flag_Query(368); + Game_Flag_Query(368); // bug in game? } Game_Flag_Reset(360); } diff --git a/engines/bladerunner/slice_renderer.cpp b/engines/bladerunner/slice_renderer.cpp index 4555b17fdb..42aaf253fe 100644 --- a/engines/bladerunner/slice_renderer.cpp +++ b/engines/bladerunner/slice_renderer.cpp @@ -37,11 +37,29 @@ namespace BladeRunner { SliceRenderer::SliceRenderer(BladeRunnerEngine *vm) { _vm = vm; _pixelFormat = createRGB555(); - int i; - for (i = 0; i < 942; i++) { // yes, its going just to 942 and not 997 + for (int i = 0; i < 942; i++) { // yes, its going just to 942 and not 997 _animationsShadowEnabled[i] = true; } + _animation = -1; + _frame = -1; + _facing = 0.0f; + _scale = 0.0f; + + _screenEffects = nullptr; + _view = nullptr; + _lights = nullptr; + _setEffects = nullptr; + _sliceFramePtr = nullptr; + + _frameBottomZ = 0.0f; + _frameSliceHeight = 0.0f; + _framePaletteIndex = 0; + _frameSliceCount = 0; + _startSlice = 0.0f; + _endSlice = 0.0f; + _m13 = 0; + _m23 = 0; } SliceRenderer::~SliceRenderer() { @@ -51,7 +69,7 @@ void SliceRenderer::setScreenEffects(ScreenEffects *screenEffects) { _screenEffects = screenEffects; } -void SliceRenderer::setView(const View &view) { +void SliceRenderer::setView(View *view) { _view = view; } @@ -82,7 +100,7 @@ void SliceRenderer::getScreenRectangle(Common::Rect *screenRectangle, int animat Matrix3x2 SliceRenderer::calculateFacingRotationMatrix() { assert(_sliceFramePtr); - Matrix4x3 viewMatrix = _view._sliceViewMatrix; + Matrix4x3 viewMatrix = _view->_sliceViewMatrix; Vector3 viewPos = viewMatrix * _position; float dir = atan2f(viewPos.x, viewPos.z) + _facing; float s = sinf(dir); @@ -105,7 +123,7 @@ void SliceRenderer::calculateBoundingRect() { _screenRectangle.top = 0; _screenRectangle.bottom = 0; - Matrix4x3 viewMatrix = _view._sliceViewMatrix; + Matrix4x3 viewMatrix = _view->_sliceViewMatrix; Vector3 frameBottom = Vector3(0.0f, 0.0f, _frameBottomZ); Vector3 frameTop = Vector3(0.0f, 0.0f, _frameBottomZ + _frameSliceCount * _frameSliceHeight); @@ -121,7 +139,7 @@ void SliceRenderer::calculateBoundingRect() { Matrix3x2 facingRotation = calculateFacingRotationMatrix(); - Matrix3x2 m_projection(_view._viewportDistance / bottom.z, 0.0f, 0.0f, + Matrix3x2 m_projection(_view->_viewportDistance / bottom.z, 0.0f, 0.0f, 0.0f, 25.5f, 0.0f); Matrix3x2 m_frame(_frameScale.x, 0.0f, _framePos.x, @@ -130,14 +148,14 @@ void SliceRenderer::calculateBoundingRect() { _modelMatrix = m_projection * (facingRotation * m_frame); Vector4 startScreenVector( - _view._viewportHalfWidth + top.x / top.z * _view._viewportDistance, - _view._viewportHalfHeight + top.y / top.z * _view._viewportDistance, + _view->_viewportHalfWidth + top.x / top.z * _view->_viewportDistance, + _view->_viewportHalfHeight + top.y / top.z * _view->_viewportDistance, 1.0f / top.z, _frameSliceCount * (1.0f / top.z)); Vector4 endScreenVector( - _view._viewportHalfWidth + bottom.x / bottom.z * _view._viewportDistance, - _view._viewportHalfHeight + bottom.y / bottom.z * _view._viewportDistance, + _view->_viewportHalfWidth + bottom.x / bottom.z * _view->_viewportDistance, + _view->_viewportHalfHeight + bottom.y / bottom.z * _view->_viewportDistance, 1.0f / bottom.z, 0.0f); @@ -359,12 +377,12 @@ void SliceRenderer::drawInWorld(int animationId, int animationFrame, Vector3 pos _modelMatrix ); - Vector3 cameraPosition(_view._cameraPosition.x, _view._cameraPosition.z, _view._cameraPosition.y); // not a bug + Vector3 cameraPosition(_view->_cameraPosition.x, _view->_cameraPosition.z, _view->_cameraPosition.y); // not a bug SliceRendererLights sliceRendererLights = SliceRendererLights(_lights); - _lights->setupFrame(_view._frame); - _setEffects->setupFrame(_view._frame); + _lights->setupFrame(_view->_frame); + _setEffects->setupFrame(_view->_frame); float sliceLine = sliceLineIterator.line(); diff --git a/engines/bladerunner/slice_renderer.h b/engines/bladerunner/slice_renderer.h index bf00454cb1..cf3066f9e8 100644 --- a/engines/bladerunner/slice_renderer.h +++ b/engines/bladerunner/slice_renderer.h @@ -52,12 +52,12 @@ class SliceRenderer { float _facing; float _scale; - ScreenEffects *_screenEffects; - View _view; - Lights *_lights; - SetEffects *_setEffects; + ScreenEffects *_screenEffects; + View *_view; + Lights *_lights; + SetEffects *_setEffects; - void *_sliceFramePtr; + void *_sliceFramePtr; // Animation frame data Vector2 _frameScale; @@ -96,7 +96,7 @@ public: ~SliceRenderer(); void setScreenEffects(ScreenEffects *aesc); - void setView(const View &view); + void setView(View *view); void setLights(Lights *lights); void setSetEffects(SetEffects *setEffects); diff --git a/engines/bladerunner/suspects_database.cpp b/engines/bladerunner/suspects_database.cpp index d7e9c1f999..834694b50d 100644 --- a/engines/bladerunner/suspects_database.cpp +++ b/engines/bladerunner/suspects_database.cpp @@ -113,7 +113,7 @@ int SuspectDatabaseEntry::getSex() const { } bool SuspectDatabaseEntry::hasMOClue(int clueId) const { - for (int i = 0; i < _moClueCount; i++) { + for (int i = 0; i < _moClueCount; ++i) { if (_moClues[i] == clueId) { return true; } @@ -122,7 +122,7 @@ bool SuspectDatabaseEntry::hasMOClue(int clueId) const { } bool SuspectDatabaseEntry::hasWhereaboutsClue(int clueId) const { - for (int i = 0; i < _whereaboutsClueCount; i++) { + for (int i = 0; i < _whereaboutsClueCount; ++i) { if (_whereaboutsClues[i] == clueId) { return true; } @@ -131,7 +131,7 @@ bool SuspectDatabaseEntry::hasWhereaboutsClue(int clueId) const { } bool SuspectDatabaseEntry::hasReplicantClue(int clueId) const { - for (int i = 0; i < _replicantClueCount; i++) { + for (int i = 0; i < _replicantClueCount; ++i) { if (_replicantClues[i] == clueId) { return true; } @@ -140,7 +140,7 @@ bool SuspectDatabaseEntry::hasReplicantClue(int clueId) const { } bool SuspectDatabaseEntry::hasNonReplicantClue(int clueId) const { - for (int i = 0; i < _nonReplicantClueCount; i++) { + for (int i = 0; i < _nonReplicantClueCount; ++i) { if (_nonReplicantClues[i] == clueId) { return true; } @@ -149,7 +149,7 @@ bool SuspectDatabaseEntry::hasNonReplicantClue(int clueId) const { } bool SuspectDatabaseEntry::hasOtherClue(int clueId) const { - for (int i = 0; i < _otherClueCount; i++) { + for (int i = 0; i < _otherClueCount; ++i) { if (_otherClues[i] == clueId) { return true; } @@ -158,7 +158,7 @@ bool SuspectDatabaseEntry::hasOtherClue(int clueId) const { } bool SuspectDatabaseEntry::hasIdentityClue(int clueId) const { - for (int i = 0; i < _identityClueCount; i++) { + for (int i = 0; i < _identityClueCount; ++i) { if (_identityClues[i] == clueId) { return true; } @@ -193,24 +193,29 @@ int SuspectDatabaseEntry::getPhotoNotUsed(int photoId) const { void SuspectDatabaseEntry::reset() { _actorId = -1; _sex = -1; - for (int i = 0; i < kMOClueCount; i++) { + for (int i = 0; i < kMOClueCount; ++i) { _moClues[i] = -1; } - for (int i = 0; i < kWhereaboutsClueCount; i++) { + for (int i = 0; i < kWhereaboutsClueCount; ++i) { _whereaboutsClues[i] = -1; } - for (int i = 0; i < kIdentityClueCount; i++) { + for (int i = 0; i < kIdentityClueCount; ++i) { _identityClues[i] = -1; } - for (int i = 0; i < kReplicantClueCount; i++) { + for (int i = 0; i < kReplicantClueCount; ++i) { _replicantClues[i] = -1; } - for (int i = 0; i < kNonReplicantClueCount; i++) { + for (int i = 0; i < kNonReplicantClueCount; ++i) { _nonReplicantClues[i] = -1; } - for (int i = 0; i < kOtherClueCount; i++) { + for (int i = 0; i < kOtherClueCount; ++i) { _otherClues[i] = -1; } + for (int i = 0; i < kPhotoClueCount; ++i) { + _photoClues[i].clueId = -1; + _photoClues[i].shapeId = -1; + _photoClues[i].notUsed = -1; + } // photo clues are not reseted in original game @@ -225,7 +230,7 @@ void SuspectDatabaseEntry::reset() { SuspectsDatabase::SuspectsDatabase(BladeRunnerEngine *vm, int size) { _vm = vm; - for (int i = 0; i < size; i++) { + for (int i = 0; i < size; ++i) { _suspects.push_back(new SuspectDatabaseEntry(_vm)); } } diff --git a/engines/bladerunner/ui/kia.cpp b/engines/bladerunner/ui/kia.cpp index c27a548b3a..0a6229411e 100644 --- a/engines/bladerunner/ui/kia.cpp +++ b/engines/bladerunner/ui/kia.cpp @@ -99,6 +99,11 @@ KIA::KIA(BladeRunnerEngine *vm) { _loadSection = new KIASectionLoad(_vm); _diagnosticSection = new KIASectionDiagnostic(_vm); _pogoSection = new KIASectionPogo(_vm); + + for (int i = 0; i < kPlayerActorDialogueQueueCapacity; ++i) { + _playerActorDialogueQueue[i].actorId = -1; + _playerActorDialogueQueue[i].sentenceId = -1; + } } KIA::~KIA() { diff --git a/engines/bladerunner/ui/kia_section_crimes.cpp b/engines/bladerunner/ui/kia_section_crimes.cpp index 417a0588e0..96075fbc22 100644 --- a/engines/bladerunner/ui/kia_section_crimes.cpp +++ b/engines/bladerunner/ui/kia_section_crimes.cpp @@ -60,6 +60,10 @@ KIASectionCrimes::KIASectionCrimes(BladeRunnerEngine *vm, ActorClues *clues) : K _uiContainer->add(_cluesScrollBox); _acquiredClueCount = 0; + for (int i = 0; i < kClueCount; ++i) { + _acquiredClues[i].clueId = -1; + _acquiredClues[i].actorId = -1; + } _crimeSelected = -1; _crimesFoundCount = 0; diff --git a/engines/bladerunner/ui/kia_section_diagnostic.cpp b/engines/bladerunner/ui/kia_section_diagnostic.cpp index d4ccc32433..55672cdf2c 100644 --- a/engines/bladerunner/ui/kia_section_diagnostic.cpp +++ b/engines/bladerunner/ui/kia_section_diagnostic.cpp @@ -32,11 +32,17 @@ namespace BladeRunner { const int KIASectionDiagnostic::kTextColors[] = { 0x0000, 0x0821, 0x1061, 0x1C82, 0x24C2, 0x2CE3, 0x3524, 0x4145, 0x4586, 0x4DC7, 0x5609, 0x5E4B, 0x668C, 0x6EEE, 0x7730, 0x7B92 }; -KIASectionDiagnostic::KIASectionDiagnostic(BladeRunnerEngine *vm) : KIASectionBase(vm) {} +KIASectionDiagnostic::KIASectionDiagnostic(BladeRunnerEngine *vm) : KIASectionBase(vm) { + _text = nullptr; + _offset = 0; + _timeLast = 0; +} void KIASectionDiagnostic::open() { _text = new TextResource(_vm); - _text->open("KIACRED"); + if (!_text->open("KIACRED")) { + return; + } _vm->_kia->playActorDialogue(kActorRunciter, 140); _offset = 0; _timeLast = _vm->getTotalPlayTime(); diff --git a/engines/bladerunner/ui/kia_section_pogo.cpp b/engines/bladerunner/ui/kia_section_pogo.cpp index 27cd9891c6..a0c5ac6a63 100644 --- a/engines/bladerunner/ui/kia_section_pogo.cpp +++ b/engines/bladerunner/ui/kia_section_pogo.cpp @@ -193,7 +193,20 @@ const char *KIASectionPogo::kStrings[] = { "Zion National Park" }; -KIASectionPogo::KIASectionPogo(BladeRunnerEngine *vm) : KIASectionBase(vm) {} +KIASectionPogo::KIASectionPogo(BladeRunnerEngine *vm) : KIASectionBase(vm) { + _stringIndex = 0; + _timeLast = 0; + + for (int i = 0; i < kStringCount; ++i) { + _strings[i] = nullptr; + } + + for (int i = 0; i < kLineCount; ++i) { + _lineTexts[i] = nullptr; + _lineTimeouts[i] = 0; + _lineOffsets[i] = 0; + } +} void KIASectionPogo::open() { _stringIndex = 0; diff --git a/engines/bladerunner/ui/kia_section_suspects.cpp b/engines/bladerunner/ui/kia_section_suspects.cpp index af2c457d92..54e33cb62b 100644 --- a/engines/bladerunner/ui/kia_section_suspects.cpp +++ b/engines/bladerunner/ui/kia_section_suspects.cpp @@ -77,6 +77,12 @@ KIASectionSuspects::KIASectionSuspects(BladeRunnerEngine *vm, ActorClues *clues) _uiContainer->add(_crimesScrollBox); _acquiredClueCount = 0; + for (int i = 0; i < kClueCount; ++i) { + _acquiredClues[i].clueId = -1; + _acquiredClues[i].actorId = -1; + } + + _crimeSelected = -1; _suspectSelected = -1; _suspectPhotoShapeId = -1; @@ -84,8 +90,6 @@ KIASectionSuspects::KIASectionSuspects(BladeRunnerEngine *vm, ActorClues *clues) _suspectsFoundCount = 0; _suspectsFound.resize(_vm->_gameInfo->getSuspectCount()); _suspectsWithIdentity.resize(_vm->_gameInfo->getSuspectCount()); - - _crimeSelected = -1; } KIASectionSuspects::~KIASectionSuspects() { diff --git a/engines/bladerunner/ui/ui_image_picker.cpp b/engines/bladerunner/ui/ui_image_picker.cpp index 639c02f592..5cee12fef8 100644 --- a/engines/bladerunner/ui/ui_image_picker.cpp +++ b/engines/bladerunner/ui/ui_image_picker.cpp @@ -159,29 +159,29 @@ void UIImagePicker::activate(UIImagePickerCallback *mouseInCallback, UIImagePickerCallback *mouseDownCallback, UIImagePickerCallback *mouseUpCallback, void *callbackData) { - _isButtonDown = false; - _mouseInCallback = mouseInCallback; - _mouseOutCallback = mouseOutCallback; - _mouseDownCallback = mouseDownCallback; - _mouseUpCallback = mouseUpCallback; - _callbackData = callbackData; + _isButtonDown = false; + _mouseInCallback = mouseInCallback; + _mouseOutCallback = mouseOutCallback; + _mouseDownCallback = mouseDownCallback; + _mouseUpCallback = mouseUpCallback; + _callbackData = callbackData; _hoverStartTimestamp = 0; - _isVisible = true; - _hoveredImageIndex = -1; - _pressedImageIndex = -1; + _isVisible = true; + _hoveredImageIndex = -1; + _pressedImageIndex = -1; } void UIImagePicker::deactivate() { - _isButtonDown = false; - _mouseInCallback = nullptr; - _mouseOutCallback = nullptr; - _mouseDownCallback = nullptr; - _mouseUpCallback = nullptr; - _callbackData = nullptr; + _isButtonDown = false; + _mouseInCallback = nullptr; + _mouseOutCallback = nullptr; + _mouseDownCallback = nullptr; + _mouseUpCallback = nullptr; + _callbackData = nullptr; _hoverStartTimestamp = 0; - _isVisible = false; - _hoveredImageIndex = -1; - _pressedImageIndex = -1; + _isVisible = false; + _hoveredImageIndex = -1; + _pressedImageIndex = -1; } void UIImagePicker::draw(Graphics::Surface &surface) { @@ -343,6 +343,17 @@ bool UIImagePicker::hasHoveredImage() { return _hoveredImageIndex >= 0; } -void UIImagePicker::reset() {} +void UIImagePicker::reset() { + _isVisible = false; + _hoveredImageIndex = -1; + _pressedImageIndex = -1; + _hoverStartTimestamp = 0; + _isButtonDown = false; + _mouseInCallback = nullptr; + _mouseOutCallback = nullptr; + _mouseDownCallback = nullptr; + _mouseUpCallback = nullptr; + _callbackData = nullptr; +} } // End of namespace BladeRunner diff --git a/engines/bladerunner/ui/vk.cpp b/engines/bladerunner/ui/vk.cpp index 8145ee39db..ebd088735e 100644 --- a/engines/bladerunner/ui/vk.cpp +++ b/engines/bladerunner/ui/vk.cpp @@ -73,11 +73,11 @@ void VK::open(int actorId, int calibrationRatio) { } _volumeAmbient = _vm->_ambientSounds->getVolume(); - _volumeMusic = _vm->_music->getVolume(); + _volumeMusic = _vm->_music->getVolume(); - _actorId = actorId; + _actorId = actorId; _calibrationRatio = calibrationRatio; - _calibration = 0; + _calibration = 0; _buttons = new UIImagePicker(_vm, 8); @@ -371,9 +371,12 @@ void VK::loopEnded(void *callbackData, int frame, int loopId) { } void VK::reset() { + _actorId = -1; + _buttons = nullptr; _vqaPlayerMain = nullptr; _vqaPlayerEye = nullptr; + _vqaFrameMain = -1; _script = nullptr; @@ -381,6 +384,10 @@ void VK::reset() { _shapes.clear(); + _volumeAmbient = 0; + _volumeMusic = 0; + + _calibrationRatio = 0; _calibrationCounter = 0; _calibrationStarted = false; _calibration = 0; @@ -390,6 +397,7 @@ void VK::reset() { _needleValue = 0; _needleValueTarget = 0; _needleValueDelta = 0; + _needleValueMax = 0; _timeNextNeedleStep = 0; _timeNeedleReturn = 0; _timeNextNeedleOscillate = 0; @@ -415,10 +423,11 @@ void VK::reset() { _isClosing = false; _timeClose = 0; - _isAdjusting = false; - _adjustment = 154; - _adjustmentTarget = 154; - _adjustmentDelta = 0; + _isAdjusting = false; + _adjustment = 154; + _adjustmentTarget = 154; + _adjustmentDelta = 0; + _timeNextAdjustementStep = 0; _eyeLineSelected = 1; _eyeLineX = 315; @@ -877,24 +886,24 @@ void VK::askQuestion(int intensity) { return; } - int foundQuestionIndex = -1; + int foundQuestionIndex = -1; int foundQuestionIndexLast = -1; for (int i = 0; i < (int)_questions[intensity].size(); ++i) { if (_questions[intensity][i].isPresent && !_questions[intensity][i].wasAsked) { - int relatedQuestion = -1; - if (_questions[intensity][i].relatedSentenceId >= 0) { - // TODO: but not used in game - // relatedQuestion = vk::findQuestionById(this, questions, relatedQuestionId); - } - - if (relatedQuestion < 0 || _questions[intensity][relatedQuestion].wasAsked) { - foundQuestionIndexLast = i; - if (_vm->_rnd.getRandomNumberRng(0, 100) < 20) { - foundQuestionIndex = i; - break; - } + // TODO: related questions are not used in game + // int relatedQuestion = -1; + // if (_questions[intensity][i].relatedSentenceId >= 0) { + // relatedQuestion = vk::findQuestionById(this, questions, relatedQuestionId); + // } + + // if (relatedQuestion < 0 || _questions[intensity][relatedQuestion].wasAsked) { + foundQuestionIndexLast = i; + if (_vm->_rnd.getRandomNumberRng(0, 100) < 20) { + foundQuestionIndex = i; + break; } + // } } } diff --git a/engines/bladerunner/vqa_decoder.cpp b/engines/bladerunner/vqa_decoder.cpp index 7dc7616fe9..ac3cadff15 100644 --- a/engines/bladerunner/vqa_decoder.cpp +++ b/engines/bladerunner/vqa_decoder.cpp @@ -117,14 +117,37 @@ const char *strTag(uint32 tag) { return s; } -VQADecoder::VQADecoder() : - _s(nullptr), - _frameInfo(nullptr), - _videoTrack(nullptr), - _audioTrack(nullptr), - _maxVIEWChunkSize(0), - _maxZBUFChunkSize(0), - _maxAESCChunkSize(0) { +VQADecoder::VQADecoder() { + _s = nullptr; + _frameInfo = nullptr; + _videoTrack = nullptr; + _audioTrack = nullptr; + _maxVIEWChunkSize = 0; + _maxZBUFChunkSize = 0; + _maxAESCChunkSize = 0; + _header.version = 0; + _header.flags = 0; + _header.numFrames = 0; + _header.width = 0; + _header.height = 0; + _header.blockW = 0; + _header.blockH = 0; + _header.frameRate = 0; + _header.cbParts = 0; + _header.colors = 0; + _header.maxBlocks = 0; + _header.offsetX = 0; + _header.offsetY = 0; + _header.maxVPTRSize = 0; + _header.freq = 0; + _header.channels = 0; + _header.bits = 0; + _header.unk3 = 0; + _header.unk4 = 0; + _header.maxCBFZSize = 0; + _header.unk5 = 0; + _readingFrame = -1; + _decodingFrame = -1; } VQADecoder::~VQADecoder() { @@ -592,20 +615,25 @@ VQADecoder::VQAVideoTrack::VQAVideoTrack(VQADecoder *vqaDecoder) { _maxCBFZSize = header->maxCBFZSize; _maxZBUFChunkSize = vqaDecoder->_maxZBUFChunkSize; - _codebook = nullptr; - _cbfz = nullptr; - _zbufChunk = nullptr; + _codebook = nullptr; + _cbfz = nullptr; _vpointerSize = 0; _vpointer = nullptr; _curFrame = -1; - _zbufChunk = new uint8[roundup(_maxZBUFChunkSize)]; + _zbufChunkSize = 0; + _zbufChunk = new uint8[roundup(_maxZBUFChunkSize)]; - _viewData = nullptr; - _screenEffectsData = nullptr; - _lightsData = nullptr; + _viewDataSize = 0; + _viewData = nullptr; + + _screenEffectsDataSize = 0; + _screenEffectsData = nullptr; + + _lightsDataSize = 0; + _lightsData = nullptr; } VQADecoder::VQAVideoTrack::~VQAVideoTrack() { |