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

bluegr noreply at scummvm.org
Tue May 26 00:29:43 UTC 2026


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:
f0e10d0b57 NANCY: Implement differences in rotatinglockpuzzle for Nancy10+


Commit: f0e10d0b570e287e7ad7898c5bd4e5edba44f16f
    https://github.com/scummvm/scummvm/commit/f0e10d0b570e287e7ad7898c5bd4e5edba44f16f
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-05-26T03:29:31+03:00

Commit Message:
NANCY: Implement differences in rotatinglockpuzzle for Nancy10+

Changed paths:
    engines/nancy/action/puzzle/rotatinglockpuzzle.cpp
    engines/nancy/action/puzzle/rotatinglockpuzzle.h


diff --git a/engines/nancy/action/puzzle/rotatinglockpuzzle.cpp b/engines/nancy/action/puzzle/rotatinglockpuzzle.cpp
index 5265088fa2c..d8f9b4608c7 100644
--- a/engines/nancy/action/puzzle/rotatinglockpuzzle.cpp
+++ b/engines/nancy/action/puzzle/rotatinglockpuzzle.cpp
@@ -45,12 +45,17 @@ void RotatingLockPuzzle::init() {
 }
 
 void RotatingLockPuzzle::readData(Common::SeekableReadStream &stream) {
+	const bool isNancy10 = g_nancy->getGameType() >= kGameTypeNancy10;
+
 	readFilename(stream, _imageName);
 
 	uint numDials = stream.readUint16LE();
 
-	_srcRects.reserve(10);
-	for (uint i = 0; i < 10; ++i) {
+	_iconsPerDial = isNancy10 ? stream.readUint16LE() : 10;
+
+	const uint numSrcRects = isNancy10 ? 12 : 10;
+	_srcRects.reserve(numSrcRects);
+	for (uint i = 0; i < numSrcRects; ++i) {
 		_srcRects.push_back(Common::Rect());
 		readRect(stream, _srcRects.back());
 	}
@@ -90,18 +95,43 @@ void RotatingLockPuzzle::readData(Common::SeekableReadStream &stream) {
 		_correctSequence.push_back(stream.readByte());
 	}
 
-	stream.skip(8 - numDials);
+	const uint padding = isNancy10 ? 12 : 8;
+	stream.skip(padding - numDials);
 
 	_clickSound.readNormal(stream);
-	_solveExitScene.readData(stream);
-	_solveSoundDelay = stream.readUint16LE();
-	_solveSound.readNormal(stream);
 
-	_exitScene.readData(stream);
-	readRect(stream, _exitHotspot);
+	if (isNancy10) {
+		// Nancy 10 splits the old SceneChangeWithFlag (25 bytes with embedded
+		// flag) into a 20-byte SceneChangeDescription + 2-byte pause tail,
+		// with the event flag stored as a separate (label, value) pair.
+		_solveExitScene._sceneChange.readData(stream);
+		stream.skip(2);
+		_solveExitScene._flag.label = stream.readSint16LE();
+		_solveExitScene._flag.flag  = stream.readByte();
+
+		_solveSoundDelay = stream.readUint16LE();
+		_solveSound.readNormal(stream);
+
+		_exitScene._sceneChange.readData(stream);
+		stream.skip(2);
+		_exitScene._flag.label = stream.readSint16LE();
+		_exitScene._flag.flag  = stream.readByte();
+
+		readRect(stream, _exitHotspot);
+		// 16 trailing bytes (cursor type + unused) at offset 0x317 are ignored.
+	} else {
+		_solveExitScene.readData(stream);
+		_solveSoundDelay = stream.readUint16LE();
+		_solveSound.readNormal(stream);
+
+		_exitScene.readData(stream);
+		readRect(stream, _exitHotspot);
+	}
 }
 
 void RotatingLockPuzzle::execute() {
+	const bool isNancy10 = g_nancy->getGameType() >= kGameTypeNancy10;
+
 	switch (_state) {
 	case kBegin:
 		init();
@@ -110,7 +140,12 @@ void RotatingLockPuzzle::execute() {
 		NancySceneState.setNoHeldItem();
 
 		for (uint i = 0; i < _correctSequence.size(); ++i) {
-			_currentSequence.push_back(g_nancy->_randomSource->getRandomNumber(9));
+			byte v = g_nancy->_randomSource->getRandomNumber(_iconsPerDial - 1);
+			// Nancy 10 rerolls until the starting value differs from the
+			// solution so the puzzle never appears already-solved.
+			while (isNancy10 && v == _correctSequence[i])
+				v = g_nancy->_randomSource->getRandomNumber(_iconsPerDial - 1);
+			_currentSequence.push_back(v);
 			drawDial(i);
 		}
 
@@ -151,11 +186,10 @@ void RotatingLockPuzzle::execute() {
 		g_nancy->_sound->stopSound(_clickSound);
 		g_nancy->_sound->stopSound(_solveSound);
 
-		if (_solveState == kNotSolved) {
+		if (_solveState == kNotSolved)
 			_exitScene.execute();
-		} else {
+		else
 			NancySceneState.changeScene(_solveExitScene._sceneChange);
-		}
 
 		finishExecution();
 	}
@@ -183,7 +217,10 @@ void RotatingLockPuzzle::handleInput(NancyInput &input) {
 			if (!g_nancy->_sound->isSoundPlaying(_clickSound) && input.input & NancyInput::kLeftMouseButtonUp) {
 				g_nancy->_sound->playSound(_clickSound);
 
-				_currentSequence[i] = ++_currentSequence[i] > 9 ? 0 : _currentSequence[i];
+				int n = _currentSequence[i] + 1;
+				if (n >= (int)_iconsPerDial)
+					n = 0;
+				_currentSequence[i] = (byte)n;
 				drawDial(i);
 			}
 
@@ -198,9 +235,10 @@ void RotatingLockPuzzle::handleInput(NancyInput &input) {
 			if (!g_nancy->_sound->isSoundPlaying(_clickSound) && input.input & NancyInput::kLeftMouseButtonUp) {
 				g_nancy->_sound->playSound(_clickSound);
 
-				int8 n = _currentSequence[i];
-				n = --n < 0 ? 9 : n;
-				_currentSequence[i] = n;
+				int n = (int)_currentSequence[i] - 1;
+				if (n < 0)
+					n = (int)_iconsPerDial - 1;
+				_currentSequence[i] = (byte)n;
 				drawDial(i);
 			}
 
diff --git a/engines/nancy/action/puzzle/rotatinglockpuzzle.h b/engines/nancy/action/puzzle/rotatinglockpuzzle.h
index fa7e7e406fe..1e5f4402584 100644
--- a/engines/nancy/action/puzzle/rotatinglockpuzzle.h
+++ b/engines/nancy/action/puzzle/rotatinglockpuzzle.h
@@ -45,6 +45,7 @@ public:
 	Common::Array<Common::Rect> _upHotspots;
 	Common::Array<Common::Rect> _downHotspots;
 	Common::Array<byte> _correctSequence;
+	uint16 _iconsPerDial = 10;
 	SoundDescription _clickSound;
 	SceneChangeWithFlag _solveExitScene;
 	uint16 _solveSoundDelay = 0;




More information about the Scummvm-git-logs mailing list