From 783e3fea628d32a7286ee1810ee720eea2a8ea78 Mon Sep 17 00:00:00 2001 From: D G Turner Date: Sun, 13 Nov 2011 23:35:02 +0000 Subject: AGOS: Fix engine crash when playing Feeble Files from cabinet datafiles. Playing with cabinet datafiles, this failed to find the "Charisma.smk" file in the cabinets when in the Recreation (TV) room on Cygnus Alpha and this caused an engine abort after the GUI dialog warning of the "missing" video file. This was due to animation.cpp code using Common::file::exists() instead of going via the ArchiveMan. However,a hasFile() method implementation was also required to implement fallback to decompressed (movie) files if the file requested is not in the cabinet or the cabinet has been externally decompressed to files. Thanks to fuzzie for the hasFile() patch. Also, removed noisy warning which this correction triggers repeatedly in installshield_cab.cpp hasFile(). This looks like leftover from debugging, so not critical. --- engines/agos/agos.h | 1 + engines/agos/animation.cpp | 8 ++++---- engines/agos/installshield_cab.cpp | 1 - engines/agos/res.cpp | 7 +++++++ 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/engines/agos/agos.h b/engines/agos/agos.h index cf75842cdd..03feafa70f 100644 --- a/engines/agos/agos.h +++ b/engines/agos/agos.h @@ -197,6 +197,7 @@ public: void registerArchive(const Common::String &filename, int priority); #endif + bool hasFile(const Common::String &name); Common::SeekableReadStream *open(const Common::String &filename); private: diff --git a/engines/agos/animation.cpp b/engines/agos/animation.cpp index d9d6b71a2a..db2cff328c 100644 --- a/engines/agos/animation.cpp +++ b/engines/agos/animation.cpp @@ -525,25 +525,25 @@ MoviePlayer *makeMoviePlayer(AGOSEngine_Feeble *vm, const char *name) { memcpy(shortName, baseName, 6); sprintf(filename, "%s~1.dxa", shortName); - if (Common::File::exists(filename)) { + if (vm->_archives.hasFile(filename)) { memset(baseName, 0, sizeof(baseName)); memcpy(baseName, filename, 8); } sprintf(filename, "%s~1.smk", shortName); - if (Common::File::exists(filename)) { + if (vm->_archives.hasFile(filename)) { memset(baseName, 0, sizeof(baseName)); memcpy(baseName, filename, 8); } } sprintf(filename, "%s.dxa", baseName); - if (Common::File::exists(filename)) { + if (vm->_archives.hasFile(filename)) { return new MoviePlayerDXA(vm, baseName); } sprintf(filename, "%s.smk", baseName); - if (Common::File::exists(filename)) { + if (vm->_archives.hasFile(filename)) { return new MoviePlayerSMK(vm, baseName); } diff --git a/engines/agos/installshield_cab.cpp b/engines/agos/installshield_cab.cpp index f7b49a64c5..ac4e40d1d1 100644 --- a/engines/agos/installshield_cab.cpp +++ b/engines/agos/installshield_cab.cpp @@ -162,7 +162,6 @@ InstallShieldCabinet::InstallShieldCabinet(const Common::String &filename) : _in } bool InstallShieldCabinet::hasFile(const Common::String &name) { - warning("hasFile: Filename %s", name.c_str()); return _map.contains(name); } diff --git a/engines/agos/res.cpp b/engines/agos/res.cpp index 69447f4b83..62197340d2 100644 --- a/engines/agos/res.cpp +++ b/engines/agos/res.cpp @@ -47,6 +47,13 @@ void ArchiveMan::registerArchive(const Common::String &filename, int priority) { } #endif +bool ArchiveMan::hasFile(const Common::String &name) { + if (_fallBack && SearchMan.hasFile(name)) + return true; + + return Common::SearchSet::hasFile(name); +} + Common::SeekableReadStream *ArchiveMan::open(const Common::String &filename) { if (_fallBack && SearchMan.hasFile(filename)) { return SearchMan.createReadStreamForMember(filename); -- cgit v1.2.3