[Scummvm-git-logs] scummvm master -> 79168e176962cb6c00d68fc677815d102dd7e79a

moralrecordings code at moral.net.au
Thu Jun 11 17:30:37 UTC 2020


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
79168e1769 DIRECTOR: LINGO: Fix D4 event handler lookups


Commit: 79168e176962cb6c00d68fc677815d102dd7e79a
    https://github.com/scummvm/scummvm/commit/79168e176962cb6c00d68fc677815d102dd7e79a
Author: Scott Percival (code at moral.net.au)
Date: 2020-06-12T01:30:17+08:00

Commit Message:
DIRECTOR: LINGO: Fix D4 event handler lookups

Changed paths:
    engines/director/lingo/lingo-codegen.cpp
    engines/director/lingo/lingo-events.cpp
    engines/director/lingo/lingo.cpp
    engines/director/lingo/lingo.h


diff --git a/engines/director/lingo/lingo-codegen.cpp b/engines/director/lingo/lingo-codegen.cpp
index 4262b834d5..01a987778f 100644
--- a/engines/director/lingo/lingo-codegen.cpp
+++ b/engines/director/lingo/lingo-codegen.cpp
@@ -99,7 +99,7 @@ Symbol Lingo::define(Common::String &name, int nargs, ScriptData *code, Common::
 		if (!_eventHandlerTypeIds.contains(name)) {
 			_archives[_archiveIndex].functionHandlers[name] = sym;
 		} else {
-			_archives[_archiveIndex].eventHandlers[ENTITY_INDEX(_eventHandlerTypeIds[name.c_str()], _currentEntityId)] = sym;
+			_archives[_archiveIndex].eventHandlers[ENTITY_INDEX(_eventHandlerTypeIds[name], _currentEntityId)] = sym;
 		}
 	}
 
diff --git a/engines/director/lingo/lingo-events.cpp b/engines/director/lingo/lingo-events.cpp
index 763e286e2e..f456911914 100644
--- a/engines/director/lingo/lingo-events.cpp
+++ b/engines/director/lingo/lingo-events.cpp
@@ -323,7 +323,8 @@ void Lingo::processEvent(LEvent event, ScriptType st, int entityId, int channelI
 	if (!_eventHandlerTypes.contains(event))
 		error("processEvent: Unknown event %d for entity %d", event, entityId);
 
-	if (_archives[_archiveIndex].eventHandlers.contains(ENTITY_INDEX(event, entityId))) {
+	if (_archives[0].eventHandlers.contains(ENTITY_INDEX(event, entityId)) ||
+		_archives[1].eventHandlers.contains(ENTITY_INDEX(event, entityId))) {
 		debugC(1, kDebugEvents, "Lingo::processEvent(%s, %s, %d), _eventHandler", _eventHandlerTypes[event], scriptType2str(st), entityId);
 		executeHandler(_eventHandlerTypes[event]); // D4+ Events
 	} else if (_vm->getVersion() < 4 && event == kEventNone && getScriptContext(st, entityId)) {
diff --git a/engines/director/lingo/lingo.cpp b/engines/director/lingo/lingo.cpp
index 971d93e083..ae5a5ae038 100644
--- a/engines/director/lingo/lingo.cpp
+++ b/engines/director/lingo/lingo.cpp
@@ -237,10 +237,14 @@ Symbol Lingo::getHandler(const Common::String &name) {
 	}
 
 	uint32 entityIndex = ENTITY_INDEX(_eventHandlerTypeIds[name], _currentEntityId);
-	// event handlers should only be defined locally, the score in a shared file is ignored
+	// local scripts
 	if (_archives[0].eventHandlers.contains(entityIndex))
 		return _archives[0].eventHandlers[entityIndex];
 
+	// shared scripts
+	if (_archives[1].eventHandlers.contains(entityIndex))
+		return _archives[1].eventHandlers[entityIndex];
+
 	return result;
 }
 
@@ -611,9 +615,10 @@ void Lingo::executeScript(ScriptType type, uint16 id, uint16 function) {
 	execute(_pc);
 }
 
-void Lingo::executeHandler(Common::String name) {
+void Lingo::executeHandler(const Common::String &name) {
 	debugC(1, kDebugLingoExec, "Executing script handler : %s", name.c_str());
-	LC::call(name, 0);
+	Symbol sym = getHandler(name);
+	LC::call(sym, 0);
 	execute(_pc);
 }
 
diff --git a/engines/director/lingo/lingo.h b/engines/director/lingo/lingo.h
index 0eac41da15..2a0cd950c8 100644
--- a/engines/director/lingo/lingo.h
+++ b/engines/director/lingo/lingo.h
@@ -319,7 +319,7 @@ public:
 	void addCode(const char *code, ScriptType type, uint16 id);
 	void addCodeV4(Common::SeekableSubReadStreamEndian &stream, ScriptType type, uint16 id, Common::String &archName);
 	void addNamesV4(Common::SeekableSubReadStreamEndian &stream);
-	void executeHandler(Common::String name);
+	void executeHandler(const Common::String &name);
 	void executeScript(ScriptType type, uint16 id, uint16 function);
 	void printStack(const char *s, uint pc);
 	void printCallStack(uint pc);




More information about the Scummvm-git-logs mailing list