diff options
Diffstat (limited to 'engines/xeen/files.cpp')
-rw-r--r-- | engines/xeen/files.cpp | 60 |
1 files changed, 50 insertions, 10 deletions
diff --git a/engines/xeen/files.cpp b/engines/xeen/files.cpp index bcee6bf9f6..b928677aac 100644 --- a/engines/xeen/files.cpp +++ b/engines/xeen/files.cpp @@ -183,37 +183,78 @@ Common::SeekableReadStream *CCArchive::createReadStreamForMember(const Common::S /*------------------------------------------------------------------------*/ +CCArchive *FileManager::_archives[3]; + FileManager::FileManager(XeenEngine *vm) { Common::File f; int sideNum = 0; + File::_currentArchive = ANY_ARCHIVE; _isDarkCc = vm->getGameID() == GType_DarkSide; - _sideArchives[0] = _sideArchives[1] = nullptr; + _archives[0] = _archives[1] = _archives[2] = nullptr; if (vm->getGameID() != GType_DarkSide) { - _sideArchives[0] = new CCArchive("xeen.cc", "xeen", true); - SearchMan.add("xeen", _sideArchives[0]); + _archives[0] = new CCArchive("xeen.cc", "xeen", true); + SearchMan.add("xeen", _archives[0]); sideNum = 1; } if (vm->getGameID() == GType_DarkSide || vm->getGameID() == GType_WorldOfXeen) { - _sideArchives[sideNum] = new CCArchive("dark.cc", "dark", true); - SearchMan.add("dark", _sideArchives[sideNum]); + _archives[sideNum] = new CCArchive("dark.cc", "dark", true); + SearchMan.add("dark", _archives[sideNum]); + } + + if (f.exists("intro.cc")) { + _archives[2] = new CCArchive("intro.cc", "intro", true); + SearchMan.add("intro", _archives[2]); } +} - SearchMan.add("intro", new CCArchive("intro.cc", "intro", true)); +void FileManager::setGameCc(bool isDarkCc) { + _isDarkCc = isDarkCc; + File::_currentArchive = isDarkCc ? ALTSIDE_ARCHIVE : GAME_ARCHIVE; } /*------------------------------------------------------------------------*/ -void File::openFile(const Common::String &filename) { - if (!Common::File::open(filename)) +ArchiveType File::_currentArchive; + +File::File(const Common::String &filename) { + File::open(filename); +} + +File::File(const Common::String &filename, ArchiveType archiveType) { + File::open(filename, archiveType); +} + +File::File(const Common::String &filename, Common::Archive &archive) { + File::open(filename, archive); +} + +bool File::open(const Common::String &filename) { + return File::open(filename, _currentArchive); +} + +bool File::open(const Common::String &filename, ArchiveType archiveType) { + if (archiveType == ANY_ARCHIVE) { + Common::File::open(filename); + } else { + CCArchive &archive = *FileManager::_archives[archiveType]; + if (!Common::File::open(filename, archive)) + // If not in the designated archive, try opening from any archive, + // or as a standalone file in the filesystem + Common::File::open(filename); + } + + if (!isOpen()) error("Could not open file - %s", filename.c_str()); + return true; } -void File::openFile(const Common::String &filename, Common::Archive &archive) { +bool File::open(const Common::String &filename, Common::Archive &archive) { if (!Common::File::open(filename, archive)) error("Could not open file - %s", filename.c_str()); + return true; } Common::String File::readString() { @@ -226,5 +267,4 @@ Common::String File::readString() { return result; } - } // End of namespace Xeen |