[Scummvm-git-logs] scummvm master -> 3a3db20267ebc262bb49a9c7a64278787adf24ee

sev- noreply at scummvm.org
Sun Oct 22 15:20:01 UTC 2023


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

Summary:
52fb94307c GRAPHICS: MACGUI: Add guardrails for MacWindow::updateInnerDims()
432d2b07b7 DIRECTOR: XOBJ: Add WinInfo stub
5f3ebad4d2 DIRECTOR: Add workaround for blank SCVW chunks
ac597ab95e DIRECTOR: Add factory methods to disassembler
d493c0beaa DIRECTOR: Make TextCastMember::formatInfo load in the STXT data
bf546a5afb DIRECTOR: Add support for factory methods to debugger
490cc0aeb9 DIRECTOR: Add more debug output to preprocessor
b1a180739e DIRECTOR: Add patch to fix boar hunt in Wrath of the Gods
e9ba46db1b DIRECTOR: Add kTheVideoForWindowsPresent
e44f40318e GRAPHICS: MACGUI: Fix MacText::getMouseWord()/getMouseItem()
3a3db20267 DIRECTOR: Mark Wrath of the Gods as supported


Commit: 52fb94307cf18ea601d428fa081dc1ddd2e6cd1c
    https://github.com/scummvm/scummvm/commit/52fb94307cf18ea601d428fa081dc1ddd2e6cd1c
Author: Scott Percival (code at moral.net.au)
Date: 2023-10-22T17:19:54+02:00

Commit Message:
GRAPHICS: MACGUI: Add guardrails for MacWindow::updateInnerDims()

Changed paths:
    graphics/macgui/macwindow.cpp


diff --git a/graphics/macgui/macwindow.cpp b/graphics/macgui/macwindow.cpp
index ba7123785d0..5332964d959 100644
--- a/graphics/macgui/macwindow.cpp
+++ b/graphics/macgui/macwindow.cpp
@@ -98,7 +98,7 @@ void MacWindow::resize(int w, int h) {
 	_dims.setWidth(w);
 	_dims.setHeight(h);
 	updateInnerDims();
-	
+
 	rebuildSurface();
 }
 
@@ -239,6 +239,9 @@ void MacWindow::updateInnerDims() {
 		_innerDims = _dims;
 		_innerDims.grow(-kBorderWidth);
 	}
+	// Prevent negative dimensions
+	_innerDims.right = MAX(_innerDims.left, _innerDims.right);
+	_innerDims.bottom = MAX(_innerDims.top, _innerDims.bottom);
 }
 
 void MacWindow::updateOuterDims() {
@@ -292,7 +295,7 @@ void MacWindow::setTitle(const Common::String &title) {
 		_shadowedTitle = title;
 		return;
 	}
-	
+
 	_title = title;
 	_borderIsDirty = true;
 	_macBorder.setTitle(title, _borderSurface.w, _wm);


Commit: 432d2b07b7184dfad3f4302cc42085c177466795
    https://github.com/scummvm/scummvm/commit/432d2b07b7184dfad3f4302cc42085c177466795
Author: Scott Percival (code at moral.net.au)
Date: 2023-10-22T17:19:54+02:00

Commit Message:
DIRECTOR: XOBJ: Add WinInfo stub

Changed paths:
  A engines/director/lingo/xlibs/wininfo.cpp
  A engines/director/lingo/xlibs/wininfo.h
    engines/director/castmember/digitalvideo.cpp
    engines/director/lingo/lingo-object.cpp
    engines/director/module.mk


diff --git a/engines/director/castmember/digitalvideo.cpp b/engines/director/castmember/digitalvideo.cpp
index a6b09d021a0..0db90313893 100644
--- a/engines/director/castmember/digitalvideo.cpp
+++ b/engines/director/castmember/digitalvideo.cpp
@@ -218,9 +218,14 @@ Graphics::MacWidget *DigitalVideoCastMember::createWidget(Common::Rect &bbox, Ch
 		if (_lastFrame) {
 			_lastFrame->free();
 			delete _lastFrame;
+			_lastFrame = nullptr;
 		}
 
-		_lastFrame = frame->convertTo(g_director->_pixelformat, g_director->getPalette());
+		if (frame->getPixels()) {
+			_lastFrame = frame->convertTo(g_director->_pixelformat, g_director->getPalette());
+		} else {
+			warning("DigitalVideoCastMember::createWidget(): frame has no pixel data");
+		}
 	}
 	if (_lastFrame)
 		widget->getSurface()->blitFrom(*_lastFrame);
diff --git a/engines/director/lingo/lingo-object.cpp b/engines/director/lingo/lingo-object.cpp
index c432003182f..1146fb2d037 100644
--- a/engines/director/lingo/lingo-object.cpp
+++ b/engines/director/lingo/lingo-object.cpp
@@ -89,6 +89,7 @@
 #include "director/lingo/xlibs/videodiscxobj.h"
 #include "director/lingo/xlibs/volumelist.h"
 #include "director/lingo/xlibs/widgetxobj.h"
+#include "director/lingo/xlibs/wininfo.h"
 #include "director/lingo/xlibs/winxobj.h"
 #include "director/lingo/xlibs/xio.h"
 #include "director/lingo/xlibs/xplayanim.h"
@@ -223,6 +224,7 @@ static struct XLibProto {
 	{ ValkyrieXObj::fileNames,			ValkyrieXObj::open,			ValkyrieXObj::close,		kXObj,					400 },	// D4
 	{ VideodiscXObj::fileNames,			VideodiscXObj::open,		VideodiscXObj::close,		kXObj,					200 },	// D2
 	{ VolumeList::fileNames,			VolumeList::open,			VolumeList::close,			kXObj,					300 },	// D3
+	{ WinInfoXObj::fileNames,			WinInfoXObj::open,			WinInfoXObj::close,			kXObj,					400 },  // D4
 	{ WidgetXObj::fileNames,			WidgetXObj::open,			WidgetXObj::close, 			kXObj,					400 },  // D4
 	{ XioXObj::fileNames,				XioXObj::open,				XioXObj::close,				kXObj,					400 },	// D3
 	{ XPlayAnim::fileNames,				XPlayAnim::open,			XPlayAnim::close,			kXObj,					300 },	// D3
diff --git a/engines/director/lingo/xlibs/wininfo.cpp b/engines/director/lingo/xlibs/wininfo.cpp
new file mode 100644
index 00000000000..a610f5b7341
--- /dev/null
+++ b/engines/director/lingo/xlibs/wininfo.cpp
@@ -0,0 +1,97 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/system.h"
+
+#include "director/director.h"
+#include "director/lingo/lingo.h"
+#include "director/lingo/lingo-object.h"
+#include "director/lingo/lingo-utils.h"
+#include "director/lingo/xlibs/wininfo.h"
+
+/**************************************************
+ *
+ * USED IN:
+ * Devil's Canyon: A Dinamation Adventure
+ *
+ **************************************************/
+
+/*
+-- Wininfo Interface - (c)24/9/1995 Terabyte Interactive Ltd - Robert P. Beyer
+Wininfo
+I      mNew                                --Creates the XObject
+X      mDispose                            --Closes the XObject
+S      mName                               --Returns the XObject Name and Version
+SSSS   mWinInfo, file, section, entry      --Returns Windows information item
+ */
+
+namespace Director {
+
+const char *WinInfoXObj::xlibName = "wininfo";
+const char *WinInfoXObj::fileNames[] = {
+	"wininfo",
+	nullptr
+};
+
+static MethodProto xlibMethods[] = {
+	{ "new",				WinInfoXObj::m_new,		 0, 0,	400 },
+	{ "dispose",				WinInfoXObj::m_dispose,		 0, 0,	400 },
+	{ "name",				WinInfoXObj::m_name,		 0, 0,	400 },
+	{ "winInfo",				WinInfoXObj::m_winInfo,		 3, 3,	400 },
+	{ nullptr, nullptr, 0, 0, 0 }
+};
+
+WinInfoXObject::WinInfoXObject(ObjectType ObjectType) : Object<WinInfoXObject>("WinInfoXObj") {
+	_objType = ObjectType;
+}
+
+void WinInfoXObj::open(int type) {
+	if (type == kXObj) {
+		WinInfoXObject::initMethods(xlibMethods);
+		WinInfoXObject *xobj = new WinInfoXObject(kXObj);
+		g_lingo->exposeXObject(xlibName, xobj);
+	} else if (type == kXtraObj) {
+		// TODO - Implement Xtra
+	}
+}
+
+void WinInfoXObj::close(int type) {
+	if (type == kXObj) {
+		WinInfoXObject::cleanupMethods();
+		g_lingo->_globalvars[xlibName] = Datum();
+	} else if (type == kXtraObj) {
+		// TODO - Implement Xtra
+	}
+}
+
+void WinInfoXObj::m_new(int nargs) {
+	if (nargs != 0) {
+		warning("WinInfoXObj::m_new: expected 0 arguments");
+		g_lingo->dropStack(nargs);
+	}
+	g_lingo->push(g_lingo->_state->me);
+}
+
+XOBJSTUBNR(WinInfoXObj::m_dispose)
+XOBJSTUB(WinInfoXObj::m_name, "")
+XOBJSTUB(WinInfoXObj::m_winInfo, "")
+
+}
diff --git a/engines/director/lingo/xlibs/wininfo.h b/engines/director/lingo/xlibs/wininfo.h
new file mode 100644
index 00000000000..8a8021aa0ba
--- /dev/null
+++ b/engines/director/lingo/xlibs/wininfo.h
@@ -0,0 +1,49 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef DIRECTOR_LINGO_XLIBS_WININFO_H
+#define DIRECTOR_LINGO_XLIBS_WININFO_H
+
+namespace Director {
+
+class WinInfoXObject : public Object<WinInfoXObject> {
+public:
+	WinInfoXObject(ObjectType objType);
+};
+
+namespace WinInfoXObj {
+
+extern const char *xlibName;
+extern const char *fileNames[];
+
+void open(int type);
+void close(int type);
+
+void m_new(int nargs);
+void m_dispose(int nargs);
+void m_name(int nargs);
+void m_winInfo(int nargs);
+
+} // End of namespace WinInfoXObj
+
+} // End of namespace Director
+
+#endif
diff --git a/engines/director/module.mk b/engines/director/module.mk
index d2dbf3dcd0c..d401b57f16a 100644
--- a/engines/director/module.mk
+++ b/engines/director/module.mk
@@ -113,6 +113,7 @@ MODULE_OBJS = \
 	lingo/xlibs/volumelist.o \
 	lingo/xlibs/widgetxobj.o \
 	lingo/xlibs/winxobj.o \
+	lingo/xlibs/wininfo.o \
 	lingo/xlibs/xio.o \
 	lingo/xlibs/xplayanim.o \
 	lingo/xlibs/yasix.o


Commit: 5f3ebad4d2074fb76fcf9783986a1538b3442a89
    https://github.com/scummvm/scummvm/commit/5f3ebad4d2074fb76fcf9783986a1538b3442a89
Author: Scott Percival (code at moral.net.au)
Date: 2023-10-22T17:19:54+02:00

Commit Message:
DIRECTOR: Add workaround for blank SCVW chunks

Changed paths:
    engines/director/castmember/filmloop.cpp


diff --git a/engines/director/castmember/filmloop.cpp b/engines/director/castmember/filmloop.cpp
index 0b2bf300c22..beae040d83f 100644
--- a/engines/director/castmember/filmloop.cpp
+++ b/engines/director/castmember/filmloop.cpp
@@ -129,7 +129,11 @@ void FilmLoopCastMember::loadFilmLoopDataD2(Common::SeekableReadStreamEndian &st
 	FilmLoopFrame newFrame;
 
 	while (stream.pos() < size) {
-		uint16 frameSize = stream.readUint16BE() - 2;
+		uint16 frameSize = stream.readUint16BE();
+		if (frameSize == 0) {
+			continue;
+		}
+		frameSize -= 2;
 		if (debugChannelSet(5, kDebugLoading)) {
 			debugC(5, kDebugLoading, "loadFilmLoopDataD2: Frame entry:");
 			stream.hexdump(frameSize);
@@ -236,7 +240,11 @@ void FilmLoopCastMember::loadFilmLoopDataD4(Common::SeekableReadStreamEndian &st
 	FilmLoopFrame newFrame;
 
 	while (stream.pos() < size) {
-		uint16 frameSize = stream.readUint16BE() - 2;
+		uint16 frameSize = stream.readUint16BE();
+		if (frameSize == 0) {
+			continue;
+		}
+		frameSize -= 2;
 		if (debugChannelSet(5, kDebugLoading)) {
 			debugC(5, kDebugLoading, "loadFilmLoopDataD4: Frame entry:");
 			stream.hexdump(frameSize);


Commit: ac597ab95e7f333b094c93ed44d59e7b276b6ded
    https://github.com/scummvm/scummvm/commit/ac597ab95e7f333b094c93ed44d59e7b276b6ded
Author: Scott Percival (code at moral.net.au)
Date: 2023-10-22T17:19:54+02:00

Commit Message:
DIRECTOR: Add factory methods to disassembler

Changed paths:
    engines/director/debugger.cpp


diff --git a/engines/director/debugger.cpp b/engines/director/debugger.cpp
index 01d10486569..1723a31bf0c 100644
--- a/engines/director/debugger.cpp
+++ b/engines/director/debugger.cpp
@@ -502,7 +502,24 @@ bool Debugger::cmdDisasm(int argc, const char **argv) {
 						}
 					}
 				}
-
+				debugPrintf("  Factories:\n");
+				if (cast->_lingoArchive->factoryContexts.empty()) {
+					debugPrintf("    [empty]\n");
+				} else {
+					for (auto it : cast->_lingoArchive->factoryContexts) {
+						debugPrintf("  %d:\n", it._key);
+						if (it._value->empty()) {
+							debugPrintf("    [empty]\n");
+						} else {
+							for (auto jt : *it._value) {
+								debugPrintf("    %s:\n", jt._key.c_str());
+								for (auto &kt : jt._value->_functionHandlers) {
+									debugPrintf("%s\n", g_lingo->formatFunctionBody(kt._value).c_str());
+								}
+							}
+						}
+					}
+				}
 			} else {
 				debugPrintf("  [empty]\n");
 			}
@@ -521,6 +538,24 @@ bool Debugger::cmdDisasm(int argc, const char **argv) {
 						}
 					}
 				}
+				debugPrintf("  Factories:\n");
+				if (sharedCast->_lingoArchive->factoryContexts.empty()) {
+					debugPrintf("    [empty]\n");
+				} else {
+					for (auto it : sharedCast->_lingoArchive->factoryContexts) {
+						debugPrintf("  %d:\n", it._key);
+						if (it._value->empty()) {
+							debugPrintf("    [empty]\n");
+						} else {
+							for (auto jt : *it._value) {
+								debugPrintf("    %s:\n", jt._key.c_str());
+								for (auto &kt : jt._value->_functionHandlers) {
+									debugPrintf("%s\n", g_lingo->formatFunctionBody(kt._value).c_str());
+								}
+							}
+						}
+					}
+				}
 
 			} else {
 				debugPrintf("  [empty]\n");


Commit: d493c0beaa9a5559cbf8f0e00546c2f3b108bb50
    https://github.com/scummvm/scummvm/commit/d493c0beaa9a5559cbf8f0e00546c2f3b108bb50
Author: Scott Percival (code at moral.net.au)
Date: 2023-10-22T17:19:54+02:00

Commit Message:
DIRECTOR: Make TextCastMember::formatInfo load in the STXT data

Changed paths:
    engines/director/castmember/text.cpp


diff --git a/engines/director/castmember/text.cpp b/engines/director/castmember/text.cpp
index 9a4136b3873..448f1ab540a 100644
--- a/engines/director/castmember/text.cpp
+++ b/engines/director/castmember/text.cpp
@@ -390,6 +390,9 @@ void TextCastMember::updateFromWidget(Graphics::MacWidget *widget) {
 }
 
 Common::String TextCastMember::formatInfo() {
+	// need to pull the data from the STXT resource before the
+	// debug output will be visible
+	load();
 	Common::String format = formatStringForDump(_ptext.encode());
 
 	return Common::String::format(


Commit: bf546a5afbcded15d4707bc16e33e3a2e0034a0c
    https://github.com/scummvm/scummvm/commit/bf546a5afbcded15d4707bc16e33e3a2e0034a0c
Author: Scott Percival (code at moral.net.au)
Date: 2023-10-22T17:19:54+02:00

Commit Message:
DIRECTOR: Add support for factory methods to debugger

Changed paths:
    engines/director/debugger.cpp
    engines/director/lingo/lingo.cpp


diff --git a/engines/director/debugger.cpp b/engines/director/debugger.cpp
index 1723a31bf0c..a62cf84a09e 100644
--- a/engines/director/debugger.cpp
+++ b/engines/director/debugger.cpp
@@ -477,6 +477,8 @@ bool Debugger::cmdDisasm(int argc, const char **argv) {
 		if (!strcmp(argv[1], "all")) {
 			Movie *movie = g_director->getCurrentMovie();
 			Score *score = movie->getScore();
+			Cast *targets[2] = {movie->getCast(), movie->getSharedCast()};
+			const char *targetNames[2] = {"Cast", "Shared cast"};
 			ScriptContext *csc = lingo->_state->context;
 			if (csc) {
 				debugPrintf("Functions attached to frame %d:\n", score->getCurrentFrameNum());
@@ -488,79 +490,44 @@ bool Debugger::cmdDisasm(int argc, const char **argv) {
 				debugPrintf("  [empty]\n");
 			}
 			debugPrintf("\n");
-			debugPrintf("Cast functions:\n");
-			Cast *cast = movie->getCast();
-			if (cast && cast->_lingoArchive) {
-				for (int i = 0; i <= kMaxScriptType; i++) {
-					debugPrintf("  %s:\n", scriptType2str((ScriptType)i));
-					if (cast->_lingoArchive->scriptContexts[i].size() == 0)
-						debugPrintf("    [empty]\n");
-
-					for (auto &it : cast->_lingoArchive->scriptContexts[i]) {
-						for (auto &jt : it._value->_functionHandlers) {
-							debugPrintf("%s\n", g_lingo->formatFunctionBody(jt._value).c_str());
-						}
-					}
-				}
-				debugPrintf("  Factories:\n");
-				if (cast->_lingoArchive->factoryContexts.empty()) {
-					debugPrintf("    [empty]\n");
-				} else {
-					for (auto it : cast->_lingoArchive->factoryContexts) {
-						debugPrintf("  %d:\n", it._key);
-						if (it._value->empty()) {
+			for (int t = 0; t < 2; t++) {
+				debugPrintf("%s functions:\n", targetNames[t]);
+				Cast *cast = targets[t];
+				if (cast && cast->_lingoArchive) {
+					for (int i = 0; i <= kMaxScriptType; i++) {
+						debugPrintf("  %s:\n", scriptType2str((ScriptType)i));
+						if (cast->_lingoArchive->scriptContexts[i].size() == 0)
 							debugPrintf("    [empty]\n");
-						} else {
-							for (auto jt : *it._value) {
-								debugPrintf("    %s:\n", jt._key.c_str());
-								for (auto &kt : jt._value->_functionHandlers) {
-									debugPrintf("%s\n", g_lingo->formatFunctionBody(kt._value).c_str());
-								}
+
+						for (auto &it : cast->_lingoArchive->scriptContexts[i]) {
+							for (auto &jt : it._value->_functionHandlers) {
+								debugPrintf("%s\n", g_lingo->formatFunctionBody(jt._value).c_str());
 							}
 						}
 					}
-				}
-			} else {
-				debugPrintf("  [empty]\n");
-			}
-			debugPrintf("\n");
-			debugPrintf("Shared cast functions:\n");
-			Cast *sharedCast = movie->getSharedCast();
-			if (sharedCast && sharedCast->_lingoArchive) {
-				for (int i = 0; i <= kMaxScriptType; i++) {
-					debugPrintf("  %s:\n", scriptType2str((ScriptType)i));
-					if (sharedCast->_lingoArchive->scriptContexts[i].size() == 0)
+					debugPrintf("  Factories:\n");
+					if (cast->_lingoArchive->factoryContexts.empty()) {
 						debugPrintf("    [empty]\n");
-
-					for (auto &it : sharedCast->_lingoArchive->scriptContexts[i]) {
-						for (auto &jt : it._value->_functionHandlers) {
-							debugPrintf("%s\n", g_lingo->formatFunctionBody(jt._value).c_str());
-						}
-					}
-				}
-				debugPrintf("  Factories:\n");
-				if (sharedCast->_lingoArchive->factoryContexts.empty()) {
-					debugPrintf("    [empty]\n");
-				} else {
-					for (auto it : sharedCast->_lingoArchive->factoryContexts) {
-						debugPrintf("  %d:\n", it._key);
-						if (it._value->empty()) {
-							debugPrintf("    [empty]\n");
-						} else {
-							for (auto jt : *it._value) {
-								debugPrintf("    %s:\n", jt._key.c_str());
-								for (auto &kt : jt._value->_functionHandlers) {
-									debugPrintf("%s\n", g_lingo->formatFunctionBody(kt._value).c_str());
+					} else {
+						for (auto it : cast->_lingoArchive->factoryContexts) {
+							debugPrintf("  %d:\n", it._key);
+							if (it._value->empty()) {
+								debugPrintf("    [empty]\n");
+							} else {
+								for (auto jt : *it._value) {
+									debugPrintf("    %s:\n", jt._key.c_str());
+									for (auto &kt : jt._value->_functionHandlers) {
+										debugPrintf("%s\n", g_lingo->formatFunctionBody(kt._value).c_str());
+									}
 								}
 							}
 						}
 					}
+				} else {
+					debugPrintf("  [empty]\n");
 				}
-
-			} else {
-				debugPrintf("  [empty]\n");
+				debugPrintf("\n");
 			}
-
 			return true;
 		}
 		Common::String target(argv[1]);
@@ -578,23 +545,30 @@ bool Debugger::cmdDisasm(int argc, const char **argv) {
 
 		Common::String funcName = target.substr(splitPoint + 1, Common::String::npos);
 		Movie *movie = g_director->getCurrentMovie();
-		Cast *cast = movie->getCast();
-		if (cast && cast->_lingoArchive) {
-			ScriptContext *ctx = cast->_lingoArchive->findScriptContext(scriptId);
-			if (ctx && ctx->_functionHandlers.contains(funcName)) {
-				debugPrintf("%s\n", lingo->formatFunctionBody(ctx->_functionHandlers[funcName]).c_str());
-				return true;
-			}
-		}
-		Cast *sharedCast = movie->getSharedCast();
-		if (sharedCast && sharedCast->_lingoArchive) {
-			ScriptContext *ctx = sharedCast->_lingoArchive->findScriptContext(scriptId);
-			if (ctx && ctx->_functionHandlers.contains(funcName)) {
-				debugPrintf("%s\n", lingo->formatFunctionBody(ctx->_functionHandlers[funcName]).c_str());
-				return true;
+		Cast *targets[2] = {movie->getCast(), movie->getSharedCast()};
+
+		for (int i = 0; i < 2; i++) {
+			Cast *cast = targets[i];
+			if (cast && cast->_lingoArchive) {
+				ScriptContext *ctx = cast->_lingoArchive->findScriptContext(scriptId);
+				if (ctx && ctx->_functionHandlers.contains(funcName)) {
+					debugPrintf("%s\n", lingo->formatFunctionBody(ctx->_functionHandlers[funcName]).c_str());
+					return true;
+				}
+				if (cast->_lingoArchive->factoryContexts.contains(scriptId)) {
+					for (auto &it : *cast->_lingoArchive->factoryContexts.getVal(scriptId)) {
+						Common::String prefix = Common::String::format("%s:", it._key.c_str());
+						if (funcName.hasPrefixIgnoreCase(prefix)) {
+							Common::String handler = funcName.substr(prefix.size());
+							if (it._value->_functionHandlers.contains(handler)) {
+								debugPrintf("%s\n", lingo->formatFunctionBody(it._value->_functionHandlers[handler]).c_str());
+								return true;
+							}
+						}
+					}
+				}
 			}
 		}
-
 	} else {
 		Common::Array<CFrame *> &callstack = g_lingo->_state->callstack;
 		if (callstack.size() == 0) {
@@ -1037,7 +1011,13 @@ void Debugger::bpUpdateState() {
 				continue;
 			if (!head->sp.ctx)
 				continue;
-			if (it.funcName.equalsIgnoreCase(*head->sp.name)) {
+			// check for a straight function name match
+			bool nameTest = it.funcName.equalsIgnoreCase(*head->sp.name);
+			if (head->sp.ctx->isFactory()) {
+				// for factories, check for a "FactoryName:funcName" match
+				nameTest |= it.funcName.equalsIgnoreCase(Common::String::format("%s:%s", head->sp.ctx->getName().c_str(), head->sp.name->c_str()));
+			}
+			if (nameTest) {
 				if (it.scriptId) {
 					if (it.scriptId == head->sp.ctx->_id) {
 						_bpMatchScriptId = head->sp.ctx->_id;
diff --git a/engines/director/lingo/lingo.cpp b/engines/director/lingo/lingo.cpp
index 376d2905803..41ac52eda3d 100644
--- a/engines/director/lingo/lingo.cpp
+++ b/engines/director/lingo/lingo.cpp
@@ -413,6 +413,9 @@ Common::String Lingo::formatCallStack(uint pc) {
 			if (frame->sp.ctx && frame->sp.ctx->_id) {
 				result += Common::String::format("%d:", frame->sp.ctx->_id);
 			}
+			if (frame->sp.ctx && frame->sp.ctx->isFactory()) {
+				result += Common::String::format("%s:", frame->sp.ctx->getName().c_str());
+			}
 			result += Common::String::format("%s at [%5d]\n",
 				frame->sp.name->c_str(),
 				framePc
@@ -439,6 +442,9 @@ Common::String Lingo::formatFrame() {
 	if (_state->context->_id)
 		result += Common::String::format("%d:", _state->context->_id);
 	CFrame *frame = callstack[callstack.size() - 1];
+	if (frame->sp.ctx && frame->sp.ctx->isFactory()) {
+		result += Common::String::format("%s:", frame->sp.ctx->getName().c_str());
+	}
 	if (frame->sp.type == VOIDSYM || !frame->sp.name)
 		result += "[unknown]";
 	else


Commit: 490cc0aeb9df2997ea9d1fdf3ec65c3347c9159a
    https://github.com/scummvm/scummvm/commit/490cc0aeb9df2997ea9d1fdf3ec65c3347c9159a
Author: Scott Percival (code at moral.net.au)
Date: 2023-10-22T17:19:54+02:00

Commit Message:
DIRECTOR: Add more debug output to preprocessor

Changed paths:
    engines/director/lingo/lingo-preprocessor.cpp


diff --git a/engines/director/lingo/lingo-preprocessor.cpp b/engines/director/lingo/lingo-preprocessor.cpp
index 0f07d238121..f5dfa0572d5 100644
--- a/engines/director/lingo/lingo-preprocessor.cpp
+++ b/engines/director/lingo/lingo-preprocessor.cpp
@@ -19,9 +19,12 @@
  *
  */
 
+#include "common/debug.h"
 #include "director/director.h"
+#include "director/cast.h"
 #include "director/movie.h"
 #include "director/lingo/lingo-codegen.h"
+#include "director/types.h"
 
 namespace Director {
 
@@ -65,6 +68,12 @@ static Common::U32String nexttok(const Common::u32char_type_t *s, const Common::
 Common::U32String LingoCompiler::codePreprocessor(const Common::U32String &code, LingoArchive *archive, ScriptType type, CastMemberID id, uint32 flags) {
 	const Common::u32char_type_t *s = code.c_str();
 	Common::U32String res;
+	if (debugChannelSet(2, kDebugParse | kDebugPreprocess)) {
+		Common::String movie = g_director->getCurrentPath();
+		if (archive)
+			movie += archive->cast->getMacName();
+		debugC(2, kDebugParse | kDebugPreprocess, "LingoCompiler::codePreprocessor: \"%s\", %s, %d, %d", movie.c_str(),  scriptType2str(type), id.member, id.castLib);
+	}
 
 	// We start from processing the continuation symbols
 	// (The continuation symbol is \xC2 in Mac Roman, \xAC in Unicode.)
@@ -193,7 +202,7 @@ Common::U32String LingoCompiler::codePreprocessor(const Common::U32String &code,
 				continuationCount++;
 			}
 		}
-		debugC(2, kDebugParse | kDebugPreprocess, "line: '%s'", line.encode().c_str());
+		debugC(2, kDebugParse | kDebugPreprocess, "line %d: '%s'", linenumber, line.encode().c_str());
 
 		if (!defFound && (type == kMovieScript || type == kCastScript) && (g_director->getVersion() < 400 || g_director->getCurrentMovie()->_allowOutdatedLingo)) {
 			tok = nexttok(line.c_str());


Commit: b1a180739e6f5a55786df8483c0372e9f27f3974
    https://github.com/scummvm/scummvm/commit/b1a180739e6f5a55786df8483c0372e9f27f3974
Author: Scott Percival (code at moral.net.au)
Date: 2023-10-22T17:19:54+02:00

Commit Message:
DIRECTOR: Add patch to fix boar hunt in Wrath of the Gods

Changed paths:
    engines/director/lingo/lingo-patcher.cpp


diff --git a/engines/director/lingo/lingo-patcher.cpp b/engines/director/lingo/lingo-patcher.cpp
index 74012a9af4d..7e597a9f448 100644
--- a/engines/director/lingo/lingo-patcher.cpp
+++ b/engines/director/lingo/lingo-patcher.cpp
@@ -205,6 +205,12 @@ struct ScriptPatch {
 	{"smile", "v1.1", kPlatformMacintosh, "SMILE! The Splattering", kScoreScript, 24, DEFAULT_CAST_LIB,
 			1, "go to frame \"Info b\"If you have not paid   ", "go to frame \"Info b\""},
 
+	// Hack to fix the undefined sprite collision behaviour relied on by the boar hunt
+	{"wrath", "", kPlatformWindows, "57AM1", kMovieScript, 1, DEFAULT_CAST_LIB,
+			385, "(StartV57a-6) <=  YesV57a", "    if sprite 5 intersects 3 and StartV57a <=  YesV57a + 16 then"},
+	{"wrath", "", kPlatformMacintosh, "Wrath:57AM1", kMovieScript, 1, DEFAULT_CAST_LIB,
+			382, "(StartV57a-6) <=  YesV57a", "    if sprite 5 intersects 3 and StartV57a <=  YesV57a + 16 then"},
+
 
 	{"amandastories", "", kPlatformWindows, "Shared Cast", kMovieScript, 512, DEFAULT_CAST_LIB,
 			55, "    set mytest1 = FileIO(mnew, \"read\" mymovie)", "    set mytest1 = FileIO(mnew, \"read\", mymovie)"},


Commit: e9ba46db1b89475f811370f0a5cd206647cf126e
    https://github.com/scummvm/scummvm/commit/e9ba46db1b89475f811370f0a5cd206647cf126e
Author: Scott Percival (code at moral.net.au)
Date: 2023-10-22T17:19:54+02:00

Commit Message:
DIRECTOR: Add kTheVideoForWindowsPresent

Changed paths:
    engines/director/lingo/lingo-the.cpp
    engines/director/lingo/lingo-the.h


diff --git a/engines/director/lingo/lingo-the.cpp b/engines/director/lingo/lingo-the.cpp
index 6719a432c99..09363e2f373 100644
--- a/engines/director/lingo/lingo-the.cpp
+++ b/engines/director/lingo/lingo-the.cpp
@@ -157,6 +157,7 @@ TheEntity entities[] = {
 	{ kTheTraceLoad,		"traceLoad",		false, 400, false },	//			D4 p
 	{ kTheTraceLogFile,		"traceLogFile",		false, 400, false },	//			D4 p
 	{ kTheUpdateMovieEnabled,"updateMovieEnabled",false,400, false },//			D4 p
+	{ kTheVideoForWindowsPresent,	"videoForWindowsPresent",	false, 400, true },	//		D4 f
 	{ kTheWindow,			"window",			true,  400, false },	//			D4
 	{ kTheWindowList,		"windowList",		false, 400, false },	//			D4 p
 	{ kTheNOEntity, nullptr, false, 0, false }
@@ -746,7 +747,7 @@ Datum Lingo::getTheEntity(int entity, Datum &id, int field) {
 		d = M_PI;
 		break;
 	case kTheQuickTimePresent:
-		// QuickTime is always present for scummvm
+		// QuickTime is always present for ScummVM
 		d = 1;
 		break;
 	case kTheRandomSeed:
@@ -890,6 +891,10 @@ Datum Lingo::getTheEntity(int entity, Datum &id, int field) {
 	case kTheUpdateMovieEnabled:
 		d = g_lingo->_updateMovieEnabled;
 		break;
+	case kTheVideoForWindowsPresent:
+		// Video For Windows is always present for ScummVM
+		d = 1;
+		break;
 	case kTheWindow:
 		g_lingo->push(id);
 		LB::b_window(1);
diff --git a/engines/director/lingo/lingo-the.h b/engines/director/lingo/lingo-the.h
index 70f2beea68d..70e9162a6ec 100644
--- a/engines/director/lingo/lingo-the.h
+++ b/engines/director/lingo/lingo-the.h
@@ -144,6 +144,7 @@ enum TheEntityType {
 	kTheTraceLoad,
 	kTheTraceLogFile,
 	kTheUpdateMovieEnabled,
+	kTheVideoForWindowsPresent,
 	kTheWindow,
 	kTheWindowList,
 	kTheWords,


Commit: e44f40318e2f88fefe0fc2795181951656be8ed1
    https://github.com/scummvm/scummvm/commit/e44f40318e2f88fefe0fc2795181951656be8ed1
Author: Scott Percival (code at moral.net.au)
Date: 2023-10-22T17:19:54+02:00

Commit Message:
GRAPHICS: MACGUI: Fix MacText::getMouseWord()/getMouseItem()

Fixes the text entry puzzles in Wrath of the Gods.

Changed paths:
    graphics/macgui/mactext.cpp


diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index 314c49e1c38..57adb0a5bc9 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -2226,12 +2226,28 @@ int MacText::getMouseWord(int x, int y) {
 	int dx, dy, row, col;
 	getRowCol(x, y, &dx, &dy, &row, &col);
 
-	int index = 0;
+	int index = 1;
+	bool inWhitespace = true;
+	// getMouseWord:
+	// - starts from index 1
+	// - a word goes from the first leading whitespace character
+	//   up until the end of the word
+	// - trailing whitespace or empty space at the end of a line
+	//   counts as part of the word on the next line
+	// - empty space at the end of the text counts as a word
 	for (int i = 0; i < row; i++) {
 		for (uint j = 0; j < _canvas._text[i].chunks.size(); j++) {
 			if (_canvas._text[i].chunks[j].text.empty())
 				continue;
-			index++;
+			Common::String data = _canvas._text[i].chunks[j].getEncodedText();
+			for (auto it : data) {
+				if (it == ' ' && !inWhitespace) {
+					index++;
+					inWhitespace = true;
+				} else if (it != ' ' && inWhitespace) {
+					inWhitespace = false;
+				}
+			}
 		}
 	}
 
@@ -2239,16 +2255,23 @@ int MacText::getMouseWord(int x, int y) {
 	for (uint j = 0; j < _canvas._text[row].chunks.size(); j++) {
 		if (_canvas._text[row].chunks[j].text.empty())
 			continue;
-		cur += _canvas._text[row].chunks[j].text.size();
-		// Avoid overflowing the word index if we run out of line;
-		// it should count as part of the last chunk
-		if ((cur <= col) && (j < _canvas._text[row].chunks.size() - 1))
-			index++;
-		else
+		Common::String data = _canvas._text[row].chunks[j].getEncodedText();
+		for (auto it : data) {
+			cur++;
+			if (it == ' ' && !inWhitespace) {
+				index++;
+				inWhitespace = true;
+			} else if (it != ' ' && inWhitespace) {
+				inWhitespace = false;
+			}
+			if (cur > col)
+				break;
+		}
+		if (cur > col)
 			break;
 	}
 
-	return index + 1;
+	return index;
 }
 
 int MacText::getMouseItem(int x, int y) {
@@ -2260,13 +2283,28 @@ int MacText::getMouseItem(int x, int y) {
 	int dx, dy, row, col;
 	getRowCol(x, y, &dx, &dy, &row, &col);
 
-	int index = 0;
+	// getMouseItem
+	// - starts from index 1
+	// - an item goes from the first non-comma character up until a comma
+	// - trailing whitespace or empty space at the end of a line
+	//   counts as part of the item on the next line
+	// - empty space at the end of the text counts as an item
+	int index = 1;
+	bool onComma = false;
 	for (int i = 0; i < row; i++) {
 		for (uint j = 0; j < _canvas._text[i].chunks.size(); j++) {
 			if (_canvas._text[i].chunks[j].text.empty())
 				continue;
-			if (_canvas._text[i].chunks[j].getEncodedText().contains(','))
-				index++;
+			Common::String data = _canvas._text[i].chunks[j].getEncodedText();
+			for (auto it : data) {
+				if (onComma) {
+					index += 1;
+					onComma = false;
+				}
+				if (it == ',') {
+					onComma = true;
+				}
+			}
 		}
 	}
 
@@ -2274,20 +2312,24 @@ int MacText::getMouseItem(int x, int y) {
 	for (uint i = 0; i < _canvas._text[row].chunks.size(); i++) {
 		if (_canvas._text[row].chunks[i].text.empty())
 			continue;
-
-		for (uint j = 0; j < _canvas._text[row].chunks[i].text.size(); j++) {
+		Common::String data = _canvas._text[row].chunks[i].getEncodedText();
+		for (auto it : data) {
+			if (onComma) {
+				index += 1;
+				onComma = false;
+			}
+			if (it == ',') {
+				onComma = true;
+			}
 			cur++;
 			if (cur > col)
 				break;
-			if (_canvas._text[row].chunks[i].text[j] == ',')
-				index++;
 		}
-
 		if (cur > col)
 			break;
 	}
 
-	return index + 1;
+	return index;
 }
 
 int MacText::getMouseLine(int x, int y) {


Commit: 3a3db20267ebc262bb49a9c7a64278787adf24ee
    https://github.com/scummvm/scummvm/commit/3a3db20267ebc262bb49a9c7a64278787adf24ee
Author: Scott Percival (code at moral.net.au)
Date: 2023-10-22T17:19:54+02:00

Commit Message:
DIRECTOR: Mark Wrath of the Gods as supported

Changed paths:
    engines/director/detection_tables.h


diff --git a/engines/director/detection_tables.h b/engines/director/detection_tables.h
index f5929a6166d..9b91925a0a2 100644
--- a/engines/director/detection_tables.h
+++ b/engines/director/detection_tables.h
@@ -1973,6 +1973,14 @@ static const DirectorGameDescription gameDescriptions[] = {
 
 	MACGAME1_l("timegal", "", "TimeGal", "f5277c53bacd27936158dd3867e587e2", 392230, Common::JA_JPN, 311),
 
+	MACGAME1("wrath", "", "Wrath of the Gods", "2ce360c9ea2da80a2c6d1040b0ad92dd", 413730, 300),
+	WINGAME2("wrath", "", "000WRATH.EXE", "3162423a1d0885eb1eb94f557a86b258", 372970,
+						  "SHARDCST.MMM", "22af72fba773cc5313d99c91b2e5aea9", 3432948, 300),
+	WINGAME2("wrath", "", "000WRATH.EXE", "3162423a1d0885eb1eb94f557a86b258", 372970,
+						  "SHARDCST.MMM", "35b0a9fa9cc4ed5088d665848c5258dc", 3432878, 300),
+	WINDEMO2("wrath", "Demo", "000WRATH.EXE", "3162423a1d0885eb1eb94f557a86b258", 372970,
+							  "SHARDCST.MMM", "85d166abe18730d96e9d4137c66255a1", 3553330, 300),
+
 //////////////////////////////////////////////////
 //
 // Macromedia Director v4
@@ -3101,14 +3109,6 @@ static const DirectorGameDescription gameDescriptions[] = {
 
 	WINDEMO1("wpmainstreet", "", "WPMAINST.EXE", "65d06b5fef155a2473434571aff5bc29", 370000, 300),
 
-	MACGAME1("wrath", "", "Wrath of the Gods", "2ce360c9ea2da80a2c6d1040b0ad92dd", 413730, 300),
-	WINGAME2("wrath", "", "000WRATH.EXE", "3162423a1d0885eb1eb94f557a86b258", 372970,
-						  "SHARDCST.MMM", "22af72fba773cc5313d99c91b2e5aea9", 3432948, 300),
-	WINGAME2("wrath", "", "000WRATH.EXE", "3162423a1d0885eb1eb94f557a86b258", 372970,
-						  "SHARDCST.MMM", "35b0a9fa9cc4ed5088d665848c5258dc", 3432878, 300),
-	WINDEMO2("wrath", "Demo", "000WRATH.EXE", "3162423a1d0885eb1eb94f557a86b258", 372970,
-							  "SHARDCST.MMM", "85d166abe18730d96e9d4137c66255a1", 3553330, 300),
-
 	MACDEMO1("wriggle", "Demo", "'93 Wriggle Demo", "9f0bb7ec7720e4f680ee3aa3d22c1c9d", 353737, 300),
 
 	MACGAME1("wti", "", "WTI Projector", "1ae45c23586b41997ba52e2e7c771c4c", 3715229, 310),




More information about the Scummvm-git-logs mailing list