aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilippos Karapetis2009-01-17 21:45:53 +0000
committerFilippos Karapetis2009-01-17 21:45:53 +0000
commit56f75b4c41b9fbd8736477ac28a6004e6b4a5014 (patch)
tree72a7397799c244feefdf5914f5778f613a0d3cf6
parentba4b872a205528c4159a2d633e12595256eaa990 (diff)
downloadscummvm-rg350-56f75b4c41b9fbd8736477ac28a6004e6b4a5014.tar.gz
scummvm-rg350-56f75b4c41b9fbd8736477ac28a6004e6b4a5014.tar.bz2
scummvm-rg350-56f75b4c41b9fbd8736477ac28a6004e6b4a5014.zip
Fixed bug #2057987 - "IHNM: Music stops in Ellen's chapter"
svn-id: r35884
-rw-r--r--engines/saga/events.cpp13
-rw-r--r--engines/saga/events.h2
-rw-r--r--engines/saga/saveload.cpp3
-rw-r--r--engines/saga/sfuncs_ihnm.cpp7
4 files changed, 17 insertions, 8 deletions
diff --git a/engines/saga/events.cpp b/engines/saga/events.cpp
index 0a3b7fe21b..482bb6d46e 100644
--- a/engines/saga/events.cpp
+++ b/engines/saga/events.cpp
@@ -625,7 +625,7 @@ int Events::initializeEvent(Event *event) {
return SUCCESS;
}
-int Events::clearList() {
+int Events::clearList(bool playQueuedMusic) {
Event *chain_walk;
Event *next_chain;
Event *event_p;
@@ -636,7 +636,16 @@ int Events::clearList() {
// Only remove events not marked kEvFNoDestory (engine events)
if (!(event_p->code & kEvFNoDestory)) {
- // Remove any events chained off this one */
+ // Handle queued music change events before deleting them
+ // This can happen in IHNM by music events set by sfQueueMusic()
+ // Fixes bug #2057987 - "IHNM: Music stops in Ellen's chapter"
+ if (playQueuedMusic && ((event_p->code & EVENT_MASK) == kMusicEvent)) {
+ _vm->_music->stop();
+ if (event_p->op == kEventPlay)
+ _vm->_music->play(event_p->param, (MusicFlags)event_p->param2);
+ }
+
+ // Remove any events chained off this one
for (chain_walk = event_p->chain; chain_walk != NULL; chain_walk = next_chain) {
next_chain = chain_walk->chain;
free(chain_walk);
diff --git a/engines/saga/events.h b/engines/saga/events.h
index 3ae8551a88..c2082994bc 100644
--- a/engines/saga/events.h
+++ b/engines/saga/events.h
@@ -165,7 +165,7 @@ class Events {
Events(SagaEngine *vm);
~Events(void);
int handleEvents(long msec);
- int clearList();
+ int clearList(bool playQueuedMusic = true);
int freeList();
Event *queue(Event *event);
Event *chain(Event *headEvent, Event *addEvent);
diff --git a/engines/saga/saveload.cpp b/engines/saga/saveload.cpp
index e908a54ad9..90aafb9802 100644
--- a/engines/saga/saveload.cpp
+++ b/engines/saga/saveload.cpp
@@ -292,6 +292,9 @@ void SagaEngine::load(const char *fileName) {
// TODO: played time
}
+ // Clear pending events here, and don't process queued music events
+ _events->clearList(false);
+
// Surrounding scene
sceneNumber = in->readSint32LE();
#ifdef ENABLE_IHNM
diff --git a/engines/saga/sfuncs_ihnm.cpp b/engines/saga/sfuncs_ihnm.cpp
index 0f648e2cbd..fe586b54ae 100644
--- a/engines/saga/sfuncs_ihnm.cpp
+++ b/engines/saga/sfuncs_ihnm.cpp
@@ -422,11 +422,8 @@ void Script::sfQueueMusic(SCRIPTFUNC_PARAMS) {
event.param = _vm->_music->_songTable[param1];
event.param2 = param2 ? MUSIC_LOOP : MUSIC_NORMAL;
event.op = kEventPlay;
- event.time = _vm->ticksToMSec(500); // I find the delay in the original to be too long, so I've set it to
- // wait for half the time, which sounds better when chapter points
- // change
- // FIXME: If this is too short for other cases apart from chapter
- // point change, set it back to 1000
+ event.time = _vm->ticksToMSec(1000);
+
_vm->_events->queue(&event);
if (!_vm->_scene->haveChapterPointsChanged()) {