[Scummvm-git-logs] scummvm master -> 815011941f2c1f148c22e2bcbe20b7b04fe756b8

sev- noreply at scummvm.org
Wed Jul 26 00:45:54 UTC 2023


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

Summary:
d9be4daa4f DIRECTOR: Allow anonymous function to access instance
b53c5871ce DIRECTOR: LINGO: Added test for `do` inside object
815011941f DIRECTOR: Fix memory leaks while loading exe


Commit: d9be4daa4f94af4c62f68ba7a27637cc53288d3c
    https://github.com/scummvm/scummvm/commit/d9be4daa4f94af4c62f68ba7a27637cc53288d3c
Author: Harishankar Kumar (hari01584 at gmail.com)
Date: 2023-07-26T02:45:49+02:00

Commit Message:
DIRECTOR: Allow anonymous function to access instance

Anonymous functions are allowed to access the instance variables
that are in scope, just like localVariables. This patch restores the
original behavior by not resetting `_state->_me` when a context is
pushed that belongs to anonymous function while it is being called
from object, ie `kFactoryObj | kScriptObj`. Commands like
`do("set instanceVar = 1")` and `do("set abc = instanceVar")`
will now work.

Fixes food maker in food bar where up/down buttons were not working.

--start-movie="ATD\HD\cfTWR4FO.DXR" totaldistortion-win

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


diff --git a/engines/director/lingo/lingo-code.cpp b/engines/director/lingo/lingo-code.cpp
index d4bef99f910..5e30d424255 100644
--- a/engines/director/lingo/lingo-code.cpp
+++ b/engines/director/lingo/lingo-code.cpp
@@ -247,7 +247,11 @@ void Lingo::pushContext(const Symbol funcSym, bool allowRetVal, Datum defaultRet
 
 	_state->script = funcSym.u.defn;
 
-	_state->me = funcSym.target;
+	// Do not set the context for anonymous functions that are called from factory
+	// ie something like b_do(), which is called from mNew() should have access to instance
+	// variables, thus it is in same context as the caller.
+	if (!(funcSym.anonymous && _state->me.type == OBJECT && _state->me.u.obj->getObjType() & (kFactoryObj | kScriptObj)))
+		_state->me = funcSym.target;
 
 	if (funcSym.ctx) {
 		_state->context = funcSym.ctx;


Commit: b53c5871ce8edd0973f243daa01ba924117bdf09
    https://github.com/scummvm/scummvm/commit/b53c5871ce8edd0973f243daa01ba924117bdf09
Author: Harishankar Kumar (hari01584 at gmail.com)
Date: 2023-07-26T02:45:49+02:00

Commit Message:
DIRECTOR: LINGO: Added test for `do` inside object

Changed paths:
  A engines/director/lingo/tests/factory-do.lingo


diff --git a/engines/director/lingo/tests/factory-do.lingo b/engines/director/lingo/tests/factory-do.lingo
new file mode 100644
index 00000000000..676b6161f8d
--- /dev/null
+++ b/engines/director/lingo/tests/factory-do.lingo
@@ -0,0 +1,18 @@
+abc(mNew)
+
+factory abc
+method mNew
+    instance avar
+    set avar to "a variable"
+    set res1 = me(callDo)
+    scummvmAssertEqual(res1, "a variable")
+    me(setDo)
+    scummvmAssertEqual(avar, 100)
+    
+method callDo
+    set myvar = 0
+    do("set myvar = avar")
+    return myvar
+
+method setDo
+    do("set avar = 100")


Commit: 815011941f2c1f148c22e2bcbe20b7b04fe756b8
    https://github.com/scummvm/scummvm/commit/815011941f2c1f148c22e2bcbe20b7b04fe756b8
Author: Harishankar Kumar (hari01584 at gmail.com)
Date: 2023-07-26T02:45:49+02:00

Commit Message:
DIRECTOR: Fix memory leaks while loading exe

This patch fixes memory leaks associated with loading exe files,
in the cases where archive cannot be loaded up from exe, exeStream
is deleted.

Changed paths:
    engines/director/resource.cpp


diff --git a/engines/director/resource.cpp b/engines/director/resource.cpp
index d040da44496..6cba68db3de 100644
--- a/engines/director/resource.cpp
+++ b/engines/director/resource.cpp
@@ -332,6 +332,9 @@ Archive *DirectorEngine::loadEXE(const Common::Path &movie) {
 
 		if (result)
 			result->setPathName(movie.toString(g_director->_dirSeparator));
+		else {
+			delete exeStream;
+		}
 
 		return result;
 	}




More information about the Scummvm-git-logs mailing list