aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2015-03-09 20:35:10 -0400
committerPaul Gilbert2015-03-09 20:35:10 -0400
commitd23e493b467a24e5d61dcb936b1c2e042c3ae9ce (patch)
tree92e6696cd8615ee32adcafeaa29e524adf41cdc6 /engines
parent82faf6b50da5996b1783877a9c2685d8272ffc0e (diff)
downloadscummvm-rg350-d23e493b467a24e5d61dcb936b1c2e042c3ae9ce.tar.gz
scummvm-rg350-d23e493b467a24e5d61dcb936b1c2e042c3ae9ce.tar.bz2
scummvm-rg350-d23e493b467a24e5d61dcb936b1c2e042c3ae9ce.zip
MADS: Fix crash if you talk to intern in gurney room too quickly
Diffstat (limited to 'engines')
-rw-r--r--engines/mads/nebular/nebular_scenes3.cpp6
-rw-r--r--engines/mads/sequence.cpp17
-rw-r--r--engines/mads/sequence.h3
3 files changed, 23 insertions, 3 deletions
diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index 8f07993e07..0b22aa7720 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -2581,6 +2581,12 @@ void Scene318::handleInternDialog(int quoteId, int quoteNum, uint32 timeout) {
_scene->_kernelMessages.reset();
_internTalkingFl = true;
+ // WORKAROUND: In case the player launches multiple talk selections with the
+ // intern before previous ones have finished, take care of removing any
+ int seqIndex;
+ while ((seqIndex = _scene->_sequences.findByTrigger(63)) != -1)
+ _scene->_sequences.remove(seqIndex);
+
for (int i = 0; i < quoteNum; i++) {
_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
_scene->_sequences.addTimer(180, 63);
diff --git a/engines/mads/sequence.cpp b/engines/mads/sequence.cpp
index 7dbf4cf3be..744e246321 100644
--- a/engines/mads/sequence.cpp
+++ b/engines/mads/sequence.cpp
@@ -144,7 +144,7 @@ int SequenceList::add(int spriteListIndex, bool flipped, int frameIndex, int tri
return seqIndex;
}
-int SequenceList::addTimer(int timeout, int abortVal) {
+int SequenceList::addTimer(int timeout, int endTrigger) {
Scene &scene = _vm->_game->_scene;
uint seqIndex;
for (seqIndex = 0; seqIndex < _entries.size(); ++seqIndex) {
@@ -164,7 +164,7 @@ int SequenceList::addTimer(int timeout, int abortVal) {
se._entries._count = 0;
se._triggerMode = _vm->_game->_triggerSetupMode;
se._actionNouns = _vm->_game->_scene._action._activeAction;
- addSubEntry(seqIndex, SEQUENCE_TRIGGER_EXPIRE, 0, abortVal);
+ addSubEntry(seqIndex, SEQUENCE_TRIGGER_EXPIRE, 0, endTrigger);
return seqIndex;
}
@@ -181,6 +181,19 @@ void SequenceList::remove(int seqIndex) {
scene._spriteSlots.deleteTimer(seqIndex);
}
+int SequenceList::findByTrigger(int trigger) {
+ for (int idx = 0; idx < _entries.size(); ++idx) {
+ if (_entries[idx]._active) {
+ for (uint subIdx = 0; subIdx < _entries[idx]._entries._count; ++subIdx) {
+ if (_entries[idx]._entries._trigger[subIdx] == trigger)
+ return idx;
+ }
+ }
+ }
+
+ return -1;
+}
+
void SequenceList::setSpriteSlot(int seqIndex, SpriteSlot &spriteSlot) {
Scene &scene = _vm->_game->_scene;
SequenceEntry &timerEntry = _entries[seqIndex];
diff --git a/engines/mads/sequence.h b/engines/mads/sequence.h
index 1555232780..8b236af15e 100644
--- a/engines/mads/sequence.h
+++ b/engines/mads/sequence.h
@@ -101,8 +101,9 @@ public:
int extraTicks, int numTicks, int msgX, int msgY, bool nonFixed, int scale, int depth,
int frameInc, SpriteAnimType animType, int numSprites, int frameStart);
- int addTimer(int timeout, int abortVal);
+ int addTimer(int timeout, int endTrigger);
void remove(int seqIndex);
+ int findByTrigger(int trigger);
void setSpriteSlot(int seqIndex, SpriteSlot &spriteSlot);
bool loadSprites(int seqIndex);
void tick();