[Scummvm-git-logs] scummvm master -> 9eb56873b427db17acfc71bb4d170e969064dbd9

bluegr noreply at scummvm.org
Sat Jul 19 19:24:12 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:
9eb56873b4 NANCY: Add handling for multiple "I can't" texts for Nancy9 and newer


Commit: 9eb56873b427db17acfc71bb4d170e969064dbd9
    https://github.com/scummvm/scummvm/commit/9eb56873b427db17acfc71bb4d170e969064dbd9
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-07-19T22:23:23+03:00

Commit Message:
NANCY: Add handling for multiple "I can't" texts for Nancy9 and newer

Changed paths:
    engines/nancy/enginedata.cpp
    engines/nancy/enginedata.h
    engines/nancy/state/scene.cpp


diff --git a/engines/nancy/enginedata.cpp b/engines/nancy/enginedata.cpp
index c6b523f2d60..8aa89b4420c 100644
--- a/engines/nancy/enginedata.cpp
+++ b/engines/nancy/enginedata.cpp
@@ -205,19 +205,15 @@ INV::INV(Common::SeekableReadStream *chunkStream) : EngineData(chunkStream) {
 
 			item.cantSound.readNormal(*chunkStream);
 		} else if (s.getVersion() >= kGameTypeNancy9) {
-			s.syncBytes(textBuf, 60);
-			textBuf[59] = '\0';
-			assembleTextLine((char *)textBuf, item.cantText, 60);
-
-			// TODO: The "I can't do that" sound format has changed,
-			// so only override the sound name, to avoid reading junk
-			// into the SoundDescription members.
-			// item.cantSound.readNormal(*chunkStream);
-			SoundDescription tmp;
-			tmp.readNormal(*chunkStream);
-			item.cantSound.name = tmp.name;
+			for (int j = 0; j < 3; ++j) {
+				s.syncBytes(textBuf, 60);
+				textBuf[59] = '\0';
+				assembleTextLine((char *)textBuf, item.cantTexts[j], 60);
+				readFilename(s, item.cantSounds[j].name);
+			}
 
-			s.skip(170);	// TODO: Handle this data properly
+			item.cantText = item.cantTexts[0]; // Default text is the first one
+			item.cantSound.name = item.cantSounds[0].name;
 		}
 	}
 }
diff --git a/engines/nancy/enginedata.h b/engines/nancy/enginedata.h
index 6e401197cb8..cc6bfcc733f 100644
--- a/engines/nancy/enginedata.h
+++ b/engines/nancy/enginedata.h
@@ -116,8 +116,10 @@ struct INV : public EngineData {
 
 		Common::String cantText;
 		Common::String cantTextNotHolding; // nancy2 only
+		Common::String cantTexts[3];       // Nancy9 and newer
 		SoundDescription cantSound;
 		SoundDescription cantSoundNotHolding; // nancy2 only
+		SoundDescription cantSounds[3];       // Nancy9 and newer
 	};
 
 	INV(Common::SeekableReadStream *chunkStream);
diff --git a/engines/nancy/state/scene.cpp b/engines/nancy/state/scene.cpp
index bfd8be50047..0a17e7fb671 100644
--- a/engines/nancy/state/scene.cpp
+++ b/engines/nancy/state/scene.cpp
@@ -22,6 +22,7 @@
 #include "common/serializer.h"
 #include "common/config-manager.h"
 #include "common/func.h"
+#include "common/random.h"
 
 #include "engines/nancy/nancy.h"
 #include "engines/nancy/iff.h"
@@ -481,11 +482,23 @@ void Scene::playItemCantSound(int16 itemID, bool notHoldingSound) {
 
 		if (item.cantSound.name.size()) {
 			// The inventory data contains a custom "can't" sound for this item
-			g_nancy->_sound->loadSound(item.cantSound);
-			g_nancy->_sound->playSound(item.cantSound);
+			SoundDescription cantSound = item.cantSound;
+			Common::String cantText = item.cantText;
+
+			// For Nancy9 and newer, we have multiple sounds to choose from,
+			// so randomly select one, if available
+			if (g_nancy->getGameType() >= kGameTypeNancy9 && !item.cantSounds[1].name.empty()) {
+				const uint maxSound = item.cantSounds[2].name.empty() ? 1 : 2;
+				uint soundIndex = g_nancy->_randomSource->getRandomNumber(maxSound);
+				cantSound = item.cantSounds[soundIndex];
+				cantText = item.cantTexts[soundIndex];
+			}
+
+			g_nancy->_sound->loadSound(cantSound);
+			g_nancy->_sound->playSound(cantSound);
 
 			if (ConfMan.getBool("subtitles")) {
-				_textbox.addTextLine(item.cantText, inventoryData->captionAutoClearTime);
+				_textbox.addTextLine(cantText, inventoryData->captionAutoClearTime);
 			}
 		} else if (inventoryData->cantSound.name.size()) {
 			// No custom sound, play default "can't" inside inventory data. Should (?) be unreachable




More information about the Scummvm-git-logs mailing list