SHERLOCK: RT: Extra integrity checks for the _talkSequenceStack

This commit is contained in:
Paul Gilbert 2015-08-17 20:16:22 -04:00
parent 39e75d75c6
commit d3b8152a71
6 changed files with 33 additions and 5 deletions

View File

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

View File

@ -336,11 +336,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
*/
@ -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

View File

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

View File

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

View File

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

View File

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