[Scummvm-git-logs] scummvm master -> 832d7d2f021792ac41d211a745de27cddce7cdb2
sev-
noreply at scummvm.org
Mon May 29 17:36:19 UTC 2023
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:
9955c95806 DIRECTOR: Add multiple resources in exe using ProjectorArchive
608beef745 DIRECTOR: Fix memory leak due to bad flag
832d7d2f02 DIRECTOR: Change error in case of bad file to warning, to exit gracefully
Commit: 9955c958066c194ec22c1fdd08f25652d4e3ae63
https://github.com/scummvm/scummvm/commit/9955c958066c194ec22c1fdd08f25652d4e3ae63
Author: Harishankar Kumar (hari01584 at gmail.com)
Date: 2023-05-29T19:36:15+02:00
Commit Message:
DIRECTOR: Add multiple resources in exe using ProjectorArchive
This patch uses ProjectorArchive to extract multiple resources embedded into executable files, additionally a new function getRawExe is defined which gets raw exe file name without --start-movie overriding it.
Solves the problem for finding multiple resource files like `ModTB.DXR` in 'mcluhan', uses 'mcluhan.exe' to extract resources and add them to SearchMan.
Changed paths:
engines/director/archive.h
engines/director/director.cpp
engines/director/director.h
engines/director/resource.cpp
diff --git a/engines/director/archive.h b/engines/director/archive.h
index 15ba9070a5f..408f5fdd9ef 100644
--- a/engines/director/archive.h
+++ b/engines/director/archive.h
@@ -149,6 +149,36 @@ protected:
Common::HashMap<uint32, KeyMap> _keyData;
};
+/*******************************************
+ *
+ * Projector Archive
+ *
+ *******************************************/
+
+class ProjectorArchive : public Common::Archive {
+public:
+ ProjectorArchive(Common::String path);
+ ~ProjectorArchive() override;
+
+ bool hasFile(const Common::Path &path) const override;
+ int listMembers(Common::ArchiveMemberList &list) const override;
+ const Common::ArchiveMemberPtr getMember(const Common::Path &path) const override;
+ Common::SeekableReadStream *createReadStreamForMember(const Common::Path &path) const override;
+ bool isLoaded() { return _isLoaded; }
+private:
+ Common::SeekableReadStream *createBufferedReadStream();
+ bool loadArchive(Common::SeekableReadStream *stream);
+
+ struct Entry {
+ uint32 offset;
+ uint32 size;
+ };
+ typedef Common::HashMap<Common::String, Entry, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> FileMap;
+ FileMap _files;
+ Common::String _path;
+
+ bool _isLoaded;
+};
} // End of namespace Director
#endif
diff --git a/engines/director/director.cpp b/engines/director/director.cpp
index 4ce14ec104d..b63f54a5089 100644
--- a/engines/director/director.cpp
+++ b/engines/director/director.cpp
@@ -290,12 +290,17 @@ Common::CodePage DirectorEngine::getPlatformEncoding() {
return getEncoding(getPlatform(), getLanguage());
}
+Common::String DirectorEngine::getRawEXEName() const {
+ // Returns raw executable name (without getting overloaded from --start-movie option)
+ return Common::punycode_decodefilename(Common::lastPathComponent(_gameDescription->desc.filesDescriptions[0].fileName, '/'));
+}
+
Common::String DirectorEngine::getEXEName() const {
StartMovie startMovie = getStartMovie();
if (startMovie.startMovie.size() > 0)
return startMovie.startMovie;
- return Common::punycode_decodefilename(Common::lastPathComponent(_gameDescription->desc.filesDescriptions[0].fileName, '/'));
+ return getRawEXEName();
}
void DirectorEngine::parseOptions() {
diff --git a/engines/director/director.h b/engines/director/director.h
index 11a3043bc79..3967903f10b 100644
--- a/engines/director/director.h
+++ b/engines/director/director.h
@@ -159,6 +159,7 @@ public:
Common::Language getLanguage() const;
Common::String getTargetName() { return _targetName; }
const char *getExtra();
+ Common::String getRawEXEName() const;
Common::String getEXEName() const;
StartMovie getStartMovie() const;
void parseOptions();
diff --git a/engines/director/resource.cpp b/engines/director/resource.cpp
index 2ef76960bed..d24451d5c3b 100644
--- a/engines/director/resource.cpp
+++ b/engines/director/resource.cpp
@@ -63,6 +63,15 @@ Common::Error Window::loadInitialMovie() {
return Common::kNoGameDataFoundError;
}
+ // Load multiple-resources based executable file (Projector)
+ ProjectorArchive *multiArchive = new ProjectorArchive(_vm->getRawEXEName());
+ if (multiArchive->isLoaded()) {
+ // A valid projector archive, add to SearchMan
+ SearchMan.add(_vm->getRawEXEName(), multiArchive);
+ } else {
+ delete multiArchive;
+ }
+
_currentMovie = new Movie(this);
_currentPath = getPath(movie, _currentPath);
Common::String sharedCastPath = getSharedCastPath();
@@ -531,35 +540,6 @@ void Window::loadStartMovieXLibs() {
g_lingo->openXLib("SerialPort", kXObj);
}
-/*******************************************
- *
- * Projector Archive
- *
- *******************************************/
-
-class ProjectorArchive : public Common::Archive {
-public:
- ProjectorArchive(Common::String path);
- ~ProjectorArchive() override;
-
- bool hasFile(const Common::Path &path) const override;
- int listMembers(Common::ArchiveMemberList &list) const override;
- const Common::ArchiveMemberPtr getMember(const Common::Path &path) const override;
- Common::SeekableReadStream *createReadStreamForMember(const Common::Path &path) const override;
-
-private:
- Common::SeekableReadStream *createBufferedReadStream();
- bool loadArchive(Common::SeekableReadStream *stream);
-
- struct Entry {
- uint32 offset;
- uint32 size;
- };
- typedef Common::HashMap<Common::String, Entry, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> FileMap;
- FileMap _files;
- Common::String _path;
-};
-
ProjectorArchive::ProjectorArchive(Common::String path)
: _path(path), _files() {
@@ -567,7 +547,7 @@ ProjectorArchive::ProjectorArchive(Common::String path)
Common::SeekableReadStream *stream = createBufferedReadStream();
// Build our filemap using the buffered stream
- loadArchive(stream);
+ _isLoaded = loadArchive(stream);
delete stream;
}
Commit: 608beef74567a1a58f40fa7411fc8150668ae06a
https://github.com/scummvm/scummvm/commit/608beef74567a1a58f40fa7411fc8150668ae06a
Author: Harishankar Kumar (hari01584 at gmail.com)
Date: 2023-05-29T19:36:15+02:00
Commit Message:
DIRECTOR: Fix memory leak due to bad flag
ProjectorArchive was giving memory leak and build failures due to not deleting unwrapped stream after use
Changed paths:
engines/director/resource.cpp
diff --git a/engines/director/resource.cpp b/engines/director/resource.cpp
index d24451d5c3b..4ed8abe23c9 100644
--- a/engines/director/resource.cpp
+++ b/engines/director/resource.cpp
@@ -559,7 +559,7 @@ Common::SeekableReadStream *ProjectorArchive::createBufferedReadStream() {
if (!stream)
error("ProjectorArchive::createBufferedReadStream(): Cannot open %s", _path.c_str());
- return Common::wrapBufferedSeekableReadStream(stream, READ_BUFFER_SIZE, DisposeAfterUse::NO);
+ return Common::wrapBufferedSeekableReadStream(stream, READ_BUFFER_SIZE, DisposeAfterUse::YES);
}
ProjectorArchive::~ProjectorArchive() {
Commit: 832d7d2f021792ac41d211a745de27cddce7cdb2
https://github.com/scummvm/scummvm/commit/832d7d2f021792ac41d211a745de27cddce7cdb2
Author: Harishankar Kumar (hari01584 at gmail.com)
Date: 2023-05-29T19:36:15+02:00
Commit Message:
DIRECTOR: Change error in case of bad file to warning, to exit gracefully
Initially for a bad file that didn't exist, the ProjectorArchive was throwing up, now however implemented gracefully loading.
Fixed error and termination for `Majestic.bin`, the path it tried to look up was `Majestic` from detection entry.
Changed paths:
engines/director/resource.cpp
diff --git a/engines/director/resource.cpp b/engines/director/resource.cpp
index 4ed8abe23c9..efa7c02eefa 100644
--- a/engines/director/resource.cpp
+++ b/engines/director/resource.cpp
@@ -545,6 +545,10 @@ ProjectorArchive::ProjectorArchive(Common::String path)
// Buffer 100K into memory
Common::SeekableReadStream *stream = createBufferedReadStream();
+ if (!stream) {
+ _isLoaded = false;
+ return;
+ }
// Build our filemap using the buffered stream
_isLoaded = loadArchive(stream);
@@ -556,8 +560,10 @@ Common::SeekableReadStream *ProjectorArchive::createBufferedReadStream() {
const uint32 READ_BUFFER_SIZE = 1024 * 100;
Common::SeekableReadStream *stream = SearchMan.createReadStreamForMember(_path);
- if (!stream)
- error("ProjectorArchive::createBufferedReadStream(): Cannot open %s", _path.c_str());
+ if (!stream) {
+ warning("ProjectorArchive::createBufferedReadStream(): Cannot open %s", _path.c_str());
+ return nullptr;
+ }
return Common::wrapBufferedSeekableReadStream(stream, READ_BUFFER_SIZE, DisposeAfterUse::YES);
}
More information about the Scummvm-git-logs
mailing list