[Scummvm-git-logs] scummvm master -> 5409c087cdd0b66527b84adb6b4f09241f15f886

tnm23 noreply at scummvm.org
Sun Oct 5 18:16:58 UTC 2025


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

Summary:
5409c087cd ZVISION: Add extra script processing cycles upon a location change.


Commit: 5409c087cdd0b66527b84adb6b4f09241f15f886
    https://github.com/scummvm/scummvm/commit/5409c087cdd0b66527b84adb6b4f09241f15f886
Author: Thomas N McEwan (46427621+tnm23 at users.noreply.github.com)
Date: 2025-10-05T19:13:23+01:00

Commit Message:
ZVISION: Add extra script processing cycles upon a location change.
Amend code so each extra such cycle no longer uses up a render frame.

Changed paths:
    engines/zvision/scripting/script_manager.cpp
    engines/zvision/scripting/script_manager.h


diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp
index f84d9a0d26e..b40f9ff39d7 100644
--- a/engines/zvision/scripting/script_manager.cpp
+++ b/engines/zvision/scripting/script_manager.cpp
@@ -63,8 +63,6 @@ void ScriptManager::initialize(bool restarted) {
 	_currentLocation.world = 0;
 	_currentLocation.room = 0;
 	_currentLocation.view = 0;
-
-	_changeLocationDelayCycles = 0;
 	if (restarted) {
 		for (auto &fx : _activeSideFx)
 			delete fx;
@@ -98,31 +96,29 @@ bool ScriptManager::changingLocation() const {
 }
 
 void ScriptManager::process(uint deltaTimeMillis) {
-	if (changingLocation()) {
-		// The location is changing. The script that did that may have
-		// triggered other scripts, so give them all one extra cycle to
-		// run. This fixes some missing scoring in ZGI, and quite
-		// possibly other minor glitches as well.
-		//
-		// Another idea would be to change if there are pending scripts
-		// in the exec queues, but that could cause this to hang
-		// indefinitely.
-		// TODO - this causes noticeable pauses on location change; see if these can be reduced by improving this functionality.
-		if (_changeLocationDelayCycles-- <= 0)
-			ChangeLocationReal(false);
-	}
-
-	updateNodes(deltaTimeMillis);
-	debugC(5, kDebugLoop, "Script nodes updated");
-	if (!execScope(_nodeview))
-		return;
-	if (!execScope(_room))
-		return;
-	if (!execScope(_world))
-		return;
-	if (!execScope(_universe))
-		return;
+	// If the location is changing, the script that did that may have
+	// triggered other scripts, so we give them all a few extra cycles to
+	// run. This fixes some missing scoring in ZGI, and quite
+	// possibly other minor glitches as well.
+	//
+	// Another idea would be to change if there are pending scripts
+	// in the exec queues, but that could cause this to hang
+	// indefinitely.
+	for (uint8 pass = 0; pass <= changingLocation() ? _changeLocationExtraCycles : 0; pass++) {
+		updateNodes(pass == 0 ? deltaTimeMillis : 0);
+		debugC(5, kDebugLoop, "Script nodes updated");
+		if (!execScope(_nodeview))
+			break;
+		if (!execScope(_room))
+			break;
+		if (!execScope(_world))
+			break;
+		if (!execScope(_universe))
+			break;
+	}
 	updateControls(deltaTimeMillis);
+	if (changingLocation())
+		ChangeLocationReal(false);
 }
 
 bool ScriptManager::execScope(ScriptScope &scope) {
@@ -565,8 +561,6 @@ void ScriptManager::changeLocation(const Location &_newLocation) {
 
 void ScriptManager::changeLocation(char world, char room, char node, char view, uint32 offset) {
 	debugC(1, kDebugScript, "\tPreparing to change location");
-	_changeLocationDelayCycles = 1;
-
 	_nextLocation.world = world;
 	_nextLocation.room = room;
 	_nextLocation.node = node;
diff --git a/engines/zvision/scripting/script_manager.h b/engines/zvision/scripting/script_manager.h
index fba3ca490b1..baa664f91dd 100644
--- a/engines/zvision/scripting/script_manager.h
+++ b/engines/zvision/scripting/script_manager.h
@@ -192,7 +192,7 @@ private:
 
 	Location _currentLocation;
 	Location _nextLocation;
-	int _changeLocationDelayCycles;
+	const uint8 _changeLocationExtraCycles = 16;
 
 	uint32 _currentlyFocusedControl;
 




More information about the Scummvm-git-logs mailing list