Permalink
Browse files

PINK: fixed original bug when ActionSfx continues to play when it sho…

…uld stop
  • Loading branch information...
whiterandrek committed Aug 16, 2018
1 parent 486a63d commit d6f2a8948810ed8c7f6d241b7ef194f2ef095d09
@@ -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
@@ -28,6 +28,8 @@

namespace Pink {

extern bool g_skipping;

class ActionSfx;

class ActionPlayWithSfx : public ActionPlay {
@@ -61,6 +63,7 @@ class ActionSfx : public Object {
void toConsole() override;

void play();
void end();

int32 getFrame() { return _frame; }

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

0 comments on commit d6f2a89

Please sign in to comment.