aboutsummaryrefslogtreecommitdiff
path: root/engines/sherlock/tattoo
diff options
context:
space:
mode:
authorPaul Gilbert2015-08-17 20:16:22 -0400
committerPaul Gilbert2015-08-17 20:16:22 -0400
commitd3b8152a714d8ec4a573d51bc844a129c80b533c (patch)
treea4a4f6678c27505a96c733c7014a066281937052 /engines/sherlock/tattoo
parent39e75d75c6dbc728124ebacfa97937ae6f042e2f (diff)
downloadscummvm-rg350-d3b8152a714d8ec4a573d51bc844a129c80b533c.tar.gz
scummvm-rg350-d3b8152a714d8ec4a573d51bc844a129c80b533c.tar.bz2
scummvm-rg350-d3b8152a714d8ec4a573d51bc844a129c80b533c.zip
SHERLOCK: RT: Extra integrity checks for the _talkSequenceStack
Diffstat (limited to 'engines/sherlock/tattoo')
-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
4 files changed, 23 insertions, 0 deletions
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) {