From d6f2a8948810ed8c7f6d241b7ef194f2ef095d09 Mon Sep 17 00:00:00 2001 From: Andrei Prykhodko Date: Thu, 16 Aug 2018 06:32:56 +0300 Subject: PINK: fixed original bug when ActionSfx continues to play when it should stop --- engines/pink/objects/actions/action_play_with_sfx.cpp | 12 ++++++++++++ engines/pink/objects/actions/action_play_with_sfx.h | 3 +++ engines/pink/objects/sequences/sequencer.cpp | 16 +++++++++++++--- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/engines/pink/objects/actions/action_play_with_sfx.cpp b/engines/pink/objects/actions/action_play_with_sfx.cpp index 0c8aa94c2c..3064215fd3 100644 --- a/engines/pink/objects/actions/action_play_with_sfx.cpp +++ b/engines/pink/objects/actions/action_play_with_sfx.cpp @@ -29,6 +29,8 @@ namespace Pink { +bool g_skipping = false; // FIXME: non-const global var + ActionPlayWithSfx::~ActionPlayWithSfx() { ActionPlay::end(); for (uint i = 0; i < _sfxArray.size(); ++i) { @@ -74,6 +76,12 @@ void ActionPlayWithSfx::onStart() { void ActionPlayWithSfx::end() { ActionCEL::end(); debugC(6, kPinkDebugActions, "ActionPlayWithSfx %s of Actor %s is ended", _name.c_str(), _actor->getName().c_str()); + // original bug fix + if (g_skipping) { + for (uint i = 0; i < _sfxArray.size(); ++i) { + _sfxArray[i]->end(); + } + } } void ActionSfx::deserialize(Pink::Archive &archive) { @@ -97,4 +105,8 @@ void ActionSfx::play() { } } +void ActionSfx::end() { + _sound.stop(); +} + } // End of namespace Pink diff --git a/engines/pink/objects/actions/action_play_with_sfx.h b/engines/pink/objects/actions/action_play_with_sfx.h index 2797604671..16d1855584 100644 --- a/engines/pink/objects/actions/action_play_with_sfx.h +++ b/engines/pink/objects/actions/action_play_with_sfx.h @@ -28,6 +28,8 @@ namespace Pink { +extern bool g_skipping; + class ActionSfx; class ActionPlayWithSfx : public ActionPlay { @@ -61,6 +63,7 @@ public: void toConsole() override; void play(); + void end(); int32 getFrame() { return _frame; } diff --git a/engines/pink/objects/sequences/sequencer.cpp b/engines/pink/objects/sequences/sequencer.cpp index 8885fdc213..df5522de54 100644 --- a/engines/pink/objects/sequences/sequencer.cpp +++ b/engines/pink/objects/sequences/sequencer.cpp @@ -24,6 +24,7 @@ #include "pink/archive.h" #include "pink/pink.h" +#include "pink/objects/actions/action_play_with_sfx.h" #include "pink/objects/actors/lead_actor.h" #include "pink/objects/pages/game_page.h" #include "pink/objects/sequences/sequencer.h" @@ -143,18 +144,27 @@ void Sequencer::removeContext(SequenceContext *context) { } void Sequencer::skipSubSequence() { - if (_context) + if (_context) { + g_skipping = true; _context->getSequence()->skipSubSequence(); + g_skipping = false; + } } void Sequencer::restartSequence() { - if (_context) + if (_context) { + g_skipping = true; _context->getSequence()->restart(); + g_skipping = false; + } } void Sequencer::skipSequence() { - if (_context && _context->getSequence()->isSkippingAllowed()) + if (_context && _context->getSequence()->isSkippingAllowed()) { + g_skipping = true; _context->getSequence()->skip(); + g_skipping = false; + } } void Sequencer::loadState(Archive &archive) { -- cgit v1.2.3