[Scummvm-git-logs] scummvm master -> aed4c89b132848be04b3361d5a5ba331dfcbfcb3
sev-
noreply at scummvm.org
Sun Jun 11 21:24:56 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:
aed4c89b13 DIRECTOR: Print out list of unprocessed chunks in Director files
Commit: aed4c89b132848be04b3361d5a5ba331dfcbfcb3
https://github.com/scummvm/scummvm/commit/aed4c89b132848be04b3361d5a5ba331dfcbfcb3
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-06-11T23:24:47+02:00
Commit Message:
DIRECTOR: Print out list of unprocessed chunks in Director files
Changed paths:
engines/director/archive.cpp
engines/director/archive.h
diff --git a/engines/director/archive.cpp b/engines/director/archive.cpp
index 5e6d49fe406..19aeb90b6b8 100644
--- a/engines/director/archive.cpp
+++ b/engines/director/archive.cpp
@@ -67,6 +67,8 @@ bool Archive::openFile(const Common::String &fileName) {
}
void Archive::close() {
+ listUnaccessedChunks();
+
_types.clear();
if (_stream)
@@ -75,6 +77,27 @@ void Archive::close() {
_stream = nullptr;
}
+void Archive::listUnaccessedChunks() {
+ Common::String s;
+
+ for (const auto &type : _types) {
+ bool accessed = false;
+
+ for (const auto &res : type._value) {
+ if (res._value.accessed) {
+ accessed = true;
+ break;
+ }
+ }
+
+ if (!accessed && type._key != MKTAG('f','r','e','e') && type._key != MKTAG('j','u','n','k'))
+ s += Common::String::format("%s: %d items\n", tag2str(type._key), type._value.size());
+ }
+
+ if (!s.empty())
+ debug("Unaccessed Chunks in '%s':\n%s", _pathName.c_str(), s.c_str());
+}
+
int Archive::getFileSize() {
if (!_stream)
return 0;
@@ -121,6 +144,8 @@ Common::SeekableReadStreamEndian *Archive::getResource(uint32 tag, uint16 id) {
const Resource &res = resMap[id];
auto stream = new Common::SeekableSubReadStream(_stream, res.offset, res.offset + res.size, DisposeAfterUse::NO);
+ _types[tag][id].accessed = true; // Mark it as accessed
+
return new Common::SeekableReadStreamEndianWrapper(stream, _isBigEndian, DisposeAfterUse::YES);
}
@@ -340,9 +365,12 @@ void MacArchive::readTags() {
res.name = _resFork->getResName(tagArray[i], idArray[j]);
res.tag = tagArray[i];
res.index = idArray[j];
+ res.accessed = false;
debug(3, "MacArchive::readTags(): Found MacArchive resource '%s' %d: %s", tag2str(tagArray[i]), idArray[j], res.name.c_str());
if (ConfMan.getBool("dump_scripts"))
dumpChunk(res, out);
+
+ res.accessed = false; // Clear flag so stats are not spoiled
}
// Don't assign a 0-entry resMap to _types.
@@ -366,6 +394,8 @@ Common::SeekableReadStreamEndian *MacArchive::getResource(uint32 tag, uint16 id)
error("MacArchive::getResource(): Archive does not contain '%s' %d", tag2str(tag), id);
}
+ _types[tag][id].accessed = true; // Mark it as accessed
+
return new Common::SeekableReadStreamEndianWrapper(stream, true, DisposeAfterUse::YES);
}
@@ -449,10 +479,13 @@ bool RIFFArchive::openStream(Common::SeekableReadStream *stream, uint32 startOff
res.size = size;
res.name = name;
res.tag = tag;
+ res.accessed = false;
if (ConfMan.getBool("dump_scripts"))
dumpChunk(res, out);
+ res.accessed = false; // Clear flag so stats are not spoiled
+
stream->seek(startResPos);
}
@@ -499,6 +532,8 @@ Common::SeekableReadStreamEndian *RIFFArchive::getResource(uint32 tag, uint16 id
debugC(4, kDebugLoading, "RIFFArchive::getResource() tag: %s id: %i offset: %i size: %i", tag2str(tag), id, res.offset, res.size);
+ _types[tag][id].accessed = true; // Mark it as accessed
+
auto stream = new Common::SeekableSubReadStream(_stream, _startOffset + offset, _startOffset + offset + size, DisposeAfterUse::NO);
return new Common::SeekableReadStreamEndianWrapper(stream, true, DisposeAfterUse::YES);
}
@@ -622,6 +657,8 @@ bool RIFXArchive::openStream(Common::SeekableReadStream *stream, uint32 startOff
break;
}
+ _types[MKTAG('R', 'I', 'F', 'X')][0].accessed = true; // Mark it as accessed
+
// Now that the dump data has been patched, actually dump it.
if (dumpData) {
Common::DumpFile out;
@@ -715,6 +752,8 @@ bool RIFXArchive::readMemoryMap(Common::SeekableReadStreamEndian &stream, uint32
if (stream.readUint32() != MKTAG('i', 'm', 'a', 'p'))
return false;
+ _types[MKTAG('i', 'm', 'a', 'p')][0].accessed = true; // Mark it as accessed
+
stream.readUint32(); // imap length
stream.readUint32(); // unknown
uint32 mmapOffsetPos = stream.pos();
@@ -737,6 +776,8 @@ bool RIFXArchive::readMemoryMap(Common::SeekableReadStreamEndian &stream, uint32
return false;
}
+ _types[MKTAG('m', 'm', 'a', 'p')][0].accessed = true; // Mark it as accessed
+
stream.readUint32(); // mmap length
stream.readUint16(); // unknown
stream.readUint16(); // unknown
@@ -771,6 +812,7 @@ bool RIFXArchive::readMemoryMap(Common::SeekableReadStreamEndian &stream, uint32
res.offset = offset;
res.size = size;
res.tag = tag;
+ res.accessed = false;
_resources.push_back(&res);
}
@@ -884,6 +926,7 @@ bool RIFXArchive::readAfterburnerMap(Common::SeekableReadStreamEndian &stream, u
res.uncompSize = uncompSize;
res.compressionType = compressionType;
res.tag = tag;
+ res.accessed = false;
_resources.push_back(&res);
resourceMap[resId] = &res;
}
@@ -1015,6 +1058,8 @@ Common::SeekableReadStreamEndian *RIFXArchive::getResource(uint32 tag, uint16 id
if (!resMap.contains(id))
error("RIFXArchive::getResource(): Archive does not contain '%s' %d", tag2str(tag), id);
+ _types[tag][id].accessed = true; // Mark it as accessed
+
const Resource &res = resMap[id];
bool bigEndian = fileEndianness ? _isBigEndian : true;
diff --git a/engines/director/archive.h b/engines/director/archive.h
index 408f5fdd9ef..cbdc988e0a2 100644
--- a/engines/director/archive.h
+++ b/engines/director/archive.h
@@ -44,6 +44,7 @@ struct Resource {
uint32 tag;
Common::String name;
Common::Array<Resource> children;
+ bool accessed;
};
class Archive {
@@ -79,6 +80,8 @@ public:
virtual Common::String formatArchiveInfo();
+ void listUnaccessedChunks();
+
protected:
void dumpChunk(Resource &res, Common::DumpFile &out);
Common::SeekableReadStream *_stream;
More information about the Scummvm-git-logs
mailing list