aboutsummaryrefslogtreecommitdiff
path: root/engines/director
diff options
context:
space:
mode:
authorScott Percival2020-01-01 12:47:18 +0800
committerScott Percival2020-01-01 12:47:18 +0800
commit608f89617bc28fd2b136a371fc69d07f028d1e09 (patch)
treeb109a6ed1b11d2e3b5492329758f985d51a8ad33 /engines/director
parent7121a915d85a49a1e1111e282a1fee992152e5ea (diff)
downloadscummvm-rg350-608f89617bc28fd2b136a371fc69d07f028d1e09.tar.gz
scummvm-rg350-608f89617bc28fd2b136a371fc69d07f028d1e09.tar.bz2
scummvm-rg350-608f89617bc28fd2b136a371fc69d07f028d1e09.zip
DIRECTOR: LINGO: Add wrapper for executing script handlers
Diffstat (limited to 'engines/director')
-rw-r--r--engines/director/lingo/lingo-events.cpp2
-rw-r--r--engines/director/lingo/lingo.cpp10
-rw-r--r--engines/director/lingo/lingo.h1
3 files changed, 12 insertions, 1 deletions
diff --git a/engines/director/lingo/lingo-events.cpp b/engines/director/lingo/lingo-events.cpp
index 4aeed4cc38..fe64b80e29 100644
--- a/engines/director/lingo/lingo-events.cpp
+++ b/engines/director/lingo/lingo-events.cpp
@@ -316,7 +316,7 @@ void Lingo::processEvent(LEvent event, ScriptType st, int entityId) {
if (_handlers.contains(ENTITY_INDEX(event, entityId))) {
debugC(1, kDebugEvents, "Lingo::processEvent(%s, %s, %d), _eventHandler", _eventHandlerTypes[event], scriptType2str(st), entityId);
- LC::call(_eventHandlerTypes[event], 0); // D4+ Events
+ executeHandler(_eventHandlerTypes[event]); // D4+ Events
} else if (event == kEventNone && _scriptContexts[st].contains(entityId)) {
debugC(1, kDebugEvents, "Lingo::processEvent(%s, %s, %d), script", _eventHandlerTypes[event], scriptType2str(st), entityId);
diff --git a/engines/director/lingo/lingo.cpp b/engines/director/lingo/lingo.cpp
index 2200276526..f5a0d73ac2 100644
--- a/engines/director/lingo/lingo.cpp
+++ b/engines/director/lingo/lingo.cpp
@@ -243,6 +243,16 @@ void Lingo::executeScript(ScriptType type, uint16 id, uint16 function) {
cleanLocalVars();
}
+void Lingo::executeHandler(Common::String name) {
+ _returning = false;
+ _localvars = new SymbolHash;
+
+ debugC(1, kDebugLingoExec, "Executing script handler : %s", name.c_str());
+ LC::call(name, 0);
+
+ cleanLocalVars();
+}
+
void Lingo::restartLingo() {
warning("STUB: restartLingo()");
diff --git a/engines/director/lingo/lingo.h b/engines/director/lingo/lingo.h
index a6d45b6cea..bcac9842d1 100644
--- a/engines/director/lingo/lingo.h
+++ b/engines/director/lingo/lingo.h
@@ -148,6 +148,7 @@ public:
void addCode(const char *code, ScriptType type, uint16 id);
void addCodeV4(Common::SeekableSubReadStreamEndian &stream, ScriptType type, uint16 id);
void addNamesV4(Common::SeekableSubReadStreamEndian &stream);
+ void executeHandler(Common::String name);
void executeScript(ScriptType type, uint16 id, uint16 function);
void printStack(const char *s, uint pc);
Common::String decodeInstruction(ScriptData *sd, uint pc, uint *newPC = NULL);