[Scummvm-git-logs] scummvm master -> dbdbb179c32ce5c85fa9181fb51809d429ec4aa1

sev- noreply at scummvm.org
Sun Jul 7 20:11:09 UTC 2024


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

Summary:
079e86c3d5 DIRECTOR: LINGO: Fix behaviour of c_procret
97f0c94a17 DIRECTOR: Add nikolaipharaohs to detection table
6cf9272bbf DIRECTOR: XOBJ: Add modded version of MoveMouse from Jungle Park
e96bdca165 DIRECTOR: Persist sprite dimensions when _stretched flag is set
b7d55c157d DIRECTOR: XOBJ: Have FileIO XObject return error codes from constructor
23a6f49e74 DIRECTOR: LINGO: Lists WIP
4d438a808d DIRECTOR: LINGO: Track all arguments to a function, even unnamed
2f6dac578d IMGUI: Fix memory allocator mismatch
dbdbb179c3 DIRECTOR: Unset ImGui callback if debug flag is not set


Commit: 079e86c3d58aafc3f00938be46220c1898b528d1
    https://github.com/scummvm/scummvm/commit/079e86c3d58aafc3f00938be46220c1898b528d1
Author: Scott Percival (code at moral.net.au)
Date: 2024-07-07T22:11:03+02:00

Commit Message:
DIRECTOR: LINGO: Fix behaviour of c_procret

c_procret is equivalent to the "exit" command in Lingo, and must
clear any new stack items. The proper way to return values is with
b_return.

Fixes start sequence in Gus Goes to CyberStone Park.

Changed paths:
    engines/director/lingo/lingo-builtins.cpp
    engines/director/lingo/lingo-code.cpp
    engines/director/lingo/lingo-code.h


diff --git a/engines/director/lingo/lingo-builtins.cpp b/engines/director/lingo/lingo-builtins.cpp
index d930aa21d90..fb8ff5740e6 100644
--- a/engines/director/lingo/lingo-builtins.cpp
+++ b/engines/director/lingo/lingo-builtins.cpp
@@ -1870,7 +1870,7 @@ void LB::b_return(int nargs) {
 		g_lingo->push(retVal);
 	}
 
-	LC::c_procret();
+	LC::procret();
 }
 
 void LB::b_restart(int nargs) {
diff --git a/engines/director/lingo/lingo-code.cpp b/engines/director/lingo/lingo-code.cpp
index 470f4789c7f..ffdaf61b0f5 100644
--- a/engines/director/lingo/lingo-code.cpp
+++ b/engines/director/lingo/lingo-code.cpp
@@ -1775,6 +1775,25 @@ void LC::call(const Symbol &funcSym, int nargs, bool allowRetVal) {
 }
 
 void LC::c_procret() {
+	// Equivalent of Lingo's "exit" command.
+	// If we hit this instruction, wipe whatever new is on the Lingo stack,
+	// as we could e.g. be in a loop.
+	// Returning a value must be done by calling LB::b_return().
+	Common::Array<CFrame *> &callstack = g_lingo->_state->callstack;
+	CFrame *fp = callstack.back();
+	int extra = g_lingo->_stack.size() - fp->stackSizeBefore;
+	if (extra > 0) {
+		debugC(5, kDebugLingoExec, "c_procret: dropping %d items", extra);
+		g_lingo->dropStack(extra);
+	} else if (extra < 0) {
+		error("c_procret: handler %s has a stack delta size of %d", fp->sp.name->c_str(), extra);
+	}
+
+	procret();
+}
+
+void LC::procret() {
+	// Lingo stack must be empty or have one value
 	Common::Array<CFrame *> &callstack = g_lingo->_state->callstack;
 
 	if (callstack.size() == 0) {
@@ -1792,6 +1811,7 @@ void LC::c_procret() {
 	}
 }
 
+
 void LC::c_delete() {
 	Datum d = g_lingo->pop();
 
diff --git a/engines/director/lingo/lingo-code.h b/engines/director/lingo/lingo-code.h
index 54390a51e9f..30779047fdf 100644
--- a/engines/director/lingo/lingo-code.h
+++ b/engines/director/lingo/lingo-code.h
@@ -127,6 +127,7 @@ void call(const Symbol &targetSym, int nargs, bool allowRetVal);
 void call(const Common::String &name, int nargs, bool allowRetVal);
 
 void c_procret();
+void procret();
 
 void c_mci();
 void c_mciwait();


Commit: 97f0c94a172b793b02918c13ae7e32abb23f2606
    https://github.com/scummvm/scummvm/commit/97f0c94a172b793b02918c13ae7e32abb23f2606
Author: Scott Percival (code at moral.net.au)
Date: 2024-07-07T22:11:03+02:00

Commit Message:
DIRECTOR: Add nikolaipharaohs to detection table

Changed paths:
    engines/director/detection_tables.h


diff --git a/engines/director/detection_tables.h b/engines/director/detection_tables.h
index 021b9b3753e..8a38bf3dea6 100644
--- a/engines/director/detection_tables.h
+++ b/engines/director/detection_tables.h
@@ -345,6 +345,7 @@ static const PlainGameDescriptor directorGames[] = {
 	{ "nightlight",			"Night Light" },
 	{ "nikolaiknights",		"Nikolai in Time: In the Time of the Knights" },
 	{ "nikolaimystery",		"Nikolai's Mysteries: The Mystery of the Black Windows" },
+	{ "nikolaipharaohs",	"Nikolai's Pharaohs" },
 	{ "nikolaipirates",		"Nikolai's Pirates" },
 	{ "nikolaispace",		"Nikolai in Outer Space" },
 	{ "nikolaispaceedu",	"Nikolai Space Education" },
@@ -4260,9 +4261,9 @@ static const DirectorGameDescription gameDescriptions[] = {
 	MACDEMO1("gusolis", "Demo", "Cyberopolis DEMO", "r:77f4098988d5386794d1530065f514cd", 303961, 404),
 
 	MACGAME1("guspark", "",		"Gus goes to CyberStone Park", "r:ccfbfc1a0ac231db40a250babaa6ad7c", 285282, 404),
-	MACGAME1("guspark", "",		"Gus goes to CyberStone Park", "r:ccfbfc1a0ac231db40a250babaa6ad7c", 288490, 404),
+	MACGAME1("guspark", "",		"Gus goes to CyberStone Park", "tr:6cb8084d74e94d6f04f619ee9b423a06", 288490, 404),
 	WINGAME1("guspark", "",		"PCINST/CYBSTONE.EXE", "d:ac22c7568c90ab4af7396148521f446e", 707439, 404),
-	WINGAME2("guspark", "",		"CYBSTONE.EXE",		   "d:dc0be57ab8e9f9b54de24ac41b1b4854", 703913,
+	WINGAME2("guspark", "",		"PCINST/CYBSTONE.EXE", "t:296e7735cc8fbf8d2fb6046cef88ee4c", 703913,
 								"CONTENT/INTRO.DIR",   "d:05fbf807ea9b766a12c2c08483cc6fa7", 1082406, 404),
 	WINGAME2_l("guspark", "",	"CYBSTONE.EXE",		   "d:dc0be57ab8e9f9b54de24ac41b1b4854", 703913,
 								"CONTENT/INTRO.DIR",   "d:fb97a887ac99dcb5a1a78520cc00c7d9", 1092858, Common::PT_BRA, 404),
@@ -6758,10 +6759,15 @@ static const DirectorGameDescription gameDescriptions[] = {
 	// All original Mac filenames end with â„¢
 	// Nikolai in Outer Space did not get a Mac release
 	MACGAME1("nikolaiknights", "v2.0", "Nikolai's Knights",   "c43bfadda9be111e461dc0b735430ad3", 720690, 501),
+	WINGAME1("nikolaiknights", "v2.0", "KNIGHT95.EXE",         "1a7acbba10a7246ba58c1d53fc7203f5", 1410541, 501),
+
 	MACGAME1("nikolaimystery", "",     "Nikolai's Mysteries", "c43bfadda9be111e461dc0b735430ad3", 719241, 501),
+
+	WINGAME1("nikolaipharaohs", "",    "PHAR95.EXE",           "t:97e3ec47de3b06d8349d34c2016cc528", 1407221, 501),
+
 	MACGAME1("nikolaipirates", "",     "Nikolai's Pirates",   "c43bfadda9be111e461dc0b735430ad3", 719289, 501),
-	WINGAME1("nikolaiknights", "v2.0", "KNIGHT95.EXE",         "1a7acbba10a7246ba58c1d53fc7203f5", 1410541, 501),
 	WINGAME1("nikolaipirates", "",     "PIRATE95.EXE",         "3460ad87d2ba57104e2810a77b53c220", 1394017, 500),
+
 	WINGAME1("nikolaispace", "",       "0_LAUNCH.EXE",         "3460ad87d2ba57104e2810a77b53c220", 1394291, 501),
 
 	// spaceedu module can also be launched externally


Commit: 6cf9272bbf0cb9d20f0f86f1f2a75f088928b7e6
    https://github.com/scummvm/scummvm/commit/6cf9272bbf0cb9d20f0f86f1f2a75f088928b7e6
Author: Scott Percival (code at moral.net.au)
Date: 2024-07-07T22:11:03+02:00

Commit Message:
DIRECTOR: XOBJ: Add modded version of MoveMouse from Jungle Park

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


diff --git a/engines/director/lingo/lingo-object.cpp b/engines/director/lingo/lingo-object.cpp
index ecdd2fe0fdb..70eee59f8c5 100644
--- a/engines/director/lingo/lingo-object.cpp
+++ b/engines/director/lingo/lingo-object.cpp
@@ -89,6 +89,7 @@
 #include "director/lingo/xlibs/mmaskxobj.h"
 #include "director/lingo/xlibs/mmovie.h"
 #include "director/lingo/xlibs/moovxobj.h"
+#include "director/lingo/xlibs/movemousejp.h"
 #include "director/lingo/xlibs/movemousexobj.h"
 #include "director/lingo/xlibs/movieidxxobj.h"
 #include "director/lingo/xlibs/movutils.h"
@@ -268,6 +269,7 @@ static struct XLibProto {
 	XLIBDEF(MMaskXObj,			kXObj,			400),	// D4
 	XLIBDEF(MoovXObj,			kXObj,			300),	// D3
 	XLIBDEF(MovUtilsXObj,		kXObj,			400),	// D4
+	XLIBDEF(MoveMouseJPXObj,			kXObj,					400),	// D4
 	XLIBDEF(MoveMouseXObj,		kXObj,			400),	// D4
 	XLIBDEF(MovieIdxXObj,		kXObj,			400),	// D4
 	XLIBDEF(MovUtilsXObj,		kXObj,			400),	// D4
diff --git a/engines/director/lingo/xlibs/movemousejp.cpp b/engines/director/lingo/xlibs/movemousejp.cpp
new file mode 100644
index 00000000000..d178333dad1
--- /dev/null
+++ b/engines/director/lingo/xlibs/movemousejp.cpp
@@ -0,0 +1,143 @@
+/* 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/movemousejp.h"
+
+/**************************************************
+ *
+ * USED IN:
+ * junglepark
+ *
+ **************************************************/
+
+/*
+-- MoveMouse . Implimented by @Sakai Youichi
+--MoveMouse
+I      mNew                --Creates a new instance of the XObject
+X      mDispose            --Disposes of XObject instance
+S      mName               --Returns the XObject name (Widget)
+I      mStatus             --Returns an integer status code
+SI     mError, code        --Returns an error string
+S      mLastError          --Returns last error string
+III    mAdd, arg1, arg2    --Returns arg1+arg2
+SSI    mFirst, str, nchars --Return the first nchars of string str
+V      mMul, f1, f2        --Returns f1*f2 as floating point
+X      mGlobals            --Sample code to Read & Modify globals
+X      mSymbols            --Sample code to work with Symbols
+X      mSendPerform        --Sample code to show SendPerform call
+X      mFactory            --Sample code to find Factory objects
+III    mSetMouseLoc,h,v    --Sample code to find Factory objects
+I      mWtop               --Sample code to find Factory objects
+I      mWbottom            --Sample code to find Factory objects
+I      mWleft              --Sample code to find Factory objects
+I      mWright             --Sample code to find Factory objects
+I      mCtop               --Sample code to find Factory objects
+I      mCbottom            --Sample code to find Factory objects
+I      mCleft              --Sample code to find Factory objects
+I      mCright             --Sample code to find Factory objects
+S      mGetWindowsDir      --GetWindows Directory
+ */
+
+namespace Director {
+
+const char *MoveMouseJPXObj::xlibName = "MoveMouse";
+const XlibFileDesc MoveMouseJPXObj::fileNames[] = {
+	{ "MOVEWIN",   "junglepark" },
+	{ "MOVEMOUSE",   "junglepark" },
+	{ nullptr,        nullptr },
+};
+
+static MethodProto xlibMethods[] = {
+	{ "new",				MoveMouseJPXObj::m_new,		 0, 0,	400 },
+	{ "dispose",				MoveMouseJPXObj::m_dispose,		 0, 0,	400 },
+	{ "setMouseLoc",				MoveMouseJPXObj::m_setMouseLoc,		 2, 2,	400 },
+	{ "wtop",				MoveMouseJPXObj::m_wtop,		 0, 0,	400 },
+	{ "wbottom",				MoveMouseJPXObj::m_wbottom,		 0, 0,	400 },
+	{ "wleft",				MoveMouseJPXObj::m_wleft,		 0, 0,	400 },
+	{ "wright",				MoveMouseJPXObj::m_wright,		 0, 0,	400 },
+	{ "ctop",				MoveMouseJPXObj::m_ctop,		 0, 0,	400 },
+	{ "cbottom",				MoveMouseJPXObj::m_cbottom,		 0, 0,	400 },
+	{ "cleft",				MoveMouseJPXObj::m_cleft,		 0, 0,	400 },
+	{ "cright",				MoveMouseJPXObj::m_cright,		 0, 0,	400 },
+	{ "getWindowsDir",				MoveMouseJPXObj::m_getWindowsDir,		 0, 0,	400 },
+	{ nullptr, nullptr, 0, 0, 0 }
+};
+
+static BuiltinProto xlibBuiltins[] = {
+
+	{ nullptr, nullptr, 0, 0, 0, VOIDSYM }
+};
+
+MoveMouseJPXObject::MoveMouseJPXObject(ObjectType ObjectType) :Object<MoveMouseJPXObject>("MoveMouse") {
+	_objType = ObjectType;
+}
+
+void MoveMouseJPXObj::open(ObjectType type, const Common::Path &path) {
+    MoveMouseJPXObject::initMethods(xlibMethods);
+    MoveMouseJPXObject *xobj = new MoveMouseJPXObject(type);
+    if (type == kXtraObj)
+        g_lingo->_openXtras.push_back(xlibName);
+    g_lingo->exposeXObject(xlibName, xobj);
+    g_lingo->initBuiltIns(xlibBuiltins);
+}
+
+void MoveMouseJPXObj::close(ObjectType type) {
+    MoveMouseJPXObject::cleanupMethods();
+    g_lingo->_globalvars[xlibName] = Datum();
+
+}
+
+void MoveMouseJPXObj::m_new(int nargs) {
+	g_lingo->printSTUBWithArglist("MoveMouseJPXObj::m_new", nargs);
+	g_lingo->dropStack(nargs);
+	g_lingo->push(g_lingo->_state->me);
+}
+
+XOBJSTUBNR(MoveMouseJPXObj::m_dispose)
+
+void MoveMouseJPXObj::m_setMouseLoc(int nargs) {
+	if (nargs != 2) {
+		warning("MoveMouseJPXObj::m_setMouseLoc: expected 2 arguments");
+		g_lingo->dropStack(nargs);
+		return;
+	}
+	int y = g_lingo->pop().asInt();
+	int x = g_lingo->pop().asInt();
+	g_system->warpMouse(x, y);
+}
+
+XOBJSTUB(MoveMouseJPXObj::m_wtop, 0)
+XOBJSTUB(MoveMouseJPXObj::m_wbottom, 0)
+XOBJSTUB(MoveMouseJPXObj::m_wleft, 0)
+XOBJSTUB(MoveMouseJPXObj::m_wright, 0)
+XOBJSTUB(MoveMouseJPXObj::m_ctop, 0)
+XOBJSTUB(MoveMouseJPXObj::m_cbottom, 0)
+XOBJSTUB(MoveMouseJPXObj::m_cleft, 0)
+XOBJSTUB(MoveMouseJPXObj::m_cright, 0)
+XOBJSTUB(MoveMouseJPXObj::m_getWindowsDir, "")
+
+}
diff --git a/engines/director/lingo/xlibs/movemousejp.h b/engines/director/lingo/xlibs/movemousejp.h
new file mode 100644
index 00000000000..89424c4cc7e
--- /dev/null
+++ b/engines/director/lingo/xlibs/movemousejp.h
@@ -0,0 +1,57 @@
+/* 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_MOVEMOUSEJP_H
+#define DIRECTOR_LINGO_XLIBS_MOVEMOUSEJP_H
+
+namespace Director {
+
+class MoveMouseJPXObject : public Object<MoveMouseJPXObject> {
+public:
+	MoveMouseJPXObject(ObjectType objType);
+};
+
+namespace MoveMouseJPXObj {
+
+extern const char *xlibName;
+extern const XlibFileDesc fileNames[];
+
+void open(ObjectType type, const Common::Path &path);
+void close(ObjectType type);
+
+void m_new(int nargs);
+void m_dispose(int nargs);
+void m_setMouseLoc(int nargs);
+void m_wtop(int nargs);
+void m_wbottom(int nargs);
+void m_wleft(int nargs);
+void m_wright(int nargs);
+void m_ctop(int nargs);
+void m_cbottom(int nargs);
+void m_cleft(int nargs);
+void m_cright(int nargs);
+void m_getWindowsDir(int nargs);
+
+} // End of namespace MoveMouseJPXObj
+
+} // End of namespace Director
+
+#endif
diff --git a/engines/director/module.mk b/engines/director/module.mk
index 494771c5732..f8445e85cde 100644
--- a/engines/director/module.mk
+++ b/engines/director/module.mk
@@ -118,6 +118,7 @@ MODULE_OBJS = \
 	lingo/xlibs/mmaskxobj.o \
 	lingo/xlibs/mmovie.o \
 	lingo/xlibs/moovxobj.o \
+	lingo/xlibs/movemousejp.o \
 	lingo/xlibs/movemousexobj.o \
 	lingo/xlibs/movieidxxobj.o \
 	lingo/xlibs/movutils.o \


Commit: e96bdca165ad605a41c57dfb47332ee83abbc599
    https://github.com/scummvm/scummvm/commit/e96bdca165ad605a41c57dfb47332ee83abbc599
Author: Scott Percival (code at moral.net.au)
Date: 2024-07-07T22:11:03+02:00

Commit Message:
DIRECTOR: Persist sprite dimensions when _stretched flag is set

Fixes most of the character and diorama animations in Jungle Park.

Changed paths:
    engines/director/channel.cpp


diff --git a/engines/director/channel.cpp b/engines/director/channel.cpp
index f859ae0072f..f37f2c9e90f 100644
--- a/engines/director/channel.cpp
+++ b/engines/director/channel.cpp
@@ -386,7 +386,13 @@ void Channel::setCast(CastMemberID memberID) {
 	if (_sprite->_cast)
 		_sprite->_cast->releaseWidget();
 
-	_sprite->setCast(memberID);
+	// Replace the cast member in the sprite.
+	// Only change the dimensions if the "stretch" flag is set,
+	// indicating that the sprite has already been warped away from cast
+	// dimensions. In puppet mode Lingo can first change the
+	// dimensions of the sprite, -then- change the cast ID, and expect
+	// those custom dimensions to stick around.
+	_sprite->setCast(memberID, !_sprite->_stretch);
 	replaceWidget();
 
 	// Based on Director in a Nutshell, page 15


Commit: b7d55c157dc886885744ba158860c254e94bd083
    https://github.com/scummvm/scummvm/commit/b7d55c157dc886885744ba158860c254e94bd083
Author: Scott Percival (code at moral.net.au)
Date: 2024-07-07T22:11:03+02:00

Commit Message:
DIRECTOR: XOBJ: Have FileIO XObject return error codes from constructor

Fixes crash when loading the config file for Jungle Park.

Changed paths:
    engines/director/lingo/xlibs/fileio.cpp


diff --git a/engines/director/lingo/xlibs/fileio.cpp b/engines/director/lingo/xlibs/fileio.cpp
index 2eb2db6aab4..92d67cfbd90 100644
--- a/engines/director/lingo/xlibs/fileio.cpp
+++ b/engines/director/lingo/xlibs/fileio.cpp
@@ -341,18 +341,33 @@ FileIOError FileObject::saveFileError() {
 
 void FileIO::m_new(int nargs) {
 	FileObject *me = static_cast<FileObject *>(g_lingo->_state->me.u.obj);
+	Datum result = g_lingo->_state->me;
 	if (nargs == 2) {
+		if (me->getObjType() != kXObj) {
+			warning("FileIO::m_new: called with XObject API however was expecting object type %d", me->getObjType());
+		}
 		Datum d2 = g_lingo->pop();
 		Datum d1 = g_lingo->pop();
 
 		Common::String option = d1.asString();
 		Common::String path = d2.asString();
-		FileIOError result = me->open(path, option);
-		if (result != kErrorNone) {
-			me->_lastError = result;
+		FileIOError err = me->open(path, option);
+		// if there's an error, return an errorcode int instead of an object
+		if (err != kErrorNone) {
+			me->_lastError = err;
+			warning("FileIO::m_new: couldn't open file at path %s, error %d", path.c_str(), err);
+			g_lingo->push(Datum(err));
+			return;
+		}
+	} else if (nargs == 0) {
+		if (me->getObjType() != kXtraObj) {
+			warning("FileIO::m_new: called with Xtra API however was expecting object type %d", me->getObjType());
 		}
+	} else {
+		warning("FileIO::m_new: expected 0 or 2 args, assuming 0");
+		g_lingo->dropStack(nargs);
 	}
-	g_lingo->push(g_lingo->_state->me);
+	g_lingo->push(result);
 }
 
 void FileIO::m_openFile(int nargs) {


Commit: 23a6f49e74e3e354d35392822ad6dcd90c7a2eef
    https://github.com/scummvm/scummvm/commit/23a6f49e74e3e354d35392822ad6dcd90c7a2eef
Author: Scott Percival (code at moral.net.au)
Date: 2024-07-07T22:11:03+02:00

Commit Message:
DIRECTOR: LINGO: Lists WIP

Changed paths:
    engines/director/lingo/lingo-code.cpp
    engines/director/lingo/tests/lists.lingo


diff --git a/engines/director/lingo/lingo-code.cpp b/engines/director/lingo/lingo-code.cpp
index ffdaf61b0f5..a8de4b189fe 100644
--- a/engines/director/lingo/lingo-code.cpp
+++ b/engines/director/lingo/lingo-code.cpp
@@ -687,26 +687,47 @@ static DatumType getArrayAlignedType(Datum &d1, Datum &d2) {
 Datum LC::mapBinaryOp(Datum (*mapFunc)(Datum &, Datum &), Datum &d1, Datum &d2) {
 	// At least one of d1 and d2 must be an array
 	uint arraySize;
+
 	if (d1.isArray() && d2.isArray()) {
 		arraySize = MIN(d1.u.farr->arr.size(), d2.u.farr->arr.size());
-	} else if (d1.isArray()) {
+	} else if (d1.type == PARRAY && d2.type == PARRAY) {
+		arraySize = MIN(d1.u.parr->arr.size(), d2.u.parr->arr.size());
+	// if d1 and d2 are different arrays, result is [x+d2 for x in d1], with type of d1
+	} else if (d1.isArray() && d2.type == PARRAY) {
 		arraySize = d1.u.farr->arr.size();
+	} else if (d1.type == PARRAY && d2.isArray()) {
+		arraySize = d1.u.parr->arr.size();
+	} else if (d1.isArray() || d1.type == PARRAY) {
+		arraySize = d1.type == PARRAY ? d1.u.parr->arr.size() : d1.u.farr->arr.size();
 	} else {
-		arraySize = d2.u.farr->arr.size();
+		arraySize = d2.type == PARRAY ? d2.u.parr->arr.size() : d2.u.farr->arr.size();
 	}
 	Datum res;
-	res.type = getArrayAlignedType(d1, d2);
-	res.u.farr = new FArray(arraySize);
+	if (d1.type == PARRAY) {
+		res.type = PARRAY;
+		res.u.parr = new PArray(arraySize);
+	} else {
+		res.type = getArrayAlignedType(d1, d2);
+		res.u.farr = new FArray(arraySize);
+	}
 	Datum a = d1;
 	Datum b = d2;
 	for (uint i = 0; i < arraySize; i++) {
 		if (d1.isArray()) {
 			a = d1.u.farr->arr[i];
+		} else if (d1.type == PARRAY) {
+			a = d1.u.parr->arr[i].v;
 		}
 		if (d2.isArray()) {
 			b = d2.u.farr->arr[i];
+		} else if (d2.type == PARRAY) {
+			a = d2.u.parr->arr[i].v;
+		}
+		if (res.type == PARRAY) {
+			res.u.parr->arr[i] = PCell(d1.u.parr->arr[i].p, mapFunc(a, b));
+		} else {
+			res.u.farr->arr[i] = mapFunc(a, b);
 		}
-		res.u.farr->arr[i] = mapFunc(a, b);
 	}
 	return res;
 }
@@ -717,7 +738,7 @@ Datum LC::addData(Datum &d1, Datum &d2) {
 		return Datum(0);
 	}
 
-	if (d1.isArray() || d2.isArray()) {
+	if (d1.isArray() || d2.isArray() || d1.type == PARRAY || d2.type == PARRAY) {
 		return LC::mapBinaryOp(LC::addData, d1, d2);
 	}
 
@@ -746,7 +767,7 @@ Datum LC::subData(Datum &d1, Datum &d2) {
 		return Datum(0);
 	}
 
-	if (d1.isArray() || d2.isArray()) {
+	if (d1.isArray() || d2.isArray() || d1.type == PARRAY || d2.type == PARRAY) {
 		return LC::mapBinaryOp(LC::subData, d1, d2);
 	}
 
@@ -775,7 +796,7 @@ Datum LC::mulData(Datum &d1, Datum &d2) {
 		return Datum(0);
 	}
 
-	if (d1.isArray() || d2.isArray()) {
+	if (d1.isArray() || d2.isArray() || d1.type == PARRAY || d2.type == PARRAY) {
 		return LC::mapBinaryOp(LC::mulData, d1, d2);
 	}
 
@@ -804,7 +825,7 @@ Datum LC::divData(Datum &d1, Datum &d2) {
 		return Datum(0);
 	}
 
-	if (d1.isArray() || d2.isArray()) {
+	if (d1.isArray() || d2.isArray() || d1.type == PARRAY || d2.type == PARRAY) {
 		return LC::mapBinaryOp(LC::divData, d1, d2);
 	}
 
diff --git a/engines/director/lingo/tests/lists.lingo b/engines/director/lingo/tests/lists.lingo
index 473adb5526f..abad9c1a9ed 100644
--- a/engines/director/lingo/tests/lists.lingo
+++ b/engines/director/lingo/tests/lists.lingo
@@ -12,40 +12,20 @@ set gList = [point(70, 190), point(217, 66), point(364, 185)]
 set gBugList = [[energy: 10, mood: "Happy"], [energy: -10, mood: "Sad"], [energy: 60, mood: "Hungry"], [energy: 20, mood: "Sad"]]
 
 set b to [4, 5, 6, 7]
-set res to a + b
-set res to a - b
-set res to a * b
-set res to b / a
-set res to b mod a
-set res to -a
+scummvmAssertEqual(string(a + b), "[5, 7, 9]")
+scummvmAssertEqual(string(a - b), "[3, 3, 3]")
+scummvmAssertEqual(string(a * b), "[4, 10, 18]")
+scummvmAssertEqual(string(b / a), "[4, 2, 2]")
+scummvmAssertEqual(string(b mod a), "[0, 1, 0]")
+scummvmAssertEqual(string(-a), "[-1, -2, -3]")
 
 set floats to [4.0, 5.0, 6.0, 7.0]
 set strings to ["4", "5", "6", "7"]
 
-set res to a + floats
-set res to a + strings
-set res to a + 1
-set res to 1 + b
-
-set res to a = a
-set res to a = b
-set res to a < b
-
-set a to [0, 0]
-set b to [0]
-set res to a = b
-set res to a >= b
-set res to b = a
-set res to b >= a
-set b to [1]
-set res to a = b
-set res to a <> b
-
-set a to [#a:6, #b:3, #c:8, #d:5]
-set res to a = machinery
-set res to a >= machinery
-set res to machinery = a
-set res to machinery >= a
+scummvmAssertEqual(a + floats, [5.0, 7.0, 9.0])
+scummvmAssertEqual(a + strings, [5.0, 7.0, 9.0])
+scummvmAssertEqual(string(a + 1), "[2, 3, 4]")
+scummvmAssertEqual(string(1 + b), "[5, 6, 7, 8]")
 
 -- property Array tests
 set propArray to [501: "cast", 502: "value", 1.5: "script", a: "score", #b: "member", "color": "red"]


Commit: 4d438a808d8b88ae42bea6d90f0407f433f465ef
    https://github.com/scummvm/scummvm/commit/4d438a808d8b88ae42bea6d90f0407f433f465ef
Author: Scott Percival (code at moral.net.au)
Date: 2024-07-07T22:11:03+02:00

Commit Message:
DIRECTOR: LINGO: Track all arguments to a function, even unnamed

Fixes the collision detection in Jungle Park.

Changed paths:
    engines/director/lingo/lingo-builtins.cpp
    engines/director/lingo/lingo-code.cpp
    engines/director/lingo/lingo.h


diff --git a/engines/director/lingo/lingo-builtins.cpp b/engines/director/lingo/lingo-builtins.cpp
index fb8ff5740e6..0c7b0aaa437 100644
--- a/engines/director/lingo/lingo-builtins.cpp
+++ b/engines/director/lingo/lingo-builtins.cpp
@@ -1827,10 +1827,16 @@ void LB::b_param(int nargs) {
 	int pos = g_lingo->pop().asInt();
 	Datum result;
 	CFrame *cf = g_lingo->_state->callstack[g_lingo->_state->callstack.size() - 1];
-	if (pos > 0 && cf->sp.argNames && (int)cf->sp.argNames->size() <= pos) {
+	// for named parameters, b_param must return what the current value is (i.e.
+	// if the handler has changed it, return that)
+	if (pos > 0 && cf->sp.argNames && pos <= (int)cf->sp.argNames->size()) {
 		Datum func((*cf->sp.argNames)[pos - 1]);
 		func.type = LOCALREF;
 		result = g_lingo->varFetch(func);
+	} else if (pos > 0 && pos <= (int)cf->paramList.size()) {
+		// otherwise, if a function was called with extra unnamed arguments,
+		// return that.
+		result = cf->paramList[pos - 1];
 	} else {
 		warning("Invalid argument position %d", pos);
 	}
diff --git a/engines/director/lingo/lingo-code.cpp b/engines/director/lingo/lingo-code.cpp
index a8de4b189fe..dc0d7bff3f7 100644
--- a/engines/director/lingo/lingo-code.cpp
+++ b/engines/director/lingo/lingo-code.cpp
@@ -241,6 +241,9 @@ void Lingo::pushContext(const Symbol funcSym, bool allowRetVal, Datum defaultRet
 	fp->allowRetVal = allowRetVal;
 	fp->defaultRetVal = defaultRetVal;
 	fp->paramCount = paramCount;
+	for (int i = 0; i < paramCount; i++) {
+		fp->paramList.insert_at(0, pop());
+	}
 
 	_state->script = funcSym.u.defn;
 
@@ -264,25 +267,20 @@ void Lingo::pushContext(const Symbol funcSym, bool allowRetVal, Datum defaultRet
 	}
 
 	if (funcSym.argNames) {
-		int symNArgs = funcSym.nargs;
-		if ((int)funcSym.argNames->size() < symNArgs) {
-			int dropSize = symNArgs - funcSym.argNames->size();
-			warning("%d arg names defined for %d args! Dropping the last %d values", funcSym.argNames->size(), symNArgs, dropSize);
-			for (int i = 0; i < dropSize; i++) {
-				pop();
-				symNArgs -= 1;
-			}
-		} else if ((int)funcSym.argNames->size() > symNArgs) {
-			warning("%d arg names defined for %d args! Ignoring the last %d names", funcSym.argNames->size(), symNArgs, funcSym.argNames->size() - symNArgs);
+		if ((int)funcSym.argNames->size() > fp->paramCount) {
+			warning("%d arg names defined for %d args! Ignoring the last %d names", funcSym.argNames->size(), fp->paramCount, funcSym.argNames->size() - fp->paramCount);
 		}
-		for (int i = symNArgs - 1; i >= 0; i--) {
+		for (int i = (int)funcSym.argNames->size() - 1; i >= 0; i--) {
 			Common::String name = (*funcSym.argNames)[i];
 			if (!localvars->contains(name)) {
-				Datum value = pop();
-				(*localvars)[name] = value;
+				if (i < fp->paramCount) {
+					Datum value = fp->paramList[i];
+					(*localvars)[name] = value;
+				} else {
+					(*localvars)[name] = Datum();
+				}
 			} else {
 				warning("Argument %s already defined", name.c_str());
-				pop();
 			}
 		}
 	}
@@ -1704,14 +1702,6 @@ void LC::call(const Symbol &funcSym, int nargs, bool allowRetVal) {
 		if (funcSym.type == HANDLER || funcSym.type == HBLTIN) {
 			// Lingo supports providing a different number of arguments than expected,
 			// and several games rely on this behaviour.
-			if (funcSym.maxArgs < nargs) {
-				debugC(kDebugLingoExec, 1, "Incorrect number of arguments for handler '%s' (%d, expected %d to %d). Dropping extra %d",
-							funcSym.name->c_str(), nargs, funcSym.nargs, funcSym.maxArgs, nargs - funcSym.maxArgs);
-				while (nargs > funcSym.maxArgs) {
-					g_lingo->pop();
-					nargs--;
-				}
-			}
 			if (funcSym.nargs > nargs) {
 				debugC(kDebugLingoExec, 1, "Incorrect number of arguments for handler '%s' (%d, expected %d to %d). Adding extra %d voids",
 							funcSym.name->c_str(), nargs, funcSym.nargs, funcSym.maxArgs, funcSym.nargs - nargs);
@@ -1721,6 +1711,7 @@ void LC::call(const Symbol &funcSym, int nargs, bool allowRetVal) {
 					d.type = VOID;
 					g_lingo->push(d);
 					nargs++;
+					paramCount++;
 				}
 			}
 		} else if (funcSym.nargs > nargs || funcSym.maxArgs < nargs) {
diff --git a/engines/director/lingo/lingo.h b/engines/director/lingo/lingo.h
index f28f4a6d578..4b56c20ce1f 100644
--- a/engines/director/lingo/lingo.h
+++ b/engines/director/lingo/lingo.h
@@ -257,6 +257,7 @@ struct CFrame {	/* proc/func call stack frame */
 	bool			allowRetVal;		/* whether to allow a return value */
 	Datum			defaultRetVal;		/* default return value */
 	int				paramCount;			/* original number of arguments submitted */
+	Common::Array<Datum> paramList;		/* original argument list */
 };
 
 struct LingoEvent {


Commit: 2f6dac578d3e71a99669e61c990078d7cd5224fa
    https://github.com/scummvm/scummvm/commit/2f6dac578d3e71a99669e61c990078d7cd5224fa
Author: Scott Percival (code at moral.net.au)
Date: 2024-07-07T22:11:03+02:00

Commit Message:
IMGUI: Fix memory allocator mismatch

Changed paths:
    backends/imgui/imgui_fonts.cpp


diff --git a/backends/imgui/imgui_fonts.cpp b/backends/imgui/imgui_fonts.cpp
index 5f3c6bf4cf1..d199ba95385 100644
--- a/backends/imgui/imgui_fonts.cpp
+++ b/backends/imgui/imgui_fonts.cpp
@@ -90,7 +90,7 @@ ImFont *addTTFFontFromArchive(const char *filename, float size_pixels, const ImF
 
 	uint size = f.size();
 
-	uint8 *ttfFile = new uint8[size];
+	uint8 *ttfFile = (uint8 *)ImGui::MemAlloc(size);
 	f.read(ttfFile, size);
 	ImGuiIO &io = ImGui::GetIO();
 	return io.Fonts->AddFontFromMemoryTTF(ttfFile, size, size_pixels, font_cfg_template, glyph_ranges);


Commit: dbdbb179c32ce5c85fa9181fb51809d429ec4aa1
    https://github.com/scummvm/scummvm/commit/dbdbb179c32ce5c85fa9181fb51809d429ec4aa1
Author: Scott Percival (code at moral.net.au)
Date: 2024-07-07T22:11:03+02:00

Commit Message:
DIRECTOR: Unset ImGui callback if debug flag is not set

For script/screen update intensive games, even calling ImgUi::NewFrame()
with an empty renderer callback has a massive performance penalty.

Changed paths:
    engines/director/director.cpp


diff --git a/engines/director/director.cpp b/engines/director/director.cpp
index 587a5cd26ca..97ed9d5fe27 100644
--- a/engines/director/director.cpp
+++ b/engines/director/director.cpp
@@ -291,8 +291,9 @@ Common::Error DirectorEngine::run() {
 
 #ifdef USE_IMGUI
 	ImGuiCallbacks callbacks;
+	bool drawImGui = debugChannelSet(-1, kDebugImGui);
 	callbacks.init = DT::onImGuiInit;
-	callbacks.render = DT::onImGuiRender;
+	callbacks.render = drawImGui ? DT::onImGuiRender : nullptr;
 	callbacks.cleanup = DT::onImGuiCleanup;
 	_system->setImGuiCallbacks(callbacks);
 #endif
@@ -321,6 +322,14 @@ Common::Error DirectorEngine::run() {
 
 		draw();
 		g_director->delayMillis(10);
+#ifdef USE_IMGUI
+		// For performance reasons, disable the renderer callback if the ImGui debug flag isn't set
+		if (debugChannelSet(-1, kDebugImGui) != drawImGui) {
+			drawImGui = !drawImGui;
+			callbacks.render = drawImGui ? DT::onImGuiRender : nullptr;
+			_system->setImGuiCallbacks(callbacks);
+		}
+#endif
 	}
 
 	return Common::kNoError;




More information about the Scummvm-git-logs mailing list