[Scummvm-git-logs] scummvm master -> b06893a692028d531ddfbf26ebdb6bb27bd67d05
sev-
noreply at scummvm.org
Wed May 10 20:44:10 UTC 2023
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:
088b14a83a COMMON: Add function to open data fork from macbinary stream
0208fac907 SCUMM: Make Scumm*File compatible with non-File streams
4479f1438f SCUMM: Detect macbinary files
b06893a692 SCUMM: Support extracting resources from macbinary
Commit: 088b14a83aade75a499db7f4bd92f9ca80eb29c8
https://github.com/scummvm/scummvm/commit/088b14a83aade75a499db7f4bd92f9ca80eb29c8
Author: Vladimir Serbinenko (phcoder at gmail.com)
Date: 2023-05-10T22:44:04+02:00
Commit Message:
COMMON: Add function to open data fork from macbinary stream
Changed paths:
common/macresman.cpp
common/macresman.h
diff --git a/common/macresman.cpp b/common/macresman.cpp
index a4f02d54571..ae8c3250875 100644
--- a/common/macresman.cpp
+++ b/common/macresman.cpp
@@ -313,6 +313,15 @@ SeekableReadStream * MacResManager::openFileOrDataFork(const Path &fileName) {
return openFileOrDataFork(fileName, SearchMan);
}
+SeekableReadStream * MacResManager::openDataForkFromMacBinary(SeekableReadStream *inStream, DisposeAfterUse::Flag disposeAfterUse) {
+ if (!inStream && !isMacBinary(*inStream)) {
+ return nullptr;
+ }
+ inStream->seek(MBI_DFLEN);
+ uint32 dataSize = inStream->readUint32BE();
+ return new SeekableSubReadStream(inStream, MBI_INFOHDR, MBI_INFOHDR + dataSize, disposeAfterUse);
+}
+
SeekableReadStream * MacResManager::openFileOrDataFork(const Path &fileName, Archive &archive) {
SeekableReadStream *stream = archive.createReadStreamForMember(fileName);
// Our preference is as following:
diff --git a/common/macresman.h b/common/macresman.h
index 8c8386f90b1..8bc20dcf082 100644
--- a/common/macresman.h
+++ b/common/macresman.h
@@ -159,6 +159,12 @@ public:
static SeekableReadStream *openFileOrDataFork(const Path &fileName, Archive &archive);
static SeekableReadStream *openFileOrDataFork(const Path &fileName);
+ /**
+ * Open data fork of macbinary.
+ * @return The stream if found, 0 otherwise
+ */
+ static SeekableReadStream *openDataForkFromMacBinary(SeekableReadStream *inStream, DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::NO);
+
/**
* See if a Mac data/resource fork pair exists.
* @param fileName The base file name of the file
Commit: 0208fac907cee5b9b9fa66b9655dbf19f16296e0
https://github.com/scummvm/scummvm/commit/0208fac907cee5b9b9fa66b9655dbf19f16296e0
Author: Vladimir Serbinenko (phcoder at gmail.com)
Date: 2023-05-10T22:44:04+02:00
Commit Message:
SCUMM: Make Scumm*File compatible with non-File streams
Changed paths:
engines/scumm/file.cpp
engines/scumm/file.h
engines/scumm/file_nes.cpp
engines/scumm/imuse_digi/dimuse_bndmgr.cpp
engines/scumm/resource.cpp
diff --git a/engines/scumm/file.cpp b/engines/scumm/file.cpp
index d233531fe53..acc11619176 100644
--- a/engines/scumm/file.cpp
+++ b/engines/scumm/file.cpp
@@ -26,6 +26,11 @@
namespace Scumm {
+void BaseScummFile::close() {
+ _baseStream.reset();
+ _debugName.clear();
+}
+
#pragma mark -
#pragma mark --- ScummFile ---
#pragma mark -
@@ -35,7 +40,7 @@ ScummFile::ScummFile() : _subFileStart(0), _subFileLen(0), _myEos(false) {
void ScummFile::setSubfileRange(int32 start, int32 len) {
// TODO: Add sanity checks
- const int32 fileSize = File::size();
+ const int32 fileSize = _baseStream->size();
assert(start <= fileSize);
assert(start + len <= fileSize);
_subFileStart = start;
@@ -50,7 +55,9 @@ void ScummFile::resetSubfile() {
}
bool ScummFile::open(const Common::Path &filename) {
- if (File::open(filename)) {
+ _baseStream.reset(SearchMan.createReadStreamForMember(filename));
+ _debugName = filename.toString();
+ if (_baseStream) {
resetSubfile();
return true;
} else {
@@ -59,7 +66,7 @@ bool ScummFile::open(const Common::Path &filename) {
}
bool ScummFile::openSubFile(const Common::String &filename) {
- assert(isOpen());
+ assert(_baseStream);
// Disable the XOR encryption and reset any current subfile range
setEnc(0);
@@ -117,15 +124,15 @@ bool ScummFile::openSubFile(const Common::String &filename) {
bool ScummFile::eos() const {
- return _subFileLen ? _myEos : File::eos();
+ return _subFileLen ? _myEos : _baseStream->eos();
}
int64 ScummFile::pos() const {
- return File::pos() - _subFileStart;
+ return _baseStream->pos() - _subFileStart;
}
int64 ScummFile::size() const {
- return _subFileLen ? _subFileLen : File::size();
+ return _subFileLen ? _subFileLen : _baseStream->size();
}
bool ScummFile::seek(int64 offs, int whence) {
@@ -140,13 +147,13 @@ bool ScummFile::seek(int64 offs, int whence) {
offs += _subFileStart;
break;
case SEEK_CUR:
- offs += File::pos();
+ offs += _baseStream->pos();
break;
}
assert((int32)_subFileStart <= offs && offs <= (int32)(_subFileStart + _subFileLen));
whence = SEEK_SET;
}
- bool ret = File::seek(offs, whence);
+ bool ret = _baseStream->seek(offs, whence);
if (ret)
_myEos = false;
return ret;
@@ -166,7 +173,7 @@ uint32 ScummFile::read(void *dataPtr, uint32 dataSize) {
}
}
- realLen = File::read(dataPtr, dataSize);
+ realLen = _baseStream->read(dataPtr, dataSize);
// If an encryption byte was specified, XOR the data we just read by it.
@@ -283,7 +290,7 @@ ScummDiskImage::ScummDiskImage(const char *disk1, const char *disk2, GameSetting
byte ScummDiskImage::fileReadByte() {
byte b = 0;
- File::read(&b, 1);
+ _baseStream->read(&b, 1);
return b;
}
@@ -299,22 +306,21 @@ bool ScummDiskImage::openDisk(char num) {
if (num == '2')
num = 2;
- if (_openedDisk != num || !File::isOpen()) {
- if (File::isOpen())
- File::close();
-
- if (num == 1)
- File::open(_disk1);
- else if (num == 2)
- File::open(_disk2);
- else {
+ if (_openedDisk != num || !_baseStream) {
+ if (num == 1) {
+ _baseStream.reset(SearchMan.createReadStreamForMember(_disk1));
+ _debugName = _disk1;
+ } else if (num == 2) {
+ _baseStream.reset(SearchMan.createReadStreamForMember(_disk2));
+ _debugName = _disk2;
+ } else {
error("ScummDiskImage::open(): wrong disk (%c)", num);
return false;
}
_openedDisk = num;
- if (!File::isOpen()) {
+ if (!_baseStream) {
error("ScummDiskImage::open(): cannot open disk (%d)", num);
return false;
}
@@ -329,9 +335,9 @@ bool ScummDiskImage::open(const Common::Path &filename) {
openDisk(1);
if (_game.platform == Common::kPlatformApple2GS) {
- File::seek(142080);
+ _baseStream->seek(142080);
} else {
- File::seek(0);
+ _baseStream->seek(0);
}
signature = fileReadUint16LE();
@@ -348,12 +354,12 @@ bool ScummDiskImage::open(const Common::Path &filename) {
openDisk(2);
if (_game.platform == Common::kPlatformApple2GS) {
- File::seek(143104);
+ _baseStream->seek(143104);
signature = fileReadUint16LE();
if (signature != 0x0032)
error("Error: signature not found in disk 2");
} else {
- File::seek(0);
+ _baseStream->seek(0);
signature = fileReadUint16LE();
if (signature != 0x0132)
error("Error: signature not found in disk 2");
@@ -371,9 +377,9 @@ uint16 ScummDiskImage::extractIndex(Common::WriteStream *out) {
openDisk(1);
if (_game.platform == Common::kPlatformApple2GS) {
- File::seek(142080);
+ _baseStream->seek(142080);
} else {
- File::seek(0);
+ _baseStream->seek(0);
}
// skip signature
@@ -457,9 +463,9 @@ uint16 ScummDiskImage::extractResource(Common::WriteStream *out, int res) {
openDisk(_roomDisks[res]);
if (_game.platform == Common::kPlatformApple2GS) {
- File::seek((AppleSectorOffset[_roomTracks[res]] + _roomSectors[res]) * 256);
+ _baseStream->seek((AppleSectorOffset[_roomTracks[res]] + _roomSectors[res]) * 256);
} else {
- File::seek((C64SectorOffset[_roomTracks[res]] + _roomSectors[res]) * 256);
+ _baseStream->seek((C64SectorOffset[_roomTracks[res]] + _roomSectors[res]) * 256);
}
for (i = 0; i < _resourcesPerFile[res]; i++) {
@@ -505,11 +511,12 @@ void ScummDiskImage::close() {
free(_buf);
_buf = nullptr;
- File::close();
+ _baseStream.reset();
+ _debugName.clear();
}
bool ScummDiskImage::openSubFile(const Common::String &filename) {
- assert(isOpen());
+ assert(_baseStream);
const char *ext = strrchr(filename.c_str(), '.');
char resNum[3];
diff --git a/engines/scumm/file.h b/engines/scumm/file.h
index d84bf520270..0f956c60aaa 100644
--- a/engines/scumm/file.h
+++ b/engines/scumm/file.h
@@ -29,21 +29,28 @@
namespace Scumm {
-class BaseScummFile : public Common::File {
+class BaseScummFile : public Common::SeekableReadStream {
protected:
byte _encbyte;
+ Common::ScopedPtr<Common::SeekableReadStream> _baseStream;
+ Common::String _debugName;
public:
BaseScummFile() : _encbyte(0) {}
void setEnc(byte value) { _encbyte = value; }
- bool open(const Common::Path &filename) override = 0;
+ virtual bool open(const Common::Path &filename) = 0;
virtual bool openSubFile(const Common::String &filename) = 0;
+ virtual void close();
int64 pos() const override = 0;
int64 size() const override = 0;
bool seek(int64 offs, int whence = SEEK_SET) override = 0;
+ Common::String getDebugName() const { return _debugName; }
+
+ bool isOpen() const { return !!_baseStream; }
+
// Unused
#if 0
virtual bool eos() const = 0;
diff --git a/engines/scumm/file_nes.cpp b/engines/scumm/file_nes.cpp
index 3a9c82f81b8..c21333ebe12 100644
--- a/engines/scumm/file_nes.cpp
+++ b/engines/scumm/file_nes.cpp
@@ -934,7 +934,7 @@ static uint16 write_word(Common::WriteStream *out, uint16 val) {
byte ScummNESFile::fileReadByte() {
byte b = 0;
- File::read(&b, 1);
+ _baseStream->read(&b, 1);
return b;
}
@@ -956,7 +956,7 @@ uint16 ScummNESFile::extractResource(Common::WriteStream *output, const Resource
if ((res->offset == 0) && (res->length == 0))
return 0; /* there are 8 scripts that are zero bytes long, so we should skip them */
- File::seek(res->offset, SEEK_SET);
+ _baseStream->seek(res->offset, SEEK_SET);
switch (type) {
case NES_GLOBDATA:
@@ -984,8 +984,8 @@ uint16 ScummNESFile::extractResource(Common::WriteStream *output, const Resource
reslen += write_byte(output, fileReadByte());
}
- if (File::pos() - res->offset != res->length)
- error("extract_resource - length mismatch while extracting graphics resource (was %04X, should be %04X)", (int32)File::pos() - res->offset, res->length);
+ if (_baseStream->pos() - res->offset != res->length)
+ error("extract_resource - length mismatch while extracting graphics resource (was %04X, should be %04X)", (int32)_baseStream->pos() - res->offset, res->length);
break;
@@ -996,7 +996,7 @@ uint16 ScummNESFile::extractResource(Common::WriteStream *output, const Resource
if (len != res->length)
error("extract_resource - length mismatch while extracting room/script resource (was %04X, should be %04X)", len, res->length);
- File::seek(-2, SEEK_CUR);
+ _baseStream->seek(-2, SEEK_CUR);
for (i = 0; i < len; i++)
reslen += write_byte(output, fileReadByte());
@@ -1047,8 +1047,8 @@ uint16 ScummNESFile::extractResource(Common::WriteStream *output, const Resource
} else
error("extract_resource - unknown sound type %d/%d detected",val,cnt);
- if (File::pos() - res->offset != res->length)
- error("extract_resource - length mismatch while extracting sound resource (was %04X, should be %04X)", (int32)File::pos() - res->offset, res->length);
+ if (_baseStream->pos() - res->offset != res->length)
+ error("extract_resource - length mismatch while extracting sound resource (was %04X, should be %04X)", (int32)_baseStream->pos() - res->offset, res->length);
break;
@@ -1364,7 +1364,7 @@ bool ScummNESFile::open(const Common::Path &filename) {
if (_ROMset == kROMsetNum) {
Common::String md5str;
- File f;
+ Common::File f;
f.open(filename);
if (f.isOpen())
md5str = Common::computeStreamMD5AsString(f);
@@ -1400,7 +1400,9 @@ bool ScummNESFile::open(const Common::Path &filename) {
}
}
- if (File::open(filename)) {
+ _baseStream.reset(SearchMan.createReadStreamForMember(filename));
+ _debugName = filename.toString();
+ if (_baseStream) {
delete _stream;
_stream = nullptr;
@@ -1420,11 +1422,12 @@ void ScummNESFile::close() {
free(_buf);
_buf = nullptr;
- File::close();
+ _baseStream.reset();
+ _debugName.clear();
}
bool ScummNESFile::openSubFile(const Common::String &filename) {
- assert(isOpen());
+ assert(_baseStream);
const char *ext = strrchr(filename.c_str(), '.');
char resNum[3];
diff --git a/engines/scumm/imuse_digi/dimuse_bndmgr.cpp b/engines/scumm/imuse_digi/dimuse_bndmgr.cpp
index c4e6353e5e8..96d6b7eac22 100644
--- a/engines/scumm/imuse_digi/dimuse_bndmgr.cpp
+++ b/engines/scumm/imuse_digi/dimuse_bndmgr.cpp
@@ -235,7 +235,7 @@ bool BundleMgr::loadCompTable(int32 index) {
_file->seek(4, SEEK_CUR);
_lastBlockDecompressedSize = _file->readUint32BE();
if (tag != MKTAG('C','O','M','P')) {
- debug("BundleMgr::loadCompTable() Compressed sound %d (%s:%d) invalid (%s)", index, _file->getName(), _bundleTable[index].offset, tag2str(tag));
+ debug("BundleMgr::loadCompTable() Compressed sound %d (%s:%d) invalid (%s)", index, _file->getDebugName().c_str(), _bundleTable[index].offset, tag2str(tag));
return false;
}
diff --git a/engines/scumm/resource.cpp b/engines/scumm/resource.cpp
index 303532215b0..2501962fada 100644
--- a/engines/scumm/resource.cpp
+++ b/engines/scumm/resource.cpp
@@ -706,7 +706,7 @@ int ScummEngine::loadResource(ResType type, ResId idx) {
"while trying to load res (%s,%d) in room %d at %d+%d in file %s",
tag2str(tag), tag2str(_res->_types[type]._tag),
nameOfResType(type), idx, roomNr,
- _fileOffset, fileOffs, _fileHandle->getName());
+ _fileOffset, fileOffs, _fileHandle->getDebugName().c_str());
}
size = _fileHandle->readUint32BE();
Commit: 4479f1438f48177a8f569f2f6b2a919c6b2ad20f
https://github.com/scummvm/scummvm/commit/4479f1438f48177a8f569f2f6b2a919c6b2ad20f
Author: Vladimir Serbinenko (phcoder at gmail.com)
Date: 2023-05-10T22:44:04+02:00
Commit Message:
SCUMM: Detect macbinary files
Changed paths:
engines/scumm/detection_internal.h
diff --git a/engines/scumm/detection_internal.h b/engines/scumm/detection_internal.h
index 24e8959da0b..44555a881fb 100644
--- a/engines/scumm/detection_internal.h
+++ b/engines/scumm/detection_internal.h
@@ -23,6 +23,7 @@
#define SCUMM_DETECTION_INTERNAL_H
#include "common/debug.h"
+#include "common/macresman.h"
#include "common/md5.h"
#include "common/punycode.h"
#include "common/translation.h"
@@ -463,8 +464,14 @@ static void detectGames(const Common::FSList &fslist, Common::List<DetectorResul
// exist in the directory we are looking at, we can skip to the next
// one immediately.
Common::String file(generateFilenameForDetection(gfp->pattern, gfp->genMethod, gfp->platform));
- if (!fileMD5Map.contains(file))
- continue;
+ Common::Platform platform = gfp->platform;
+ if (!fileMD5Map.contains(file)) {
+ if (fileMD5Map.contains(file + ".bin") && (platform == Common::Platform::kPlatformMacintosh || platform == Common::Platform::kPlatformUnknown)) {
+ file += ".bin";
+ platform = Common::Platform::kPlatformMacintosh;
+ } else
+ continue;
+ }
// Reset the DetectorResult variable.
dr.fp.pattern = gfp->pattern;
@@ -506,10 +513,26 @@ static void detectGames(const Common::FSList &fslist, Common::List<DetectorResul
if (tmp)
md5str = computeStreamMD5AsString(*tmp, kMD5FileSizeLimit);
if (!md5str.empty()) {
+ int filesize = tmp->size();
d.md5 = md5str;
d.md5Entry = findInMD5Table(md5str.c_str());
+ if (!d.md5Entry && (platform == Common::Platform::kPlatformMacintosh || platform == Common::Platform::kPlatformUnknown)) {
+ Common::SeekableReadStream *dataStream = Common::MacResManager::openDataForkFromMacBinary(tmp);
+ if (dataStream) {
+ Common::String dataMD5 = computeStreamMD5AsString(*dataStream, kMD5FileSizeLimit);
+ const MD5Table *dataMD5Entry = findInMD5Table(dataMD5.c_str());
+ if (dataMD5Entry) {
+ d.md5 = dataMD5;
+ d.md5Entry = dataMD5Entry;
+ filesize = dataStream->size();
+ platform = Common::Platform::kPlatformMacintosh;
+ }
+ delete dataStream;
+ }
+ }
+
dr.md5 = d.md5;
if (d.md5Entry) {
@@ -517,7 +540,6 @@ static void detectGames(const Common::FSList &fslist, Common::List<DetectorResul
computeGameSettingsFromMD5(fslist, gfp, d.md5Entry, dr);
// Print some debug info.
- int filesize = tmp->size();
debugC(1, kDebugGlobalDetection, "SCUMM detector found matching file '%s' with MD5 %s, size %d\n",
file.c_str(), md5str.c_str(), filesize);
@@ -568,8 +590,8 @@ static void detectGames(const Common::FSList &fslist, Common::List<DetectorResul
dr.game = *g;
dr.extra = g->variant; // FIXME: We (ab)use 'variant' for the 'extra' description for now.
- if (gfp->platform != Common::kPlatformUnknown)
- dr.game.platform = gfp->platform;
+ if (platform != Common::kPlatformUnknown)
+ dr.game.platform = platform;
// If a variant has been specified, use that!
Commit: b06893a692028d531ddfbf26ebdb6bb27bd67d05
https://github.com/scummvm/scummvm/commit/b06893a692028d531ddfbf26ebdb6bb27bd67d05
Author: Vladimir Serbinenko (phcoder at gmail.com)
Date: 2023-05-10T22:44:04+02:00
Commit Message:
SCUMM: Support extracting resources from macbinary
Changed paths:
engines/scumm/charset.cpp
engines/scumm/file.cpp
engines/scumm/file.h
engines/scumm/he/sound_he.cpp
engines/scumm/imuse_digi/dimuse_bndmgr.cpp
engines/scumm/imuse_digi/dimuse_bndmgr.h
engines/scumm/imuse_digi/dimuse_sndmgr.cpp
engines/scumm/insane/insane.cpp
engines/scumm/nut_renderer.cpp
engines/scumm/players/player_he.cpp
engines/scumm/scumm.cpp
engines/scumm/smush/smush_player.cpp
engines/scumm/sound.cpp
engines/scumm/string.cpp
diff --git a/engines/scumm/charset.cpp b/engines/scumm/charset.cpp
index d5f8f38496c..829879d20b3 100644
--- a/engines/scumm/charset.cpp
+++ b/engines/scumm/charset.cpp
@@ -66,7 +66,7 @@ void ScummEngine::loadCJKFont() {
return;
}
- ScummFile fp;
+ ScummFile fp(this);
if (_game.version <= 5 && _game.platform == Common::kPlatformFMTowns && _language == Common::JA_JPN) { // FM-TOWNS v3 / v5 Kanji
#if defined(DISABLE_TOWNS_DUAL_LAYER_MODE) || !defined(USE_RGB_COLOR)
diff --git a/engines/scumm/file.cpp b/engines/scumm/file.cpp
index acc11619176..7a0de987ed9 100644
--- a/engines/scumm/file.cpp
+++ b/engines/scumm/file.cpp
@@ -20,7 +20,9 @@
*/
#include "scumm/file.h"
+#include "scumm/scumm.h"
+#include "common/macresman.h"
#include "common/memstream.h"
#include "common/substream.h"
@@ -35,7 +37,7 @@ void BaseScummFile::close() {
#pragma mark --- ScummFile ---
#pragma mark -
-ScummFile::ScummFile() : _subFileStart(0), _subFileLen(0), _myEos(false) {
+ScummFile::ScummFile(const ScummEngine *vm) : _subFileStart(0), _subFileLen(0), _myEos(false), _isMac(vm->_game.platform == Common::kPlatformMacintosh) {
}
void ScummFile::setSubfileRange(int32 start, int32 len) {
@@ -55,7 +57,9 @@ void ScummFile::resetSubfile() {
}
bool ScummFile::open(const Common::Path &filename) {
- _baseStream.reset(SearchMan.createReadStreamForMember(filename));
+ _baseStream.reset(_isMac ?
+ Common::MacResManager::openFileOrDataFork(filename) :
+ SearchMan.createReadStreamForMember(filename));
_debugName = filename.toString();
if (_baseStream) {
resetSubfile();
diff --git a/engines/scumm/file.h b/engines/scumm/file.h
index 0f956c60aaa..9ae46a54819 100644
--- a/engines/scumm/file.h
+++ b/engines/scumm/file.h
@@ -29,6 +29,8 @@
namespace Scumm {
+class ScummEngine;
+
class BaseScummFile : public Common::SeekableReadStream {
protected:
byte _encbyte;
@@ -63,12 +65,13 @@ protected:
int32 _subFileStart;
int32 _subFileLen;
bool _myEos; // Have we read past the end of the subfile?
+ bool _isMac;
void setSubfileRange(int32 start, int32 len);
void resetSubfile();
public:
- ScummFile();
+ explicit ScummFile(const ScummEngine *vm);
bool open(const Common::Path &filename) override;
bool openSubFile(const Common::String &filename) override;
@@ -142,7 +145,7 @@ private:
bool openWithSubRange(const Common::String &filename, int32 subFileStart, int32 subFileLen);
public:
- ScummSteamFile(const SteamIndexFile &indexFile) : ScummFile(), _indexFile(indexFile) {}
+ ScummSteamFile(const ScummEngine *vm, const SteamIndexFile &indexFile) : ScummFile(vm), _indexFile(indexFile) {}
bool open(const Common::Path &filename) override;
};
diff --git a/engines/scumm/he/sound_he.cpp b/engines/scumm/he/sound_he.cpp
index 0c50824e9e9..279e82c286a 100644
--- a/engines/scumm/he/sound_he.cpp
+++ b/engines/scumm/he/sound_he.cpp
@@ -891,7 +891,7 @@ void SoundHE::startHETalkSound(uint32 offset) {
return;
}
- ScummFile file;
+ ScummFile file(_vm);
if (!_vm->openFile(file, _sfxFilename)) {
warning("startHETalkSound: Could not open speech file %s", _sfxFilename.c_str());
return;
diff --git a/engines/scumm/imuse_digi/dimuse_bndmgr.cpp b/engines/scumm/imuse_digi/dimuse_bndmgr.cpp
index 96d6b7eac22..048e01152e6 100644
--- a/engines/scumm/imuse_digi/dimuse_bndmgr.cpp
+++ b/engines/scumm/imuse_digi/dimuse_bndmgr.cpp
@@ -29,7 +29,7 @@
namespace Scumm {
-BundleDirCache::BundleDirCache() {
+BundleDirCache::BundleDirCache(const ScummEngine *vm) : _vm(vm) {
for (int fileId = 0; fileId < ARRAYSIZE(_bundleDirCache); fileId++) {
_bundleDirCache[fileId].bundleTable = nullptr;
_bundleDirCache[fileId].fileName[0] = 0;
@@ -79,7 +79,7 @@ int BundleDirCache::matchFile(const char *filename) {
}
if (!found) {
- ScummFile file;
+ ScummFile file(_vm);
if (g_scumm->openFile(file, filename) == false) {
error("BundleDirCache::matchFile() Can't open bundle file: %s", filename);
@@ -137,7 +137,7 @@ int BundleDirCache::matchFile(const char *filename) {
}
}
-BundleMgr::BundleMgr(BundleDirCache *cache) {
+BundleMgr::BundleMgr(const ScummEngine *vm, BundleDirCache *cache) {
_cache = cache;
_bundleTable = nullptr;
_compTable = nullptr;
@@ -146,7 +146,7 @@ BundleMgr::BundleMgr(BundleDirCache *cache) {
_lastBlockDecompressedSize = 0;
_curSampleId = -1;
_fileBundleId = -1;
- _file = new ScummFile();
+ _file = new ScummFile(vm);
_compInputBuff = nullptr;
}
diff --git a/engines/scumm/imuse_digi/dimuse_bndmgr.h b/engines/scumm/imuse_digi/dimuse_bndmgr.h
index ec7993e78ed..005b6edaa6b 100644
--- a/engines/scumm/imuse_digi/dimuse_bndmgr.h
+++ b/engines/scumm/imuse_digi/dimuse_bndmgr.h
@@ -53,8 +53,9 @@ private:
IndexNode *indexTable;
} _bundleDirCache[4];
+ const ScummEngine *_vm;
public:
- BundleDirCache();
+ BundleDirCache(const ScummEngine *vm);
~BundleDirCache();
int matchFile(const char *filename);
@@ -67,6 +68,7 @@ public:
class BundleMgr {
private:
+ const ScummEngine *_vm;
struct CompTable {
int32 offset;
@@ -96,7 +98,7 @@ private:
public:
- BundleMgr(BundleDirCache *_cache);
+ BundleMgr(const ScummEngine *vm, BundleDirCache *_cache);
~BundleMgr();
bool open(const char *filename, bool &isCompressed, bool errorFlag = false);
diff --git a/engines/scumm/imuse_digi/dimuse_sndmgr.cpp b/engines/scumm/imuse_digi/dimuse_sndmgr.cpp
index 93cf727ddd1..132b8ed7339 100644
--- a/engines/scumm/imuse_digi/dimuse_sndmgr.cpp
+++ b/engines/scumm/imuse_digi/dimuse_sndmgr.cpp
@@ -42,7 +42,7 @@ ImuseDigiSndMgr::ImuseDigiSndMgr(ScummEngine *scumm) {
}
_vm = scumm;
_disk = 0;
- _cacheBundleDir = new BundleDirCache();
+ _cacheBundleDir = new BundleDirCache(scumm);
assert(_cacheBundleDir);
BundleCodecs::initializeImcTables();
}
@@ -72,7 +72,7 @@ bool ImuseDigiSndMgr::openMusicBundle(SoundDesc *sound, int &disk) {
bool result = false;
bool compressed = false;
- sound->bundle = new BundleMgr(_cacheBundleDir);
+ sound->bundle = new BundleMgr(_vm, _cacheBundleDir);
assert(sound->bundle);
if (_vm->_game.id == GID_CMI) {
if (_vm->_game.features & GF_DEMO) {
@@ -108,7 +108,7 @@ bool ImuseDigiSndMgr::openVoiceBundle(SoundDesc *sound, int &disk) {
bool result = false;
bool compressed = false;
- sound->bundle = new BundleMgr(_cacheBundleDir);
+ sound->bundle = new BundleMgr(_vm, _cacheBundleDir);
assert(sound->bundle);
if (_vm->_game.id == GID_CMI) {
if (_vm->_game.features & GF_DEMO) {
diff --git a/engines/scumm/insane/insane.cpp b/engines/scumm/insane/insane.cpp
index 76ef262c2f4..cf9bfe85a29 100644
--- a/engines/scumm/insane/insane.cpp
+++ b/engines/scumm/insane/insane.cpp
@@ -611,7 +611,7 @@ int32 Insane::processKeyboard() {
}
void Insane::readFileToMem(const char *name, byte **buf) {
- ScummFile in;
+ ScummFile in(_vm);
uint32 len;
if (!_vm->openFile(in, name))
diff --git a/engines/scumm/nut_renderer.cpp b/engines/scumm/nut_renderer.cpp
index 9a0a7164f59..78c59152deb 100644
--- a/engines/scumm/nut_renderer.cpp
+++ b/engines/scumm/nut_renderer.cpp
@@ -101,7 +101,7 @@ void NutRenderer::codec21(byte *dst, const byte *src, int width, int height, int
}
void NutRenderer::loadFont(const char *filename) {
- ScummFile file;
+ ScummFile file(_vm);
_vm->openFile(file, filename);
if (!file.isOpen()) {
error("NutRenderer::loadFont() Can't open font file: %s", filename);
diff --git a/engines/scumm/players/player_he.cpp b/engines/scumm/players/player_he.cpp
index 91c19811ec0..3f7d723753c 100644
--- a/engines/scumm/players/player_he.cpp
+++ b/engines/scumm/players/player_he.cpp
@@ -134,7 +134,7 @@ int Player_HE::getMusicTimer() {
}
void Player_HE::loadAdLibBank() {
- ScummFile file;
+ ScummFile file(_vm);
Common::String drvName;
char entryName[14];
uint32 tag, entrySize, fileSize;
diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp
index 6707eaf7c16..3092a04dd12 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -1042,7 +1042,7 @@ Common::Error ScummEngine::init() {
// code in openResourceFile() (and in the Sound class, for MONSTER.SOU
// handling).
assert(_game.version >= 5 && _game.heversion == 0);
- _fileHandle = new ScummFile();
+ _fileHandle = new ScummFile(this);
_containerFile = _filenamePattern.pattern;
@@ -1096,11 +1096,11 @@ Common::Error ScummEngine::init() {
if (!indexFile || indexFile->id != _game.id) {
error("Couldn't find index file description for Steam version");
} else {
- _fileHandle = new ScummSteamFile(*indexFile);
+ _fileHandle = new ScummSteamFile(this, *indexFile);
}
} else {
// Regular access, no container file involved
- _fileHandle = new ScummFile();
+ _fileHandle = new ScummFile(this);
}
}
@@ -1515,8 +1515,8 @@ void ScummEngine_v7::setupScumm(const Common::String &macResourceFile) {
// COMI demo is excluded from the count since it appears it can't be compressed
// DIG demo uses raw VOC files for speech instead of a MONSTER.SOU file
if ((_game.id == GID_CMI || _game.id == GID_DIG) && !(_game.features & GF_DEMO)) {
- BundleDirCache *ch = new BundleDirCache();
- BundleMgr *bnd = new BundleMgr(ch);
+ BundleDirCache *ch = new BundleDirCache(this);
+ BundleMgr *bnd = new BundleMgr(this, ch);
filesAreCompressed |= bnd->isExtCompBun(_game.id);
delete bnd;
delete ch;
diff --git a/engines/scumm/smush/smush_player.cpp b/engines/scumm/smush/smush_player.cpp
index 365f1e5755b..82b62efce38 100644
--- a/engines/scumm/smush/smush_player.cpp
+++ b/engines/scumm/smush/smush_player.cpp
@@ -182,7 +182,7 @@ public:
static StringResource *getStrings(ScummEngine *vm, const char *file, bool is_encoded) {
debugC(DEBUG_SMUSH, "trying to read text resources from %s", file);
- ScummFile theFile;
+ ScummFile theFile(vm);
vm->openFile(theFile, file);
if (!theFile.isOpen()) {
@@ -1023,7 +1023,7 @@ void SmushPlayer::parseNextFrame() {
if (_seekFile.size() > 0) {
delete _base;
- ScummFile *tmp = new ScummFile();
+ ScummFile *tmp = new ScummFile(_vm);
if (!g_scumm->openFile(*tmp, _seekFile))
error("SmushPlayer: Unable to open file %s", _seekFile.c_str());
_base = tmp;
@@ -1190,7 +1190,7 @@ void SmushPlayer::unpause() {
void SmushPlayer::play(const char *filename, int32 speed, int32 offset, int32 startFrame) {
// Verify the specified file exists
- ScummFile f;
+ ScummFile f(_vm);
_vm->openFile(f, filename);
if (!f.isOpen()) {
warning("SmushPlayer::play() File not found %s", filename);
diff --git a/engines/scumm/sound.cpp b/engines/scumm/sound.cpp
index f6acaf2affc..156a795d3af 100644
--- a/engines/scumm/sound.cpp
+++ b/engines/scumm/sound.cpp
@@ -763,7 +763,7 @@ void Sound::startTalkSound(uint32 offset, uint32 b, int mode, Audio::SoundHandle
return;
}
- file.reset(new ScummFile());
+ file.reset(new ScummFile(_vm));
if (!file)
error("startTalkSound: Out of memory");
@@ -793,7 +793,7 @@ void Sound::startTalkSound(uint32 offset, uint32 b, int mode, Audio::SoundHandle
int totalOffset, soundSize, fileSize, headerTag, vctlBlockSize;
if (_vm->_voiceMode != 2) {
- file.reset(new ScummFile());
+ file.reset(new ScummFile(_vm));
if (!file)
error("startTalkSound: Out of memory");
@@ -910,7 +910,7 @@ void Sound::startTalkSound(uint32 offset, uint32 b, int mode, Audio::SoundHandle
offset += 8;
}
- file.reset(new ScummFile());
+ file.reset(new ScummFile(_vm));
if (!file)
error("startTalkSound: Out of memory");
@@ -1256,7 +1256,7 @@ bool Sound::hasSfxFile() const
ScummFile *Sound::restoreDiMUSESpeechFile(const char *fileName) {
Common::ScopedPtr<ScummFile> file;
- file.reset(new ScummFile());
+ file.reset(new ScummFile(_vm));
if (!_vm->openFile(*file, fileName)) {
return NULL;
}
@@ -1305,7 +1305,7 @@ void Sound::setupSfxFile() {
{ nullptr, kVOCMode }
};
- ScummFile file;
+ ScummFile file(_vm);
_offsetTable = nullptr;
_sfxFileEncByte = 0;
_sfxFilename.clear();
diff --git a/engines/scumm/string.cpp b/engines/scumm/string.cpp
index fe1c89575f9..af906813274 100644
--- a/engines/scumm/string.cpp
+++ b/engines/scumm/string.cpp
@@ -1846,7 +1846,7 @@ void ScummEngine_v7::loadLanguageBundle() {
ScummEngine::loadLanguageBundle();
return;
}
- ScummFile file;
+ ScummFile file(this);
int32 size;
if (_game.id == GID_DIG) {
@@ -2137,7 +2137,7 @@ void ScummEngine::loadLanguageBundle() {
return;
}
- ScummFile file;
+ ScummFile file(this);
openFile(file, "korean.trs");
if (!file.isOpen()) {
More information about the Scummvm-git-logs
mailing list