[Scummvm-git-logs] scummvm master -> 95e6a9d678c8b95e215d172e90434decad233e5b

sev- noreply at scummvm.org
Tue Apr 5 23:02:40 UTC 2022


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

Summary:
07fd5bc8cd BASE: Fix include path and sorted alphabetically
726f187442 JANITORIAL: Fix code formatting
f5b9c2ef40 PRINCE: Remove leftover include
95e6a9d678 BASE: Added support for computing tail md5 for --md5 command line key.


Commit: 07fd5bc8cdd01d961190bedb280ccba0dc6b33be
    https://github.com/scummvm/scummvm/commit/07fd5bc8cdd01d961190bedb280ccba0dc6b33be
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2022-04-06T01:02:10+02:00

Commit Message:
BASE: Fix include path and sorted alphabetically

Changed paths:
    base/commandLine.cpp


diff --git a/base/commandLine.cpp b/base/commandLine.cpp
index 72973f8ab5e..911db8a1d6e 100644
--- a/base/commandLine.cpp
+++ b/base/commandLine.cpp
@@ -26,6 +26,7 @@
 
 #include <limits.h>
 
+#include "engines/advancedDetector.h"
 #include "engines/metaengine.h"
 #include "base/commandLine.h"
 #include "base/plugins.h"
@@ -45,7 +46,6 @@
 #include "audio/musicplugin.h"
 
 #include "graphics/renderer.h"
-#include "advancedDetector.h"
 
 #define DETECTOR_TESTING_HACK
 #define UPGRADE_ALL_TARGETS_HACK


Commit: 726f187442d66f97fbe96df7fcd8e1cffe039ae6
    https://github.com/scummvm/scummvm/commit/726f187442d66f97fbe96df7fcd8e1cffe039ae6
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2022-04-06T01:02:11+02:00

Commit Message:
JANITORIAL: Fix code formatting

Changed paths:
    base/commandLine.cpp
    engines/advancedDetector.h


diff --git a/base/commandLine.cpp b/base/commandLine.cpp
index 911db8a1d6e..b0cf9b56b76 100644
--- a/base/commandLine.cpp
+++ b/base/commandLine.cpp
@@ -1703,7 +1703,7 @@ bool processSettings(Common::String &command, Common::StringMap &settings, Commo
 					warning("This engine doesn't support MD5 based detection");
 					return true;
 				}
-				md5Length = (long int) advEnginePtr->getMD5Bytes();
+				md5Length = (long int)advEnginePtr->getMD5Bytes();
 			}
 		}
 
diff --git a/engines/advancedDetector.h b/engines/advancedDetector.h
index 963f0fe9163..95c7a259e9f 100644
--- a/engines/advancedDetector.h
+++ b/engines/advancedDetector.h
@@ -386,7 +386,7 @@ public:
 
 	static Common::StringArray getPathsFromEntry(const ADGameDescription *g);
 
-	uint getMD5Bytes() const {return _md5Bytes;}
+	uint getMD5Bytes() const { return _md5Bytes; }
 
 protected:
 	/**


Commit: f5b9c2ef406bd18fc903dbc3afa02bb370003f38
    https://github.com/scummvm/scummvm/commit/f5b9c2ef406bd18fc903dbc3afa02bb370003f38
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2022-04-06T01:02:11+02:00

Commit Message:
PRINCE: Remove leftover include

Changed paths:
    engines/prince/detection.cpp


diff --git a/engines/prince/detection.cpp b/engines/prince/detection.cpp
index 2cc2ad91cfa..2fe0993535a 100644
--- a/engines/prince/detection.cpp
+++ b/engines/prince/detection.cpp
@@ -19,7 +19,6 @@
  *
  */
 
-#include "common/translation.h"
 #include "engines/advancedDetector.h"
 
 #include "prince/detection.h"


Commit: 95e6a9d678c8b95e215d172e90434decad233e5b
    https://github.com/scummvm/scummvm/commit/95e6a9d678c8b95e215d172e90434decad233e5b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2022-04-06T01:02:11+02:00

Commit Message:
BASE: Added support for computing tail md5 for --md5 command line key.

Also fix non-portable data types.

Changed paths:
    base/commandLine.cpp


diff --git a/base/commandLine.cpp b/base/commandLine.cpp
index b0cf9b56b76..c1fe09b7ec9 100644
--- a/base/commandLine.cpp
+++ b/base/commandLine.cpp
@@ -215,7 +215,8 @@ static const char HELP_STRING[] =
     "                           If --md5-engine=ENGINE_ID is passed, it fetches the MD5 length\n"
     "                           automatically, overriding --md5-length\n"
 	"  --md5-path=PATH          Used with --md5 to specify path of file to calculate MD5 hash of\n"
-	"  --md5-length=NUM         Used with --md5 to specify the number of bytes to be hashed\n"
+	"  --md5-length=NUM         Used with --md5 to specify the number of bytes to be hashed.\n"
+	"                           Use negative number for calculating tail md5.\n"
     "                           Is overriden when used with --md5-engine\n"
     "  --md5-engine=ENGINE_ID   Used with --md5 to specify the engine for which number of bytes\n"
     "                           to be hashed must be calculated. This option overrides --md5-length\n"
@@ -1372,11 +1373,23 @@ static int recAddGames(const Common::FSNode &dir, const Common::String &engineId
 	return count;
 }
 
-static void calcMD5(Common::FSNode &path, long int length) {
+static void calcMD5(Common::FSNode &path, int32 length) {
 	Common::SeekableReadStream *stream = path.createReadStream();
+
 	if (stream) {
+		bool tail = false;
+
+		if (length < 0) {// Tail md5 is requested
+			length = -length;
+			tail = true;
+
+			if (stream->size() > length)
+				stream->seek(-length, SEEK_END);
+		}
+
 		Common::String md5 = Common::computeStreamMD5AsString(*stream, length);
-		printf("(hash) : %s, (filename) : %s, (bytes) : %d\n", md5.c_str(), path.getName().c_str(), length && length <= stream->size() ? (int32)length : (int32)stream->size());
+		printf("(hash) : %s, (filename) : %s, (bytes) : %d%s\n", md5.c_str(), path.getName().c_str(), length && length <= stream->size() ? (int32)length : (int32)stream->size(), tail ? ", tail" : "");
+
 		delete stream;
 	} else {
 		printf("Usage : --md5 --md5-path=<PATH> [--md5-length=NUM]\n");
@@ -1683,9 +1696,11 @@ bool processSettings(Common::String &command, Common::StringMap &settings, Commo
 		Common::String filename = settings.getValOrDefault("md5-path", "scummvm");
 		Common::Path Filename(filename, '/');
 		Common::FSNode path(Filename);
-		long int md5Length = 0;
+		int32 md5Length = 0;
+
 		if (settings.contains("md5-length"))
-			md5Length = settings["md5-length"].asUint64();
+			md5Length = strtol(settings["md5-length"].c_str(), nullptr, 10);
+
 		if (settings.contains("md5-engine")) {
 			Common::String engineID = settings["md5-engine"];
 			if (engineID == "scumm") {
@@ -1700,14 +1715,15 @@ bool processSettings(Common::String &command, Common::StringMap &settings, Commo
 
 				const AdvancedMetaEngineDetection* advEnginePtr = dynamic_cast<AdvancedMetaEngineDetection*>(&(plugin->get<MetaEngineDetection>()));
 				if (advEnginePtr == nullptr) {
-					warning("This engine doesn't support MD5 based detection");
+					warning("The requested engine (%s) doesn't support MD5-based detection", engineID.c_str());
 					return true;
 				}
-				md5Length = (long int)advEnginePtr->getMD5Bytes();
+				md5Length = (int32)advEnginePtr->getMD5Bytes();
 			}
 		}
 
 		calcMD5(path, md5Length);
+
 		return true;
 #ifdef DETECTOR_TESTING_HACK
 	} else if (command == "test-detector") {




More information about the Scummvm-git-logs mailing list