aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2015-08-17 20:16:22 -0400
committerPaul Gilbert2015-08-17 20:16:22 -0400
commitd3b8152a714d8ec4a573d51bc844a129c80b533c (patch)
treea4a4f6678c27505a96c733c7014a066281937052
parent39e75d75c6dbc728124ebacfa97937ae6f042e2f (diff)
downloadscummvm-rg350-d3b8152a714d8ec4a573d51bc844a129c80b533c.tar.gz
scummvm-rg350-d3b8152a714d8ec4a573d51bc844a129c80b533c.tar.bz2
scummvm-rg350-d3b8152a714d8ec4a573d51bc844a129c80b533c.zip
SHERLOCK: RT: Extra integrity checks for the _talkSequenceStack
-rw-r--r--engines/sherlock/scalpel/scalpel_talk.h5
-rw-r--r--engines/sherlock/talk.h10
-rw-r--r--engines/sherlock/tattoo/tattoo_scene.cpp6
-rw-r--r--engines/sherlock/tattoo/tattoo_talk.cpp9
-rw-r--r--engines/sherlock/tattoo/tattoo_talk.h5
-rw-r--r--engines/sherlock/tattoo/tattoo_user_interface.cpp3
6 files changed, 33 insertions, 5 deletions
diff --git a/engines/sherlock/scalpel/scalpel_talk.h b/engines/sherlock/scalpel/scalpel_talk.h
index 6f8b62cd2f..1d70db14b9 100644
--- a/engines/sherlock/scalpel/scalpel_talk.h
+++ b/engines/sherlock/scalpel/scalpel_talk.h
@@ -107,6 +107,11 @@ public:
* object's sequence
*/
virtual void pullSequence();
+
+ /**
+ * Returns true if the script stack is empty
+ */
+ virtual bool isSequencesEmpty() const { return _scriptStack.empty(); }
};
} // End of namespace Scalpel
diff --git a/engines/sherlock/talk.h b/engines/sherlock/talk.h
index dcc970a2ba..8352435a09 100644
--- a/engines/sherlock/talk.h
+++ b/engines/sherlock/talk.h
@@ -337,11 +337,6 @@ public:
void pushTalkSequence(Object *obj);
/**
- * Returns true if the script stack is empty
- */
- bool isSequencesEmpty() const { return _scriptStack.empty(); }
-
- /**
* Pops an entry off of the script stack
*/
void popStack();
@@ -372,6 +367,11 @@ public:
* object's sequence
*/
virtual void pullSequence() = 0;
+
+ /**
+ * Returns true if the script stack is empty
+ */
+ virtual bool isSequencesEmpty() const = 0;
};
} // End of namespace Sherlock
diff --git a/engines/sherlock/tattoo/tattoo_scene.cpp b/engines/sherlock/tattoo/tattoo_scene.cpp
index 78100ebd99..e94e10caf0 100644
--- a/engines/sherlock/tattoo/tattoo_scene.cpp
+++ b/engines/sherlock/tattoo/tattoo_scene.cpp
@@ -22,6 +22,7 @@
#include "sherlock/tattoo/tattoo_scene.h"
#include "sherlock/tattoo/tattoo_people.h"
+#include "sherlock/tattoo/tattoo_talk.h"
#include "sherlock/tattoo/tattoo_user_interface.h"
#include "sherlock/tattoo/tattoo.h"
#include "sherlock/events.h"
@@ -292,12 +293,17 @@ void TattooScene::checkBgShapes() {
}
void TattooScene::freeScene() {
+ TattooTalk &talk = *(TattooTalk *)_vm->_talk;
TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui;
Scene::freeScene();
+ // Delete any scene overlays that were used by the scene
delete ui._mask;
delete ui._mask1;
ui._mask = ui._mask1 = nullptr;
+
+ // Ensure that there wasn't anything left on the talk stack, since their _obj pointers will no longer be valid
+ assert(talk.isSequencesEmpty());
}
void TattooScene::doBgAnimCheckCursor() {
diff --git a/engines/sherlock/tattoo/tattoo_talk.cpp b/engines/sherlock/tattoo/tattoo_talk.cpp
index b8b8944688..49becbe3b4 100644
--- a/engines/sherlock/tattoo/tattoo_talk.cpp
+++ b/engines/sherlock/tattoo/tattoo_talk.cpp
@@ -948,6 +948,15 @@ void TattooTalk::pullSequence() {
}
}
+bool TattooTalk::isSequencesEmpty() const {
+ for (int idx = 0; idx < TALK_SEQUENCE_STACK_SIZE; ++idx) {
+ if (_talkSequenceStack[idx]._obj)
+ return false;
+ }
+
+ return true;
+}
+
} // End of namespace Tattoo
} // End of namespace Sherlock
diff --git a/engines/sherlock/tattoo/tattoo_talk.h b/engines/sherlock/tattoo/tattoo_talk.h
index 22ac3fcc94..68db063751 100644
--- a/engines/sherlock/tattoo/tattoo_talk.h
+++ b/engines/sherlock/tattoo/tattoo_talk.h
@@ -106,6 +106,11 @@ public:
* object's sequence
*/
virtual void pullSequence();
+
+ /**
+ * Returns true if the script stack is empty
+ */
+ virtual bool isSequencesEmpty() const;
};
} // End of namespace Tattoo
diff --git a/engines/sherlock/tattoo/tattoo_user_interface.cpp b/engines/sherlock/tattoo/tattoo_user_interface.cpp
index 62fd890be9..68bc29bd12 100644
--- a/engines/sherlock/tattoo/tattoo_user_interface.cpp
+++ b/engines/sherlock/tattoo/tattoo_user_interface.cpp
@@ -378,6 +378,9 @@ void TattooUserInterface::doStandardControl() {
if (vm._runningProlog)
return;
+ // There shouldn't be anything left on the talk sequence stack since we're back in control
+ assert(talk.isSequencesEmpty());
+
// When the end credits are active, any press will open the ScummVM global main menu
if (_creditsWidget.active()) {
if (_keyState.keycode || events._released || events._rightReleased) {