[Scummvm-git-logs] scummvm master -> 43acda0c9abc958d51f6f15c97800f7eda78f20f
criezy
noreply at scummvm.org
Tue Apr 5 22:18:39 UTC 2022
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
bc0bd86594 BASE: Add MD5 hash to commandline
2e656c30d3 BASE: Add --md5-engine flag
43acda0c9a GRAPHICS: Add override for TTFont class
Commit: bc0bd865948bd6df83684d7370a7e880054e6b5c
https://github.com/scummvm/scummvm/commit/bc0bd865948bd6df83684d7370a7e880054e6b5c
Author: Pragyansh Chaturvedi (r41k0u) (pragyanshchaturvedi18 at gmail.com)
Date: 2022-04-05T23:06:06+01:00
Commit Message:
BASE: Add MD5 hash to commandline
Changed paths:
base/commandLine.cpp
doc/docportal/advanced_topics/command_line.rst
diff --git a/base/commandLine.cpp b/base/commandLine.cpp
index fc885ca1953..2e426a12887 100644
--- a/base/commandLine.cpp
+++ b/base/commandLine.cpp
@@ -33,6 +33,7 @@
#include "common/config-manager.h"
#include "common/fs.h"
+#include "common/md5.h"
#include "common/rendermode.h"
#include "common/savefile.h"
#include "common/system.h"
@@ -207,6 +208,11 @@ static const char HELP_STRING[] =
" --engine-speed=NUM Set frame per second limit (0 - 100), 0 = no limit\n"
" (default: 60)\n"
" Grim Fandango or Escape from Monkey Island\n"
+ " --md5 Shows MD5 hash of the file given by --md5-path=PATH\n"
+ " If --md5-length=NUM is passed then it shows the MD5 hash of\n"
+ " the first NUM bytes of the file given by PATH\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"
"\n"
"The meaning of boolean long options can be inverted by prefixing them with\n"
"\"no-\", e.g. \"--no-aspect-ratio\".\n"
@@ -581,6 +587,9 @@ Common::String parseCommandLine(Common::StringMap &settings, int argc, const cha
DO_LONG_COMMAND("auto-detect")
END_COMMAND
+ DO_LONG_COMMAND("md5")
+ END_COMMAND
+
#ifdef DETECTOR_TESTING_HACK
// HACK FIXME TODO: This command is intentionally *not* documented!
DO_LONG_COMMAND("test-detector")
@@ -809,6 +818,17 @@ Common::String parseCommandLine(Common::StringMap &settings, int argc, const cha
}
END_OPTION
+ DO_LONG_OPTION("md5-path")
+ Common::FSNode path(option);
+ if (!path.exists()) {
+ usage("Non-existent file path '%s'", option);
+ } else if (path.isDirectory()) {
+ usage("'%s' is a directory, not a file path!", option);
+ } else if (!path.isReadable()) {
+ usage("Non-readable file path '%s'", option);
+ }
+ END_OPTION
+
DO_LONG_OPTION_INT("talkspeed")
END_OPTION
@@ -860,6 +880,9 @@ Common::String parseCommandLine(Common::StringMap &settings, int argc, const cha
DO_LONG_OPTION_INT("engine-speed")
END_OPTION
+ DO_LONG_OPTION_INT("md5-length")
+ END_OPTION
+
#ifdef IPHONE
// This is automatically set when launched from the Springboard.
DO_LONG_OPTION_OPT("launchedFromSB", 0)
@@ -1339,6 +1362,17 @@ static int recAddGames(const Common::FSNode &dir, const Common::String &engineId
return count;
}
+static void calcMD5(Common::FSNode &path, long int length) {
+ Common::SeekableReadStream *stream = path.createReadStream();
+ if (stream) {
+ Common::String md5 = Common::computeStreamMD5AsString(*stream, length);
+ printf("(hash) : %s, (filename) : %s, (bytes) : %d\n", md5.c_str(), path.getName().c_str(), length ? (int32)length : (int32)stream->size());
+ delete stream;
+ } else {
+ printf("Usage : --md5 --md5-path=<PATH> [--md5-length=NUM]\n");
+ }
+}
+
static bool addGames(const Common::String &path, const Common::String &engineId, const Common::String &gameId, bool recursive) {
//Current directory
Common::FSNode dir(path);
@@ -1635,6 +1669,15 @@ bool processSettings(Common::String &command, Common::StringMap &settings, Commo
} else if (command == "add") {
addGames(settings["path"], gameOption.engineId, gameOption.gameId, settings["recursive"] == "true");
return true;
+ } else if (command == "md5") {
+ Common::String filename = settings.getValOrDefault("md5-path", "scummvm");
+ Common::Path Filename(filename, '/');
+ Common::FSNode path(Filename);
+ long int md5Length = 0;
+ if (settings.contains("md5-length"))
+ md5Length = settings["md5-length"].asUint64();
+ calcMD5(path, md5Length);
+ return true;
#ifdef DETECTOR_TESTING_HACK
} else if (command == "test-detector") {
runDetectorTest();
diff --git a/doc/docportal/advanced_topics/command_line.rst b/doc/docportal/advanced_topics/command_line.rst
index ca3f0691338..09c99ae5c6f 100755
--- a/doc/docportal/advanced_topics/command_line.rst
+++ b/doc/docportal/advanced_topics/command_line.rst
@@ -166,6 +166,9 @@ Short options are listed where they are available.
``--tempo=NUM``,,"Sets music tempo (in percent, 50-200) for SCUMM games (default: 100)"
``--themepath=PATH``,,":ref:`Specifies path to where GUI themes are stored <themepath>`"
``--version``,``-v``,"Displays ScummVM version information and exits"
+ ``--md5``,,"Shows MD5 hash of the file given by ``--md5-path=PATH``. If ``--md5-length=NUM`` is passed then it shows the MD5 hash of the first ``NUM`` bytes of the file given by ``PATH``"
+ ``--md5-path=PATH``,,"Used with ``--md5`` to specify path of file to calculate MD5 hash of (default: ./scummvm)"
+ ``--md5-length=NUM``,,"Used with ``--md5`` to specify the number of bytes to be hashed. If ``NUM`` is 0, MD5 hash of the whole file is calculated. (default: 0)"
Commit: 2e656c30d3c972c95f2d652f2d8280c66c240f10
https://github.com/scummvm/scummvm/commit/2e656c30d3c972c95f2d652f2d8280c66c240f10
Author: Pragyansh Chaturvedi (r41k0u) (pragyanshchaturvedi18 at gmail.com)
Date: 2022-04-05T23:08:14+01:00
Commit Message:
BASE: Add --md5-engine flag
Changed paths:
base/commandLine.cpp
doc/docportal/advanced_topics/command_line.rst
engines/advancedDetector.h
diff --git a/base/commandLine.cpp b/base/commandLine.cpp
index 2e426a12887..72973f8ab5e 100644
--- a/base/commandLine.cpp
+++ b/base/commandLine.cpp
@@ -45,6 +45,7 @@
#include "audio/musicplugin.h"
#include "graphics/renderer.h"
+#include "advancedDetector.h"
#define DETECTOR_TESTING_HACK
#define UPGRADE_ALL_TARGETS_HACK
@@ -211,8 +212,14 @@ static const char HELP_STRING[] =
" --md5 Shows MD5 hash of the file given by --md5-path=PATH\n"
" If --md5-length=NUM is passed then it shows the MD5 hash of\n"
" the first NUM bytes of the file given by PATH\n"
+ " 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"
+ " 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"
+ " if used along with it. Use --list-engines to find all engineIds\n"
"\n"
"The meaning of boolean long options can be inverted by prefixing them with\n"
"\"no-\", e.g. \"--no-aspect-ratio\".\n"
@@ -829,6 +836,9 @@ Common::String parseCommandLine(Common::StringMap &settings, int argc, const cha
}
END_OPTION
+ DO_LONG_OPTION("md5-engine")
+ END_OPTION
+
DO_LONG_OPTION_INT("talkspeed")
END_OPTION
@@ -1366,7 +1376,7 @@ static void calcMD5(Common::FSNode &path, long int length) {
Common::SeekableReadStream *stream = path.createReadStream();
if (stream) {
Common::String md5 = Common::computeStreamMD5AsString(*stream, length);
- printf("(hash) : %s, (filename) : %s, (bytes) : %d\n", md5.c_str(), path.getName().c_str(), length ? (int32)length : (int32)stream->size());
+ printf("(hash) : %s, (filename) : %s, (bytes) : %d\n", md5.c_str(), path.getName().c_str(), length && length <= stream->size() ? (int32)length : (int32)stream->size());
delete stream;
} else {
printf("Usage : --md5 --md5-path=<PATH> [--md5-length=NUM]\n");
@@ -1676,6 +1686,27 @@ bool processSettings(Common::String &command, Common::StringMap &settings, Commo
long int md5Length = 0;
if (settings.contains("md5-length"))
md5Length = settings["md5-length"].asUint64();
+ if (settings.contains("md5-engine")) {
+ Common::String engineID = settings["md5-engine"];
+ if (engineID == "scumm") {
+ // Hardcoding value as scumm doesn't use AdvancedMetaEngineDetection
+ md5Length = 1024 * 1024;
+ } else {
+ const Plugin *plugin = EngineMan.findPlugin(engineID);
+ if (!plugin) {
+ warning("'%s' is an invalid engine ID. Use the --list-engines command to list supported engine IDs", engineID.c_str());
+ return true;
+ }
+
+ const AdvancedMetaEngineDetection* advEnginePtr = dynamic_cast<AdvancedMetaEngineDetection*>(&(plugin->get<MetaEngineDetection>()));
+ if (advEnginePtr == nullptr) {
+ warning("This engine doesn't support MD5 based detection");
+ return true;
+ }
+ md5Length = (long int) advEnginePtr->getMD5Bytes();
+ }
+ }
+
calcMD5(path, md5Length);
return true;
#ifdef DETECTOR_TESTING_HACK
diff --git a/doc/docportal/advanced_topics/command_line.rst b/doc/docportal/advanced_topics/command_line.rst
index 09c99ae5c6f..e4e7e702835 100755
--- a/doc/docportal/advanced_topics/command_line.rst
+++ b/doc/docportal/advanced_topics/command_line.rst
@@ -166,10 +166,10 @@ Short options are listed where they are available.
``--tempo=NUM``,,"Sets music tempo (in percent, 50-200) for SCUMM games (default: 100)"
``--themepath=PATH``,,":ref:`Specifies path to where GUI themes are stored <themepath>`"
``--version``,``-v``,"Displays ScummVM version information and exits"
- ``--md5``,,"Shows MD5 hash of the file given by ``--md5-path=PATH``. If ``--md5-length=NUM`` is passed then it shows the MD5 hash of the first ``NUM`` bytes of the file given by ``PATH``"
+ ``--md5``,,"Shows MD5 hash of the file given by ``--md5-path=PATH``. If ``--md5-length=NUM`` is passed then it shows the MD5 hash of the first ``NUM`` bytes of the file given by ``PATH``. If ``--md5-engine=ENGINE_ID`` option is passed then it auto-calculates the required bytes and its hash, overriding ``--md5-length``"
``--md5-path=PATH``,,"Used with ``--md5`` to specify path of file to calculate MD5 hash of (default: ./scummvm)"
- ``--md5-length=NUM``,,"Used with ``--md5`` to specify the number of bytes to be hashed. If ``NUM`` is 0, MD5 hash of the whole file is calculated. (default: 0)"
-
+ ``--md5-length=NUM``,,"Used with ``--md5`` to specify the number of bytes to be hashed. If ``NUM`` is 0, MD5 hash of the whole file is calculated. Is overriden if passed with ``--md5-engine`` option. (default: 0)"
+ ``--md5-engine=ENGINE_ID``,,"Used with ``--md5`` to specify engine of game for which hash is to be calculated. Overrides ``--md5-length`` if passed with it"
diff --git a/engines/advancedDetector.h b/engines/advancedDetector.h
index 2f3b76af10a..963f0fe9163 100644
--- a/engines/advancedDetector.h
+++ b/engines/advancedDetector.h
@@ -386,6 +386,8 @@ public:
static Common::StringArray getPathsFromEntry(const ADGameDescription *g);
+ uint getMD5Bytes() const {return _md5Bytes;}
+
protected:
/**
* A hashmap of files and their MD5 checksums.
Commit: 43acda0c9abc958d51f6f15c97800f7eda78f20f
https://github.com/scummvm/scummvm/commit/43acda0c9abc958d51f6f15c97800f7eda78f20f
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2022-04-05T23:18:05+01:00
Commit Message:
GRAPHICS: Add override for TTFont class
Changed paths:
graphics/fonts/ttf.cpp
diff --git a/graphics/fonts/ttf.cpp b/graphics/fonts/ttf.cpp
index 5a993866ca3..dabef54be27 100644
--- a/graphics/fonts/ttf.cpp
+++ b/graphics/fonts/ttf.cpp
@@ -139,27 +139,27 @@ void TTFLibrary::closeFont(FT_Face &face) {
class TTFFont : public Font {
public:
TTFFont();
- virtual ~TTFFont();
+ ~TTFFont() override;
bool load(Common::SeekableReadStream &stream, int size, TTFSizeMode sizeMode,
uint dpi, TTFRenderMode renderMode, const uint32 *mapping, bool stemDarkening);
bool load(uint8 *ttfFile, uint32 sizeFile, int32 faceIndex, bool fakeBold, bool fakeItalic,
int size, TTFSizeMode sizeMode, uint dpi, TTFRenderMode renderMode, const uint32 *mapping, bool stemDarkening);
- virtual int getFontHeight() const;
+ int getFontHeight() const override;
Common::String getFontName() const override;
- virtual int getFontAscent() const;
+ int getFontAscent() const override;
- virtual int getMaxCharWidth() const;
+ int getMaxCharWidth() const override;
- virtual int getCharWidth(uint32 chr) const;
+ int getCharWidth(uint32 chr) const override;
- virtual int getKerningOffset(uint32 left, uint32 right) const;
+ int getKerningOffset(uint32 left, uint32 right) const override;
- virtual Common::Rect getBoundingBox(uint32 chr) const;
+ Common::Rect getBoundingBox(uint32 chr) const override;
- virtual void drawChar(Surface *dst, uint32 chr, int x, int y, uint32 color) const;
- virtual void drawChar(ManagedSurface *dst, uint32 chr, int x, int y, uint32 color) const;
+ void drawChar(Surface *dst, uint32 chr, int x, int y, uint32 color) const override;
+ void drawChar(ManagedSurface *dst, uint32 chr, int x, int y, uint32 color) const override;
private:
bool _initialized;
More information about the Scummvm-git-logs
mailing list