[Scummvm-git-logs] scummvm master -> 0375a44f663ed2a3f362417ae40667dcda6cd491

aquadran noreply at scummvm.org
Sun Jan 16 07:33:12 UTC 2022


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:
0375a44f66 GRIM: LUA: Restore original callhooks


Commit: 0375a44f663ed2a3f362417ae40667dcda6cd491
    https://github.com/scummvm/scummvm/commit/0375a44f663ed2a3f362417ae40667dcda6cd491
Author: Paweł Kołodziejski (aquadran at gmail.com)
Date: 2022-01-16T08:33:08+01:00

Commit Message:
GRIM: LUA: Restore original callhooks

Changed paths:
    engines/grim/lua/ldo.cpp
    engines/grim/lua/lvm.cpp


diff --git a/engines/grim/lua/ldo.cpp b/engines/grim/lua/ldo.cpp
index e4fb4240528..ddaa459edad 100644
--- a/engines/grim/lua/ldo.cpp
+++ b/engines/grim/lua/ldo.cpp
@@ -137,15 +137,13 @@ static StkId callC(lua_CFunction f, StkId base) {
 	CS->num = numarg;
 	CS->lua2C = base;
 	CS->base = base + numarg;  // == top - stack
-	if (lua_callhook) {
-		TObject *r = lua_state->stack.stack + base - 1;
-		(*lua_callhook)(Ref(r), "(C)", -1);
-	}
+	if (lua_callhook)
+		luaD_callHook(base, nullptr, 0);
 	lua_state->callLevelCounter++;
 	(*f)();  // do the actual call
 	lua_state->callLevelCounter--;
-//	if (lua_callhook)  // func may have changed lua_callhook
-//		(*lua_callhook)(LUA_NOOBJECT, "(return)", 0);
+	if (lua_callhook)  // func may have changed lua_callhook
+		luaD_callHook(base, nullptr, 1);
 	firstResult = CS->base;
 	*CS = oldCLS;
 	return firstResult;
diff --git a/engines/grim/lua/lvm.cpp b/engines/grim/lua/lvm.cpp
index c73a50c5c6d..d0888fd0084 100644
--- a/engines/grim/lua/lvm.cpp
+++ b/engines/grim/lua/lvm.cpp
@@ -243,6 +243,8 @@ static void adjust_varargs(StkId first_extra_arg) {
 
 StkId luaV_execute(lua_Task *task) {
 	if (!task->executed) {
+		if (lua_callhook)
+			luaD_callHook(task->base, task->tf, 0);
 		luaD_checkstack((*task->pc++) + EXTRA_STACK);
 		if (*task->pc < ZEROVARARG) {
 			luaD_adjusttop(task->base + *(task->pc++));
@@ -660,6 +662,8 @@ callfunc:
 			task->S->top = task->S->stack + task->base;
 			// fall through
 		case RETCODE:
+			if (lua_callhook)
+				luaD_callHook(task->base, nullptr, 1);
 			lua_state->callLevelCounter--;
 			return (task->base + ((task->aux == RETCODE) ? *task->pc : 0));
 		case SETLINEW:




More information about the Scummvm-git-logs mailing list