[Scummvm-git-logs] scummvm master -> 8394f8549ba3d7a1e7d97da65291f24467a9cfb4
eriktorbjorn
noreply at scummvm.org
Mon Nov 22 17:39:31 UTC 2021
This automated email contains information about 12 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
8574d19f20 KYRA: First attempt at loading Kyra1 StuffIt archive
509492074a KYRA: Ugly workaround to keep the Mac resource manager alive
767853db01 KYRA: Add archives for the .PAK files inside the StuffIt archive
7dc4fc11cf KYRA: Move MacResManager object out of StuffItLoader
b88713faef KYRA: Read Mac music resources from the StuffIt installer
cb1a6a0e38 KYRA: (LoK/Mac) - cleanup Stuffit code
a76ce525d2 KYRA: Further Mac/LoK audio driver cleanup
3054e32278 KYRA: Move Mac file finding code into Util
9a758940e1 KYRA: (Mac/LoK) - slightly rearrange mac resource detection
18f1382412 KYRA: (LoK/Mac) - cleanup installer archive retrievement
23e3acba0f KYRA: Only create MacResManager when needed
8394f8549b KYRA: Use same MacResManager object throughout findMacResourceFile()
Commit: 8574d19f2044380b6d4b5d07627e8766145dedea
https://github.com/scummvm/scummvm/commit/8574d19f2044380b6d4b5d07627e8766145dedea
Author: Torbjörn Andersson (eriktorbjorn at users.sourceforge.net)
Date: 2021-11-22T18:39:23+01:00
Commit Message:
KYRA: First attempt at loading Kyra1 StuffIt archive
This doesn't work. Not even close.
Changed paths:
common/stuffit.cpp
common/stuffit.h
engines/kyra/detection_tables.h
engines/kyra/resource/resource.cpp
engines/kyra/resource/resource.h
engines/kyra/resource/resource_intern.cpp
engines/kyra/resource/resource_intern.h
diff --git a/common/stuffit.cpp b/common/stuffit.cpp
index 43d46fe038..082470e161 100644
--- a/common/stuffit.cpp
+++ b/common/stuffit.cpp
@@ -43,6 +43,7 @@ public:
~StuffItArchive() override;
bool open(const Common::String &filename);
+ bool open(Common::SeekableReadStream *stream);
void close();
bool isOpen() const { return _stream != nullptr; }
@@ -90,9 +91,14 @@ static const uint32 s_magicNumbers[] = {
};
bool StuffItArchive::open(const Common::String &filename) {
+ Common::SeekableReadStream *stream = SearchMan.createReadStreamForMember(filename);
+ return open(stream);
+}
+
+bool StuffItArchive::open(Common::SeekableReadStream *stream) {
close();
- _stream = SearchMan.createReadStreamForMember(filename);
+ _stream = stream;
if (!_stream)
return false;
@@ -195,7 +201,8 @@ bool StuffItArchive::open(const Common::String &filename) {
}
void StuffItArchive::close() {
- delete _stream; _stream = nullptr;
+ delete _stream;
+ _stream = nullptr;
_map.clear();
}
@@ -537,4 +544,15 @@ Common::Archive *createStuffItArchive(const Common::String &fileName) {
return archive;
}
+Common::Archive *createStuffItArchive(Common::SeekableReadStream *stream) {
+ StuffItArchive *archive = new StuffItArchive();
+
+ if (!archive->open(stream)) {
+ delete archive;
+ return nullptr;
+ }
+
+ return archive;
+}
+
} // End of namespace Common
diff --git a/common/stuffit.h b/common/stuffit.h
index caf4479368..11b1861939 100644
--- a/common/stuffit.h
+++ b/common/stuffit.h
@@ -25,6 +25,7 @@
* StuffIt decompressor used in engines:
* - grim
* - groovie
+ * - kyra
*/
#ifndef COMMON_STUFFIT_H
@@ -43,6 +44,7 @@ namespace Common {
class Archive;
class String;
+class SeekableReadStream;
/**
* This factory method creates an Archive instance corresponding to the content
@@ -51,6 +53,7 @@ class String;
* May return 0 in case of a failure.
*/
Archive *createStuffItArchive(const String &fileName);
+Archive *createStuffItArchive(SeekableReadStream *stream);
/** @} */
diff --git a/engines/kyra/detection_tables.h b/engines/kyra/detection_tables.h
index 3dafe45edb..69761ee611 100644
--- a/engines/kyra/detection_tables.h
+++ b/engines/kyra/detection_tables.h
@@ -325,6 +325,19 @@ const KYRAGameDescription adGameDescs[] = {
KYRA1_FLOPPY_FLAGS
},
+ {
+ {
+ "kyra1",
+ "StuffIt",
+ AD_ENTRY1s("xn--Install Legend of Kyrandia-jf8p", "1d763e991c787431cac3786afbbdae72", 53899),
+ Common::EN_ANY,
+ Common::kPlatformMacintosh,
+ ADGF_MACRESFORK,
+ GUIO3(GUIO_NOSPEECH, GUIO_MIDIGM, GUIO_RENDERVGA)
+ },
+ KYRA1_FLOPPY_CMP_FLAGS
+ },
+
{ // FM-TOWNS version
{
"kyra1",
diff --git a/engines/kyra/resource/resource.cpp b/engines/kyra/resource/resource.cpp
index 4a376e532c..fe78cdd3af 100644
--- a/engines/kyra/resource/resource.cpp
+++ b/engines/kyra/resource/resource.cpp
@@ -24,6 +24,8 @@
#include "kyra/resource/resource_intern.h"
#include "common/config-manager.h"
+#include "common/macresman.h"
+#include "common/punycode.h"
#include "common/fs.h"
namespace Kyra {
@@ -62,7 +64,41 @@ bool Resource::reset() {
if (!dir.exists() || !dir.isDirectory())
error("invalid game path '%s'", dir.getPath().c_str());
- if (_vm->game() == GI_KYRA1 || _vm->game() == GI_EOB1) {
+ if (_vm->game() == GI_KYRA1 && _vm->gameFlags().platform == Common::kPlatformMacintosh && _vm->gameFlags().useInstallerPackage) {
+ const char *const tryFileNames[] = {
+ "Install Legend of Kyrandia",
+ "Install Legend of Kyrandia\xaa"
+ };
+
+ const Common::CodePage tryCodePages[] = {
+ Common::kMacRoman,
+ Common::kISO8859_1
+ };
+
+ Common::MacResManager resource;
+ Common::String kyraInstaller;
+
+ for (int i = 0; i < ARRAYSIZE(tryCodePages); ++i) {
+ for (int ii = 0; ii < ARRAYSIZE(tryFileNames); ++ii) {
+ Common::U32String fn(tryFileNames[ii], tryCodePages[i]);
+ kyraInstaller = fn.encode(Common::kUtf8);
+ if (resource.exists(kyraInstaller))
+ break;
+ kyraInstaller = Common::punycode_encodefilename(fn);
+ if (resource.exists(kyraInstaller))
+ break;
+ kyraInstaller.clear();
+ }
+ if (!kyraInstaller.empty())
+ break;
+ }
+
+ if (kyraInstaller.empty()) {
+ error("Could not find Legend of Kyrandia installer file");
+ }
+
+ _files.add("installer", loadStuffItArchive(kyraInstaller));
+ } else if (_vm->game() == GI_KYRA1 || _vm->game() == GI_EOB1) {
// We only need kyra.dat for the demo.
if (_vm->gameFlags().isDemo && !_vm->gameFlags().isTalkie)
return true;
@@ -375,6 +411,19 @@ Common::Archive *Resource::loadInstallerArchive(const Common::String &file, cons
return archive;
}
+Common::Archive *Resource::loadStuffItArchive(const Common::String &file) {
+ ArchiveMap::iterator cachedArchive = _archiveCache.find(file);
+ if (cachedArchive != _archiveCache.end())
+ return cachedArchive->_value;
+
+ Common::Archive *archive = StuffItLoader::load(this, file);
+ if (!archive)
+ return nullptr;
+
+ _archiveCache[file] = archive;
+ return archive;
+}
+
#pragma mark -
void Resource::initializeLoaders() {
diff --git a/engines/kyra/resource/resource.h b/engines/kyra/resource/resource.h
index a1d63dc53b..d9617e76c1 100644
--- a/engines/kyra/resource/resource.h
+++ b/engines/kyra/resource/resource.h
@@ -94,6 +94,7 @@ protected:
Common::Archive *loadArchive(const Common::String &name, Common::ArchiveMemberPtr member);
Common::Archive *loadInstallerArchive(const Common::String &file, const Common::String &ext, const uint8 offset);
+ Common::Archive *loadStuffItArchive(const Common::String &file);
bool loadProtectedFiles(const char *const * list);
diff --git a/engines/kyra/resource/resource_intern.cpp b/engines/kyra/resource/resource_intern.cpp
index 01f87b4817..6981f03fa1 100644
--- a/engines/kyra/resource/resource_intern.cpp
+++ b/engines/kyra/resource/resource_intern.cpp
@@ -26,6 +26,8 @@
#include "common/endian.h"
#include "common/memstream.h"
#include "common/substream.h"
+#include "common/macresman.h"
+#include "common/stuffit.h"
namespace Kyra {
@@ -927,7 +929,7 @@ struct InsArchive {
uint32 totalSize;
};
-} // end of anonymouse namespace
+} // end of anonymous namespace
class CmpVocDecoder {
public:
@@ -1198,6 +1200,20 @@ Common::Archive *InstallerLoader::load(Resource *owner, const Common::String &fi
return new CachedArchive(fileList);
}
+Common::Archive *StuffItLoader::load(Resource *owner, const Common::String &filename) {
+ Common::MacResManager resource;
+
+ if (resource.open(filename)) {
+ Common::SeekableReadStream *stream = resource.getDataFork();
+ if (stream) {
+ Common::Archive *archive = Common::createStuffItArchive(stream);
+ return archive;
+ }
+ }
+
+ error("StuffItLoader::load: Could not load %s", filename.c_str());
+}
+
CmpVocDecoder::CmpVocDecoder() {
_tbl1 = new int32[4000];
_p1 = _tbl1 + 2000;
diff --git a/engines/kyra/resource/resource_intern.h b/engines/kyra/resource/resource_intern.h
index b11a2618eb..1225254537 100644
--- a/engines/kyra/resource/resource_intern.h
+++ b/engines/kyra/resource/resource_intern.h
@@ -142,6 +142,11 @@ public:
static Common::Archive *load(Resource *owner, const Common::String &filename, const Common::String &extension, const uint8 offset);
};
+class StuffItLoader {
+public:
+ static Common::Archive *load(Resource *owner, const Common::String &filename);
+};
+
class EndianAwareStreamWrapper : public Common::SeekableReadStreamEndian {
public:
EndianAwareStreamWrapper(Common::SeekableReadStream *stream, bool bigEndian, bool disposeAfterUse = true) : Common::SeekableReadStreamEndian(bigEndian), Common::ReadStreamEndian(bigEndian), _stream(stream), _dispose(disposeAfterUse) {}
Commit: 509492074ab56c8d1bf0e79c6c5b49a0e92d847f
https://github.com/scummvm/scummvm/commit/509492074ab56c8d1bf0e79c6c5b49a0e92d847f
Author: Torbjörn Andersson (eriktorbjorn at users.sourceforge.net)
Date: 2021-11-22T18:39:23+01:00
Commit Message:
KYRA: Ugly workaround to keep the Mac resource manager alive
Changed paths:
engines/kyra/resource/resource_intern.cpp
diff --git a/engines/kyra/resource/resource_intern.cpp b/engines/kyra/resource/resource_intern.cpp
index 6981f03fa1..39338349fa 100644
--- a/engines/kyra/resource/resource_intern.cpp
+++ b/engines/kyra/resource/resource_intern.cpp
@@ -1201,7 +1201,9 @@ Common::Archive *InstallerLoader::load(Resource *owner, const Common::String &fi
}
Common::Archive *StuffItLoader::load(Resource *owner, const Common::String &filename) {
- Common::MacResManager resource;
+ // TODO: The resource manager has to be alive for the duration of the
+ // game but there has to be a better way...
+ static Common::MacResManager resource;
if (resource.open(filename)) {
Common::SeekableReadStream *stream = resource.getDataFork();
Commit: 767853db019dffba5f524b00f65bc25cdb098266
https://github.com/scummvm/scummvm/commit/767853db019dffba5f524b00f65bc25cdb098266
Author: Torbjörn Andersson (eriktorbjorn at users.sourceforge.net)
Date: 2021-11-22T18:39:23+01:00
Commit Message:
KYRA: Add archives for the .PAK files inside the StuffIt archive
I will have to look out for memory leaks later.
Changed paths:
engines/kyra/resource/resource.cpp
diff --git a/engines/kyra/resource/resource.cpp b/engines/kyra/resource/resource.cpp
index fe78cdd3af..001496ec85 100644
--- a/engines/kyra/resource/resource.cpp
+++ b/engines/kyra/resource/resource.cpp
@@ -97,7 +97,16 @@ bool Resource::reset() {
error("Could not find Legend of Kyrandia installer file");
}
- _files.add("installer", loadStuffItArchive(kyraInstaller));
+ Common::Archive *archive = loadStuffItArchive(kyraInstaller);
+ _files.add("installer", archive, 0, false);
+
+ Common::ArchiveMemberList members;
+ archive->listMatchingMembers(members, "*.PAK");
+ for (Common::ArchiveMemberList::const_iterator it = members.begin(); it != members.end(); ++it) {
+ Common::String name = (*it)->getName();
+ Common::Archive *pak = loadArchive(name, *it);
+ _files.add(name, pak, 0, false);
+ }
} else if (_vm->game() == GI_KYRA1 || _vm->game() == GI_EOB1) {
// We only need kyra.dat for the demo.
if (_vm->gameFlags().isDemo && !_vm->gameFlags().isTalkie)
Commit: 7dc4fc11cf8358afd1a4ced6a2e4bf23364ab1a5
https://github.com/scummvm/scummvm/commit/7dc4fc11cf8358afd1a4ced6a2e4bf23364ab1a5
Author: Torbjörn Andersson (eriktorbjorn at users.sourceforge.net)
Date: 2021-11-22T18:39:23+01:00
Commit Message:
KYRA: Move MacResManager object out of StuffItLoader
This fixes a Valgrind warning on exit, I believe.
Changed paths:
engines/kyra/resource/resource.cpp
engines/kyra/resource/resource.h
engines/kyra/resource/resource_intern.cpp
engines/kyra/resource/resource_intern.h
diff --git a/engines/kyra/resource/resource.cpp b/engines/kyra/resource/resource.cpp
index 001496ec85..384859677c 100644
--- a/engines/kyra/resource/resource.cpp
+++ b/engines/kyra/resource/resource.cpp
@@ -54,6 +54,7 @@ Resource::~Resource() {
for (ArchiveMap::iterator i = _archiveCache.begin(); i != _archiveCache.end(); ++i)
delete i->_value;
_archiveCache.clear();
+ _macResMan.close();
}
bool Resource::reset() {
@@ -425,7 +426,7 @@ Common::Archive *Resource::loadStuffItArchive(const Common::String &file) {
if (cachedArchive != _archiveCache.end())
return cachedArchive->_value;
- Common::Archive *archive = StuffItLoader::load(this, file);
+ Common::Archive *archive = StuffItLoader::load(this, file, _macResMan);
if (!archive)
return nullptr;
diff --git a/engines/kyra/resource/resource.h b/engines/kyra/resource/resource.h
index d9617e76c1..6c53db8bb5 100644
--- a/engines/kyra/resource/resource.h
+++ b/engines/kyra/resource/resource.h
@@ -30,6 +30,7 @@
#include "common/list.h"
#include "common/hash-str.h"
#include "common/hashmap.h"
+#include "common/macresman.h"
#include "common/stream.h"
#include "common/ptr.h"
#include "common/archive.h"
@@ -92,6 +93,8 @@ protected:
Common::SearchSet _archiveFiles;
Common::SearchSet _protectedFiles;
+ Common::MacResManager _macResMan;
+
Common::Archive *loadArchive(const Common::String &name, Common::ArchiveMemberPtr member);
Common::Archive *loadInstallerArchive(const Common::String &file, const Common::String &ext, const uint8 offset);
Common::Archive *loadStuffItArchive(const Common::String &file);
diff --git a/engines/kyra/resource/resource_intern.cpp b/engines/kyra/resource/resource_intern.cpp
index 39338349fa..16eac30e4c 100644
--- a/engines/kyra/resource/resource_intern.cpp
+++ b/engines/kyra/resource/resource_intern.cpp
@@ -1200,13 +1200,9 @@ Common::Archive *InstallerLoader::load(Resource *owner, const Common::String &fi
return new CachedArchive(fileList);
}
-Common::Archive *StuffItLoader::load(Resource *owner, const Common::String &filename) {
- // TODO: The resource manager has to be alive for the duration of the
- // game but there has to be a better way...
- static Common::MacResManager resource;
-
- if (resource.open(filename)) {
- Common::SeekableReadStream *stream = resource.getDataFork();
+Common::Archive *StuffItLoader::load(Resource *owner, const Common::String &filename, Common::MacResManager &macResMan) {
+ if (macResMan.open(filename)) {
+ Common::SeekableReadStream *stream = macResMan.getDataFork();
if (stream) {
Common::Archive *archive = Common::createStuffItArchive(stream);
return archive;
diff --git a/engines/kyra/resource/resource_intern.h b/engines/kyra/resource/resource_intern.h
index 1225254537..d70c5ff523 100644
--- a/engines/kyra/resource/resource_intern.h
+++ b/engines/kyra/resource/resource_intern.h
@@ -28,6 +28,7 @@
#include "common/hashmap.h"
#include "common/str.h"
#include "common/list.h"
+#include "common/macresman.h"
#include "common/stream.h"
namespace Kyra {
@@ -144,7 +145,7 @@ public:
class StuffItLoader {
public:
- static Common::Archive *load(Resource *owner, const Common::String &filename);
+ static Common::Archive *load(Resource *owner, const Common::String &filename, Common::MacResManager &macResMan);
};
class EndianAwareStreamWrapper : public Common::SeekableReadStreamEndian {
Commit: b88713faefbac6419db97513b8ac69f83758cf8e
https://github.com/scummvm/scummvm/commit/b88713faefbac6419db97513b8ac69f83758cf8e
Author: Torbjörn Andersson (eriktorbjorn at users.sourceforge.net)
Date: 2021-11-22T18:39:23+01:00
Commit Message:
KYRA: Read Mac music resources from the StuffIt installer
The game appears to be entirely playable from the StuffIt installer now,
but I haven't tested past the start of the game.
Changed paths:
engines/kyra/sound/sound_mac_lok.cpp
engines/kyra/sound/sound_mac_res.h
diff --git a/engines/kyra/sound/sound_mac_lok.cpp b/engines/kyra/sound/sound_mac_lok.cpp
index 8651cd82a2..4237634375 100644
--- a/engines/kyra/sound/sound_mac_lok.cpp
+++ b/engines/kyra/sound/sound_mac_lok.cpp
@@ -27,6 +27,7 @@
#include "common/config-manager.h"
#include "common/macresman.h"
#include "common/punycode.h"
+#include "common/stuffit.h"
#include "audio/mixer.h"
@@ -37,12 +38,17 @@
namespace Kyra {
-SoundMacRes::SoundMacRes() : _macRes(nullptr) {
+SoundMacRes::SoundMacRes(KyraEngine_v1 *vm) : _macInstallerRes(nullptr), _macRes(nullptr), _stuffItArchive(nullptr) {
+ _useInstaller = vm->gameFlags().useInstallerPackage;
_macRes = new Common::MacResManager();
+ if (_useInstaller)
+ _macInstallerRes = new Common::MacResManager();
}
SoundMacRes::~SoundMacRes() {
+ delete _stuffItArchive;
delete _macRes;
+ delete _macInstallerRes;
}
bool SoundMacRes::init() {
@@ -55,6 +61,11 @@ bool SoundMacRes::init() {
// versions, also for punycode encoded files and also for the case where the
// user might have just removed the last character by renaming the file.
+ const char *const tryInstallerNames[] = {
+ "Install Legend of Kyrandia",
+ "Install Legend of Kyrandia\xaa"
+ };
+
const char *const tryExeNames[] = {
"Legend of Kyrandia\xaa",
"Legend of Kyrandia"
@@ -65,9 +76,20 @@ bool SoundMacRes::init() {
Common::kISO8859_1
};
+ const char *const *tryNames;
+ int numTryNames;
+
+ if (_useInstaller) {
+ tryNames = tryInstallerNames;
+ numTryNames = ARRAYSIZE(tryInstallerNames);
+ } else {
+ tryNames = tryExeNames;
+ numTryNames = ARRAYSIZE(tryExeNames);
+ }
+
for (int i = 0; i < ARRAYSIZE(tryCodePages); ++i) {
- for (int ii = 0; ii < ARRAYSIZE(tryExeNames); ++ii) {
- Common::U32String fn(tryExeNames[ii], tryCodePages[i]);
+ for (int ii = 0; ii < numTryNames; ++ii) {
+ Common::U32String fn(tryNames[ii], tryCodePages[i]);
_kyraMacExe = fn.encode(Common::kUtf8);
if (_macRes->exists(_kyraMacExe))
break;
@@ -81,16 +103,25 @@ bool SoundMacRes::init() {
}
if (_kyraMacExe.empty()) {
- warning("SoundMacRes::init(): Legend of Kyrandia resource fork not found");
+ warning("SoundMacRes::init(): Legend of Kyrandia %s not found",
+ _useInstaller ? "installer" : "resource fork");
return false;
}
+ if (_useInstaller) {
+ _macInstallerRes->open(_kyraMacExe);
+ Common::SeekableReadStream *stream = _macInstallerRes->getDataFork();
+ _stuffItArchive = Common::createStuffItArchive(stream);
+ }
+
setQuality(true);
- for (Common::StringArray::iterator i = _resFiles.begin(); i != _resFiles.end(); ++i) {
- if (!_macRes->exists(*i)) {
- warning("SoundMacRes::init(): Error opening data file: '%s'", i->c_str());
- return false;
+ if (!_useInstaller) {
+ for (Common::StringArray::iterator i = _resFiles.begin(); i != _resFiles.end(); ++i) {
+ if (!_macRes->exists(*i)) {
+ warning("SoundMacRes::init(): Error opening data file: '%s'", i->c_str());
+ return false;
+ }
}
}
@@ -114,9 +145,17 @@ bool SoundMacRes::init() {
Common::SeekableReadStream *SoundMacRes::getResource(uint16 id, uint32 type) {
Common::SeekableReadStream *res = nullptr;
+
for (Common::StringArray::iterator i = _resFiles.begin(); i != _resFiles.end(); ++i) {
- if (!_macRes->open(Common::Path(*i)))
- warning("SoundMacRes::getResource(): Error opening data file: '%s'", i->c_str());
+ if (_useInstaller) {
+ if (!_macRes->open(Common::Path(*i), *_stuffItArchive)) {
+ warning("SoundMacRes::getResource(): Error opening archive member: '%s'", i->c_str());
+ }
+ } else {
+ if (!_macRes->open(Common::Path(*i)))
+ warning("SoundMacRes::getResource(): Error opening data file: '%s'", i->c_str());
+ }
+
if ((res = _macRes->getResource(type, id)))
break;
}
@@ -126,7 +165,11 @@ Common::SeekableReadStream *SoundMacRes::getResource(uint16 id, uint32 type) {
void SoundMacRes::setQuality(bool hi) {
_resFiles.clear();
_resFiles.push_back(hi ? "HQ_Music.res" : "LQ_Music.res");
- _resFiles.push_back(_kyraMacExe);
+ if (_useInstaller) {
+ _resFiles.push_back("Legend of Kyrandia\xaa");
+ } else {
+ _resFiles.push_back(_kyraMacExe);
+ }
}
SoundMac::SoundMac(KyraEngine_v1 *vm, Audio::Mixer *mixer) : Sound(vm, mixer), _driver(nullptr), _res(nullptr), _currentResourceSet(-1), _resIDMusic(nullptr), _ready(false) {
@@ -142,7 +185,7 @@ Sound::kType SoundMac::getMusicType() const {
}
bool SoundMac::init(bool hiQuality) {
- _res = new SoundMacRes();
+ _res = new SoundMacRes(_vm);
if (!(_res && _res->init()))
return false;
diff --git a/engines/kyra/sound/sound_mac_res.h b/engines/kyra/sound/sound_mac_res.h
index 22ee684d2d..35e880ef15 100644
--- a/engines/kyra/sound/sound_mac_res.h
+++ b/engines/kyra/sound/sound_mac_res.h
@@ -24,6 +24,7 @@
#define KYRA_SOUND_MACRES_H
namespace Common {
+ class Archive;
class MacResManager;
class String;
template<class T> class Array;
@@ -33,16 +34,19 @@ namespace Kyra {
class SoundMacRes {
public:
- SoundMacRes();
+ SoundMacRes(KyraEngine_v1 *vm);
~SoundMacRes();
bool init();
void setQuality(bool hi);
Common::SeekableReadStream *getResource(uint16 id, uint32 type);
private:
+ bool _useInstaller;
+ Common::MacResManager *_macInstallerRes;
Common::MacResManager *_macRes;
Common::String _kyraMacExe;
Common::Array<Common::String> _resFiles;
+ Common::Archive *_stuffItArchive;
};
} // End of namespace Kyra
Commit: cb1a6a0e3861ea9f9ebea6b79d4a1b170118216f
https://github.com/scummvm/scummvm/commit/cb1a6a0e3861ea9f9ebea6b79d4a1b170118216f
Author: athrxx (athrxx at scummvm.org)
Date: 2021-11-22T18:39:23+01:00
Commit Message:
KYRA: (LoK/Mac) - cleanup Stuffit code
(get rid of separate archive object in the sound code)
Changed paths:
engines/kyra/resource/resource.cpp
engines/kyra/resource/resource.h
engines/kyra/sound/sound_mac_lok.cpp
engines/kyra/sound/sound_mac_res.h
diff --git a/engines/kyra/resource/resource.cpp b/engines/kyra/resource/resource.cpp
index 384859677c..fc6311b205 100644
--- a/engines/kyra/resource/resource.cpp
+++ b/engines/kyra/resource/resource.cpp
@@ -30,7 +30,7 @@
namespace Kyra {
-Resource::Resource(KyraEngine_v1 *vm) : _archiveCache(), _files(), _archiveFiles(), _protectedFiles(), _loaders(), _vm(vm), _bigEndianPlatForm(vm->gameFlags().platform == Common::kPlatformAmiga || vm->gameFlags().platform == Common::kPlatformSegaCD) {
+Resource::Resource(KyraEngine_v1 *vm) : _archiveCache(), _files(), _archiveFiles(), _protectedFiles(), _loaders(), _vm(vm), _bigEndianPlatForm(vm->gameFlags().platform == Common::kPlatformAmiga || vm->gameFlags().platform == Common::kPlatformSegaCD), _installerArchive() {
initializeLoaders();
// Initialize directories for playing from CD or with original
@@ -98,11 +98,14 @@ bool Resource::reset() {
error("Could not find Legend of Kyrandia installer file");
}
- Common::Archive *archive = loadStuffItArchive(kyraInstaller);
- _files.add("installer", archive, 0, false);
+ _installerArchive = loadStuffItArchive(kyraInstaller);
+ if (!_installerArchive)
+ error("Failed to load Legend of Kyrandia installer file");
+
+ _files.add("installer", _installerArchive, 0, false);
Common::ArchiveMemberList members;
- archive->listMatchingMembers(members, "*.PAK");
+ _installerArchive->listMatchingMembers(members, "*.PAK");
for (Common::ArchiveMemberList::const_iterator it = members.begin(); it != members.end(); ++it) {
Common::String name = (*it)->getName();
Common::Archive *pak = loadArchive(name, *it);
diff --git a/engines/kyra/resource/resource.h b/engines/kyra/resource/resource.h
index 6c53db8bb5..cb64201910 100644
--- a/engines/kyra/resource/resource.h
+++ b/engines/kyra/resource/resource.h
@@ -85,6 +85,10 @@ public:
Common::SeekableReadStreamEndian *createEndianAwareReadStream(const Common::String &file, int endianness = kPlatformEndianness);
bool loadFileToBuf(const char *file, void *buf, uint32 maxSize);
+
+ // This is only used for the Mac Stuffit Installer
+ Common::Archive *getInstallerArchive() const { return _installerArchive; }
+
protected:
typedef Common::HashMap<Common::String, Common::Archive *, Common::CaseSensitiveString_Hash, Common::CaseSensitiveString_EqualTo> ArchiveMap;
ArchiveMap _archiveCache;
@@ -106,6 +110,8 @@ protected:
typedef Common::List<Common::SharedPtr<ResArchiveLoader> > LoaderList;
LoaderList _loaders;
+ Common::Archive *_installerArchive;
+
const bool _bigEndianPlatForm;
KyraEngine_v1 *_vm;
};
diff --git a/engines/kyra/sound/sound_mac_lok.cpp b/engines/kyra/sound/sound_mac_lok.cpp
index 4237634375..9d5f16f6b5 100644
--- a/engines/kyra/sound/sound_mac_lok.cpp
+++ b/engines/kyra/sound/sound_mac_lok.cpp
@@ -20,6 +20,7 @@
*
*/
+#include "kyra/resource/resource.h"
#include "kyra/sound/sound_intern.h"
#include "kyra/sound/sound_mac_res.h"
#include "kyra/sound/drivers/halestorm.h"
@@ -38,17 +39,15 @@
namespace Kyra {
-SoundMacRes::SoundMacRes(KyraEngine_v1 *vm) : _macInstallerRes(nullptr), _macRes(nullptr), _stuffItArchive(nullptr) {
+SoundMacRes::SoundMacRes(KyraEngine_v1 *vm) : _macRes(nullptr), _stuffItArchive(nullptr) {
_useInstaller = vm->gameFlags().useInstallerPackage;
_macRes = new Common::MacResManager();
if (_useInstaller)
- _macInstallerRes = new Common::MacResManager();
+ _stuffItArchive = vm->resource()->getInstallerArchive();
}
SoundMacRes::~SoundMacRes() {
- delete _stuffItArchive;
delete _macRes;
- delete _macInstallerRes;
}
bool SoundMacRes::init() {
@@ -108,12 +107,6 @@ bool SoundMacRes::init() {
return false;
}
- if (_useInstaller) {
- _macInstallerRes->open(_kyraMacExe);
- Common::SeekableReadStream *stream = _macInstallerRes->getDataFork();
- _stuffItArchive = Common::createStuffItArchive(stream);
- }
-
setQuality(true);
if (!_useInstaller) {
diff --git a/engines/kyra/sound/sound_mac_res.h b/engines/kyra/sound/sound_mac_res.h
index 35e880ef15..3307c66de3 100644
--- a/engines/kyra/sound/sound_mac_res.h
+++ b/engines/kyra/sound/sound_mac_res.h
@@ -42,7 +42,6 @@ public:
private:
bool _useInstaller;
- Common::MacResManager *_macInstallerRes;
Common::MacResManager *_macRes;
Common::String _kyraMacExe;
Common::Array<Common::String> _resFiles;
Commit: a76ce525d2b0ae5b94b4e10e1fd7059a4668e9c5
https://github.com/scummvm/scummvm/commit/a76ce525d2b0ae5b94b4e10e1fd7059a4668e9c5
Author: Torbjörn Andersson (eriktorbjorn at users.sourceforge.net)
Date: 2021-11-22T18:39:23+01:00
Commit Message:
KYRA: Further Mac/LoK audio driver cleanup
Now that the audio drive uses the same StuffIt archive as the rest of
the engine (thanks for the help with that!), it no longer needs to
verify that the installer file is present.
Changed paths:
engines/kyra/sound/sound_mac_lok.cpp
engines/kyra/sound/sound_mac_res.h
diff --git a/engines/kyra/sound/sound_mac_lok.cpp b/engines/kyra/sound/sound_mac_lok.cpp
index 9d5f16f6b5..ff4a1baacd 100644
--- a/engines/kyra/sound/sound_mac_lok.cpp
+++ b/engines/kyra/sound/sound_mac_lok.cpp
@@ -40,9 +40,8 @@
namespace Kyra {
SoundMacRes::SoundMacRes(KyraEngine_v1 *vm) : _macRes(nullptr), _stuffItArchive(nullptr) {
- _useInstaller = vm->gameFlags().useInstallerPackage;
_macRes = new Common::MacResManager();
- if (_useInstaller)
+ if (vm->gameFlags().useInstallerPackage)
_stuffItArchive = vm->resource()->getInstallerArchive();
}
@@ -54,62 +53,48 @@ bool SoundMacRes::init() {
if (!_macRes)
return false;
- // The original executable has a TM char as its last character (character 0xaa
- // from Mac code page). Depending on the emulator or platform used to copy the
- // file it might have been reencoded to something else. So I look for multiple
- // versions, also for punycode encoded files and also for the case where the
- // user might have just removed the last character by renaming the file.
-
- const char *const tryInstallerNames[] = {
- "Install Legend of Kyrandia",
- "Install Legend of Kyrandia\xaa"
- };
-
- const char *const tryExeNames[] = {
- "Legend of Kyrandia\xaa",
- "Legend of Kyrandia"
- };
-
- const Common::CodePage tryCodePages[] = {
- Common::kMacRoman,
- Common::kISO8859_1
- };
-
- const char *const *tryNames;
- int numTryNames;
-
- if (_useInstaller) {
- tryNames = tryInstallerNames;
- numTryNames = ARRAYSIZE(tryInstallerNames);
- } else {
- tryNames = tryExeNames;
- numTryNames = ARRAYSIZE(tryExeNames);
- }
-
- for (int i = 0; i < ARRAYSIZE(tryCodePages); ++i) {
- for (int ii = 0; ii < numTryNames; ++ii) {
- Common::U32String fn(tryNames[ii], tryCodePages[i]);
- _kyraMacExe = fn.encode(Common::kUtf8);
- if (_macRes->exists(_kyraMacExe))
- break;
- _kyraMacExe = Common::punycode_encodefilename(fn);
- if (_macRes->exists(_kyraMacExe))
+ if (!_stuffItArchive) {
+ // The original executable has a TM char as its last character
+ // (character 0xaa from Mac code page). Depending on the emulator or
+ // platform used to copy the file it might have been reencoded to
+ // something else. So I look for multiple versions, also for punycode
+ // encoded files and also for the case where the user might have just
+ // removed the last character by renaming the file.
+
+ const Common::CodePage tryCodePages[] = {
+ Common::kMacRoman,
+ Common::kISO8859_1
+ };
+
+ const char *const tryExeNames[] = {
+ "Legend of Kyrandia\xaa",
+ "Legend of Kyrandia"
+ };
+
+ for (int i = 0; i < ARRAYSIZE(tryCodePages); ++i) {
+ for (int ii = 0; ii < ARRAYSIZE(tryExeNames); ++ii) {
+ Common::U32String fn(tryExeNames[ii], tryCodePages[i]);
+ _kyraMacExe = fn.encode(Common::kUtf8);
+ if (_macRes->exists(_kyraMacExe))
+ break;
+ _kyraMacExe = Common::punycode_encodefilename(fn);
+ if (_macRes->exists(_kyraMacExe))
+ break;
+ _kyraMacExe.clear();
+ }
+ if (!_kyraMacExe.empty())
break;
- _kyraMacExe.clear();
}
- if (!_kyraMacExe.empty())
- break;
- }
- if (_kyraMacExe.empty()) {
- warning("SoundMacRes::init(): Legend of Kyrandia %s not found",
- _useInstaller ? "installer" : "resource fork");
- return false;
+ if (_kyraMacExe.empty()) {
+ warning("SoundMacRes::init(): Legend of Kyrandia resource fork not found");
+ return false;
+ }
}
setQuality(true);
- if (!_useInstaller) {
+ if (!_stuffItArchive) {
for (Common::StringArray::iterator i = _resFiles.begin(); i != _resFiles.end(); ++i) {
if (!_macRes->exists(*i)) {
warning("SoundMacRes::init(): Error opening data file: '%s'", i->c_str());
@@ -140,7 +125,7 @@ Common::SeekableReadStream *SoundMacRes::getResource(uint16 id, uint32 type) {
Common::SeekableReadStream *res = nullptr;
for (Common::StringArray::iterator i = _resFiles.begin(); i != _resFiles.end(); ++i) {
- if (_useInstaller) {
+ if (_stuffItArchive) {
if (!_macRes->open(Common::Path(*i), *_stuffItArchive)) {
warning("SoundMacRes::getResource(): Error opening archive member: '%s'", i->c_str());
}
@@ -158,7 +143,7 @@ Common::SeekableReadStream *SoundMacRes::getResource(uint16 id, uint32 type) {
void SoundMacRes::setQuality(bool hi) {
_resFiles.clear();
_resFiles.push_back(hi ? "HQ_Music.res" : "LQ_Music.res");
- if (_useInstaller) {
+ if (_stuffItArchive) {
_resFiles.push_back("Legend of Kyrandia\xaa");
} else {
_resFiles.push_back(_kyraMacExe);
diff --git a/engines/kyra/sound/sound_mac_res.h b/engines/kyra/sound/sound_mac_res.h
index 3307c66de3..5fceb862e4 100644
--- a/engines/kyra/sound/sound_mac_res.h
+++ b/engines/kyra/sound/sound_mac_res.h
@@ -41,7 +41,6 @@ public:
Common::SeekableReadStream *getResource(uint16 id, uint32 type);
private:
- bool _useInstaller;
Common::MacResManager *_macRes;
Common::String _kyraMacExe;
Common::Array<Common::String> _resFiles;
Commit: 3054e32278d3cc71798aac926ed1d14c5706f8be
https://github.com/scummvm/scummvm/commit/3054e32278d3cc71798aac926ed1d14c5706f8be
Author: Torbjörn Andersson (eriktorbjorn at users.sourceforge.net)
Date: 2021-11-22T18:39:23+01:00
Commit Message:
KYRA: Move Mac file finding code into Util
We use the same method for finding both the unpacked Legend of Kyrandia
executable and the Legend of Kyrandia installer, so there's no need for
duplicate code.
Changed paths:
engines/kyra/engine/util.cpp
engines/kyra/engine/util.h
engines/kyra/resource/resource.cpp
engines/kyra/sound/sound_mac_lok.cpp
diff --git a/engines/kyra/engine/util.cpp b/engines/kyra/engine/util.cpp
index 9b4670d54b..e94872ef0d 100644
--- a/engines/kyra/engine/util.cpp
+++ b/engines/kyra/engine/util.cpp
@@ -20,6 +20,8 @@
*
*/
+#include "common/macresman.h"
+#include "common/punycode.h"
#include "kyra/engine/util.h"
namespace Kyra {
@@ -115,4 +117,40 @@ Common::String Util::decodeString2(const Common::String &src) {
return tmp;
}
+Common::String Util::findMacResourceFile(const char *baseName) {
+ // The original executable has a TM char as its last character (character
+ // 0xAA from Mac code page). Depending on the emulator or platform used to
+ // copy the file it might have been reencoded to something else. So I look
+ // for multiple versions, also for punycode encoded files and also for the
+ // case where the user might have just removed the last character by
+ // renaming the file.
+
+ const Common::CodePage tryCodePages[] = {
+ Common::kMacRoman,
+ Common::kISO8859_1
+ };
+
+ Common::String tryName(baseName);
+ Common::String fileName;
+
+ for (int i = 0; i < ARRAYSIZE(tryCodePages); ++i) {
+ for (int ii = 0; ii < 2; ++ii) {
+ Common::MacResManager resource;
+
+ Common::U32String fn(tryName, tryCodePages[i]);
+ fileName = fn.encode(Common::kUtf8);
+ if (resource.exists(fileName))
+ return fileName;
+ fileName = Common::punycode_encodefilename(fn);
+ if (resource.exists(fileName))
+ return fileName;
+
+ tryName += "\xAA";
+ }
+ }
+
+ fileName.clear();
+ return fileName;
+}
+
} // End of namespace Kyra
diff --git a/engines/kyra/engine/util.h b/engines/kyra/engine/util.h
index fd8e9f90a1..7f5fdc451a 100644
--- a/engines/kyra/engine/util.h
+++ b/engines/kyra/engine/util.h
@@ -40,6 +40,8 @@ public:
static Common::String convertUTF8ToDOS(Common::String &str);
static Common::String convertISOToUTF8(Common::String &str);
static void convertISOToDOS(char &c);
+
+ static Common::String findMacResourceFile(const char *baseName);
};
} // End of namespace Kyra
diff --git a/engines/kyra/resource/resource.cpp b/engines/kyra/resource/resource.cpp
index fc6311b205..0d2cdc80de 100644
--- a/engines/kyra/resource/resource.cpp
+++ b/engines/kyra/resource/resource.cpp
@@ -20,12 +20,13 @@
*
*/
+#include "kyra/engine/util.h"
#include "kyra/resource/resource.h"
#include "kyra/resource/resource_intern.h"
#include "common/config-manager.h"
-#include "common/macresman.h"
-#include "common/punycode.h"
+//#include "common/macresman.h"
+//#include "common/punycode.h"
#include "common/fs.h"
namespace Kyra {
@@ -66,33 +67,7 @@ bool Resource::reset() {
error("invalid game path '%s'", dir.getPath().c_str());
if (_vm->game() == GI_KYRA1 && _vm->gameFlags().platform == Common::kPlatformMacintosh && _vm->gameFlags().useInstallerPackage) {
- const char *const tryFileNames[] = {
- "Install Legend of Kyrandia",
- "Install Legend of Kyrandia\xaa"
- };
-
- const Common::CodePage tryCodePages[] = {
- Common::kMacRoman,
- Common::kISO8859_1
- };
-
- Common::MacResManager resource;
- Common::String kyraInstaller;
-
- for (int i = 0; i < ARRAYSIZE(tryCodePages); ++i) {
- for (int ii = 0; ii < ARRAYSIZE(tryFileNames); ++ii) {
- Common::U32String fn(tryFileNames[ii], tryCodePages[i]);
- kyraInstaller = fn.encode(Common::kUtf8);
- if (resource.exists(kyraInstaller))
- break;
- kyraInstaller = Common::punycode_encodefilename(fn);
- if (resource.exists(kyraInstaller))
- break;
- kyraInstaller.clear();
- }
- if (!kyraInstaller.empty())
- break;
- }
+ Common::String kyraInstaller = Util::findMacResourceFile("Install Legend of Kyrandia");
if (kyraInstaller.empty()) {
error("Could not find Legend of Kyrandia installer file");
diff --git a/engines/kyra/sound/sound_mac_lok.cpp b/engines/kyra/sound/sound_mac_lok.cpp
index ff4a1baacd..34b988c062 100644
--- a/engines/kyra/sound/sound_mac_lok.cpp
+++ b/engines/kyra/sound/sound_mac_lok.cpp
@@ -20,6 +20,7 @@
*
*/
+#include "kyra/engine/util.h"
#include "kyra/resource/resource.h"
#include "kyra/sound/sound_intern.h"
#include "kyra/sound/sound_mac_res.h"
@@ -27,7 +28,6 @@
#include "common/config-manager.h"
#include "common/macresman.h"
-#include "common/punycode.h"
#include "common/stuffit.h"
#include "audio/mixer.h"
@@ -54,37 +54,7 @@ bool SoundMacRes::init() {
return false;
if (!_stuffItArchive) {
- // The original executable has a TM char as its last character
- // (character 0xaa from Mac code page). Depending on the emulator or
- // platform used to copy the file it might have been reencoded to
- // something else. So I look for multiple versions, also for punycode
- // encoded files and also for the case where the user might have just
- // removed the last character by renaming the file.
-
- const Common::CodePage tryCodePages[] = {
- Common::kMacRoman,
- Common::kISO8859_1
- };
-
- const char *const tryExeNames[] = {
- "Legend of Kyrandia\xaa",
- "Legend of Kyrandia"
- };
-
- for (int i = 0; i < ARRAYSIZE(tryCodePages); ++i) {
- for (int ii = 0; ii < ARRAYSIZE(tryExeNames); ++ii) {
- Common::U32String fn(tryExeNames[ii], tryCodePages[i]);
- _kyraMacExe = fn.encode(Common::kUtf8);
- if (_macRes->exists(_kyraMacExe))
- break;
- _kyraMacExe = Common::punycode_encodefilename(fn);
- if (_macRes->exists(_kyraMacExe))
- break;
- _kyraMacExe.clear();
- }
- if (!_kyraMacExe.empty())
- break;
- }
+ _kyraMacExe = Util::findMacResourceFile("Legend of Kyrandia");
if (_kyraMacExe.empty()) {
warning("SoundMacRes::init(): Legend of Kyrandia resource fork not found");
Commit: 9a758940e119fbf895f9aff7f9d1231dc2005a4d
https://github.com/scummvm/scummvm/commit/9a758940e119fbf895f9aff7f9d1231dc2005a4d
Author: athrxx (athrxx at scummvm.org)
Date: 2021-11-22T18:39:23+01:00
Commit Message:
KYRA: (Mac/LoK) - slightly rearrange mac resource detection
Changed paths:
engines/kyra/engine/util.cpp
diff --git a/engines/kyra/engine/util.cpp b/engines/kyra/engine/util.cpp
index e94872ef0d..844f4edf62 100644
--- a/engines/kyra/engine/util.cpp
+++ b/engines/kyra/engine/util.cpp
@@ -133,20 +133,19 @@ Common::String Util::findMacResourceFile(const char *baseName) {
Common::String tryName(baseName);
Common::String fileName;
- for (int i = 0; i < ARRAYSIZE(tryCodePages); ++i) {
- for (int ii = 0; ii < 2; ++ii) {
+ for (int i = 0; i < 2; ++i) {
+ for (int ii = 0; ii < ARRAYSIZE(tryCodePages); ++ii) {
Common::MacResManager resource;
- Common::U32String fn(tryName, tryCodePages[i]);
+ Common::U32String fn(tryName, tryCodePages[ii]);
fileName = fn.encode(Common::kUtf8);
if (resource.exists(fileName))
return fileName;
fileName = Common::punycode_encodefilename(fn);
if (resource.exists(fileName))
return fileName;
-
- tryName += "\xAA";
}
+ tryName += "\xAA";
}
fileName.clear();
Commit: 18f13824125d6dd1d372fb7bf1074a20ea08631b
https://github.com/scummvm/scummvm/commit/18f13824125d6dd1d372fb7bf1074a20ea08631b
Author: athrxx (athrxx at scummvm.org)
Date: 2021-11-22T18:39:23+01:00
Commit Message:
KYRA: (LoK/Mac) - cleanup installer archive retrievement
(replace my own ugly code from a7918a49)
Changed paths:
engines/kyra/resource/resource.cpp
engines/kyra/resource/resource.h
engines/kyra/sound/sound_mac_lok.cpp
diff --git a/engines/kyra/resource/resource.cpp b/engines/kyra/resource/resource.cpp
index 0d2cdc80de..45c50540f4 100644
--- a/engines/kyra/resource/resource.cpp
+++ b/engines/kyra/resource/resource.cpp
@@ -25,13 +25,11 @@
#include "kyra/resource/resource_intern.h"
#include "common/config-manager.h"
-//#include "common/macresman.h"
-//#include "common/punycode.h"
#include "common/fs.h"
namespace Kyra {
-Resource::Resource(KyraEngine_v1 *vm) : _archiveCache(), _files(), _archiveFiles(), _protectedFiles(), _loaders(), _vm(vm), _bigEndianPlatForm(vm->gameFlags().platform == Common::kPlatformAmiga || vm->gameFlags().platform == Common::kPlatformSegaCD), _installerArchive() {
+Resource::Resource(KyraEngine_v1 *vm) : _archiveCache(), _files(), _archiveFiles(), _protectedFiles(), _loaders(), _vm(vm), _bigEndianPlatForm(vm->gameFlags().platform == Common::kPlatformAmiga || vm->gameFlags().platform == Common::kPlatformSegaCD) {
initializeLoaders();
// Initialize directories for playing from CD or with original
@@ -73,14 +71,14 @@ bool Resource::reset() {
error("Could not find Legend of Kyrandia installer file");
}
- _installerArchive = loadStuffItArchive(kyraInstaller);
- if (!_installerArchive)
+ Common::Archive *archive = loadStuffItArchive(kyraInstaller);
+ if (!archive)
error("Failed to load Legend of Kyrandia installer file");
- _files.add("installer", _installerArchive, 0, false);
+ _files.add("installer", archive, 0, false);
Common::ArchiveMemberList members;
- _installerArchive->listMatchingMembers(members, "*.PAK");
+ archive->listMatchingMembers(members, "*.PAK");
for (Common::ArchiveMemberList::const_iterator it = members.begin(); it != members.end(); ++it) {
Common::String name = (*it)->getName();
Common::Archive *pak = loadArchive(name, *it);
@@ -345,6 +343,11 @@ bool Resource::loadFileToBuf(const char *file, void *buf, uint32 maxSize) {
return true;
}
+Common::Archive *Resource::getCachedArchive(const Common::String &file) const {
+ ArchiveMap::iterator a = _archiveCache.find(file);
+ return a != _archiveCache.end() ? a->_value : 0;
+}
+
Common::SeekableReadStream *Resource::createReadStream(const Common::String &file) {
return _files.createReadStreamForMember(file);
}
diff --git a/engines/kyra/resource/resource.h b/engines/kyra/resource/resource.h
index cb64201910..60bce59158 100644
--- a/engines/kyra/resource/resource.h
+++ b/engines/kyra/resource/resource.h
@@ -86,8 +86,7 @@ public:
bool loadFileToBuf(const char *file, void *buf, uint32 maxSize);
- // This is only used for the Mac Stuffit Installer
- Common::Archive *getInstallerArchive() const { return _installerArchive; }
+ Common::Archive *getCachedArchive(const Common::String &file) const;
protected:
typedef Common::HashMap<Common::String, Common::Archive *, Common::CaseSensitiveString_Hash, Common::CaseSensitiveString_EqualTo> ArchiveMap;
@@ -110,8 +109,6 @@ protected:
typedef Common::List<Common::SharedPtr<ResArchiveLoader> > LoaderList;
LoaderList _loaders;
- Common::Archive *_installerArchive;
-
const bool _bigEndianPlatForm;
KyraEngine_v1 *_vm;
};
diff --git a/engines/kyra/sound/sound_mac_lok.cpp b/engines/kyra/sound/sound_mac_lok.cpp
index 34b988c062..3cd6bb39a5 100644
--- a/engines/kyra/sound/sound_mac_lok.cpp
+++ b/engines/kyra/sound/sound_mac_lok.cpp
@@ -41,8 +41,14 @@ namespace Kyra {
SoundMacRes::SoundMacRes(KyraEngine_v1 *vm) : _macRes(nullptr), _stuffItArchive(nullptr) {
_macRes = new Common::MacResManager();
- if (vm->gameFlags().useInstallerPackage)
- _stuffItArchive = vm->resource()->getInstallerArchive();
+ if (vm->gameFlags().useInstallerPackage) {
+ Common::String str = Util::findMacResourceFile("Install Legend of Kyrandia");
+ if (str.empty())
+ error("SoundMacRes::SoundMacRes(): Could not find Legend of Kyrandia installer file");
+ _stuffItArchive = vm->resource()->getCachedArchive(str);
+ if (!_stuffItArchive)
+ error("SoundMacRes::SoundMacRes(): Failed to load Legend of Kyrandia installer file");
+ }
}
SoundMacRes::~SoundMacRes() {
Commit: 23e3acba0f2a8cf70d1e2e7db733be1d0e246e2d
https://github.com/scummvm/scummvm/commit/23e3acba0f2a8cf70d1e2e7db733be1d0e246e2d
Author: Torbjörn Andersson (eriktorbjorn at users.sourceforge.net)
Date: 2021-11-22T18:39:23+01:00
Commit Message:
KYRA: Only create MacResManager when needed
Changed paths:
engines/kyra/resource/resource.cpp
engines/kyra/resource/resource.h
engines/kyra/resource/resource_intern.cpp
engines/kyra/resource/resource_intern.h
diff --git a/engines/kyra/resource/resource.cpp b/engines/kyra/resource/resource.cpp
index 45c50540f4..82ded8f92a 100644
--- a/engines/kyra/resource/resource.cpp
+++ b/engines/kyra/resource/resource.cpp
@@ -29,9 +29,12 @@
namespace Kyra {
-Resource::Resource(KyraEngine_v1 *vm) : _archiveCache(), _files(), _archiveFiles(), _protectedFiles(), _loaders(), _vm(vm), _bigEndianPlatForm(vm->gameFlags().platform == Common::kPlatformAmiga || vm->gameFlags().platform == Common::kPlatformSegaCD) {
+Resource::Resource(KyraEngine_v1 *vm) : _archiveCache(), _files(), _archiveFiles(), _protectedFiles(), _macResMan(), _loaders(), _vm(vm), _bigEndianPlatForm(vm->gameFlags().platform == Common::kPlatformAmiga || vm->gameFlags().platform == Common::kPlatformSegaCD) {
initializeLoaders();
+ if (_vm->gameFlags().useInstallerPackage)
+ _macResMan = new Common::MacResManager();
+
// Initialize directories for playing from CD or with original
// directory structure
if (_vm->game() == GI_KYRA3)
@@ -53,7 +56,7 @@ Resource::~Resource() {
for (ArchiveMap::iterator i = _archiveCache.begin(); i != _archiveCache.end(); ++i)
delete i->_value;
_archiveCache.clear();
- _macResMan.close();
+ delete _macResMan;
}
bool Resource::reset() {
diff --git a/engines/kyra/resource/resource.h b/engines/kyra/resource/resource.h
index 60bce59158..25c22a88c0 100644
--- a/engines/kyra/resource/resource.h
+++ b/engines/kyra/resource/resource.h
@@ -96,7 +96,7 @@ protected:
Common::SearchSet _archiveFiles;
Common::SearchSet _protectedFiles;
- Common::MacResManager _macResMan;
+ Common::MacResManager *_macResMan;
Common::Archive *loadArchive(const Common::String &name, Common::ArchiveMemberPtr member);
Common::Archive *loadInstallerArchive(const Common::String &file, const Common::String &ext, const uint8 offset);
diff --git a/engines/kyra/resource/resource_intern.cpp b/engines/kyra/resource/resource_intern.cpp
index 16eac30e4c..186b7c1b0e 100644
--- a/engines/kyra/resource/resource_intern.cpp
+++ b/engines/kyra/resource/resource_intern.cpp
@@ -1200,9 +1200,9 @@ Common::Archive *InstallerLoader::load(Resource *owner, const Common::String &fi
return new CachedArchive(fileList);
}
-Common::Archive *StuffItLoader::load(Resource *owner, const Common::String &filename, Common::MacResManager &macResMan) {
- if (macResMan.open(filename)) {
- Common::SeekableReadStream *stream = macResMan.getDataFork();
+Common::Archive *StuffItLoader::load(Resource *owner, const Common::String &filename, Common::MacResManager *macResMan) {
+ if (macResMan->open(filename)) {
+ Common::SeekableReadStream *stream = macResMan->getDataFork();
if (stream) {
Common::Archive *archive = Common::createStuffItArchive(stream);
return archive;
diff --git a/engines/kyra/resource/resource_intern.h b/engines/kyra/resource/resource_intern.h
index d70c5ff523..1610272f8e 100644
--- a/engines/kyra/resource/resource_intern.h
+++ b/engines/kyra/resource/resource_intern.h
@@ -145,7 +145,7 @@ public:
class StuffItLoader {
public:
- static Common::Archive *load(Resource *owner, const Common::String &filename, Common::MacResManager &macResMan);
+ static Common::Archive *load(Resource *owner, const Common::String &filename, Common::MacResManager *macResMan);
};
class EndianAwareStreamWrapper : public Common::SeekableReadStreamEndian {
Commit: 8394f8549ba3d7a1e7d97da65291f24467a9cfb4
https://github.com/scummvm/scummvm/commit/8394f8549ba3d7a1e7d97da65291f24467a9cfb4
Author: Torbjörn Andersson (eriktorbjorn at users.sourceforge.net)
Date: 2021-11-22T18:39:23+01:00
Commit Message:
KYRA: Use same MacResManager object throughout findMacResourceFile()
No need to allocate a new one for each iteration.
Changed paths:
engines/kyra/engine/util.cpp
diff --git a/engines/kyra/engine/util.cpp b/engines/kyra/engine/util.cpp
index 844f4edf62..31a713b2fa 100644
--- a/engines/kyra/engine/util.cpp
+++ b/engines/kyra/engine/util.cpp
@@ -130,13 +130,12 @@ Common::String Util::findMacResourceFile(const char *baseName) {
Common::kISO8859_1
};
+ Common::MacResManager resource;
Common::String tryName(baseName);
Common::String fileName;
for (int i = 0; i < 2; ++i) {
for (int ii = 0; ii < ARRAYSIZE(tryCodePages); ++ii) {
- Common::MacResManager resource;
-
Common::U32String fn(tryName, tryCodePages[ii]);
fileName = fn.encode(Common::kUtf8);
if (resource.exists(fileName))
More information about the Scummvm-git-logs
mailing list