From 64cd45c30edccd34f36619eece7dbe41ca5fb812 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 27 Oct 2022 12:23:26 +0200 Subject: [PATCH] HADESCH: Support files in MacBinary format --- engines/hadesch/hadesch.cpp | 10 +++++----- engines/hadesch/pod_file.cpp | 11 ++++++++--- engines/hadesch/video.cpp | 6 ++++-- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/engines/hadesch/hadesch.cpp b/engines/hadesch/hadesch.cpp index 483c5d397ad..1fa7c88ac77 100644 --- a/engines/hadesch/hadesch.cpp +++ b/engines/hadesch/hadesch.cpp @@ -490,10 +490,10 @@ Common::Error HadeschEngine::run() { }; debug("HadeschEngine: loading wd.pod"); for (uint i = 0; i < ARRAYSIZE(wdpodpaths); ++i) { - Common::SharedPtr file(new Common::File()); - if (file->open(wdpodpaths[i])) { + Common::SharedPtr stream(Common::MacResManager::openFileOrDataFork(wdpodpaths[i])); + if (stream) { _wdPodFile = Common::SharedPtr(new PodFile("WD.POD")); - _wdPodFile->openStore(file); + _wdPodFile->openStore(stream); break; } } @@ -511,8 +511,8 @@ Common::Error HadeschEngine::run() { // on cdScenePath const char *const scenepaths[] = {"CDAssets/", "Scenes/"}; for (uint i = 0; i < ARRAYSIZE(scenepaths); ++i) { - Common::ScopedPtr file(new Common::File()); - if (file->open(Common::String(scenepaths[i]) + "OLYMPUS/OL.POD")) { + Common::ScopedPtr stream(Common::MacResManager::openFileOrDataFork(Common::String(scenepaths[i]) + "OLYMPUS/OL.POD")); + if (stream) { _cdScenesPath = scenepaths[i]; break; } diff --git a/engines/hadesch/pod_file.cpp b/engines/hadesch/pod_file.cpp index ba58a197d90..461f106d44c 100644 --- a/engines/hadesch/pod_file.cpp +++ b/engines/hadesch/pod_file.cpp @@ -22,6 +22,7 @@ */ #include "common/debug.h" #include "common/file.h" +#include "common/macresman.h" #include "common/memstream.h" #include "hadesch/hadesch.h" @@ -75,12 +76,16 @@ bool PodFile::openStore(const Common::SharedPtr &par } bool PodFile::openStore(const Common::String &name) { - Common::SharedPtr file(new Common::File()); - if (name.empty() || !file->open(name)) { + if (name.empty()) { return false; } - return openStore(file); + Common::SharedPtr stream(Common::MacResManager::openFileOrDataFork(name)); + if (!stream) { + return false; + } + + return openStore(stream); } // It's tempting to use substream but substream is not thread safe diff --git a/engines/hadesch/video.cpp b/engines/hadesch/video.cpp index 29a2ccb8eae..6fdc6e55f66 100644 --- a/engines/hadesch/video.cpp +++ b/engines/hadesch/video.cpp @@ -32,6 +32,7 @@ #include "hadesch/pod_file.h" #include "hadesch/baptr.h" #include "common/translation.h" +#include "common/macresman.h" static const int kVideoMaxW = 1280; static const int kVideoMaxH = 480; @@ -758,12 +759,13 @@ void VideoRoom::playVideo(const Common::String &name, int zValue, Common::SharedPtr decoder = Common::SharedPtr(new Video::SmackerDecoder()); - Common::File *file = new Common::File; Common::String mappedName = _assetMap.get(name, 1); if (mappedName == "") { mappedName = name; } - if (!file->open(_smkPath + "/" + mappedName + ".SMK") || !decoder->loadStream(file)) { + Common::SeekableReadStream *stream = Common::MacResManager::openFileOrDataFork(_smkPath + "/" + mappedName + ".SMK"); + + if (!stream || !decoder->loadStream(stream)) { debug("Video file %s can't be opened", name.c_str()); g_vm->handleEvent(callbackEvent); return;