[Scummvm-git-logs] scummvm master -> da64e44f88ca39959c22eb8576408854821ab832
sev-
noreply at scummvm.org
Mon Aug 28 19:52:42 UTC 2023
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
c097a43a1f COMMON: Allow to know the archive name of matching members in SearchSet
da64e44f88 GOB: Remove ArchiveMember to FSNode dynamic_casts
Commit: c097a43a1fc5fc41f3b69d0b253ee3a06c2bceaa
https://github.com/scummvm/scummvm/commit/c097a43a1fc5fc41f3b69d0b253ee3a06c2bceaa
Author: Simon Delamarre (simon.delamarre14 at gmail.com)
Date: 2023-08-28T21:52:38+02:00
Commit Message:
COMMON: Allow to know the archive name of matching members in SearchSet
Changed paths:
common/archive.cpp
common/archive.h
diff --git a/common/archive.cpp b/common/archive.cpp
index 79b935180f6..ae50f6492ae 100644
--- a/common/archive.cpp
+++ b/common/archive.cpp
@@ -356,6 +356,20 @@ int SearchSet::listMatchingMembers(ArchiveMemberList &list, const Path &pattern,
return matches;
}
+int SearchSet::listMatchingMembers(ArchiveMemberDetailsList &list, const Path &pattern, bool matchPathComponents) const {
+ int matches = 0;
+
+ ArchiveNodeList::const_iterator it = _list.begin();
+ for (; it != _list.end(); ++it) {
+ List<ArchiveMemberPtr> matchingMembers;
+ matches += it->_arc->listMatchingMembers(matchingMembers, pattern, matchPathComponents);
+ for (ArchiveMemberPtr &member : matchingMembers)
+ list.push_back(ArchiveMemberDetails(member, it->_name));
+ }
+
+ return matches;
+}
+
int SearchSet::listMembers(ArchiveMemberList &list) const {
int matches = 0;
diff --git a/common/archive.h b/common/archive.h
index 6e6e1ab0bbd..96f07d79ddd 100644
--- a/common/archive.h
+++ b/common/archive.h
@@ -74,6 +74,15 @@ public:
typedef SharedPtr<ArchiveMember> ArchiveMemberPtr; /*!< Shared pointer to an archive member. */
typedef List<ArchiveMemberPtr> ArchiveMemberList; /*!< List of archive members. */
+struct ArchiveMemberDetails {
+ ArchiveMemberPtr arcMember;
+ Common::String arcName;
+
+ ArchiveMemberDetails(const ArchiveMemberPtr &arcMember_, const Common::String &_arcName) : arcMember(arcMember_), arcName(_arcName) {
+ }
+};
+typedef List<ArchiveMemberDetails> ArchiveMemberDetailsList; /*!< List of archive members with the name of the archive they belong to */
+
/**
* Compare two archive member operators @p a and @p b and return which of them is higher.
*/
@@ -366,6 +375,7 @@ public:
bool hasFile(const Path &path) const override;
int listMatchingMembers(ArchiveMemberList &list, const Path &pattern, bool matchPathComponents = false) const override;
+ int listMatchingMembers(ArchiveMemberDetailsList &list, const Path &pattern, bool matchPathComponents = false) const;
int listMembers(ArchiveMemberList &list) const override;
const ArchiveMemberPtr getMember(const Path &path) const override;
Commit: da64e44f88ca39959c22eb8576408854821ab832
https://github.com/scummvm/scummvm/commit/da64e44f88ca39959c22eb8576408854821ab832
Author: Simon Delamarre (simon.delamarre14 at gmail.com)
Date: 2023-08-28T21:52:38+02:00
Commit Message:
GOB: Remove ArchiveMember to FSNode dynamic_casts
This fixes the Read/Count application selection in Adibou2
Changed paths:
engines/gob/inter.h
engines/gob/inter_v7.cpp
diff --git a/engines/gob/inter.h b/engines/gob/inter.h
index b0933667caa..ee410260bc2 100644
--- a/engines/gob/inter.h
+++ b/engines/gob/inter.h
@@ -743,7 +743,7 @@ private:
Common::String findFile(const Common::String &mask, const Common::String &previousFile);
void copyFile(const Common::String &sourceFile, const Common::String &destFile);
- bool setCurrentCDPath(const Common::FSNode &dir);
+ bool setCurrentCDPath(const Common::String &dir);
Common::Array<uint32> getAdibou2InstalledApplications();
};
diff --git a/engines/gob/inter_v7.cpp b/engines/gob/inter_v7.cpp
index 25742a05a1e..004bc78716e 100644
--- a/engines/gob/inter_v7.cpp
+++ b/engines/gob/inter_v7.cpp
@@ -722,14 +722,12 @@ void Inter_v7::o7_setActiveCD() {
Common::String str0 = _vm->_game->_script->evalString();
Common::String str1 = _vm->_game->_script->evalString();
- Common::ArchiveMemberList files;
+ Common::ArchiveMemberDetailsList files;
SearchMan.listMatchingMembers(files, str0);
Common::String savedCDpath = _currentCDPath;
- for (Common::ArchiveMemberPtr file : files) {
- auto *node = dynamic_cast<Common::FSNode *>(file.get());
- if (node != nullptr &&
- setCurrentCDPath(node->getParent())) {
+ for (Common::ArchiveMemberDetails file : files) {
+ if (setCurrentCDPath(file.arcName)) {
debugC(5, kDebugFileIO, "o7_setActiveCD: %s -> %s", savedCDpath.c_str(), _currentCDPath.c_str());
storeValue(1);
return;
@@ -1164,24 +1162,16 @@ void Inter_v7::o7_fillRect(OpFuncParams ¶ms) {
_vm->_draw->_pattern = savedPattern;
}
-bool Inter_v7::setCurrentCDPath(const Common::FSNode &newDir) {
- Common::FSNode gameDataDir(ConfMan.get("path"));
- bool newDirIsGameDir = (newDir.getPath() == gameDataDir.getPath());
- Common::String newDirName = newDir.getName();
-
- if (!newDirIsGameDir &&
- (newDirName.equalsIgnoreCase("applis") || newDirName.equalsIgnoreCase("envir")))
+bool Inter_v7::setCurrentCDPath(const Common::String &newDirName) {
+ if (newDirName.equalsIgnoreCase("applis") || newDirName.equalsIgnoreCase("envir"))
return false;
if (!_currentCDPath.empty())
SearchMan.setPriority(_currentCDPath, 0);
- if (newDirIsGameDir)
- _currentCDPath = "";
- else {
- _currentCDPath = newDirName;
+ _currentCDPath = newDirName;
+ if (!_currentCDPath.empty())
SearchMan.setPriority(newDirName, 1);
- }
return true;
}
@@ -1247,17 +1237,16 @@ void Inter_v7::o7_checkData(OpFuncParams ¶ms) {
int32 indexAppli = VAR_OFFSET(20196);
if (indexAppli == -1) {
// New appli, find the first directory containing an application still not installed, and set it as "current CD" path.
- Common::ArchiveMemberList files;
+ Common::ArchiveMemberDetailsList files;
SearchMan.listMatchingMembers(files, file); // Search for CD.INF files
- for (Common::ArchiveMemberPtr &cdInfFile : files) {
- Common::SeekableReadStream *stream = cdInfFile->createReadStream();
+ for (Common::ArchiveMemberDetails &cdInfFile : files) {
+ Common::SeekableReadStream *stream = cdInfFile.arcMember->createReadStream();
while (stream->pos() + 4 <= stream->size()) {
// CD.INF contains a list of applications, as uint32 LE values
uint32 applicationNumber = stream->readUint32LE();
if (Common::find(installedApplications.begin(), installedApplications.end(), applicationNumber) == installedApplications.end()) {
// Application not installed yet, set it as current CD path
- Common::FSNode cdInfFileNode(cdInfFile->getName());
- setCurrentCDPath(cdInfFileNode.getParent());
+ setCurrentCDPath(cdInfFile.arcName);
break;
}
}
@@ -1266,14 +1255,11 @@ void Inter_v7::o7_checkData(OpFuncParams ¶ms) {
// Already installed appli, find its directory and set it as "current CD" path
int32 applicationNumber = installedApplications[indexAppli - 1];
Common::String appliVmdName = Common::String::format("appli_%02d.vmd", applicationNumber);
- Common::ArchiveMemberList files;
- SearchMan.listMatchingMembers(files, appliVmdName);
- for (Common::ArchiveMemberPtr &member : files) {
- auto *node = dynamic_cast<Common::FSNode *>(member.get());
- if (node != nullptr) {
- if (setCurrentCDPath(node->getParent()))
- break;
- }
+ Common::ArchiveMemberDetailsList matchingFiles;
+ SearchMan.listMatchingMembers(matchingFiles, appliVmdName);
+ for (Common::ArchiveMemberDetails &matchingFile : matchingFiles) {
+ if (setCurrentCDPath(matchingFile.arcName))
+ break;
}
}
}
More information about the Scummvm-git-logs
mailing list