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

sev- noreply at scummvm.org
Sat Apr 8 10:31:40 UTC 2023


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:
e866ba2fc0 DIRECTOR: Properly search for previous screenshots, support for the first run


Commit: e866ba2fc0d597fd2fc0be0b8c3e05a6b2a5aa3a
    https://github.com/scummvm/scummvm/commit/e866ba2fc0d597fd2fc0be0b8c3e05a6b2a5aa3a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-04-08T12:31:08+02:00

Commit Message:
DIRECTOR: Properly search for previous screenshots, support for the first run

Changed paths:
    engines/director/score.cpp
    engines/director/score.h


diff --git a/engines/director/score.cpp b/engines/director/score.cpp
index abe778c5f2c..adf362092d8 100644
--- a/engines/director/score.cpp
+++ b/engines/director/score.cpp
@@ -1083,7 +1083,6 @@ void Score::screenShot() {
 		return;
 #else
 
-
 	Graphics::Surface rawSurface = _window->getSurface()->rawSurface();
 	const Graphics::PixelFormat requiredFormat_4byte(4, 8, 8, 8, 8, 0, 8, 16, 24);
 	Graphics::Surface *newSurface = rawSurface.convertTo(requiredFormat_4byte, _vm->getPalette());
@@ -1100,21 +1099,42 @@ void Score::screenShot() {
 		// The filename is in the form:
 		// ./dumps/theapartment/25/xn--Main Menu-zd0e-19.png
 
-		// Now we try to find any previous dump
-		int prevbuild = atoi(buildNumber) - 1;
+		int prevbuild;
 
-		while (prevbuild > 0) {
-			filename = Common::String::format("%s/%s/%d/%s-%d.png", ConfMan.get("screenshotpath").c_str(),
-				g_director->getTargetName().c_str(), prevbuild, prefix.c_str(), g_director->_framesRan);
+		Common::String buildDir = Common::String::format("%s/%s", ConfMan.get("screenshotpath").c_str(),
+			g_director->getTargetName().c_str());
 
-			Common::FSNode fs(filename);
+		// We run for the first time, let's find the previous build with screenshots
+		if (_previousBuildBotBuild == -1) {
+			Common::FSNode dir(buildDir);
 
-			if (fs.exists())
-				break;
+			// We check if the directory was previously created. If not, there is nothing to search for
+			if (!dir.exists())
+				prevbuild = 0;
+			else
+				prevbuild = atoi(buildNumber) - 1;
+
+			// Now we try to find any previous dump
+			while (prevbuild > 0) {
+				filename = Common::String::format("%s/%d/%s-%d.png", buildDir.c_str(), prevbuild, prefix.c_str(), g_director->_framesRan);
+
+				// We are running for the first time, we got the filename, so quit
+				if (!dir.exists())
+					break;
 
-			prevbuild--;
+				Common::FSNode fs(filename);
+
+				if (fs.exists())
+					break;
+
+				prevbuild--;
+			}
+		} else {
+			prevbuild = _previousBuildBotBuild;
 		}
 
+		_previousBuildBotBuild = prevbuild;
+
 		// We found previous screenshot. Let's compare it
 		if (prevbuild > 0) {
 			Common::FSNode fs(filename);
@@ -1139,6 +1159,9 @@ void Score::screenShot() {
 
 			delete stream;
 		}
+
+		// Regenerate file name with the correct build number
+		filename = Common::String::format("%s/%s/%s-%d.png", buildDir.c_str(), buildNumber, prefix.c_str(), g_director->_framesRan);
 	}
 
 	Common::DumpFile screenshotFile;
diff --git a/engines/director/score.h b/engines/director/score.h
index 94cc3b951ce..28b556fcd45 100644
--- a/engines/director/score.h
+++ b/engines/director/score.h
@@ -173,6 +173,8 @@ private:
 	int _currentLabel;
 	DirectorSound *_soundManager;
 	int _currentPalette;
+
+	int _previousBuildBotBuild = -1;
 };
 
 } // End of namespace Director




More information about the Scummvm-git-logs mailing list