diff options
225 files changed, 1204 insertions, 1102 deletions
diff --git a/backends/events/default/default-events.cpp b/backends/events/default/default-events.cpp index e12ab09433..9ab7ab620c 100644 --- a/backends/events/default/default-events.cpp +++ b/backends/events/default/default-events.cpp @@ -460,7 +460,7 @@ bool DefaultEventManager::pollEvent(Common::Event &event) { // as an event now and open up the GMM itself it would open the // menu twice. if (g_engine && !g_engine->isPaused()) - g_engine->mainMenuDialog(); + g_engine->openMainMenuDialog(); if (_shouldQuit) event.type = Common::EVENT_QUIT; @@ -530,7 +530,7 @@ bool DefaultEventManager::pollEvent(Common::Event &event) { case Common::EVENT_MAINMENU: if (g_engine && !g_engine->isPaused()) - g_engine->mainMenuDialog(); + g_engine->openMainMenuDialog(); if (_shouldQuit) event.type = Common::EVENT_QUIT; diff --git a/backends/fs/abstract-fs.cpp b/backends/fs/abstract-fs.cpp index 6daad7152a..aa341e70d9 100644 --- a/backends/fs/abstract-fs.cpp +++ b/backends/fs/abstract-fs.cpp @@ -24,7 +24,7 @@ #include "backends/fs/abstract-fs.h" -const char *AbstractFilesystemNode::lastPathComponent(const Common::String &str, const char sep) { +const char *AbstractFSNode::lastPathComponent(const Common::String &str, const char sep) { // TODO: Get rid of this eventually! Use Common::lastPathComponent instead if(str.empty()) return ""; diff --git a/backends/fs/abstract-fs.h b/backends/fs/abstract-fs.h index b3a652f2ae..68478ea8a4 100644 --- a/backends/fs/abstract-fs.h +++ b/backends/fs/abstract-fs.h @@ -29,22 +29,22 @@ #include "common/str.h" #include "common/fs.h" -class AbstractFilesystemNode; +class AbstractFSNode; -typedef Common::Array<AbstractFilesystemNode *> AbstractFSList; +typedef Common::Array<AbstractFSNode *> AbstractFSList; /** * Abstract file system node. Private subclasses implement the actual * functionality. * - * Most of the methods correspond directly to methods in class FilesystemNode, + * Most of the methods correspond directly to methods in class FSNode, * so if they are not documented here, look there for more information about * the semantics. */ -class AbstractFilesystemNode { +class AbstractFSNode { protected: - friend class Common::FilesystemNode; - typedef Common::FilesystemNode::ListMode ListMode; + friend class Common::FSNode; + typedef Common::FSNode::ListMode ListMode; /** * Returns the child node with the given name. When called on a non-directory @@ -63,13 +63,13 @@ protected: * * @param name String containing the name of the child to create a new node. */ - virtual AbstractFilesystemNode *getChild(const Common::String &name) const = 0; + virtual AbstractFSNode *getChild(const Common::String &name) const = 0; /** * The parent node of this directory. * The parent of the root is the root itself. */ - virtual AbstractFilesystemNode *getParent() const = 0; + virtual AbstractFSNode *getParent() const = 0; /** * Returns the last component of a given path. @@ -88,7 +88,7 @@ public: /** * Destructor. */ - virtual ~AbstractFilesystemNode() {} + virtual ~AbstractFSNode() {} /* * Indicates whether the object referred by this path exists in the filesystem or not. @@ -115,7 +115,7 @@ public: virtual Common::String getDisplayName() const { return getName(); } /** - * Returns the last component of the path pointed by this FilesystemNode. + * Returns the last component of the path pointed by this FSNode. * * Examples (POSIX): * /foo/bar.txt would return /bar.txt diff --git a/backends/fs/amigaos4/amigaos4-fs-factory.cpp b/backends/fs/amigaos4/amigaos4-fs-factory.cpp index 2b0b2f1908..2c7dc61278 100644 --- a/backends/fs/amigaos4/amigaos4-fs-factory.cpp +++ b/backends/fs/amigaos4/amigaos4-fs-factory.cpp @@ -26,15 +26,15 @@ #include "backends/fs/amigaos4/amigaos4-fs-factory.h" #include "backends/fs/amigaos4/amigaos4-fs.cpp" -AbstractFilesystemNode *AmigaOSFilesystemFactory::makeRootFileNode() const { +AbstractFSNode *AmigaOSFilesystemFactory::makeRootFileNode() const { return new AmigaOSFilesystemNode(); } -AbstractFilesystemNode *AmigaOSFilesystemFactory::makeCurrentDirectoryFileNode() const { +AbstractFSNode *AmigaOSFilesystemFactory::makeCurrentDirectoryFileNode() const { return new AmigaOSFilesystemNode(); } -AbstractFilesystemNode *AmigaOSFilesystemFactory::makeFileNodePath(const Common::String &path) const { +AbstractFSNode *AmigaOSFilesystemFactory::makeFileNodePath(const Common::String &path) const { return new AmigaOSFilesystemNode(path); } #endif diff --git a/backends/fs/amigaos4/amigaos4-fs-factory.h b/backends/fs/amigaos4/amigaos4-fs-factory.h index 03af6e95b9..89b3c7008d 100644 --- a/backends/fs/amigaos4/amigaos4-fs-factory.h +++ b/backends/fs/amigaos4/amigaos4-fs-factory.h @@ -34,9 +34,9 @@ */ class AmigaOSFilesystemFactory : public FilesystemFactory { public: - virtual AbstractFilesystemNode *makeRootFileNode() const; - virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const; - virtual AbstractFilesystemNode *makeFileNodePath(const Common::String &path) const; + virtual AbstractFSNode *makeRootFileNode() const; + virtual AbstractFSNode *makeCurrentDirectoryFileNode() const; + virtual AbstractFSNode *makeFileNodePath(const Common::String &path) const; }; #endif /*AMIGAOS_FILESYSTEM_FACTORY_H*/ diff --git a/backends/fs/amigaos4/amigaos4-fs.cpp b/backends/fs/amigaos4/amigaos4-fs.cpp index d517121dc0..3b8d7b635c 100644 --- a/backends/fs/amigaos4/amigaos4-fs.cpp +++ b/backends/fs/amigaos4/amigaos4-fs.cpp @@ -47,9 +47,9 @@ const uint32 kExAllBufferSize = 40960; // TODO: is this okay for sure? /** * Implementation of the ScummVM file system API. * - * Parts of this class are documented in the base interface class, AbstractFilesystemNode. + * Parts of this class are documented in the base interface class, AbstractFSNode. */ -class AmigaOSFilesystemNode : public AbstractFilesystemNode { +class AmigaOSFilesystemNode : public AbstractFSNode { protected: BPTR _pFileLock; Common::String _sDisplayName; @@ -58,7 +58,7 @@ protected: bool _bIsValid; /** - * Obtain the FileInfoBlock protection value for this FilesystemNode, + * Obtain the FileInfoBlock protection value for this FSNode, * as defined in the <proto/dos.h> header. * * @return -1 if there were errors, 0 or a positive integer otherwise. @@ -103,9 +103,9 @@ public: virtual bool isReadable() const; virtual bool isWritable() const; - virtual AbstractFilesystemNode *getChild(const Common::String &n) const; + virtual AbstractFSNode *getChild(const Common::String &n) const; virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const; - virtual AbstractFilesystemNode *getParent() const; + virtual AbstractFSNode *getParent() const; virtual Common::SeekableReadStream *openForReading(); virtual Common::WriteStream *openForWriting(); @@ -302,7 +302,7 @@ bool AmigaOSFilesystemNode::exists() const { return nodeExists; } -AbstractFilesystemNode *AmigaOSFilesystemNode::getChild(const Common::String &n) const { +AbstractFSNode *AmigaOSFilesystemNode::getChild(const Common::String &n) const { ENTER(); if (!_bIsDirectory) { debug(6, "Not a directory"); @@ -371,9 +371,9 @@ bool AmigaOSFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, b struct ExAllData *ead = data; do { - if ((mode == Common::FilesystemNode::kListAll) || - (EAD_IS_DRAWER(ead) && (mode == Common::FilesystemNode::kListDirectoriesOnly)) || - (EAD_IS_FILE(ead) && (mode == Common::FilesystemNode::kListFilesOnly))) { + if ((mode == Common::FSNode::kListAll) || + (EAD_IS_DRAWER(ead) && (mode == Common::FSNode::kListDirectoriesOnly)) || + (EAD_IS_FILE(ead) && (mode == Common::FSNode::kListFilesOnly))) { Common::String full_path = _sPath; full_path += (char*)ead->ed_Name; @@ -381,7 +381,7 @@ bool AmigaOSFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, b if (lock) { AmigaOSFilesystemNode *entry = new AmigaOSFilesystemNode(lock, (char *)ead->ed_Name); if (entry) { - //FIXME: since the isValid() function is no longer part of the AbstractFilesystemNode + //FIXME: since the isValid() function is no longer part of the AbstractFSNode // specification, the following call had to be changed: // if (entry->isValid()) // Please verify that the logic of the code remains coherent. Also, remember @@ -433,7 +433,7 @@ int AmigaOSFilesystemNode::getFibProtection() const { return fibProt; } -AbstractFilesystemNode *AmigaOSFilesystemNode::getParent() const { +AbstractFSNode *AmigaOSFilesystemNode::getParent() const { ENTER(); if (!_bIsDirectory) { @@ -543,7 +543,7 @@ AbstractFSList AmigaOSFilesystemNode::listVolumes() const { AmigaOSFilesystemNode *entry = new AmigaOSFilesystemNode(volumeLock, buffer); if (entry) { - //FIXME: since the isValid() function is no longer part of the AbstractFilesystemNode + //FIXME: since the isValid() function is no longer part of the AbstractFSNode // specification, the following call had to be changed: // if (entry->isValid()) // Please verify that the logic of the code remains coherent. Also, remember diff --git a/backends/fs/ds/ds-fs-factory.cpp b/backends/fs/ds/ds-fs-factory.cpp index 5c8c3f45f8..0dfa70b716 100644 --- a/backends/fs/ds/ds-fs-factory.cpp +++ b/backends/fs/ds/ds-fs-factory.cpp @@ -29,7 +29,7 @@ DECLARE_SINGLETON(DSFilesystemFactory); -AbstractFilesystemNode *DSFilesystemFactory::makeRootFileNode() const { +AbstractFSNode *DSFilesystemFactory::makeRootFileNode() const { if (DS::isGBAMPAvailable()) { return new DS::GBAMPFileSystemNode(); } else { @@ -37,7 +37,7 @@ AbstractFilesystemNode *DSFilesystemFactory::makeRootFileNode() const { } } -AbstractFilesystemNode *DSFilesystemFactory::makeCurrentDirectoryFileNode() const { +AbstractFSNode *DSFilesystemFactory::makeCurrentDirectoryFileNode() const { if (DS::isGBAMPAvailable()) { return new DS::GBAMPFileSystemNode(); } else { @@ -45,7 +45,7 @@ AbstractFilesystemNode *DSFilesystemFactory::makeCurrentDirectoryFileNode() cons } } -AbstractFilesystemNode *DSFilesystemFactory::makeFileNodePath(const Common::String &path) const { +AbstractFSNode *DSFilesystemFactory::makeFileNodePath(const Common::String &path) const { if (DS::isGBAMPAvailable()) { return new DS::GBAMPFileSystemNode(path); } else { diff --git a/backends/fs/ds/ds-fs-factory.h b/backends/fs/ds/ds-fs-factory.h index 67e0076b78..f4b381c477 100644 --- a/backends/fs/ds/ds-fs-factory.h +++ b/backends/fs/ds/ds-fs-factory.h @@ -35,9 +35,9 @@ */ class DSFilesystemFactory : public FilesystemFactory, public Common::Singleton<DSFilesystemFactory> { public: - virtual AbstractFilesystemNode *makeRootFileNode() const; - virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const; - virtual AbstractFilesystemNode *makeFileNodePath(const Common::String &path) const; + virtual AbstractFSNode *makeRootFileNode() const; + virtual AbstractFSNode *makeCurrentDirectoryFileNode() const; + virtual AbstractFSNode *makeFileNodePath(const Common::String &path) const; protected: DSFilesystemFactory() {}; diff --git a/backends/fs/ds/ds-fs.cpp b/backends/fs/ds/ds-fs.cpp index 911702316d..5fc284b4d8 100644 --- a/backends/fs/ds/ds-fs.cpp +++ b/backends/fs/ds/ds-fs.cpp @@ -125,7 +125,7 @@ DSFileSystemNode::DSFileSystemNode(const DSFileSystemNode* node) { //TODO: not implemented? } -AbstractFilesystemNode *DSFileSystemNode::getChild(const Common::String& n) const { +AbstractFSNode *DSFileSystemNode::getChild(const Common::String& n) const { if (_path.lastChar() == '\\') { return new DSFileSystemNode(_path + n); } else { @@ -168,8 +168,8 @@ bool DSFileSystemNode::getChildren(AbstractFSList &dirList, ListMode mode, bool _zipFile->getFileName(n); // consolePrintf("file: %s\n", n); - if ( (_zipFile->isDirectory() && ((mode == Common::FilesystemNode::kListDirectoriesOnly) || (mode == Common::FilesystemNode::kListAll)) ) - || (!_zipFile->isDirectory() && ((mode == Common::FilesystemNode::kListFilesOnly) || (mode == Common::FilesystemNode::kListAll)) ) ) + if ( (_zipFile->isDirectory() && ((mode == Common::FSNode::kListDirectoriesOnly) || (mode == Common::FSNode::kListAll)) ) + || (!_zipFile->isDirectory() && ((mode == Common::FSNode::kListFilesOnly) || (mode == Common::FSNode::kListAll)) ) ) { DSFileSystemNode* dsfsn = new DSFileSystemNode("ds:/" + Common::String(n), _zipFile->isDirectory()); dsfsn->_isDirectory = _zipFile->isDirectory(); @@ -182,7 +182,7 @@ bool DSFileSystemNode::getChildren(AbstractFSList &dirList, ListMode mode, bool return true; } -AbstractFilesystemNode* DSFileSystemNode::getParent() const { +AbstractFSNode* DSFileSystemNode::getParent() const { // consolePrintf("parent\n"); DSFileSystemNode *p; @@ -285,7 +285,7 @@ GBAMPFileSystemNode::GBAMPFileSystemNode(const GBAMPFileSystemNode* node) { //TODO: not implemented? } -AbstractFilesystemNode *GBAMPFileSystemNode::getChild(const Common::String& n) const { +AbstractFSNode *GBAMPFileSystemNode::getChild(const Common::String& n) const { if (_path.lastChar() == '\\') { return new DSFileSystemNode(_path + n); } else { @@ -322,8 +322,8 @@ bool GBAMPFileSystemNode::getChildren(AbstractFSList& dirList, ListMode mode, bo while (entryType != TYPE_NO_MORE) { - if ( ((entryType == TYPE_DIR) && ((mode == Common::FilesystemNode::kListDirectoriesOnly) || (mode == Common::FilesystemNode::kListAll))) - || ((entryType == TYPE_FILE) && ((mode == Common::FilesystemNode::kListFilesOnly) || (mode == Common::FilesystemNode::kListAll))) ) { + if ( ((entryType == TYPE_DIR) && ((mode == Common::FSNode::kListDirectoriesOnly) || (mode == Common::FSNode::kListAll))) + || ((entryType == TYPE_FILE) && ((mode == Common::FSNode::kListFilesOnly) || (mode == Common::FSNode::kListAll))) ) { GBAMPFileSystemNode* dsfsn; consolePrintf("Fname: %s\n", fname); @@ -353,7 +353,7 @@ bool GBAMPFileSystemNode::getChildren(AbstractFSList& dirList, ListMode mode, bo return true; } -AbstractFilesystemNode* GBAMPFileSystemNode::getParent() const { +AbstractFSNode* GBAMPFileSystemNode::getParent() const { // consolePrintf("parent\n"); GBAMPFileSystemNode *p; diff --git a/backends/fs/ds/ds-fs.h b/backends/fs/ds/ds-fs.h index 36e7bc9824..24d51d9d71 100644 --- a/backends/fs/ds/ds-fs.h +++ b/backends/fs/ds/ds-fs.h @@ -37,9 +37,9 @@ namespace DS { * Implementation of the ScummVM file system API. * This class is used when a Flash cart is in use. * - * Parts of this class are documented in the base interface class, AbstractFilesystemNode. + * Parts of this class are documented in the base interface class, AbstractFSNode. */ -class DSFileSystemNode : public AbstractFilesystemNode { +class DSFileSystemNode : public AbstractFSNode { protected: static ZipFile* _zipFile; @@ -85,10 +85,10 @@ public: /** * Returns a copy of this node. */ - virtual AbstractFilesystemNode *clone() const { return new DSFileSystemNode(this); } - virtual AbstractFilesystemNode *getChild(const Common::String& name) const; + virtual AbstractFSNode *clone() const { return new DSFileSystemNode(this); } + virtual AbstractFSNode *getChild(const Common::String& name) const; virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const; - virtual AbstractFilesystemNode *getParent() const; + virtual AbstractFSNode *getParent() const; virtual Common::SeekableReadStream *openForReading(); virtual Common::WriteStream *openForWriting(); @@ -104,9 +104,9 @@ public: * Implementation of the ScummVM file system API. * This class is used when the GBAMP (GBA Movie Player) is used with a CompactFlash card. * - * Parts of this class are documented in the base interface class, AbstractFilesystemNode. + * Parts of this class are documented in the base interface class, AbstractFSNode. */ -class GBAMPFileSystemNode : public AbstractFilesystemNode { +class GBAMPFileSystemNode : public AbstractFSNode { protected: Common::String _displayName; Common::String _path; @@ -150,10 +150,10 @@ public: /** * Returns a copy of this node. */ - virtual AbstractFilesystemNode *clone() const { return new GBAMPFileSystemNode(this); } - virtual AbstractFilesystemNode *getChild(const Common::String& name) const; + virtual AbstractFSNode *clone() const { return new GBAMPFileSystemNode(this); } + virtual AbstractFSNode *getChild(const Common::String& name) const; virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const; - virtual AbstractFilesystemNode *getParent() const; + virtual AbstractFSNode *getParent() const; virtual Common::SeekableReadStream *openForReading(); virtual Common::WriteStream *openForWriting(); diff --git a/backends/fs/fs-factory.h b/backends/fs/fs-factory.h index f0c82a0ca4..cfa5b87edd 100644 --- a/backends/fs/fs-factory.h +++ b/backends/fs/fs-factory.h @@ -29,7 +29,7 @@ #include "backends/fs/abstract-fs.h" /** - * Creates concrete FilesystemNode objects depending on the current architecture. + * Creates concrete FSNode objects depending on the current architecture. */ class FilesystemFactory { public: @@ -44,7 +44,7 @@ public: * emulate it or simply return some "sensible" default directory node, * e.g. the same value as getRoot() returns. */ - virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const = 0; + virtual AbstractFSNode *makeCurrentDirectoryFileNode() const = 0; /** * Construct a node based on a path; the path is in the same format as it @@ -54,9 +54,9 @@ public: * identical to oldNode. Hence, we can use the "path" value for persistent * storage e.g. in the config file. * - * @param path The path string to create a FilesystemNode for. + * @param path The path string to create a FSNode for. */ - virtual AbstractFilesystemNode *makeFileNodePath(const Common::String &path) const = 0; + virtual AbstractFSNode *makeFileNodePath(const Common::String &path) const = 0; /** * Returns a special node representing the filesystem root. @@ -65,7 +65,7 @@ public: * On Unix, this will be simply the node for / (the root directory). * On Windows, it will be a special node which "contains" all drives (C:, D:, E:). */ - virtual AbstractFilesystemNode *makeRootFileNode() const = 0; + virtual AbstractFSNode *makeRootFileNode() const = 0; }; #endif /*FILESYSTEM_FACTORY_H*/ diff --git a/backends/fs/palmos/palmos-fs-factory.cpp b/backends/fs/palmos/palmos-fs-factory.cpp index bbc1639897..889d541571 100644 --- a/backends/fs/palmos/palmos-fs-factory.cpp +++ b/backends/fs/palmos/palmos-fs-factory.cpp @@ -28,15 +28,15 @@ DECLARE_SINGLETON(PalmOSFilesystemFactory); -AbstractFilesystemNode *PalmOSFilesystemFactory::makeRootFileNode() const { +AbstractFSNode *PalmOSFilesystemFactory::makeRootFileNode() const { return new PalmOSFilesystemNode(); } -AbstractFilesystemNode *PalmOSFilesystemFactory::makeCurrentDirectoryFileNode() const { +AbstractFSNode *PalmOSFilesystemFactory::makeCurrentDirectoryFileNode() const { return new PalmOSFilesystemNode(); } -AbstractFilesystemNode *PalmOSFilesystemFactory::makeFileNodePath(const Common::String &path) const { +AbstractFSNode *PalmOSFilesystemFactory::makeFileNodePath(const Common::String &path) const { return new PalmOSFilesystemNode(path); } #endif diff --git a/backends/fs/palmos/palmos-fs-factory.h b/backends/fs/palmos/palmos-fs-factory.h index f778aa89ef..72729c570d 100644 --- a/backends/fs/palmos/palmos-fs-factory.h +++ b/backends/fs/palmos/palmos-fs-factory.h @@ -35,9 +35,9 @@ */ class PalmOSFilesystemFactory : public FilesystemFactory, public Common::Singleton<PalmOSFilesystemFactory> { public: - virtual AbstractFilesystemNode *makeRootFileNode() const; - virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const; - virtual AbstractFilesystemNode *makeFileNodePath(const Common::String &path) const; + virtual AbstractFSNode *makeRootFileNode() const; + virtual AbstractFSNode *makeCurrentDirectoryFileNode() const; + virtual AbstractFSNode *makeFileNodePath(const Common::String &path) const; protected: PalmOSFilesystemFactory() {}; diff --git a/backends/fs/palmos/palmos-fs.cpp b/backends/fs/palmos/palmos-fs.cpp index 7c415aa320..b828213817 100644 --- a/backends/fs/palmos/palmos-fs.cpp +++ b/backends/fs/palmos/palmos-fs.cpp @@ -33,9 +33,9 @@ /** * Implementation of the ScummVM file system API based on PalmOS VFS API. * - * Parts of this class are documented in the base interface class, AbstractFilesystemNode. + * Parts of this class are documented in the base interface class, AbstractFSNode. */ -class PalmOSFilesystemNode : public AbstractFilesystemNode { +class PalmOSFilesystemNode : public AbstractFSNode { protected: Common::String _displayName; Common::String _path; @@ -64,9 +64,9 @@ public: virtual bool isReadable() const { return true; } //FIXME: this is just a stub virtual bool isWritable() const { return true; } //FIXME: this is just a stub - virtual AbstractFilesystemNode *getChild(const Common::String &n) const; + virtual AbstractFSNode *getChild(const Common::String &n) const; virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const; - virtual AbstractFilesystemNode *getParent() const; + virtual AbstractFSNode *getParent() const; virtual Common::SeekableReadStream *openForReading(); virtual Common::WriteStream *openForWriting(); @@ -90,8 +90,8 @@ void PalmOSFilesystemNode::addFile(AbstractFSList &list, ListMode mode, const ch isDir = (find_data->attributes & vfsFileAttrDirectory); - if ((!isDir && mode == Common::FilesystemNode::kListDirectoriesOnly) || - (isDir && mode == Common::FilesystemNode::kListFilesOnly)) + if ((!isDir && mode == Common::FSNode::kListDirectoriesOnly) || + (isDir && mode == Common::FSNode::kListFilesOnly)) return; entry._isDirectory = isDir; @@ -139,7 +139,7 @@ PalmOSFilesystemNode::PalmOSFilesystemNode(const Common::String &p) { _isPseudoRoot = false; } -AbstractFilesystemNode *PalmOSFilesystemNode::getChild(const Common::String &n) const { +AbstractFSNode *PalmOSFilesystemNode::getChild(const Common::String &n) const { assert(_isDirectory); Common::String newPath(_path); @@ -190,7 +190,7 @@ bool PalmOSFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, bo return true; } -AbstractFilesystemNode *PalmOSFilesystemNode::getParent() const { +AbstractFSNode *PalmOSFilesystemNode::getParent() const { PalmOSFilesystemNode *p = 0; if (!_isPseudoRoot) { diff --git a/backends/fs/posix/posix-fs-factory.cpp b/backends/fs/posix/posix-fs-factory.cpp index cbfb69b76a..ae60fbaccb 100644 --- a/backends/fs/posix/posix-fs-factory.cpp +++ b/backends/fs/posix/posix-fs-factory.cpp @@ -26,17 +26,17 @@ #include "backends/fs/posix/posix-fs-factory.h" #include "backends/fs/posix/posix-fs.cpp" -AbstractFilesystemNode *POSIXFilesystemFactory::makeRootFileNode() const { +AbstractFSNode *POSIXFilesystemFactory::makeRootFileNode() const { return new POSIXFilesystemNode("/"); } -AbstractFilesystemNode *POSIXFilesystemFactory::makeCurrentDirectoryFileNode() const { +AbstractFSNode *POSIXFilesystemFactory::makeCurrentDirectoryFileNode() const { char buf[MAXPATHLEN]; getcwd(buf, MAXPATHLEN); return new POSIXFilesystemNode(buf); } -AbstractFilesystemNode *POSIXFilesystemFactory::makeFileNodePath(const Common::String &path) const { +AbstractFSNode *POSIXFilesystemFactory::makeFileNodePath(const Common::String &path) const { assert(!path.empty()); return new POSIXFilesystemNode(path); } diff --git a/backends/fs/posix/posix-fs-factory.h b/backends/fs/posix/posix-fs-factory.h index c697679814..68c1fdd876 100644 --- a/backends/fs/posix/posix-fs-factory.h +++ b/backends/fs/posix/posix-fs-factory.h @@ -33,9 +33,9 @@ * Parts of this class are documented in the base interface class, FilesystemFactory. */ class POSIXFilesystemFactory : public FilesystemFactory { - virtual AbstractFilesystemNode *makeRootFileNode() const; - virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const; - virtual AbstractFilesystemNode *makeFileNodePath(const Common::String &path) const; + virtual AbstractFSNode *makeRootFileNode() const; + virtual AbstractFSNode *makeCurrentDirectoryFileNode() const; + virtual AbstractFSNode *makeFileNodePath(const Common::String &path) const; }; #endif /*POSIX_FILESYSTEM_FACTORY_H*/ diff --git a/backends/fs/posix/posix-fs.cpp b/backends/fs/posix/posix-fs.cpp index 8dca78d82a..463d647042 100644 --- a/backends/fs/posix/posix-fs.cpp +++ b/backends/fs/posix/posix-fs.cpp @@ -92,7 +92,7 @@ POSIXFilesystemNode::POSIXFilesystemNode(const Common::String &p) { setFlags(); } -AbstractFilesystemNode *POSIXFilesystemNode::getChild(const Common::String &n) const { +AbstractFSNode *POSIXFilesystemNode::getChild(const Common::String &n) const { assert(!_path.empty()); assert(_isDirectory); @@ -197,8 +197,8 @@ bool POSIXFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, boo continue; // Honor the chosen mode - if ((mode == Common::FilesystemNode::kListFilesOnly && entry._isDirectory) || - (mode == Common::FilesystemNode::kListDirectoriesOnly && !entry._isDirectory)) + if ((mode == Common::FSNode::kListFilesOnly && entry._isDirectory) || + (mode == Common::FSNode::kListDirectoriesOnly && !entry._isDirectory)) continue; myList.push_back(new POSIXFilesystemNode(entry)); @@ -208,7 +208,7 @@ bool POSIXFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, boo return true; } -AbstractFilesystemNode *POSIXFilesystemNode::getParent() const { +AbstractFSNode *POSIXFilesystemNode::getParent() const { if (_path == "/") return 0; // The filesystem root has no parent diff --git a/backends/fs/posix/posix-fs.h b/backends/fs/posix/posix-fs.h index e09e433e05..7bd21c94b1 100644 --- a/backends/fs/posix/posix-fs.h +++ b/backends/fs/posix/posix-fs.h @@ -35,16 +35,16 @@ /** * Implementation of the ScummVM file system API based on POSIX. * - * Parts of this class are documented in the base interface class, AbstractFilesystemNode. + * Parts of this class are documented in the base interface class, AbstractFSNode. */ -class POSIXFilesystemNode : public AbstractFilesystemNode { +class POSIXFilesystemNode : public AbstractFSNode { protected: Common::String _displayName; Common::String _path; bool _isDirectory; bool _isValid; - virtual AbstractFilesystemNode *makeNode(const Common::String &path) const { + virtual AbstractFSNode *makeNode(const Common::String &path) const { return new POSIXFilesystemNode(path); } @@ -69,9 +69,9 @@ public: virtual bool isReadable() const { return access(_path.c_str(), R_OK) == 0; } virtual bool isWritable() const { return access(_path.c_str(), W_OK) == 0; } - virtual AbstractFilesystemNode *getChild(const Common::String &n) const; + virtual AbstractFSNode *getChild(const Common::String &n) const; virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const; - virtual AbstractFilesystemNode *getParent() const; + virtual AbstractFSNode *getParent() const; virtual Common::SeekableReadStream *openForReading(); virtual Common::WriteStream *openForWriting(); diff --git a/backends/fs/ps2/ps2-fs-factory.cpp b/backends/fs/ps2/ps2-fs-factory.cpp index e96671ee0a..77fb4b0866 100644 --- a/backends/fs/ps2/ps2-fs-factory.cpp +++ b/backends/fs/ps2/ps2-fs-factory.cpp @@ -28,15 +28,15 @@ DECLARE_SINGLETON(Ps2FilesystemFactory); -AbstractFilesystemNode *Ps2FilesystemFactory::makeRootFileNode() const { +AbstractFSNode *Ps2FilesystemFactory::makeRootFileNode() const { return new Ps2FilesystemNode(); } -AbstractFilesystemNode *Ps2FilesystemFactory::makeCurrentDirectoryFileNode() const { +AbstractFSNode *Ps2FilesystemFactory::makeCurrentDirectoryFileNode() const { return new Ps2FilesystemNode(); } -AbstractFilesystemNode *Ps2FilesystemFactory::makeFileNodePath(const Common::String &path) const { +AbstractFSNode *Ps2FilesystemFactory::makeFileNodePath(const Common::String &path) const { // return new Ps2FilesystemNode(path); Ps2FilesystemNode *nf = new Ps2FilesystemNode(path, true); diff --git a/backends/fs/ps2/ps2-fs-factory.h b/backends/fs/ps2/ps2-fs-factory.h index 432cf467c3..dd6b5dc013 100644 --- a/backends/fs/ps2/ps2-fs-factory.h +++ b/backends/fs/ps2/ps2-fs-factory.h @@ -35,9 +35,9 @@ */ class Ps2FilesystemFactory : public FilesystemFactory, public Common::Singleton<Ps2FilesystemFactory> { public: - virtual AbstractFilesystemNode *makeRootFileNode() const; - virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const; - virtual AbstractFilesystemNode *makeFileNodePath(const Common::String &path) const; + virtual AbstractFSNode *makeRootFileNode() const; + virtual AbstractFSNode *makeCurrentDirectoryFileNode() const; + virtual AbstractFSNode *makeFileNodePath(const Common::String &path) const; protected: Ps2FilesystemFactory() {}; diff --git a/backends/fs/ps2/ps2-fs.cpp b/backends/fs/ps2/ps2-fs.cpp index 3d7656e9f0..fd20562a24 100644 --- a/backends/fs/ps2/ps2-fs.cpp +++ b/backends/fs/ps2/ps2-fs.cpp @@ -41,9 +41,9 @@ extern OSystem_PS2 *g_systemPs2; /** * Implementation of the ScummVM file system API based on the Ps2SDK. * - * Parts of this class are documented in the base interface class, AbstractFilesystemNode. + * Parts of this class are documented in the base interface class, AbstractFSNode. */ -class Ps2FilesystemNode : public AbstractFilesystemNode { +class Ps2FilesystemNode : public AbstractFSNode { friend class Ps2FilesystemFactory; @@ -95,10 +95,10 @@ public: return false; } - virtual AbstractFilesystemNode *clone() const { return new Ps2FilesystemNode(this); } - virtual AbstractFilesystemNode *getChild(const Common::String &n) const; + virtual AbstractFSNode *clone() const { return new Ps2FilesystemNode(this); } + virtual AbstractFSNode *getChild(const Common::String &n) const; virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const; - virtual AbstractFilesystemNode *getParent() const; + virtual AbstractFSNode *getParent() const; virtual Common::SeekableReadStream *openForReading(); virtual Common::WriteStream *openForWriting(); @@ -210,7 +210,7 @@ bool Ps2FilesystemNode::getDirectoryFlag(const char *path) { return false; } -AbstractFilesystemNode *Ps2FilesystemNode::getChild(const Common::String &n) const { +AbstractFSNode *Ps2FilesystemNode::getChild(const Common::String &n) const { if (!_isDirectory) return NULL; @@ -288,9 +288,9 @@ bool Ps2FilesystemNode::getChildren(AbstractFSList &list, ListMode mode, bool hi while ((dreadRes = fio.dread(fd, &dirent)) > 0) { if (dirent.name[0] == '.') continue; // ignore '.' and '..' - if (((mode == Common::FilesystemNode::kListDirectoriesOnly) && (dirent.stat.mode & FIO_S_IFDIR)) || - ((mode == Common::FilesystemNode::kListFilesOnly) && !(dirent.stat.mode & FIO_S_IFDIR)) || - (mode == Common::FilesystemNode::kListAll)) { + if (((mode == Common::FSNode::kListDirectoriesOnly) && (dirent.stat.mode & FIO_S_IFDIR)) || + ((mode == Common::FSNode::kListFilesOnly) && !(dirent.stat.mode & FIO_S_IFDIR)) || + (mode == Common::FSNode::kListAll)) { dirEntry._isDirectory = (bool)(dirent.stat.mode & FIO_S_IFDIR); dirEntry._isRoot = false; @@ -312,7 +312,7 @@ bool Ps2FilesystemNode::getChildren(AbstractFSList &list, ListMode mode, bool hi } } -AbstractFilesystemNode *Ps2FilesystemNode::getParent() const { +AbstractFSNode *Ps2FilesystemNode::getParent() const { if (_isRoot) return new Ps2FilesystemNode(this); diff --git a/backends/fs/psp/psp-fs-factory.cpp b/backends/fs/psp/psp-fs-factory.cpp index a38462f02a..cfe8ed27d1 100644 --- a/backends/fs/psp/psp-fs-factory.cpp +++ b/backends/fs/psp/psp-fs-factory.cpp @@ -28,15 +28,15 @@ DECLARE_SINGLETON(PSPFilesystemFactory); -AbstractFilesystemNode *PSPFilesystemFactory::makeRootFileNode() const { +AbstractFSNode *PSPFilesystemFactory::makeRootFileNode() const { return new PSPFilesystemNode(); } -AbstractFilesystemNode *PSPFilesystemFactory::makeCurrentDirectoryFileNode() const { +AbstractFSNode *PSPFilesystemFactory::makeCurrentDirectoryFileNode() const { return new PSPFilesystemNode(); } -AbstractFilesystemNode *PSPFilesystemFactory::makeFileNodePath(const Common::String &path) const { +AbstractFSNode *PSPFilesystemFactory::makeFileNodePath(const Common::String &path) const { return new PSPFilesystemNode(path, true); } #endif diff --git a/backends/fs/psp/psp-fs-factory.h b/backends/fs/psp/psp-fs-factory.h index abf03d288e..36ecb8188b 100644 --- a/backends/fs/psp/psp-fs-factory.h +++ b/backends/fs/psp/psp-fs-factory.h @@ -35,9 +35,9 @@ */ class PSPFilesystemFactory : public FilesystemFactory, public Common::Singleton<PSPFilesystemFactory> { public: - virtual AbstractFilesystemNode *makeRootFileNode() const; - virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const; - virtual AbstractFilesystemNode *makeFileNodePath(const Common::String &path) const; + virtual AbstractFSNode *makeRootFileNode() const; + virtual AbstractFSNode *makeCurrentDirectoryFileNode() const; + virtual AbstractFSNode *makeFileNodePath(const Common::String &path) const; protected: PSPFilesystemFactory() {}; diff --git a/backends/fs/psp/psp-fs.cpp b/backends/fs/psp/psp-fs.cpp index 13cd63903b..bf08fdd2c6 100644 --- a/backends/fs/psp/psp-fs.cpp +++ b/backends/fs/psp/psp-fs.cpp @@ -36,9 +36,9 @@ /** * Implementation of the ScummVM file system API based on PSPSDK API. * - * Parts of this class are documented in the base interface class, AbstractFilesystemNode. + * Parts of this class are documented in the base interface class, AbstractFSNode. */ -class PSPFilesystemNode : public AbstractFilesystemNode { +class PSPFilesystemNode : public AbstractFSNode { protected: Common::String _displayName; Common::String _path; @@ -67,9 +67,9 @@ public: virtual bool isReadable() const { return access(_path.c_str(), R_OK) == 0; } virtual bool isWritable() const { return access(_path.c_str(), W_OK) == 0; } - virtual AbstractFilesystemNode *getChild(const Common::String &n) const; + virtual AbstractFSNode *getChild(const Common::String &n) const; virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const; - virtual AbstractFilesystemNode *getParent() const; + virtual AbstractFSNode *getParent() const; virtual Common::SeekableReadStream *openForReading(); virtual Common::WriteStream *openForWriting(); @@ -97,7 +97,7 @@ PSPFilesystemNode::PSPFilesystemNode(const Common::String &p, bool verify) { } } -AbstractFilesystemNode *PSPFilesystemNode::getChild(const Common::String &n) const { +AbstractFSNode *PSPFilesystemNode::getChild(const Common::String &n) const { // FIXME: Pretty lame implementation! We do no error checking to speak // of, do not check if this is a special node, etc. assert(_isDirectory); @@ -137,8 +137,8 @@ bool PSPFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, bool entry._path += "/"; // Honor the chosen mode - if ((mode == Common::FilesystemNode::kListFilesOnly && entry._isDirectory) || - (mode == Common::FilesystemNode::kListDirectoriesOnly && !entry._isDirectory)) + if ((mode == Common::FSNode::kListFilesOnly && entry._isDirectory) || + (mode == Common::FSNode::kListDirectoriesOnly && !entry._isDirectory)) continue; myList.push_back(new PSPFilesystemNode(entry)); @@ -151,7 +151,7 @@ bool PSPFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, bool } } -AbstractFilesystemNode *PSPFilesystemNode::getParent() const { +AbstractFSNode *PSPFilesystemNode::getParent() const { if (_path == ROOT_PATH) return 0; diff --git a/backends/fs/symbian/symbian-fs-factory.cpp b/backends/fs/symbian/symbian-fs-factory.cpp index c31dfb594a..c70a67f339 100644 --- a/backends/fs/symbian/symbian-fs-factory.cpp +++ b/backends/fs/symbian/symbian-fs-factory.cpp @@ -26,17 +26,17 @@ #include "backends/fs/symbian/symbian-fs-factory.h" #include "backends/fs/symbian/symbian-fs.cpp" -AbstractFilesystemNode *SymbianFilesystemFactory::makeRootFileNode() const { +AbstractFSNode *SymbianFilesystemFactory::makeRootFileNode() const { return new SymbianFilesystemNode(true); } -AbstractFilesystemNode *SymbianFilesystemFactory::makeCurrentDirectoryFileNode() const { +AbstractFSNode *SymbianFilesystemFactory::makeCurrentDirectoryFileNode() const { char path[MAXPATHLEN]; getcwd(path, MAXPATHLEN); return new SymbianFilesystemNode(path); } -AbstractFilesystemNode *SymbianFilesystemFactory::makeFileNodePath(const Common::String &path) const { +AbstractFSNode *SymbianFilesystemFactory::makeFileNodePath(const Common::String &path) const { return new SymbianFilesystemNode(path); } #endif diff --git a/backends/fs/symbian/symbian-fs-factory.h b/backends/fs/symbian/symbian-fs-factory.h index ef5a231e72..2ad75b41ee 100644 --- a/backends/fs/symbian/symbian-fs-factory.h +++ b/backends/fs/symbian/symbian-fs-factory.h @@ -34,9 +34,9 @@ */ class SymbianFilesystemFactory : public FilesystemFactory { public: - virtual AbstractFilesystemNode *makeRootFileNode() const; - virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const; - virtual AbstractFilesystemNode *makeFileNodePath(const Common::String &path) const; + virtual AbstractFSNode *makeRootFileNode() const; + virtual AbstractFSNode *makeCurrentDirectoryFileNode() const; + virtual AbstractFSNode *makeFileNodePath(const Common::String &path) const; }; #endif /*SYMBIAN_FILESYSTEM_FACTORY_H*/ diff --git a/backends/fs/symbian/symbian-fs.cpp b/backends/fs/symbian/symbian-fs.cpp index 1c6d8435a9..74b7c28873 100644 --- a/backends/fs/symbian/symbian-fs.cpp +++ b/backends/fs/symbian/symbian-fs.cpp @@ -37,9 +37,9 @@ /** * Implementation of the ScummVM file system API based on POSIX. * - * Parts of this class are documented in the base interface class, AbstractFilesystemNode. + * Parts of this class are documented in the base interface class, AbstractFSNode. */ -class SymbianFilesystemNode : public AbstractFilesystemNode { +class SymbianFilesystemNode : public AbstractFSNode { protected: Common::String _displayName; Common::String _path; @@ -75,9 +75,9 @@ public: virtual bool isReadable() const { return access(_path.c_str(), R_OK) == 0; } //FIXME: this is just a stub virtual bool isWritable() const { return access(_path.c_str(), W_OK) == 0; } //FIXME: this is just a stub - virtual AbstractFilesystemNode *getChild(const Common::String &n) const; + virtual AbstractFSNode *getChild(const Common::String &n) const; virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const; - virtual AbstractFilesystemNode *getParent() const; + virtual AbstractFSNode *getParent() const; virtual Common::SeekableReadStream *openForReading(); virtual Common::WriteStream *openForWriting(); @@ -133,7 +133,7 @@ SymbianFilesystemNode::SymbianFilesystemNode(const Common::String &path) { } } -AbstractFilesystemNode *SymbianFilesystemNode::getChild(const Common::String &n) const { +AbstractFSNode *SymbianFilesystemNode::getChild(const Common::String &n) const { assert(_isDirectory); Common::String newPath(_path); @@ -216,8 +216,8 @@ bool SymbianFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, b entry._isDirectory = fileentry.IsDir(); // Honor the chosen mode - if ((mode == Common::FilesystemNode::kListFilesOnly && entry._isDirectory) || - (mode == Common::FilesystemNode::kListDirectoriesOnly && !entry._isDirectory)) + if ((mode == Common::FSNode::kListFilesOnly && entry._isDirectory) || + (mode == Common::FSNode::kListDirectoriesOnly && !entry._isDirectory)) continue; myList.push_back(new SymbianFilesystemNode(entry)); @@ -229,7 +229,7 @@ bool SymbianFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, b return true; } -AbstractFilesystemNode *SymbianFilesystemNode::getParent() const { +AbstractFSNode *SymbianFilesystemNode::getParent() const { SymbianFilesystemNode *p =NULL; // Root node is its own parent. Still we can't just return this diff --git a/backends/fs/wii/wii-fs-factory.cpp b/backends/fs/wii/wii-fs-factory.cpp index 69086a95f1..0112ffa150 100644 --- a/backends/fs/wii/wii-fs-factory.cpp +++ b/backends/fs/wii/wii-fs-factory.cpp @@ -29,11 +29,11 @@ DECLARE_SINGLETON(WiiFilesystemFactory); -AbstractFilesystemNode *WiiFilesystemFactory::makeRootFileNode() const { +AbstractFSNode *WiiFilesystemFactory::makeRootFileNode() const { return new WiiFilesystemNode(); } -AbstractFilesystemNode *WiiFilesystemFactory::makeCurrentDirectoryFileNode() const { +AbstractFSNode *WiiFilesystemFactory::makeCurrentDirectoryFileNode() const { char buf[MAXPATHLEN]; if (getcwd(buf, MAXPATHLEN)) @@ -42,7 +42,7 @@ AbstractFilesystemNode *WiiFilesystemFactory::makeCurrentDirectoryFileNode() con return new WiiFilesystemNode(); } -AbstractFilesystemNode *WiiFilesystemFactory::makeFileNodePath(const Common::String &path) const { +AbstractFSNode *WiiFilesystemFactory::makeFileNodePath(const Common::String &path) const { return new WiiFilesystemNode(path, true); } #endif diff --git a/backends/fs/wii/wii-fs-factory.h b/backends/fs/wii/wii-fs-factory.h index 36867a392c..be20244a0e 100644 --- a/backends/fs/wii/wii-fs-factory.h +++ b/backends/fs/wii/wii-fs-factory.h @@ -33,9 +33,9 @@ */ class WiiFilesystemFactory : public FilesystemFactory, public Common::Singleton<WiiFilesystemFactory> { public: - virtual AbstractFilesystemNode *makeRootFileNode() const; - virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const; - virtual AbstractFilesystemNode *makeFileNodePath(const Common::String &path) const; + virtual AbstractFSNode *makeRootFileNode() const; + virtual AbstractFSNode *makeCurrentDirectoryFileNode() const; + virtual AbstractFSNode *makeFileNodePath(const Common::String &path) const; protected: WiiFilesystemFactory() {}; diff --git a/backends/fs/wii/wii-fs.cpp b/backends/fs/wii/wii-fs.cpp index a620df5471..714555b02d 100644 --- a/backends/fs/wii/wii-fs.cpp +++ b/backends/fs/wii/wii-fs.cpp @@ -34,9 +34,9 @@ /** * Implementation of the ScummVM file system API based on Wii. * - * Parts of this class are documented in the base interface class, AbstractFilesystemNode. + * Parts of this class are documented in the base interface class, AbstractFSNode. */ -class WiiFilesystemNode : public AbstractFilesystemNode { +class WiiFilesystemNode : public AbstractFSNode { protected: Common::String _displayName; Common::String _path; @@ -64,9 +64,9 @@ public: virtual bool isReadable() const { return _isReadable; } virtual bool isWritable() const { return _isWritable; } - virtual AbstractFilesystemNode *getChild(const Common::String &n) const; + virtual AbstractFSNode *getChild(const Common::String &n) const; virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const; - virtual AbstractFilesystemNode *getParent() const; + virtual AbstractFSNode *getParent() const; virtual Common::SeekableReadStream *openForReading(); virtual Common::WriteStream *openForWriting(); @@ -114,7 +114,7 @@ bool WiiFilesystemNode::exists() const { return stat(_path.c_str (), &st) == 0; } -AbstractFilesystemNode *WiiFilesystemNode::getChild(const Common::String &n) const { +AbstractFSNode *WiiFilesystemNode::getChild(const Common::String &n) const { assert(_isDirectory); Common::String newPath(_path); @@ -147,8 +147,8 @@ bool WiiFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, bool bool isDir = S_ISDIR(st.st_mode); - if ((mode == Common::FilesystemNode::kListFilesOnly && isDir) || - (mode == Common::FilesystemNode::kListDirectoriesOnly && !isDir)) + if ((mode == Common::FSNode::kListFilesOnly && isDir) || + (mode == Common::FSNode::kListDirectoriesOnly && !isDir)) continue; if (isDir) @@ -162,7 +162,7 @@ bool WiiFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, bool return true; } -AbstractFilesystemNode *WiiFilesystemNode::getParent() const { +AbstractFSNode *WiiFilesystemNode::getParent() const { if (_path == "/") return 0; diff --git a/backends/fs/windows/windows-fs-factory.cpp b/backends/fs/windows/windows-fs-factory.cpp index ed273bb746..c74868b40d 100644 --- a/backends/fs/windows/windows-fs-factory.cpp +++ b/backends/fs/windows/windows-fs-factory.cpp @@ -26,15 +26,15 @@ #include "backends/fs/windows/windows-fs-factory.h" #include "backends/fs/windows/windows-fs.cpp" -AbstractFilesystemNode *WindowsFilesystemFactory::makeRootFileNode() const { +AbstractFSNode *WindowsFilesystemFactory::makeRootFileNode() const { return new WindowsFilesystemNode(); } -AbstractFilesystemNode *WindowsFilesystemFactory::makeCurrentDirectoryFileNode() const { +AbstractFSNode *WindowsFilesystemFactory::makeCurrentDirectoryFileNode() const { return new WindowsFilesystemNode("", true); } -AbstractFilesystemNode *WindowsFilesystemFactory::makeFileNodePath(const Common::String &path) const { +AbstractFSNode *WindowsFilesystemFactory::makeFileNodePath(const Common::String &path) const { return new WindowsFilesystemNode(path, false); } #endif diff --git a/backends/fs/windows/windows-fs-factory.h b/backends/fs/windows/windows-fs-factory.h index 3c7b80942d..cb2b102538 100644 --- a/backends/fs/windows/windows-fs-factory.h +++ b/backends/fs/windows/windows-fs-factory.h @@ -34,9 +34,9 @@ */ class WindowsFilesystemFactory : public FilesystemFactory { public: - virtual AbstractFilesystemNode *makeRootFileNode() const; - virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const; - virtual AbstractFilesystemNode *makeFileNodePath(const Common::String &path) const; + virtual AbstractFSNode *makeRootFileNode() const; + virtual AbstractFSNode *makeCurrentDirectoryFileNode() const; + virtual AbstractFSNode *makeFileNodePath(const Common::String &path) const; }; #endif /*WINDOWS_FILESYSTEM_FACTORY_H*/ diff --git a/backends/fs/windows/windows-fs.cpp b/backends/fs/windows/windows-fs.cpp index c59c7dbe71..7f5c85ee7d 100644 --- a/backends/fs/windows/windows-fs.cpp +++ b/backends/fs/windows/windows-fs.cpp @@ -55,9 +55,9 @@ /** * Implementation of the ScummVM file system API based on Windows API. * - * Parts of this class are documented in the base interface class, AbstractFilesystemNode. + * Parts of this class are documented in the base interface class, AbstractFSNode. */ -class WindowsFilesystemNode : public AbstractFilesystemNode { +class WindowsFilesystemNode : public AbstractFSNode { protected: Common::String _displayName; Common::String _path; @@ -95,9 +95,9 @@ public: virtual bool isReadable() const { return _access(_path.c_str(), R_OK) == 0; } virtual bool isWritable() const { return _access(_path.c_str(), W_OK) == 0; } - virtual AbstractFilesystemNode *getChild(const Common::String &n) const; + virtual AbstractFSNode *getChild(const Common::String &n) const; virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const; - virtual AbstractFilesystemNode *getParent() const; + virtual AbstractFSNode *getParent() const; virtual Common::SeekableReadStream *openForReading(); virtual Common::WriteStream *openForWriting(); @@ -142,8 +142,8 @@ void WindowsFilesystemNode::addFile(AbstractFSList &list, ListMode mode, const c isDirectory = (find_data->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ? true : false); - if ((!isDirectory && mode == Common::FilesystemNode::kListDirectoriesOnly) || - (isDirectory && mode == Common::FilesystemNode::kListFilesOnly)) + if ((!isDirectory && mode == Common::FSNode::kListDirectoriesOnly) || + (isDirectory && mode == Common::FSNode::kListFilesOnly)) return; entry._isDirectory = isDirectory; @@ -223,7 +223,7 @@ WindowsFilesystemNode::WindowsFilesystemNode(const Common::String &p, const bool _isPseudoRoot = false; } -AbstractFilesystemNode *WindowsFilesystemNode::getChild(const Common::String &n) const { +AbstractFSNode *WindowsFilesystemNode::getChild(const Common::String &n) const { assert(_isDirectory); Common::String newPath(_path); @@ -285,7 +285,7 @@ bool WindowsFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, b return true; } -AbstractFilesystemNode *WindowsFilesystemNode::getParent() const { +AbstractFSNode *WindowsFilesystemNode::getParent() const { assert(_isValid || _isPseudoRoot); if (_isPseudoRoot) diff --git a/backends/platform/dc/dc-fs.cpp b/backends/platform/dc/dc-fs.cpp index 4baba5b7dc..d77e1c86df 100644 --- a/backends/platform/dc/dc-fs.cpp +++ b/backends/platform/dc/dc-fs.cpp @@ -33,9 +33,9 @@ /** * Implementation of the ScummVM file system API based on Ronin. * - * Parts of this class are documented in the base interface class, AbstractFilesystemNode. + * Parts of this class are documented in the base interface class, AbstractFSNode. */ -class RoninCDFileNode : public AbstractFilesystemNode { +class RoninCDFileNode : public AbstractFSNode { protected: Common::String _path; @@ -49,14 +49,14 @@ public: virtual bool isReadable() const { return true; } virtual bool isWritable() const { return false; } - virtual AbstractFilesystemNode *getChild(const Common::String &n) const { return NULL; } + virtual AbstractFSNode *getChild(const Common::String &n) const { return NULL; } virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const { return false; } - virtual AbstractFilesystemNode *getParent() const; + virtual AbstractFSNode *getParent() const; virtual Common::SeekableReadStream *openForReading(); virtual Common::WriteStream *openForWriting() { return 0; } - static AbstractFilesystemNode *makeFileNodePath(const Common::String &path); + static AbstractFSNode *makeFileNodePath(const Common::String &path); }; /* A directory */ @@ -65,7 +65,7 @@ public: RoninCDDirectoryNode(const Common::String &path) : RoninCDFileNode(path) {}; virtual bool isDirectory() const { return true; } - virtual AbstractFilesystemNode *getChild(const Common::String &n) const; + virtual AbstractFSNode *getChild(const Common::String &n) const; virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const; virtual Common::SeekableReadStream *openForReading() { return 0; } }; @@ -80,7 +80,7 @@ public: virtual Common::SeekableReadStream *openForReading() { return 0; } }; -AbstractFilesystemNode *RoninCDFileNode::makeFileNodePath(const Common::String &path) { +AbstractFSNode *RoninCDFileNode::makeFileNodePath(const Common::String &path) { assert(path.size() > 0); int fd; @@ -96,7 +96,7 @@ AbstractFilesystemNode *RoninCDFileNode::makeFileNodePath(const Common::String & } } -AbstractFilesystemNode *RoninCDDirectoryNode::getChild(const Common::String &n) const { +AbstractFSNode *RoninCDDirectoryNode::getChild(const Common::String &n) const { Common::String newPath(_path); if (_path.lastChar() != '/') newPath += '/'; @@ -122,13 +122,13 @@ bool RoninCDDirectoryNode::getChildren(AbstractFSList &myList, ListMode mode, bo if (dp->d_size < 0) { // Honor the chosen mode - if (mode == Common::FilesystemNode::kListFilesOnly) + if (mode == Common::FSNode::kListFilesOnly) continue; myList.push_back(new RoninCDDirectoryNode(newPath+"/")); } else { // Honor the chosen mode - if (mode == Common::FilesystemNode::kListDirectoriesOnly) + if (mode == Common::FSNode::kListDirectoriesOnly) continue; myList.push_back(new RoninCDFileNode(newPath)); @@ -139,7 +139,7 @@ bool RoninCDDirectoryNode::getChildren(AbstractFSList &myList, ListMode mode, bo return true; } -AbstractFilesystemNode *RoninCDFileNode::getParent() const { +AbstractFSNode *RoninCDFileNode::getParent() const { if (_path == "/") return 0; @@ -154,16 +154,16 @@ Common::SeekableReadStream *RoninCDFileNode::openForReading() { return StdioStream::makeFromPath(getPath().c_str(), false); } -AbstractFilesystemNode *OSystem_Dreamcast::makeRootFileNode() const { +AbstractFSNode *OSystem_Dreamcast::makeRootFileNode() const { return new RoninCDDirectoryNode("/"); } -AbstractFilesystemNode *OSystem_Dreamcast::makeCurrentDirectoryFileNode() const { +AbstractFSNode *OSystem_Dreamcast::makeCurrentDirectoryFileNode() const { return makeRootFileNode(); } -AbstractFilesystemNode *OSystem_Dreamcast::makeFileNodePath(const Common::String &path) const { - AbstractFilesystemNode *node = RoninCDFileNode::makeFileNodePath(path); +AbstractFSNode *OSystem_Dreamcast::makeFileNodePath(const Common::String &path) const { + AbstractFSNode *node = RoninCDFileNode::makeFileNodePath(path); return (node? node : new RoninCDNonexistingNode(path)); } diff --git a/backends/platform/dc/dc.h b/backends/platform/dc/dc.h index 9dfd4c331e..54cd2e982b 100644 --- a/backends/platform/dc/dc.h +++ b/backends/platform/dc/dc.h @@ -189,9 +189,9 @@ class OSystem_Dreamcast : public OSystem, public FilesystemFactory { // Filesystem FilesystemFactory *getFilesystemFactory() { return this; } - AbstractFilesystemNode *makeRootFileNode() const; - AbstractFilesystemNode *makeCurrentDirectoryFileNode() const; - AbstractFilesystemNode *makeFileNodePath(const Common::String &path) const; + AbstractFSNode *makeRootFileNode() const; + AbstractFSNode *makeCurrentDirectoryFileNode() const; + AbstractFSNode *makeFileNodePath(const Common::String &path) const; private: diff --git a/backends/platform/dc/selector.cpp b/backends/platform/dc/selector.cpp index 883787781a..f9646ff22f 100644 --- a/backends/platform/dc/selector.cpp +++ b/backends/platform/dc/selector.cpp @@ -146,12 +146,12 @@ struct Dir { char name[252]; char deficon[256]; - Common::FilesystemNode node; + Common::FSNode node; }; static Game the_game; -static bool isIcon(const Common::FilesystemNode &entry) +static bool isIcon(const Common::FSNode &entry) { int l = entry.getDisplayName().size(); if (l>4 && !strcasecmp(entry.getDisplayName().c_str()+l-4, ".ICO")) @@ -198,13 +198,13 @@ static int findGames(Game *games, int max) { Dir *dirs = new Dir[MAX_DIR]; int curr_game = 0, curr_dir = 0, num_dirs = 1; - dirs[0].node = Common::FilesystemNode(""); + dirs[0].node = Common::FSNode(""); while (curr_game < max && curr_dir < num_dirs) { strncpy(dirs[curr_dir].name, dirs[curr_dir].node.getPath().c_str(), 252); dirs[curr_dir].name[251] = '\0'; dirs[curr_dir].deficon[0] = '\0'; Common::FSList files, fslist; - dirs[curr_dir++].node.getChildren(fslist, Common::FilesystemNode::kListAll); + dirs[curr_dir++].node.getChildren(fslist, Common::FSNode::kListAll); for (Common::FSList::const_iterator entry = fslist.begin(); entry != fslist.end(); ++entry) { if (entry->isDirectory()) { diff --git a/backends/platform/gp2x/gp2x.cpp b/backends/platform/gp2x/gp2x.cpp index e5f062ed35..1fbda44077 100644 --- a/backends/platform/gp2x/gp2x.cpp +++ b/backends/platform/gp2x/gp2x.cpp @@ -145,6 +145,7 @@ void OSystem_GP2X::initBackend() { if (mkdir(enginedataPath, 0755) != 0) warning("mkdir for '%s' failed!", enginedataPath); + //FIXME: Do not use File::addDefaultDirectory, rather implement OSystem::addSysArchivesToSearchSet() ! Common::File::addDefaultDirectory(enginedataPath); // Note: Review and clean this, it's OTT at the moment. diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index fdc1ba97f6..83637605a6 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -280,12 +280,12 @@ FilesystemFactory *OSystem_SDL::getFilesystemFactory() { return _fsFactory; } -void OSystem_SDL::addSysArchivesToSearchSet(Common::SearchSet &s, uint priority) { +void OSystem_SDL::addSysArchivesToSearchSet(Common::SearchSet &s, int priority) { #ifdef DATA_PATH // Add the global DATA_PATH to the directory search list // FIXME: We use depth = 4 for now, to match the old code. May want to change that - Common::FilesystemNode dataNode(DATA_PATH); + Common::FSNode dataNode(DATA_PATH); if (dataNode.exists() && dataNode.isDirectory()) { Common::ArchivePtr dataArchive(new Common::FSDirectory(dataNode, 4)); s.add(DATA_PATH, dataArchive, priority); @@ -378,12 +378,12 @@ static Common::String getDefaultConfigFileName() { } Common::SeekableReadStream *OSystem_SDL::openConfigFileForReading() { - Common::FilesystemNode file(getDefaultConfigFileName()); + Common::FSNode file(getDefaultConfigFileName()); return file.openForReading(); } Common::WriteStream *OSystem_SDL::openConfigFileForWriting() { - Common::FilesystemNode file(getDefaultConfigFileName()); + Common::FSNode file(getDefaultConfigFileName()); return file.openForWriting(); } diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index 3639d61c3a..3881e3777f 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -212,7 +212,7 @@ public: virtual Common::SaveFileManager *getSavefileManager(); virtual FilesystemFactory *getFilesystemFactory(); - virtual void addSysArchivesToSearchSet(Common::SearchSet &s, uint priority = 0); + virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0); virtual Common::SeekableReadStream *openConfigFileForReading(); virtual Common::WriteStream *openConfigFileForWriting(); diff --git a/backends/platform/symbian/src/SymbianOS.cpp b/backends/platform/symbian/src/SymbianOS.cpp index 23876c5ec1..254b716927 100644 --- a/backends/platform/symbian/src/SymbianOS.cpp +++ b/backends/platform/symbian/src/SymbianOS.cpp @@ -124,12 +124,12 @@ static Common::String getDefaultConfigFileName() { } Common::SeekableReadStream *OSystem_SDL_Symbian::openConfigFileForReading() { - Common::FilesystemNode file(getDefaultConfigFileName()); + Common::FSNode file(getDefaultConfigFileName()); return file.openForReading(); } Common::WriteStream *OSystem_SDL_Symbian::openConfigFileForWriting() { - Common::FilesystemNode file(getDefaultConfigFileName()); + Common::FSNode file(getDefaultConfigFileName()); return file.openForWriting(); } diff --git a/backends/platform/wince/CELauncherDialog.cpp b/backends/platform/wince/CELauncherDialog.cpp index 7e306be114..f0dfda5ee4 100644 --- a/backends/platform/wince/CELauncherDialog.cpp +++ b/backends/platform/wince/CELauncherDialog.cpp @@ -72,10 +72,10 @@ void CELauncherDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 d } } -void CELauncherDialog::automaticScanDirectory(const Common::FilesystemNode &node) { +void CELauncherDialog::automaticScanDirectory(const Common::FSNode &node) { // First check if we have a recognized game in the current directory Common::FSList files; - node.getChildren(files, Common::FilesystemNode::kListFilesOnly); + node.getChildren(files, Common::FSNode::kListFilesOnly); // detect GameList candidates(EngineMan.detectGames(files)); // insert @@ -86,7 +86,7 @@ void CELauncherDialog::automaticScanDirectory(const Common::FilesystemNode &node } // Then recurse on the subdirectories Common::FSList dirs; - node.getChildren(dirs, Common::FilesystemNode::kListDirectoriesOnly); + node.getChildren(dirs, Common::FSNode::kListDirectoriesOnly); for (Common::FSList::const_iterator currentDir = dirs.begin(); currentDir != dirs.end(); ++currentDir) automaticScanDirectory(*currentDir); diff --git a/backends/platform/wince/CELauncherDialog.h b/backends/platform/wince/CELauncherDialog.h index a5f3fd0d43..7e86f808fc 100644 --- a/backends/platform/wince/CELauncherDialog.h +++ b/backends/platform/wince/CELauncherDialog.h @@ -36,7 +36,7 @@ public: virtual void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data); protected: void addGame(); - void automaticScanDirectory(const Common::FilesystemNode &node); + void automaticScanDirectory(const Common::FSNode &node); }; typedef GUI::LauncherDialog GUILauncherDialog; diff --git a/backends/plugins/dc/dc-provider.cpp b/backends/plugins/dc/dc-provider.cpp index 9b150c8db4..f73af3854b 100644 --- a/backends/plugins/dc/dc-provider.cpp +++ b/backends/plugins/dc/dc-provider.cpp @@ -27,6 +27,7 @@ #include "backends/plugins/dc/dc-provider.h" #include "backends/plugins/dynamic-plugin.h" +#include "common/fs.h" #include "dcloader.h" @@ -83,12 +84,13 @@ public: }; -Plugin* DCPluginProvider::createPlugin(const Common::String &filename) const { - return new DCPlugin(filename); +Plugin* DCPluginProvider::createPlugin(const Common::FSNode &node) const { + return new DCPlugin(node.getPath()); } -bool DCPluginProvider::isPluginFilename(const Common::String &filename) const { +bool DCPluginProvider::isPluginFilename(const Common::FSNode &node) const { // Check the plugin suffix + Common::String filename = node.getName(); if (!filename.hasSuffix(".PLG")) return false; diff --git a/backends/plugins/dc/dc-provider.h b/backends/plugins/dc/dc-provider.h index f413061828..470a586a51 100644 --- a/backends/plugins/dc/dc-provider.h +++ b/backends/plugins/dc/dc-provider.h @@ -32,9 +32,9 @@ class DCPluginProvider : public FilePluginProvider { protected: - Plugin* createPlugin(const Common::String &filename) const; + Plugin* createPlugin(const Common::FSNode &node) const; - bool isPluginFilename(const Common::String &filename) const; + bool isPluginFilename(const Common::FSNode &node) const; virtual void addCustomDirectories(Common::StringList &dirs) const { dirs.push_back("/"); diff --git a/backends/plugins/posix/posix-provider.cpp b/backends/plugins/posix/posix-provider.cpp index 39847e53bf..7dd25ddd67 100644 --- a/backends/plugins/posix/posix-provider.cpp +++ b/backends/plugins/posix/posix-provider.cpp @@ -27,6 +27,7 @@ #include "backends/plugins/posix/posix-provider.h" #include "backends/plugins/dynamic-plugin.h" +#include "common/fs.h" #include <dlfcn.h> @@ -78,8 +79,8 @@ public: }; -Plugin* POSIXPluginProvider::createPlugin(const Common::String &filename) const { - return new POSIXPlugin(filename); +Plugin* POSIXPluginProvider::createPlugin(const Common::FSNode &node) const { + return new POSIXPlugin(node.getPath()); } diff --git a/backends/plugins/posix/posix-provider.h b/backends/plugins/posix/posix-provider.h index 40c16b3e11..b7d8c9f945 100644 --- a/backends/plugins/posix/posix-provider.h +++ b/backends/plugins/posix/posix-provider.h @@ -32,7 +32,7 @@ class POSIXPluginProvider : public FilePluginProvider { protected: - Plugin* createPlugin(const Common::String &filename) const; + Plugin* createPlugin(const Common::FSNode &node) const; }; #endif // defined(DYNAMIC_MODULES) && defined(UNIX) diff --git a/backends/plugins/sdl/sdl-provider.cpp b/backends/plugins/sdl/sdl-provider.cpp index 6df1dec680..be04b5a1eb 100644 --- a/backends/plugins/sdl/sdl-provider.cpp +++ b/backends/plugins/sdl/sdl-provider.cpp @@ -27,6 +27,7 @@ #include "backends/plugins/sdl/sdl-provider.h" #include "backends/plugins/dynamic-plugin.h" +#include "common/fs.h" #include "SDL.h" #include "SDL_loadso.h" @@ -78,8 +79,8 @@ public: }; -Plugin* SDLPluginProvider::createPlugin(const Common::String &filename) const { - return new SDLPlugin(filename); +Plugin* SDLPluginProvider::createPlugin(const Common::FSNode &node) const { + return new SDLPlugin(node.getPath()); } diff --git a/backends/plugins/sdl/sdl-provider.h b/backends/plugins/sdl/sdl-provider.h index a9ec657e33..b546b028a2 100644 --- a/backends/plugins/sdl/sdl-provider.h +++ b/backends/plugins/sdl/sdl-provider.h @@ -32,7 +32,7 @@ class SDLPluginProvider : public FilePluginProvider { protected: - Plugin* createPlugin(const Common::String &filename) const; + Plugin* createPlugin(const Common::FSNode &node) const; }; #endif // defined(DYNAMIC_MODULES) && defined(UNIX) diff --git a/backends/plugins/win32/win32-provider.cpp b/backends/plugins/win32/win32-provider.cpp index b8fdd3d802..c77d31282d 100644 --- a/backends/plugins/win32/win32-provider.cpp +++ b/backends/plugins/win32/win32-provider.cpp @@ -27,6 +27,7 @@ #include "backends/plugins/win32/win32-provider.h" #include "backends/plugins/dynamic-plugin.h" +#include "common/fs.h" #include <windows.h> @@ -96,12 +97,13 @@ public: }; -Plugin* Win32PluginProvider::createPlugin(const Common::String &filename) const { - return new Win32Plugin(filename); +Plugin* Win32PluginProvider::createPlugin(const Common::FSNode &node) const { + return new Win32Plugin(node.getPath()); } -bool Win32PluginProvider::isPluginFilename(const Common::String &filename) const { +bool Win32PluginProvider::isPluginFilename(const Common::FSNode &node) const { // Check the plugin suffix + Common::String filename = node.getName(); if (!filename.hasSuffix(".dll")) return false; diff --git a/backends/plugins/win32/win32-provider.h b/backends/plugins/win32/win32-provider.h index 4ddc8b7500..d6e146371a 100644 --- a/backends/plugins/win32/win32-provider.h +++ b/backends/plugins/win32/win32-provider.h @@ -32,9 +32,9 @@ class Win32PluginProvider : public FilePluginProvider { protected: - Plugin* createPlugin(const Common::String &filename) const; + Plugin* createPlugin(const Common::FSNode &node) const; - bool isPluginFilename(const Common::String &filename) const; + bool isPluginFilename(const Common::FSNode &node) const; virtual void addCustomDirectories(Common::StringList &dirs) const {} }; diff --git a/backends/saves/default/default-saves.cpp b/backends/saves/default/default-saves.cpp index 0cfd265890..f35606f793 100644 --- a/backends/saves/default/default-saves.cpp +++ b/backends/saves/default/default-saves.cpp @@ -71,7 +71,7 @@ DefaultSaveFileManager::DefaultSaveFileManager(const Common::String &defaultSave Common::StringList DefaultSaveFileManager::listSavefiles(const char *pattern) { - Common::FilesystemNode savePath(getSavePath()); + Common::FSNode savePath(getSavePath()); Common::FSList savefiles; Common::StringList results; Common::String search(pattern); @@ -85,7 +85,7 @@ Common::StringList DefaultSaveFileManager::listSavefiles(const char *pattern) { return results; } -void DefaultSaveFileManager::checkPath(const Common::FilesystemNode &dir) { +void DefaultSaveFileManager::checkPath(const Common::FSNode &dir) { const Common::String path = dir.getPath(); clearError(); @@ -152,7 +152,7 @@ void DefaultSaveFileManager::checkPath(const Common::FilesystemNode &dir) { #else if (!dir.exists()) { // TODO: We could try to mkdir the directory here; or rather, we could - // add a mkdir method to FilesystemNode and invoke that here. + // add a mkdir method to FSNode and invoke that here. setError(SFM_DIR_NOENT, "A component of the path does not exist, or the path is an empty string: "+path); } else if (!dir.isDirectory()) { setError(SFM_DIR_NOTDIR, "The given savepath is not a directory: "+path); @@ -162,11 +162,11 @@ void DefaultSaveFileManager::checkPath(const Common::FilesystemNode &dir) { Common::InSaveFile *DefaultSaveFileManager::openForLoading(const char *filename) { // Ensure that the savepath is valid. If not, generate an appropriate error. - Common::FilesystemNode savePath(getSavePath()); + Common::FSNode savePath(getSavePath()); checkPath(savePath); if (getError() == SFM_NO_ERROR) { - Common::FilesystemNode file = savePath.getChild(filename); + Common::FSNode file = savePath.getChild(filename); // Open the file for reading Common::SeekableReadStream *sf = file.openForReading(); @@ -179,11 +179,11 @@ Common::InSaveFile *DefaultSaveFileManager::openForLoading(const char *filename) Common::OutSaveFile *DefaultSaveFileManager::openForSaving(const char *filename) { // Ensure that the savepath is valid. If not, generate an appropriate error. - Common::FilesystemNode savePath(getSavePath()); + Common::FSNode savePath(getSavePath()); checkPath(savePath); if (getError() == SFM_NO_ERROR) { - Common::FilesystemNode file = savePath.getChild(filename); + Common::FSNode file = savePath.getChild(filename); // Open the file for saving Common::WriteStream *sf = file.openForWriting(); @@ -197,10 +197,10 @@ Common::OutSaveFile *DefaultSaveFileManager::openForSaving(const char *filename) bool DefaultSaveFileManager::removeSavefile(const char *filename) { clearError(); - Common::FilesystemNode savePath(getSavePath()); - Common::FilesystemNode file = savePath.getChild(filename); + Common::FSNode savePath(getSavePath()); + Common::FSNode file = savePath.getChild(filename); - // TODO: Add new method FilesystemNode::remove() + // TODO: Add new method FSNode::remove() if (remove(file.getPath().c_str()) != 0) { #ifndef _WIN32_WCE if (errno == EACCES) diff --git a/backends/saves/default/default-saves.h b/backends/saves/default/default-saves.h index c02ce588c2..7e3c23f5ae 100644 --- a/backends/saves/default/default-saves.h +++ b/backends/saves/default/default-saves.h @@ -55,7 +55,7 @@ protected: * Checks the given path for read access, existence, etc. * Sets the internal error and error message accordingly. */ - void checkPath(const Common::FilesystemNode &dir); + void checkPath(const Common::FSNode &dir); }; #endif diff --git a/base/commandLine.cpp b/base/commandLine.cpp index 410777209f..7c4de7b0cc 100644 --- a/base/commandLine.cpp +++ b/base/commandLine.cpp @@ -365,7 +365,7 @@ Common::String parseCommandLine(Common::StringMap &settings, int argc, char **ar END_OPTION DO_OPTION('p', "path") - Common::FilesystemNode path(option); + Common::FSNode path(option); if (!path.exists()) { usage("Non-existent game path '%s'", option); } else if (!path.isReadable()) { @@ -408,7 +408,7 @@ Common::String parseCommandLine(Common::StringMap &settings, int argc, char **ar END_OPTION DO_LONG_OPTION("soundfont") - Common::FilesystemNode path(option); + Common::FSNode path(option); if (!path.exists()) { usage("Non-existent soundfont path '%s'", option); } else if (!path.isReadable()) { @@ -438,7 +438,7 @@ Common::String parseCommandLine(Common::StringMap &settings, int argc, char **ar END_OPTION DO_LONG_OPTION("savepath") - Common::FilesystemNode path(option); + Common::FSNode path(option); if (!path.exists()) { usage("Non-existent savegames path '%s'", option); } else if (!path.isWritable()) { @@ -447,7 +447,7 @@ Common::String parseCommandLine(Common::StringMap &settings, int argc, char **ar END_OPTION DO_LONG_OPTION("extrapath") - Common::FilesystemNode path(option); + Common::FSNode path(option); if (!path.exists()) { usage("Non-existent extra path '%s'", option); } else if (!path.isReadable()) { @@ -465,7 +465,7 @@ Common::String parseCommandLine(Common::StringMap &settings, int argc, char **ar END_OPTION DO_LONG_OPTION("themepath") - Common::FilesystemNode path(option); + Common::FSNode path(option); if (!path.exists()) { usage("Non-existent theme path '%s'", option); } else if (!path.isReadable()) { @@ -623,9 +623,9 @@ static void runDetectorTest() { gameid = name; } - Common::FilesystemNode dir(path); + Common::FSNode dir(path); Common::FSList files; - if (!dir.getChildren(files, Common::FilesystemNode::kListAll)) { + if (!dir.getChildren(files, Common::FSNode::kListAll)) { printf(" ... invalid path, skipping\n"); continue; } @@ -736,7 +736,7 @@ bool processSettings(Common::String &command, Common::StringMap &settings) { if (!settings.contains("savepath")) { const char *dir = getenv("SCUMMVM_SAVEPATH"); if (dir && *dir && strlen(dir) < MAXPATHLEN) { - Common::FilesystemNode saveDir(dir); + Common::FSNode saveDir(dir); if (!saveDir.exists()) { warning("Non-existent SCUMMVM_SAVEPATH save path. It will be ignored."); } else if (!saveDir.isWritable()) { diff --git a/base/plugins.cpp b/base/plugins.cpp index 7b372587a1..5429359658 100644 --- a/base/plugins.cpp +++ b/base/plugins.cpp @@ -207,8 +207,8 @@ PluginList FilePluginProvider::getPlugins() { Common::FSList pluginDirs; // Add the default directories - pluginDirs.push_back(Common::FilesystemNode(".")); - pluginDirs.push_back(Common::FilesystemNode("plugins")); + pluginDirs.push_back(Common::FSNode(".")); + pluginDirs.push_back(Common::FSNode("plugins")); // Add the provider's custom directories addCustomDirectories(pluginDirs); @@ -216,14 +216,14 @@ PluginList FilePluginProvider::getPlugins() { // Add the user specified directory Common::String pluginsPath(ConfMan.get("pluginspath")); if (!pluginsPath.empty()) - pluginDirs.push_back(Common::FilesystemNode(pluginsPath)); + pluginDirs.push_back(Common::FSNode(pluginsPath)); Common::FSList::const_iterator dir; for (dir = pluginDirs.begin(); dir != pluginDirs.end(); dir++) { // Load all plugins. // Scan for all plugins in this directory Common::FSList files; - if (!dir->getChildren(files, Common::FilesystemNode::kListFilesOnly)) { + if (!dir->getChildren(files, Common::FSNode::kListFilesOnly)) { debug(1, "Couldn't open plugin directory '%s'", dir->getPath().c_str()); continue; } else { @@ -231,8 +231,8 @@ PluginList FilePluginProvider::getPlugins() { } for (Common::FSList::const_iterator i = files.begin(); i != files.end(); ++i) { - if (isPluginFilename(i->getName())) { - pl.push_back(createPlugin(i->getPath())); + if (isPluginFilename(*i)) { + pl.push_back(createPlugin(*i)); } } } @@ -240,7 +240,9 @@ PluginList FilePluginProvider::getPlugins() { return pl; } -bool FilePluginProvider::isPluginFilename(const Common::String &filename) const { +bool FilePluginProvider::isPluginFilename(const Common::FSNode &node) const { + Common::String filename = node.getName(); + #ifdef PLUGIN_PREFIX // Check the plugin prefix if (!filename.hasPrefix(PLUGIN_PREFIX)) @@ -258,7 +260,7 @@ bool FilePluginProvider::isPluginFilename(const Common::String &filename) const void FilePluginProvider::addCustomDirectories(Common::FSList &dirs) const { #ifdef PLUGIN_DIRECTORY - dirs.push_back(Common::FilesystemNode(PLUGIN_DIRECTORY)); + dirs.push_back(Common::FSNode(PLUGIN_DIRECTORY)); #endif } diff --git a/base/plugins.h b/base/plugins.h index 90c4469e4d..bb99818648 100644 --- a/base/plugins.h +++ b/base/plugins.h @@ -32,6 +32,7 @@ namespace Common { class FSList; + class FSNode; } @@ -238,19 +239,19 @@ protected: * Subclasses of FilePluginProvider have to at least overload this method. * If the file is not found, or does not contain loadable code, 0 is returned instead. * - * @param filename the name of the loadable code module + * @param node the FSNode of the loadable code module * @return a pointer to a Plugin instance, or 0 if an error occurred. */ - virtual Plugin *createPlugin(const Common::String &filename) const = 0; + virtual Plugin *createPlugin(const Common::FSNode &node) const = 0; /** - * Check if the supplied filename corresponds to a loadable plugin file in - * the current platform. + * Check if the supplied file corresponds to a loadable plugin file in + * the current platform. Usually, this will just check the file name. * - * @param filename the name of the file to check + * @param node the FSNode of the file to check * @return true if the filename corresponds to a plugin, false otherwise */ - virtual bool isPluginFilename(const Common::String &filename) const; + virtual bool isPluginFilename(const Common::FSNode &node) const; /** * Optionally add to the list of directories to be searched for diff --git a/common/advancedDetector.cpp b/common/advancedDetector.cpp index 1b0db4755a..1ec8c47715 100644 --- a/common/advancedDetector.cpp +++ b/common/advancedDetector.cpp @@ -246,9 +246,9 @@ PluginError AdvancedMetaEngine::createInstance(OSystem *syst, Engine **engine) c path = "."; warning("No path was provided. Assuming the data files are in the current directory"); } - FilesystemNode dir(path); + FSNode dir(path); FSList files; - if (!dir.isDirectory() || !dir.getChildren(files, FilesystemNode::kListAll)) { + if (!dir.isDirectory() || !dir.getChildren(files, FSNode::kListAll)) { warning("Game data path does not exist or is not a directory (%s)", path.c_str()); return kNoGameDataFoundError; } @@ -290,6 +290,7 @@ PluginError AdvancedMetaEngine::createInstance(OSystem *syst, Engine **engine) c typedef HashMap<String, bool, IgnoreCase_Hash, IgnoreCase_EqualTo> StringSet; typedef HashMap<String, int32, IgnoreCase_Hash, IgnoreCase_EqualTo> IntMap; +typedef HashMap<String, FSNode, IgnoreCase_Hash, IgnoreCase_EqualTo> FileMap; static void reportUnknown(const StringMap &filesMD5, const IntMap &filesSize) { // TODO: This message should be cleaned up / made more specific. @@ -307,10 +308,10 @@ static void reportUnknown(const StringMap &filesMD5, const IntMap &filesSize) { printf("\n"); } -static ADGameDescList detectGameFilebased(const StringMap &allFiles, const Common::ADParams ¶ms); +static ADGameDescList detectGameFilebased(const FileMap &allFiles, const Common::ADParams ¶ms); static ADGameDescList detectGame(const FSList &fslist, const Common::ADParams ¶ms, Language language, Platform platform, const Common::String extra) { - StringMap allFiles; + FileMap allFiles; StringSet detectFiles; StringMap filesMD5; @@ -334,7 +335,7 @@ static ADGameDescList detectGame(const FSList &fslist, const Common::ADParams &p if (tstr.lastChar() == '.') tstr.deleteLastChar(); - allFiles[tstr] = file->getPath(); // Record the presence of this file + allFiles[tstr] = *file; // Record the presence of this file } // Compute the set of files for which we need MD5s for. I.e. files which are @@ -356,7 +357,7 @@ static ADGameDescList detectGame(const FSList &fslist, const Common::ADParams &p debug(3, "+ %s", fname.c_str()); char md5str[32+1]; - if (!md5_file_string(allFiles[fname].c_str(), md5str, params.md5Bytes)) + if (!md5_file_string(allFiles[fname], md5str, params.md5Bytes)) continue; filesMD5[fname] = md5str; @@ -464,7 +465,7 @@ static ADGameDescList detectGame(const FSList &fslist, const Common::ADParams &p * the maximal number of matching files. In case of a tie, the entry * coming first in the list is chosen. */ -static ADGameDescList detectGameFilebased(const StringMap &allFiles, const Common::ADParams ¶ms) { +static ADGameDescList detectGameFilebased(const FileMap &allFiles, const Common::ADParams ¶ms) { const ADFileBasedFallback *ptr; const char* const* filenames; diff --git a/common/archive.cpp b/common/archive.cpp index 7e17fdca32..7f2b67eed0 100644 --- a/common/archive.cpp +++ b/common/archive.cpp @@ -26,6 +26,7 @@ #include "common/archive.h" #include "common/fs.h" #include "common/util.h" +#include "common/system.h" namespace Common { @@ -53,7 +54,7 @@ int Archive::matchPattern(StringList &list, const String &pattern) { } -FSDirectory::FSDirectory(const FilesystemNode &node, int depth) +FSDirectory::FSDirectory(const FSNode &node, int depth) : _node(node), _cached(false), _depth(depth) { } @@ -64,11 +65,11 @@ FSDirectory::FSDirectory(const String &name, int depth) FSDirectory::~FSDirectory() { } -FilesystemNode FSDirectory::getFSNode() const { +FSNode FSDirectory::getFSNode() const { return _node; } -FilesystemNode FSDirectory::lookupCache(NodeCache &cache, const String &name) { +FSNode FSDirectory::lookupCache(NodeCache &cache, const String &name) { // make caching as lazy as possible if (!name.empty()) { if (!_cached) { @@ -80,7 +81,7 @@ FilesystemNode FSDirectory::lookupCache(NodeCache &cache, const String &name) { return cache[name]; } - return FilesystemNode(); + return FSNode(); } bool FSDirectory::hasFile(const String &name) { @@ -88,7 +89,7 @@ bool FSDirectory::hasFile(const String &name) { return false; } - FilesystemNode node = lookupCache(_fileCache, name); + FSNode node = lookupCache(_fileCache, name); return node.exists(); } @@ -97,13 +98,13 @@ SeekableReadStream *FSDirectory::openFile(const String &name) { return 0; } - FilesystemNode node = lookupCache(_fileCache, name); + FSNode node = lookupCache(_fileCache, name); if (!node.exists()) { - warning("FSDirectory::openFile: FilesystemNode does not exist"); + warning("FSDirectory::openFile: FSNode does not exist"); return 0; } else if (node.isDirectory()) { - warning("FSDirectory::openFile: FilesystemNode is a directory"); + warning("FSDirectory::openFile: FSNode is a directory"); return 0; } @@ -120,17 +121,17 @@ FSDirectory *FSDirectory::getSubDirectory(const String &name) { return 0; } - FilesystemNode node = lookupCache(_subDirCache, name); + FSNode node = lookupCache(_subDirCache, name); return new FSDirectory(node); } -void FSDirectory::cacheDirectoryRecursive(FilesystemNode node, int depth, const String& prefix) { +void FSDirectory::cacheDirectoryRecursive(FSNode node, int depth, const String& prefix) { if (depth <= 0) { return; } FSList list; - node.getChildren(list, FilesystemNode::kListAll, false); + node.getChildren(list, FSNode::kListAll, false); FSList::iterator it = list.begin(); for ( ; it != list.end(); it++) { @@ -231,9 +232,9 @@ void SearchSet::insert(const Node &node) { _list.insert(it, node); } -void SearchSet::add(const String& name, ArchivePtr archive, uint priority) { +void SearchSet::add(const String& name, ArchivePtr archive, int priority) { if (find(name) == _list.end()) { - Node node = { priority, name, archive }; + Node node(priority, name, archive); insert(node); } else { warning("SearchSet::add: archive '%s' already present", name.c_str()); @@ -256,7 +257,7 @@ void SearchSet::clear() { _list.clear(); } -void SearchSet::setPriority(const String& name, uint priority) { +void SearchSet::setPriority(const String& name, int priority) { ArchiveList::iterator it = find(name); if (it == _list.end()) { warning("SearchSet::setPriority: archive '%s' is not present", name.c_str()); @@ -328,17 +329,33 @@ SeekableReadStream *SearchSet::openFile(const String &name) { DECLARE_SINGLETON(SearchManager); -void SearchManager::addArchive(const String &name, ArchivePtr archive) { - add(name, archive); +SearchManager::SearchManager() { + clear(); // Force a reset } -void SearchManager::addDirectory(const String &name, const String &directory) { - addDirectoryRecursive(name, 1); +void SearchManager::addArchive(const String &name, ArchivePtr archive, int priority) { + add(name, archive, priority); } -void SearchManager::addDirectoryRecursive(const String &name, const String &directory, int depth) { - add(name, SharedPtr<FSDirectory>(new FSDirectory(directory, depth))); +void SearchManager::addDirectory(const String &name, const String &directory, int priority) { + addDirectoryRecursive(name, directory, 1, priority); } +void SearchManager::addDirectoryRecursive(const String &name, const String &directory, int depth, int priority) { + add(name, ArchivePtr(new FSDirectory(directory, depth)), priority); +} + +void SearchManager::clear() { + SearchSet::clear(); + + // Always keep system specific archives in the SearchManager. + // But we give them a lower priority than the default priority (which is 0), + // so that archives added by client code are searched first. + g_system->addSysArchivesToSearchSet(*this, -1); + + // Add the current dir as a very last resort. + // See also bug #2137680. + add(".", ArchivePtr(new FSDirectory(".")), -2); +} } // namespace Common diff --git a/common/archive.h b/common/archive.h index 89ea6a5ce2..9103586d7d 100644 --- a/common/archive.h +++ b/common/archive.h @@ -93,21 +93,21 @@ typedef SharedPtr<Archive> ArchivePtr; * Searching is case-insensitive, as the main intended goal is supporting * retrieval of game data. First case-insensitive match is returned when * searching, thus making FSDirectory heavily dependant on the underlying - * FilesystemNode implementation. + * FSNode implementation. */ class FSDirectory : public Archive { - FilesystemNode _node; + FSNode _node; // Caches are case insensitive, clashes are dealt with when creating // Key is stored in lowercase. - typedef HashMap<String, FilesystemNode, IgnoreCase_Hash, IgnoreCase_EqualTo> NodeCache; + typedef HashMap<String, FSNode, IgnoreCase_Hash, IgnoreCase_EqualTo> NodeCache; NodeCache _fileCache, _subDirCache; // look for a match - FilesystemNode lookupCache(NodeCache &cache, const String &name); + FSNode lookupCache(NodeCache &cache, const String &name); // cache management - void cacheDirectoryRecursive(FilesystemNode node, int depth, const String& prefix); + void cacheDirectoryRecursive(FSNode node, int depth, const String& prefix); bool _cached; int _depth; @@ -122,14 +122,14 @@ public: * Create a FSDirectory representing a tree with the specified depth. Will result in an * unbound FSDirectory if node does not exist or is not a directory. */ - FSDirectory(const FilesystemNode &node, int depth = 1); + FSDirectory(const FSNode &node, int depth = 1); virtual ~FSDirectory(); /** * This return the underlying FSNode of the FSDirectory. */ - FilesystemNode getFSNode() const; + FSNode getFSNode() const; /** * Create a new FSDirectory pointing to a sub directory of the instance. @@ -153,9 +153,12 @@ public: */ class SearchSet : public Archive { struct Node { - uint _priority; + int _priority; String _name; ArchivePtr _arc; + Node(int priority, const String &name, ArchivePtr arc) + : _priority(priority), _name(name), _arc(arc) { + } }; typedef List<Node> ArchiveList; ArchiveList _list; @@ -169,7 +172,7 @@ public: /** * Add a new archive to the searchable set. */ - void add(const String& name, ArchivePtr archive, uint priority = 0); + void add(const String& name, ArchivePtr archive, int priority = 0); /** * Remove an archive from the searchable set. @@ -184,12 +187,12 @@ public: /** * Empties the searchable set. */ - void clear(); + virtual void clear(); /** * Change the order of searches. */ - void setPriority(const String& name, uint priority); + void setPriority(const String& name, int priority); virtual bool hasFile(const String &name); virtual int matchPattern(StringList &list, const String &pattern); @@ -205,22 +208,28 @@ public: class SearchManager : public Singleton<SearchManager>, public SearchSet { public: + SearchManager(); + /** * Add an existing Archive. This is meant to support searching in system-specific * archives, namely the MACOSX/IPHONE bundles. */ - void addArchive(const String &name, ArchivePtr archive); + void addArchive(const String &name, ArchivePtr archive, int priority = 0); /** * Create and add a FSDirectory by name */ - void addDirectory(const String &name, const String &directory); + void addDirectory(const String &name, const String &directory, int priority = 0); /** * Create and add a FSDirectory and its subdirectories by name */ - void addDirectoryRecursive(const String &name, const String &directory, int depth = 4); + void addDirectoryRecursive(const String &name, const String &directory, int depth = 4, int priority = 0); + /** + * TODO + */ + virtual void clear(); }; /** Shortcut for accessing the search manager. */ diff --git a/common/config-manager.cpp b/common/config-manager.cpp index b741757cc5..0d01c39c4f 100644 --- a/common/config-manager.cpp +++ b/common/config-manager.cpp @@ -77,8 +77,9 @@ void ConfigManager::loadDefaultConfigFile() { void ConfigManager::loadConfigFile(const String &filename) { _filename = filename; + FSNode node(filename); File cfg_file; - if (!cfg_file.open(filename)) { + if (!cfg_file.open(node)) { printf("Creating configuration file: %s\n", filename.c_str()); } else { printf("Using configuration file: %s\n", _filename.c_str()); diff --git a/common/file.cpp b/common/file.cpp index cf396a32cd..ed432ce565 100644 --- a/common/file.cpp +++ b/common/file.cpp @@ -31,39 +31,30 @@ namespace Common { -static Common::SearchSet *s_searchSet = 0; - - void File::addDefaultDirectory(const String &directory) { - FilesystemNode dir(directory); + FSNode dir(directory); addDefaultDirectoryRecursive(dir, 1); } void File::addDefaultDirectoryRecursive(const String &directory, int level) { - FilesystemNode dir(directory); + FSNode dir(directory); addDefaultDirectoryRecursive(dir, level); } -void File::addDefaultDirectory(const FilesystemNode &directory) { +void File::addDefaultDirectory(const FSNode &directory) { addDefaultDirectoryRecursive(directory, 1); } -void File::addDefaultDirectoryRecursive(const FilesystemNode &dir, int level) { +void File::addDefaultDirectoryRecursive(const FSNode &dir, int level) { if (level <= 0 || !dir.exists() || !dir.isDirectory()) return; - if (!s_searchSet) { - s_searchSet = new Common::SearchSet(); - g_system->addSysArchivesToSearchSet(*s_searchSet); - } - Common::ArchivePtr dataArchive(new Common::FSDirectory(dir, level)); - s_searchSet->add(dir.getPath(), dataArchive, 1); + SearchMan.add(dir.getPath(), dataArchive); } void File::resetDefaultDirectories() { - delete s_searchSet; - s_searchSet = 0; + SearchMan.clear(); } File::File() @@ -74,78 +65,66 @@ File::~File() { close(); } - bool File::open(const String &filename) { + return open(filename, SearchMan); +} + +bool File::open(const String &filename, Archive &archive) { assert(!filename.empty()); assert(!_handle); - _name.clear(); clearIOFailed(); - if (s_searchSet && s_searchSet->hasFile(filename)) { + SeekableReadStream *stream = 0; + if (archive.hasFile(filename)) { debug(3, "Opening hashed: %s", filename.c_str()); - _handle = s_searchSet->openFile(filename); - } else if (s_searchSet && s_searchSet->hasFile(filename + ".")) { + stream = archive.openFile(filename); + } else if (archive.hasFile(filename + ".")) { // WORKAROUND: Bug #1458388: "SIMON1: Game Detection fails" // sometimes instead of "GAMEPC" we get "GAMEPC." (note trailing dot) debug(3, "Opening hashed: %s.", filename.c_str()); - _handle = s_searchSet->openFile(filename); - } else { - // Last resort: try the current directory - FilesystemNode file(filename); - if (file.exists() && !file.isDirectory()) - _handle = file.openForReading(); + stream = archive.openFile(filename + "."); } - if (_handle == NULL) - debug(2, "File %s not opened", filename.c_str()); - else - _name = filename; - - return _handle != NULL; + return open(stream, filename); } -bool File::open(const FilesystemNode &node) { +bool File::open(const FSNode &node) { + assert(!_handle); if (!node.exists()) { - warning("File::open: FilesystemNode does not exist"); + warning("File::open: '%s' does not exist", node.getPath().c_str()); return false; } else if (node.isDirectory()) { - warning("File::open: FilesystemNode is a directory"); + warning("File::open: '%s' is a directory", node.getPath().c_str()); return false; } - String filename(node.getName()); - - if (_handle) { - error("File::open: This file object already is opened (%s), won't open '%s'", _name.c_str(), filename.c_str()); - } + SeekableReadStream *stream = node.openForReading(); + return open(stream, node.getPath()); +} +bool File::open(SeekableReadStream *stream, const Common::String &name) { + assert(!_handle); clearIOFailed(); - _name.clear(); - - _handle = node.openForReading(); - - if (_handle == NULL) - debug(2, "File %s not found", filename.c_str()); - else - _name = filename; + if (stream) { + _handle = stream; + _name = name; + } else { + debug(2, "File::open: opening '%s' failed", name.c_str()); + } return _handle != NULL; } + bool File::exists(const String &filename) { - if (s_searchSet && s_searchSet->hasFile(filename)) { + if (SearchMan.hasFile(filename)) { return true; - } else if (s_searchSet && s_searchSet->hasFile(filename + ".")) { + } else if (SearchMan.hasFile(filename + ".")) { // WORKAROUND: Bug #1458388: "SIMON1: Game Detection fails" // sometimes instead of "GAMEPC" we get "GAMEPC." (note trailing dot) return true; - } else { - // Last resort: try the current directory - FilesystemNode file(filename); - if (file.exists() && !file.isDirectory()) - return true; } return false; @@ -217,15 +196,15 @@ bool DumpFile::open(const String &filename) { assert(!filename.empty()); assert(!_handle); - FilesystemNode node(filename); + FSNode node(filename); return open(node); } -bool DumpFile::open(const FilesystemNode &node) { +bool DumpFile::open(const FSNode &node) { assert(!_handle); if (node.isDirectory()) { - warning("DumpFile::open: FilesystemNode is a directory"); + warning("DumpFile::open: FSNode is a directory"); return false; } diff --git a/common/file.h b/common/file.h index a2739f795f..0634aecdd3 100644 --- a/common/file.h +++ b/common/file.h @@ -27,13 +27,14 @@ #define COMMON_FILE_H #include "common/scummsys.h" +#include "common/archive.h" #include "common/noncopyable.h" #include "common/str.h" #include "common/stream.h" namespace Common { -class FilesystemNode; +class FSNode; /** * TODO: vital to document this core class properly!!! For both users and implementors @@ -43,7 +44,7 @@ protected: /** File handle to the actual file; 0 if no file is open. */ SeekableReadStream *_handle; - /** The name of this file, for debugging. */ + /** The name of this file, kept for debugging purposes. */ String _name; public: @@ -51,11 +52,12 @@ public: static void addDefaultDirectory(const String &directory); static void addDefaultDirectoryRecursive(const String &directory, int level = 4); - static void addDefaultDirectory(const FilesystemNode &directory); - static void addDefaultDirectoryRecursive(const FilesystemNode &directory, int level = 4); + static void addDefaultDirectory(const FSNode &directory); + static void addDefaultDirectoryRecursive(const FSNode &directory, int level = 4); static void resetDefaultDirectories(); + File(); virtual ~File(); @@ -64,14 +66,56 @@ public: * (those were/are added by addDefaultDirectory and/or * addDefaultDirectoryRecursive). * - * @param filename: the file to check for - * @return: true if the file exists, else false + * @param filename the file to check for + * @return true if the file exists, false otherwise */ static bool exists(const String &filename); + /** + * Try to open the file with the given filename, by searching SearchMan. + * @note Must not be called if this file already is open (i.e. if isOpen returns true). + * + * @param filename the name of the file to open + * @return true if file was opened successfully, false otherwise + */ virtual bool open(const String &filename); - virtual bool open(const FilesystemNode &node); + /** + * Try to open the file with the given filename from within the given archive. + * @note Must not be called if this file already is open (i.e. if isOpen returns true). + * + * @param filename the name of the file to open + * @param archive the archive in which to search for the file + * @return true if file was opened successfully, false otherwise + */ + virtual bool open(const String &filename, Archive &archive); + + /** + * Try to open the file corresponding to the give node. Will check whether the + * node actually refers to an existing file (and not a directory), and handle + * those cases gracefully. + * @note Must not be called if this file already is open (i.e. if isOpen returns true). + * + * @param filename the name of the file to open + * @param archive the archive in which to search for the file + * @return true if file was opened successfully, false otherwise + */ + virtual bool open(const FSNode &node); + + /** + * Try to 'open' the given stream. That is, we just wrap around it, and if stream + * is a NULL pointer, we gracefully treat this as if opening failed. + * @note Must not be called if this file already is open (i.e. if isOpen returns true). + * + * @param stream a pointer to a SeekableReadStream, or 0 + * @param name a string describing the 'file' corresponding to stream + * @return true if stream was 0, false otherwise + */ + virtual bool open(SeekableReadStream *stream, const Common::String &name); + + /** + * Close the file, if open. + */ virtual void close(); /** @@ -82,11 +126,11 @@ public: bool isOpen() const; /** - * Returns the filename of the opened file. + * Returns the filename of the opened file for debugging purposes. * * @return: the filename */ - const char *name() const { return _name.c_str(); } + const char *getName() const { return _name.c_str(); } bool ioFailed() const; void clearIOFailed(); @@ -117,7 +161,7 @@ public: virtual ~DumpFile(); virtual bool open(const String &filename); - virtual bool open(const FilesystemNode &node); + virtual bool open(const FSNode &node); virtual void close(); diff --git a/common/fs.cpp b/common/fs.cpp index 4d31ac09fa..c1ef26e42d 100644 --- a/common/fs.cpp +++ b/common/fs.cpp @@ -29,48 +29,48 @@ namespace Common { -FilesystemNode::FilesystemNode() { +FSNode::FSNode() { } -FilesystemNode::FilesystemNode(AbstractFilesystemNode *realNode) +FSNode::FSNode(AbstractFSNode *realNode) : _realNode(realNode) { } -FilesystemNode::FilesystemNode(const Common::String &p) { +FSNode::FSNode(const Common::String &p) { FilesystemFactory *factory = g_system->getFilesystemFactory(); - AbstractFilesystemNode *tmp = 0; + AbstractFSNode *tmp = 0; if (p.empty() || p == ".") tmp = factory->makeCurrentDirectoryFileNode(); else tmp = factory->makeFileNodePath(p); - _realNode = Common::SharedPtr<AbstractFilesystemNode>(tmp); + _realNode = Common::SharedPtr<AbstractFSNode>(tmp); } -bool FilesystemNode::operator<(const FilesystemNode& node) const { +bool FSNode::operator<(const FSNode& node) const { if (isDirectory() != node.isDirectory()) return isDirectory(); return getDisplayName().compareToIgnoreCase(node.getDisplayName()) < 0; } -bool FilesystemNode::exists() const { +bool FSNode::exists() const { if (_realNode == 0) return false; return _realNode->exists(); } -FilesystemNode FilesystemNode::getChild(const Common::String &n) const { +FSNode FSNode::getChild(const Common::String &n) const { // If this node is invalid or not a directory, return an invalid node if (_realNode == 0 || !_realNode->isDirectory()) - return FilesystemNode(); + return FSNode(); - AbstractFilesystemNode *node = _realNode->getChild(n); - return FilesystemNode(node); + AbstractFSNode *node = _realNode->getChild(n); + return FSNode(node); } -bool FilesystemNode::getChildren(FSList &fslist, ListMode mode, bool hidden) const { +bool FSNode::getChildren(FSList &fslist, ListMode mode, bool hidden) const { if (!_realNode || !_realNode->isDirectory()) return false; @@ -81,61 +81,61 @@ bool FilesystemNode::getChildren(FSList &fslist, ListMode mode, bool hidden) con fslist.clear(); for (AbstractFSList::iterator i = tmp.begin(); i != tmp.end(); ++i) { - fslist.push_back(FilesystemNode(*i)); + fslist.push_back(FSNode(*i)); } return true; } -Common::String FilesystemNode::getDisplayName() const { +Common::String FSNode::getDisplayName() const { assert(_realNode); return _realNode->getDisplayName(); } -Common::String FilesystemNode::getName() const { +Common::String FSNode::getName() const { assert(_realNode); return _realNode->getName(); } -FilesystemNode FilesystemNode::getParent() const { +FSNode FSNode::getParent() const { if (_realNode == 0) return *this; - AbstractFilesystemNode *node = _realNode->getParent(); + AbstractFSNode *node = _realNode->getParent(); if (node == 0) { return *this; } else { - return FilesystemNode(node); + return FSNode(node); } } -Common::String FilesystemNode::getPath() const { +Common::String FSNode::getPath() const { assert(_realNode); return _realNode->getPath(); } -bool FilesystemNode::isDirectory() const { +bool FSNode::isDirectory() const { if (_realNode == 0) return false; return _realNode->isDirectory(); } -bool FilesystemNode::isReadable() const { +bool FSNode::isReadable() const { if (_realNode == 0) return false; return _realNode->isReadable(); } -bool FilesystemNode::isWritable() const { +bool FSNode::isWritable() const { if (_realNode == 0) return false; return _realNode->isWritable(); } -bool FilesystemNode::lookupFile(FSList &results, const Common::String &p, bool hidden, bool exhaustive, int depth) const { +bool FSNode::lookupFile(FSList &results, const Common::String &p, bool hidden, bool exhaustive, int depth) const { if (!isDirectory()) return false; @@ -146,7 +146,7 @@ bool FilesystemNode::lookupFile(FSList &results, const Common::String &p, bool h pattern.toUppercase(); // First match all files on this level - getChildren(children, FilesystemNode::kListAll, hidden); + getChildren(children, FSNode::kListAll, hidden); for (FSList::iterator entry = children.begin(); entry != children.end(); ++entry) { if (entry->isDirectory()) { if (depth != 0) @@ -173,27 +173,27 @@ bool FilesystemNode::lookupFile(FSList &results, const Common::String &p, bool h return !results.empty(); } -Common::SeekableReadStream *FilesystemNode::openForReading() const { +Common::SeekableReadStream *FSNode::openForReading() const { if (_realNode == 0) return 0; if (!_realNode->exists()) { - warning("FilesystemNode::openForReading: FilesystemNode does not exist"); + warning("FSNode::openForReading: FSNode does not exist"); return false; } else if (_realNode->isDirectory()) { - warning("FilesystemNode::openForReading: FilesystemNode is a directory"); + warning("FSNode::openForReading: FSNode is a directory"); return false; } return _realNode->openForReading(); } -Common::WriteStream *FilesystemNode::openForWriting() const { +Common::WriteStream *FSNode::openForWriting() const { if (_realNode == 0) return 0; if (_realNode->isDirectory()) { - warning("FilesystemNode::openForWriting: FilesystemNode is a directory"); + warning("FSNode::openForWriting: FSNode is a directory"); return 0; } diff --git a/common/fs.h b/common/fs.h index c5f7ca6b4c..e2db955c87 100644 --- a/common/fs.h +++ b/common/fs.h @@ -29,11 +29,11 @@ #include "common/ptr.h" #include "common/str.h" -class AbstractFilesystemNode; +class AbstractFSNode; namespace Common { -class FilesystemNode; +class FSNode; class SeekableReadStream; class WriteStream; @@ -42,21 +42,22 @@ class WriteStream; * This is subclass instead of just a typedef so that we can use forward * declarations of it in other places. */ -class FSList : public Common::Array<FilesystemNode> {}; +class FSList : public Common::Array<FSNode> {}; /** - * FilesystemNode provides an abstraction for file paths, allowing for portable - * file system browsing. To this ends, multiple or single roots have to be supported - * (compare Unix with a single root, Windows with multiple roots C:, D:, ...). + * FSNode, short for "File System Node", provides an abstraction for file + * paths, allowing for portable file system browsing. This means for example, + * that multiple or single roots have to be supported (compare Unix with a + * single root, Windows with multiple roots C:, D:, ...). * * To this end, we abstract away from paths; implementations can be based on * paths (and it's left to them whether / or \ or : is the path separator :-); * but it is also possible to use inodes or vrefs (MacOS 9) or anything else. */ -class FilesystemNode { +class FSNode { private: - Common::SharedPtr<AbstractFilesystemNode> _realNode; - FilesystemNode(AbstractFilesystemNode *realNode); + Common::SharedPtr<AbstractFSNode> _realNode; + FSNode(AbstractFSNode *realNode); public: /** @@ -69,14 +70,14 @@ public: }; /** - * Create a new pathless FilesystemNode. Since there's no path associated + * Create a new pathless FSNode. Since there's no path associated * with this node, path-related operations (i.e. exists(), isDirectory(), * getPath()) will always return false or raise an assertion. */ - FilesystemNode(); + FSNode(); /** - * Create a new FilesystemNode referring to the specified path. This is + * Create a new FSNode referring to the specified path. This is * the counterpart to the path() method. * * If path is empty or equals ".", then a node representing the "current @@ -84,15 +85,15 @@ public: * operating system doesn't support the concept), some other directory is * used (usually the root directory). */ - explicit FilesystemNode(const Common::String &path); + explicit FSNode(const Common::String &path); - virtual ~FilesystemNode() {} + virtual ~FSNode() {} /** * Compare the name of this node to the name of another. Directories * go before normal files. */ - bool operator<(const FilesystemNode& node) const; + bool operator<(const FSNode& node) const; /** * Indicates whether the object referred by this node exists in the filesystem or not. @@ -118,7 +119,7 @@ public: * @param name the name of a child of this directory * @return the node referring to the child with the given name */ - FilesystemNode getChild(const Common::String &name) const; + FSNode getChild(const Common::String &name) const; /** * Return a list of all child nodes of this directory node. If called on a node @@ -165,7 +166,7 @@ public: * Get the parent node of this node. If this node has no parent node, * then it returns a duplicate of this node. */ - FilesystemNode getParent() const; + FSNode getParent() const; /** * Indicates whether the node refers to a directory or not. diff --git a/common/md5.cpp b/common/md5.cpp index 4eeb3d9a39..107990481f 100644 --- a/common/md5.cpp +++ b/common/md5.cpp @@ -246,15 +246,15 @@ void md5_finish(md5_context *ctx, uint8 digest[16]) { PUT_UINT32(ctx->state[3], digest, 12); } -bool md5_file(const FilesystemNode &file, uint8 digest[16], uint32 length) { +bool md5_file(const FSNode &file, uint8 digest[16], uint32 length) { if (!file.exists()) { - warning("md5_file: using an inexistent FilesystemNode"); + warning("md5_file: using an inexistent FSNode"); return false; } else if (!file.isReadable()) { - warning("md5_file: using an unreadable FilesystemNode"); + warning("md5_file: using an unreadable FSNode"); return false; } else if (file.isDirectory()) { - warning("md5_file: using a directory FilesystemNode"); + warning("md5_file: using a directory FSNode"); return false; } @@ -316,7 +316,7 @@ bool md5_file(ReadStream &stream, uint8 digest[16], uint32 length) { return true; } -bool md5_file_string(const FilesystemNode &file, char *md5str, uint32 length) { +bool md5_file_string(const FSNode &file, char *md5str, uint32 length) { uint8 digest[16]; if (!md5_file(file, digest, length)) return false; diff --git a/common/md5.h b/common/md5.h index a8642b1322..ffed7d7524 100644 --- a/common/md5.h +++ b/common/md5.h @@ -29,11 +29,11 @@ namespace Common { -class FilesystemNode; +class FSNode; class ReadStream; bool md5_file(const char *name, uint8 digest[16], uint32 length = 0); -bool md5_file(const FilesystemNode &file, uint8 digest[16], uint32 length = 0); +bool md5_file(const FSNode &file, uint8 digest[16], uint32 length = 0); bool md5_file(ReadStream &stream, uint8 digest[16], uint32 length = 0); // The following two methods work similar to the above two, but @@ -41,7 +41,7 @@ bool md5_file(ReadStream &stream, uint8 digest[16], uint32 length = 0); // a human readable lowercase hexstring representing the digest. // The md5str parameter must point to a buffer of 32+1 chars. bool md5_file_string(const char *name, char *md5str, uint32 length = 0); -bool md5_file_string(const FilesystemNode &file, char *md5str, uint32 length = 0); +bool md5_file_string(const FSNode &file, char *md5str, uint32 length = 0); bool md5_file_string(ReadStream &stream, char *md5str, uint32 length = 0); diff --git a/common/str.cpp b/common/str.cpp index 6c48738533..303ed7bfac 100644 --- a/common/str.cpp +++ b/common/str.cpp @@ -339,7 +339,8 @@ bool String::matchString(const String &pat) const { } void String::deleteLastChar() { - deleteChar(_size - 1); + if (_size > 0) + deleteChar(_size - 1); } void String::deleteChar(uint32 p) { diff --git a/common/str.h b/common/str.h index 772718a087..c3e773c3e4 100644 --- a/common/str.h +++ b/common/str.h @@ -112,7 +112,7 @@ public: String(const String &str); /** Construct a string consisting of the given character. */ - String(char c); + explicit String(char c); ~String(); diff --git a/common/system.cpp b/common/system.cpp index d9bc027e91..0e29dded38 100644 --- a/common/system.cpp +++ b/common/system.cpp @@ -163,7 +163,7 @@ static Common::String getDefaultConfigFileName() { } Common::SeekableReadStream *OSystem::openConfigFileForReading() { - Common::FilesystemNode file(getDefaultConfigFileName()); + Common::FSNode file(getDefaultConfigFileName()); return file.openForReading(); } @@ -171,7 +171,7 @@ Common::WriteStream *OSystem::openConfigFileForWriting() { #ifdef __DC__ return 0; #else - Common::FilesystemNode file(getDefaultConfigFileName()); + Common::FSNode file(getDefaultConfigFileName()); return file.openForWriting(); #endif } diff --git a/common/system.h b/common/system.h index cb9dbedad7..176e53ddb4 100644 --- a/common/system.h +++ b/common/system.h @@ -917,7 +917,7 @@ public: * @param s the SearchSet to which the system specific dirs, if any, are added * @param priority the priority with which those dirs are added */ - virtual void addSysArchivesToSearchSet(Common::SearchSet &s, uint priority = 0) {} + virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0) {} /** * Open the default config file for reading, by returning a suitable diff --git a/common/unarj.cpp b/common/unarj.cpp index 244a296efb..00f51ac252 100644 --- a/common/unarj.cpp +++ b/common/unarj.cpp @@ -324,15 +324,15 @@ uint32 ArjFile::read(void *dataPtr, uint32 dataSize) { return _uncompressed->read(dataPtr, dataSize); } -bool ArjFile::eos() { +bool ArjFile::eos() const { return _uncompressed->eos(); } -int32 ArjFile::pos() { +int32 ArjFile::pos() const { return _uncompressed->pos(); } -int32 ArjFile::size() { +int32 ArjFile::size() const { return _uncompressed->size(); } diff --git a/common/unarj.h b/common/unarj.h index 52e0d13948..d16d748ad3 100644 --- a/common/unarj.h +++ b/common/unarj.h @@ -85,7 +85,7 @@ struct ArjHeader { typedef HashMap<String, int, IgnoreCase_Hash, IgnoreCase_EqualTo> ArjFilesMap; -class ArjFile : public File { +class ArjFile : public SeekableReadStream, public NonCopyable { public: ArjFile(); ~ArjFile(); @@ -98,9 +98,9 @@ public: void close(); uint32 read(void *dataPtr, uint32 dataSize); - bool eos(); - int32 pos(); - int32 size(); + bool eos() const; + int32 pos() const; + int32 size() const; bool seek(int32 offset, int whence = SEEK_SET); bool isOpen() { return _isOpen; } diff --git a/common/unzip.cpp b/common/unzip.cpp index 054200e7a2..894631b262 100644 --- a/common/unzip.cpp +++ b/common/unzip.cpp @@ -1363,7 +1363,7 @@ class ZipArchiveMember : public ArchiveMember { unzFile _zipFile; public: - ZipArchiveMember(FilesystemNode &node) : _node(node) { + ZipArchiveMember(FSNode &node) : _node(node) { } String getName() const { @@ -1393,7 +1393,22 @@ bool ZipArchive::hasFile(const Common::String &name) { } int ZipArchive::getAllNames(Common::StringList &list) { - return 0; + if (!_zipFile) + return 0; + + if (unzGoToFirstFile(_zipFile) != UNZ_OK) + return 0; + + char fileNameBuffer[UNZ_MAXFILENAMEINZIP + 1]; + int fileCount = 0; + + do { + unzGetCurrentFileInfo(_zipFile, 0, fileNameBuffer, UNZ_MAXFILENAMEINZIP + 1, 0, 0, 0, 0); + list.push_back(Common::String(fileNameBuffer)); + fileCount++; + } while (unzGoToNextFile(_zipFile) == UNZ_OK); + + return fileCount; } /* diff --git a/common/unzip.h b/common/unzip.h index 93afd0b05b..e4eb754eee 100644 --- a/common/unzip.h +++ b/common/unzip.h @@ -44,7 +44,7 @@ public: bool isOpen() const; virtual bool hasFile(const String &name); - virtual int getAllNames(StringList &list); // FIXME: This one is not (yet?) implemented + virtual int getAllNames(StringList &list); virtual Common::SeekableReadStream *openFile(const Common::String &name); }; diff --git a/common/xmlparser.h b/common/xmlparser.h index dcbfc60c2f..3b085eb544 100644 --- a/common/xmlparser.h +++ b/common/xmlparser.h @@ -187,7 +187,7 @@ public: return true; } - bool loadFile(const FilesystemNode &node) { + bool loadFile(const FSNode &node) { Common::File *f = new Common::File; if (!f->open(node)) { diff --git a/engines/agi/cycle.cpp b/engines/agi/cycle.cpp index 3d29f45ea5..53bebf1b40 100644 --- a/engines/agi/cycle.cpp +++ b/engines/agi/cycle.cpp @@ -115,7 +115,7 @@ void AgiEngine::interpretCycle() { oldSound = getflag(fSoundOn); _game.exitAllLogics = false; - while (runLogic(0) == 0 && !quit()) { + while (runLogic(0) == 0 && !shouldQuit()) { _game.vars[vWordNotFound] = 0; _game.vars[vBorderTouchObj] = 0; _game.vars[vBorderCode] = 0; @@ -352,16 +352,16 @@ int AgiEngine::playGame() { _game.vars[vKey] = 0; } - // FIXME: This has been broken with the merge of the RTL GSoC project. quit() returns a boolean, and we're trying to + // FIXME: This has been broken with the merge of the RTL GSoC project. shouldQuit() returns a boolean, and we're trying to // check it against 0xff, which is never going to be true - //if (quit() == 0xff) + //if (shouldQuit() == 0xff) // ec = errRestartGame; if (shouldPerformAutoSave(_lastSaveTime)) { saveGame(getSavegameFilename(0), "Autosave"); } - } while (quit() == 0); + } while (shouldQuit() == 0); _sound->stopSound(); diff --git a/engines/agi/detection.cpp b/engines/agi/detection.cpp index 2b2d7e080b..94cc4caf85 100644 --- a/engines/agi/detection.cpp +++ b/engines/agi/detection.cpp @@ -2207,7 +2207,7 @@ const Common::ADGameDescription *AgiMetaEngine::fallbackDetect(const Common::FSL bool matchedUsingWag = false; int wagFileCount = 0; WagFileParser wagFileParser; - Common::String wagFilePath; + Common::FSNode wagFileNode; Common::String description; Common::FSList fslistCurrentDir; // Only used if fslist == NULL @@ -2222,8 +2222,8 @@ const Common::ADGameDescription *AgiMetaEngine::fallbackDetect(const Common::FSL if (path.empty()) path = "."; - Common::FilesystemNode fsCurrentDir(path); - fsCurrentDir.getChildren(fslistCurrentDir, Common::FilesystemNode::kListFilesOnly); + Common::FSNode fsCurrentDir(path); + fsCurrentDir.getChildren(fslistCurrentDir, Common::FSNode::kListFilesOnly); fslist = &fslistCurrentDir; } @@ -2246,7 +2246,7 @@ const Common::ADGameDescription *AgiMetaEngine::fallbackDetect(const Common::FSL if (filename.hasSuffix(".wag")) { // Save latest found *.wag file's path (Can be used to open the file, the name can't) - wagFilePath = file->getPath(); + wagFileNode = *file; wagFileCount++; // Count found *.wag files } } @@ -2298,7 +2298,7 @@ const Common::ADGameDescription *AgiMetaEngine::fallbackDetect(const Common::FSL // WinAGI produces *.wag file with interpreter version, game name and other parameters. // If there's exactly one *.wag file and it parses successfully then we'll use its information. - if (wagFileCount == 1 && wagFileParser.parse(wagFilePath.c_str())) { + if (wagFileCount == 1 && wagFileParser.parse(wagFileNode)) { matchedUsingWag = true; const WagProperty *wagAgiVer = wagFileParser.getProperty(WagProperty::PC_INTVERSION); diff --git a/engines/agi/loader_v3.cpp b/engines/agi/loader_v3.cpp index 656ae232ec..bea57069c0 100644 --- a/engines/agi/loader_v3.cpp +++ b/engines/agi/loader_v3.cpp @@ -48,9 +48,9 @@ int AgiLoader_v3::detectGame() { bool found = false; Common::FSList fslist; - Common::FilesystemNode dir(ConfMan.get("path")); + Common::FSNode dir(ConfMan.get("path")); - if (!dir.getChildren(fslist, Common::FilesystemNode::kListFilesOnly)) { + if (!dir.getChildren(fslist, Common::FSNode::kListFilesOnly)) { warning("AgiEngine: invalid game path '%s'", dir.getPath().c_str()); return errInvalidAGIFile; } diff --git a/engines/agi/op_cmd.cpp b/engines/agi/op_cmd.cpp index 758bff0cb6..186002e8cc 100644 --- a/engines/agi/op_cmd.cpp +++ b/engines/agi/op_cmd.cpp @@ -1739,7 +1739,7 @@ int AgiEngine::runLogic(int n) { curLogic->cIP = curLogic->sIP; timerHack = 0; - while (ip < _game.logics[n].size && !quit()) { + while (ip < _game.logics[n].size && !shouldQuit()) { if (_debug.enabled) { if (_debug.steps > 0) { if (_debug.logic0 || n) { diff --git a/engines/agi/op_test.cpp b/engines/agi/op_test.cpp index 393057ed9c..f096c0b2e7 100644 --- a/engines/agi/op_test.cpp +++ b/engines/agi/op_test.cpp @@ -231,7 +231,7 @@ int AgiEngine::testIfCode(int lognum) { uint8 p[16] = { 0 }; bool end_test = false; - while (retval && !quit() && !end_test) { + while (retval && !shouldQuit() && !end_test) { if (_debug.enabled && (_debug.logic0 || lognum)) debugConsole(lognum, lTEST_MODE, NULL); diff --git a/engines/agi/preagi_common.cpp b/engines/agi/preagi_common.cpp index 3cd04351f7..ce085ad165 100644 --- a/engines/agi/preagi_common.cpp +++ b/engines/agi/preagi_common.cpp @@ -120,7 +120,7 @@ void PreAgiEngine::printStrXOR(char *szMsg) { int PreAgiEngine::getSelection(SelectionTypes type) { Common::Event event; - while (!quit()) { + while (!shouldQuit()) { while (_eventMan->pollEvent(event)) { switch(event.type) { case Common::EVENT_RTL: diff --git a/engines/agi/preagi_mickey.cpp b/engines/agi/preagi_mickey.cpp index f643ab9cfc..db2e01a04b 100644 --- a/engines/agi/preagi_mickey.cpp +++ b/engines/agi/preagi_mickey.cpp @@ -2160,7 +2160,7 @@ void Mickey::run() { intro(); // Game loop - while (!_vm->quit()) { + while (!_vm->shouldQuit()) { drawRoom(); if (_game.fIntro) { diff --git a/engines/agi/preagi_troll.cpp b/engines/agi/preagi_troll.cpp index beff721fda..db663797f9 100644 --- a/engines/agi/preagi_troll.cpp +++ b/engines/agi/preagi_troll.cpp @@ -56,7 +56,7 @@ bool Troll::getMenuSel(const char *szMenu, int *iSel, int nSel) { drawMenu(szMenu, *iSel); - while (!_vm->quit()) { + while (!_vm->shouldQuit()) { while (_vm->_system->getEventManager()->pollEvent(event)) { switch(event.type) { case Common::EVENT_RTL: @@ -268,7 +268,7 @@ void Troll::tutorial() { int iSel = 0; //char szTreasure[16] = {0}; - while (!_vm->quit()) { + while (!_vm->shouldQuit()) { _vm->clearScreen(0xFF); _vm->printStr(IDS_TRO_TUTORIAL_0); diff --git a/engines/agi/preagi_winnie.cpp b/engines/agi/preagi_winnie.cpp index de8839b7bc..c58d7518ac 100644 --- a/engines/agi/preagi_winnie.cpp +++ b/engines/agi/preagi_winnie.cpp @@ -796,7 +796,7 @@ void Winnie::getMenuSel(char *szMenu, int *iSel, int fCanSel[]) { // Show the mouse cursor for the menu CursorMan.showMouse(true); - while (!_vm->quit()) { + while (!_vm->shouldQuit()) { while (_vm->_system->getEventManager()->pollEvent(event)) { switch(event.type) { case Common::EVENT_RTL: @@ -1013,7 +1013,7 @@ phase2: if (parser(hdr.ofsDesc[iBlock] - _roomOffset, iBlock, roomdata) == IDI_WTP_PAR_BACK) goto phase1; } - while (!_vm->quit()) { + while (!_vm->shouldQuit()) { for (iBlock = 0; iBlock < IDI_WTP_MAX_BLOCK; iBlock++) { switch(parser(hdr.ofsBlock[iBlock] - _roomOffset, iBlock, roomdata)) { case IDI_WTP_PAR_GOTO: diff --git a/engines/agi/predictive.cpp b/engines/agi/predictive.cpp index 21f9256e70..09472235ad 100644 --- a/engines/agi/predictive.cpp +++ b/engines/agi/predictive.cpp @@ -491,7 +491,8 @@ void AgiEngine::loadDict(void) { ConfMan.registerDefault("predictive_dictionary", "pred.dic"); uint32 time1 = _system->getMillis(); - if (!inFile.open(ConfMan.get("predictive_dictionary"))) + Common::String inFileName(ConfMan.get("predictive_dictionary")); + if (!inFile.open(inFileName)) return; char *ptr; @@ -505,7 +506,7 @@ void AgiEngine::loadDict(void) { inFile.read(_predictiveDictText, size); _predictiveDictText[size] = 0; uint32 time2 = _system->getMillis(); - debug("Time to read %s: %d bytes, %d ms", inFile.name(), size, time2-time1); + debug("Time to read %s: %d bytes, %d ms", inFileName.c_str(), size, time2-time1); inFile.close(); ptr = _predictiveDictText; diff --git a/engines/agi/saveload.cpp b/engines/agi/saveload.cpp index 0b308bb37b..179db94a71 100644 --- a/engines/agi/saveload.cpp +++ b/engines/agi/saveload.cpp @@ -91,7 +91,7 @@ int AgiEngine::saveGame(const char *fileName, const char *description) { out->writeSint16BE((int16)_game.lognum); out->writeSint16BE((int16)_game.playerControl); - out->writeSint16BE((int16)quit()); + out->writeSint16BE((int16)shouldQuit()); out->writeSint16BE((int16)_game.statusLine); out->writeSint16BE((int16)_game.clockEnabled); out->writeSint16BE((int16)_game.exitAllLogics); diff --git a/engines/agi/sound.cpp b/engines/agi/sound.cpp index 3b28e75c56..7138a3adad 100644 --- a/engines/agi/sound.cpp +++ b/engines/agi/sound.cpp @@ -1007,7 +1007,7 @@ const IIgsExeInfo *SoundMgr::getIIgsExeInfo(enum AgiGameID gameid) const { return NULL; } -bool IIgsSoundMgr::loadInstrumentHeaders(const Common::String &exePath, const IIgsExeInfo &exeInfo) { +bool IIgsSoundMgr::loadInstrumentHeaders(const Common::FSNode &exePath, const IIgsExeInfo &exeInfo) { bool loadedOk = false; // Was loading successful? Common::File file; @@ -1015,7 +1015,7 @@ bool IIgsSoundMgr::loadInstrumentHeaders(const Common::String &exePath, const II file.open(exePath); if (file.size() != (int32)exeInfo.exeSize) { debugC(3, kDebugLevelSound, "Apple IIGS executable (%s) has wrong size (Is %d, should be %d)", - exePath.c_str(), file.size(), exeInfo.exeSize); + exePath.getPath().c_str(), file.size(), exeInfo.exeSize); } // Read the whole executable file into memory @@ -1029,7 +1029,7 @@ bool IIgsSoundMgr::loadInstrumentHeaders(const Common::String &exePath, const II uint16 instSetByteCount = data->readUint16LE(); if (instSetByteCount != exeInfo.instSet.byteCount) { debugC(3, kDebugLevelSound, "Wrong instrument set size (Is %d, should be %d) in Apple IIGS executable (%s)", - instSetByteCount, exeInfo.instSet.byteCount, exePath.c_str()); + instSetByteCount, exeInfo.instSet.byteCount, exePath.getPath().c_str()); } // Check instrument set's md5sum @@ -1038,7 +1038,7 @@ bool IIgsSoundMgr::loadInstrumentHeaders(const Common::String &exePath, const II Common::md5_file_string(*data, md5str, exeInfo.instSet.byteCount); if (scumm_stricmp(md5str, exeInfo.instSet.md5)) { warning("Unknown Apple IIGS instrument set (md5: %s) in %s, trying to use it nonetheless", - md5str, exePath.c_str()); + md5str, exePath.getPath().c_str()); } // Read in the instrument set one instrument at a time @@ -1051,7 +1051,7 @@ bool IIgsSoundMgr::loadInstrumentHeaders(const Common::String &exePath, const II for (uint i = 0; i < exeInfo.instSet.instCount; i++) { if (!instrument.read(*data)) { warning("Error loading Apple IIGS instrument (%d. of %d) from %s, not loading more instruments", - i + 1, exeInfo.instSet.instCount, exePath.c_str()); + i + 1, exeInfo.instSet.instCount, exePath.getPath().c_str()); break; } _instruments.push_back(instrument); // Add the successfully loaded instrument to the instruments array @@ -1060,7 +1060,7 @@ bool IIgsSoundMgr::loadInstrumentHeaders(const Common::String &exePath, const II // Loading was successful only if all instruments were loaded successfully loadedOk = (_instruments.size() == exeInfo.instSet.instCount); } else // Couldn't read enough data from the executable file - warning("Error loading instruments from Apple IIGS executable (%s)", exePath.c_str()); + warning("Error loading instruments from Apple IIGS executable (%s)", exePath.getPath().c_str()); return loadedOk; } @@ -1078,7 +1078,7 @@ bool SoundMgr::convertWave(Common::SeekableReadStream &source, int8 *dest, uint return !source.ioFailed(); } -bool IIgsSoundMgr::loadWaveFile(const Common::String &wavePath, const IIgsExeInfo &exeInfo) { +bool IIgsSoundMgr::loadWaveFile(const Common::FSNode &wavePath, const IIgsExeInfo &exeInfo) { Common::File file; // Open the wave file and read it into memory @@ -1101,20 +1101,20 @@ bool IIgsSoundMgr::loadWaveFile(const Common::String &wavePath, const IIgsExeInf _wave.resize(uint8Wave->size()); return SoundMgr::convertWave(*uint8Wave, _wave.begin(), uint8Wave->size()); } else { // Couldn't read the wave file or it had incorrect size - warning("Error loading Apple IIGS wave file (%s), not loading instruments", wavePath.c_str()); + warning("Error loading Apple IIGS wave file (%s), not loading instruments", wavePath.getPath().c_str()); return false; } } /** - * A function object (i.e. a functor) for testing if a Common::FilesystemNode + * A function object (i.e. a functor) for testing if a Common::FSNode * object's name is equal (Ignoring case) to a string or to at least * one of the strings in a list of strings. Can be used e.g. with find_if(). */ -struct fsnodeNameEqualsIgnoreCase : public Common::UnaryFunction<const Common::FilesystemNode&, bool> { +struct fsnodeNameEqualsIgnoreCase : public Common::UnaryFunction<const Common::FSNode&, bool> { fsnodeNameEqualsIgnoreCase(const Common::StringList &str) : _str(str) {} fsnodeNameEqualsIgnoreCase(const Common::String str) { _str.push_back(str); } - bool operator()(const Common::FilesystemNode ¶m) const { + bool operator()(const Common::FSNode ¶m) const { for (Common::StringList::const_iterator iter = _str.begin(); iter != _str.end(); iter++) if (param.getName().equalsIgnoreCase(*iter)) return true; @@ -1140,8 +1140,8 @@ bool SoundMgr::loadInstruments() { // List files in the game path Common::FSList fslist; - Common::FilesystemNode dir(ConfMan.get("path")); - if (!dir.getChildren(fslist, Common::FilesystemNode::kListFilesOnly)) { + Common::FSNode dir(ConfMan.get("path")); + if (!dir.getChildren(fslist, Common::FSNode::kListFilesOnly)) { warning("Invalid game path (\"%s\"), not loading Apple IIGS instruments", dir.getPath().c_str()); return false; } @@ -1178,7 +1178,7 @@ bool SoundMgr::loadInstruments() { // None of the tested SIERRASTANDARD-files have zeroes in them so // there's no need to check for prematurely ending samples here. _gsSound.setProgramChangeMapping(&exeInfo->instSet.progToInst); - return _gsSound.loadWaveFile(waveFsnode->getPath(), *exeInfo) && _gsSound.loadInstrumentHeaders(exeFsnode->getPath(), *exeInfo); + return _gsSound.loadWaveFile(*waveFsnode, *exeInfo) && _gsSound.loadInstrumentHeaders(*exeFsnode, *exeInfo); } void SoundMgr::fillAudio(void *udata, int16 *stream, uint len) { diff --git a/engines/agi/sound.h b/engines/agi/sound.h index a1f079891f..0a6f5e302d 100644 --- a/engines/agi/sound.h +++ b/engines/agi/sound.h @@ -402,8 +402,8 @@ public: // For initializing IIgsSoundMgr(); void setProgramChangeMapping(const MidiProgramChangeMapping *mapping); - bool loadInstrumentHeaders(const Common::String &exePath, const IIgsExeInfo &exeInfo); - bool loadWaveFile(const Common::String &wavePath, const IIgsExeInfo &exeInfo); + bool loadInstrumentHeaders(const Common::FSNode &exePath, const IIgsExeInfo &exeInfo); + bool loadWaveFile(const Common::FSNode &wavePath, const IIgsExeInfo &exeInfo); // Miscellaneous methods uint activeSounds() const; ///< How many active sounds are playing? void stopSounds(); ///< Stops all sounds diff --git a/engines/agi/wagparser.cpp b/engines/agi/wagparser.cpp index 77dc180f14..ea3893d957 100644 --- a/engines/agi/wagparser.cpp +++ b/engines/agi/wagparser.cpp @@ -173,44 +173,40 @@ bool WagFileParser::checkWagVersion(Common::SeekableReadStream &stream) { } } -bool WagFileParser::parse(const char *filename) { - Common::File file; +bool WagFileParser::parse(const Common::FSNode &node) { WagProperty property; // Temporary property used for reading - Common::MemoryReadStream *stream = NULL; // The file is to be read fully into memory and handled using this + Common::SeekableReadStream *stream = NULL; // The file stream _parsedOk = false; // We haven't parsed the file yet - if (file.open(filename)) { // Open the file - stream = file.readStream(file.size()); // Read the file into memory - if (stream != NULL && stream->size() == file.size()) { // Check that the whole file was read into memory - if (checkWagVersion(*stream)) { // Check that WinAGI version string is valid - // It seems we've got a valid *.wag file so let's parse its properties from the start. - stream->seek(0); // Rewind the stream - if (!_propList.empty()) _propList.clear(); // Clear out old properties (If any) - - do { // Parse the properties - if (property.read(*stream)) { // Read the property and check it was read ok - _propList.push_back(property); // Add read property to properties list - debug(4, "WagFileParser::parse: Read property with code %d, type %d, number %d, size %d, data \"%s\"", - property.getCode(), property.getType(), property.getNumber(), property.getSize(), property.getData()); - } else // Reading failed, let's bail out - break; - } while (!endOfProperties(*stream)); // Loop until the end of properties - - // File was parsed successfully only if we got to the end of properties - // and all the properties were read successfully (Also the last). - _parsedOk = endOfProperties(*stream) && property.readOk(); - - if (!_parsedOk) // Error parsing stream - warning("Error parsing WAG file (%s). WAG file ignored", filename); - } else // Invalid WinAGI version string or it couldn't be read - warning("Invalid WAG file (%s) version or error reading it. WAG file ignored", filename); - } else // Couldn't fully read file into memory - warning("Error reading WAG file (%s) into memory. WAG file ignored", filename); + stream = node.openForReading(); // Open the file + if (stream) { // Check that opening the file was succesful + if (checkWagVersion(*stream)) { // Check that WinAGI version string is valid + // It seems we've got a valid *.wag file so let's parse its properties from the start. + stream->seek(0); // Rewind the stream + if (!_propList.empty()) _propList.clear(); // Clear out old properties (If any) + + do { // Parse the properties + if (property.read(*stream)) { // Read the property and check it was read ok + _propList.push_back(property); // Add read property to properties list + debug(4, "WagFileParser::parse: Read property with code %d, type %d, number %d, size %d, data \"%s\"", + property.getCode(), property.getType(), property.getNumber(), property.getSize(), property.getData()); + } else // Reading failed, let's bail out + break; + } while (!endOfProperties(*stream)); // Loop until the end of properties + + // File was parsed successfully only if we got to the end of properties + // and all the properties were read successfully (Also the last). + _parsedOk = endOfProperties(*stream) && property.readOk(); + + if (!_parsedOk) // Error parsing stream + warning("Error parsing WAG file (%s). WAG file ignored", node.getPath().c_str()); + } else // Invalid WinAGI version string or it couldn't be read + warning("Invalid WAG file (%s) version or error reading it. WAG file ignored", node.getPath().c_str()); } else // Couldn't open file - warning("Couldn't open WAG file (%s). WAG file ignored", filename); + warning("Couldn't open WAG file (%s). WAG file ignored", node.getPath().c_str()); - if (stream != NULL) delete stream; // If file was read into memory, deallocate that buffer + delete stream; return _parsedOk; } diff --git a/engines/agi/wagparser.h b/engines/agi/wagparser.h index 827720ac85..c10be541cb 100644 --- a/engines/agi/wagparser.h +++ b/engines/agi/wagparser.h @@ -223,7 +223,7 @@ public: * @param filename Name of the file to be parsed. * @return True if parsed successfully, false otherwise. */ - bool parse(const char *filename); + bool parse(const Common::FSNode &node); /** * Get list of the loaded properties. diff --git a/engines/agos/agos.cpp b/engines/agos/agos.cpp index 97d84e036c..3968646e63 100644 --- a/engines/agos/agos.cpp +++ b/engines/agos/agos.cpp @@ -951,7 +951,7 @@ void AGOSEngine::pauseEngineIntern(bool pauseIt) { void AGOSEngine::pause() { pauseEngine(true); - while (_pause && !quit()) { + while (_pause && !shouldQuit()) { delay(1); if (_keyPressed.keycode == Common::KEYCODE_p) pauseEngine(false); @@ -988,7 +988,7 @@ int AGOSEngine::go() { (getFeatures() & GF_DEMO)) { int i; - while (!quit()) { + while (!shouldQuit()) { for (i = 0; i < 4; i++) { setWindowImage(3, 9902 + i); debug(0, "Displaying image %d", 9902 + i); @@ -1017,7 +1017,7 @@ int AGOSEngine::go() { runSubroutine101(); permitInput(); - while (!quit()) { + while (!shouldQuit()) { waitForInput(); handleVerbClicked(_verbHitArea); delay(100); @@ -1074,7 +1074,7 @@ void AGOSEngine::shutdown() { delete _moviePlay; delete _sound; - _system->quit(); + _system->shouldQuit(); } */ diff --git a/engines/agos/animation.cpp b/engines/agos/animation.cpp index f4abf19645..9f8b3f8643 100644 --- a/engines/agos/animation.cpp +++ b/engines/agos/animation.cpp @@ -150,7 +150,7 @@ void MoviePlayer::play() { startSound(); - while (_frameNum < _framesCount && !_vm->quit()) + while (_frameNum < _framesCount && !_vm->shouldQuit()) handleNextFrame(); closeFile(); diff --git a/engines/agos/event.cpp b/engines/agos/event.cpp index 4db3545594..abb7aa056b 100644 --- a/engines/agos/event.cpp +++ b/engines/agos/event.cpp @@ -142,7 +142,7 @@ bool AGOSEngine::kickoffTimeEvents() { cur_time = getTime() - _gameStoppedClock; - while ((te = _firstTimeStruct) != NULL && te->time <= cur_time && !quit()) { + while ((te = _firstTimeStruct) != NULL && te->time <= cur_time && !shouldQuit()) { result = true; _pendingDeleteTimeEvent = te; invokeTimeEvent(te); @@ -544,7 +544,7 @@ void AGOSEngine::delay(uint amount) { _system->delayMillis(this_delay); cur = _system->getMillis(); - } while (cur < start + amount && !quit()); + } while (cur < start + amount && !shouldQuit()); } void AGOSEngine::timer_callback() { diff --git a/engines/agos/gfx.cpp b/engines/agos/gfx.cpp index 25a4b919f4..01f254f453 100644 --- a/engines/agos/gfx.cpp +++ b/engines/agos/gfx.cpp @@ -1286,7 +1286,7 @@ void AGOSEngine::setWindowImageEx(uint16 mode, uint16 vga_res) { if (getGameType() == GType_WW && (mode == 6 || mode == 8 || mode == 9)) { setWindowImage(mode, vga_res); } else { - while (_copyScnFlag && !quit()) + while (_copyScnFlag && !shouldQuit()) delay(1); setWindowImage(mode, vga_res); diff --git a/engines/agos/input.cpp b/engines/agos/input.cpp index 4327c2878d..8e04f54952 100644 --- a/engines/agos/input.cpp +++ b/engines/agos/input.cpp @@ -123,7 +123,7 @@ void AGOSEngine::setup_cond_c_helper() { clearName(); _lastNameOn = last; - while (!quit()) { + while (!shouldQuit()) { _lastHitArea = NULL; _lastHitArea3 = 0; _leftButtonDown = 0; @@ -145,7 +145,7 @@ void AGOSEngine::setup_cond_c_helper() { } delay(100); - } while ((_lastHitArea3 == (HitArea *) -1 || _lastHitArea3 == 0) && !quit()); + } while ((_lastHitArea3 == (HitArea *) -1 || _lastHitArea3 == 0) && !shouldQuit()); if (_lastHitArea == NULL) { } else if (_lastHitArea->id == 0x7FFB) { @@ -189,12 +189,12 @@ void AGOSEngine::waitForInput() { resetVerbs(); } - while (!quit()) { + while (!shouldQuit()) { _lastHitArea = NULL; _lastHitArea3 = NULL; _dragAccept = 1; - while (!quit()) { + while (!shouldQuit()) { if ((getGameType() == GType_SIMON1 || getGameType() == GType_SIMON2) && _keyPressed.keycode == Common::KEYCODE_F10) displayBoxStars(); diff --git a/engines/agos/oracle.cpp b/engines/agos/oracle.cpp index c174362e7c..dfa3b801d7 100644 --- a/engines/agos/oracle.cpp +++ b/engines/agos/oracle.cpp @@ -459,7 +459,7 @@ void AGOSEngine_Feeble::saveUserGame(int slot) { } windowPutChar(window, 0x7f); - while (!quit()) { + while (!shouldQuit()) { _keyPressed.reset(); delay(1); diff --git a/engines/agos/saveload.cpp b/engines/agos/saveload.cpp index c1a4e91c95..9314d46a33 100644 --- a/engines/agos/saveload.cpp +++ b/engines/agos/saveload.cpp @@ -279,11 +279,11 @@ restart: name = buf; _saveGameNameLen = 0; - while (!quit()) { + while (!shouldQuit()) { windowPutChar(window, 128); _keyPressed.reset(); - while (!quit()) { + while (!shouldQuit()) { delay(10); if (_keyPressed.ascii && _keyPressed.ascii < 128) { i = _keyPressed.ascii; @@ -443,7 +443,7 @@ void AGOSEngine_Elvira2::userGame(bool load) { name = buf + 192; - while (!quit()) { + while (!shouldQuit()) { windowPutChar(window, 128); _saveLoadEdit = true; @@ -516,7 +516,7 @@ int AGOSEngine_Elvira2::userGameGetKey(bool *b, char *buf, uint maxChar) { _keyPressed.reset(); - while (!quit()) { + while (!shouldQuit()) { _lastHitArea = NULL; _lastHitArea3 = NULL; @@ -526,7 +526,7 @@ int AGOSEngine_Elvira2::userGameGetKey(bool *b, char *buf, uint maxChar) { return _keyPressed.ascii; } delay(10); - } while (_lastHitArea3 == 0 && !quit()); + } while (_lastHitArea3 == 0 && !shouldQuit()); ha = _lastHitArea; if (ha == NULL || ha->id < 200) { @@ -708,7 +708,7 @@ restart:; _saveGameNameLen++; } - while (!quit()) { + while (!shouldQuit()) { windowPutChar(window, 127); _saveLoadEdit = true; @@ -787,7 +787,7 @@ int AGOSEngine_Simon1::userGameGetKey(bool *b, char *buf, uint maxChar) { _keyPressed.reset(); - while (!quit()) { + while (!shouldQuit()) { _lastHitArea = NULL; _lastHitArea3 = NULL; @@ -797,7 +797,7 @@ int AGOSEngine_Simon1::userGameGetKey(bool *b, char *buf, uint maxChar) { return _keyPressed.ascii; } delay(10); - } while (_lastHitArea3 == 0 && !quit()); + } while (_lastHitArea3 == 0 && !shouldQuit()); ha = _lastHitArea; if (ha == NULL || ha->id < 205) { diff --git a/engines/agos/script.cpp b/engines/agos/script.cpp index 39c172be62..4bcb573e09 100644 --- a/engines/agos/script.cpp +++ b/engines/agos/script.cpp @@ -965,7 +965,7 @@ void AGOSEngine::writeVariable(uint16 variable, uint16 contents) { int AGOSEngine::runScript() { bool flag; - if (quit()) + if (shouldQuit()) return 1; do { @@ -1010,9 +1010,9 @@ int AGOSEngine::runScript() { error("Invalid opcode '%d' encountered", _opcode); executeOpcode(_opcode); - } while (getScriptCondition() != flag && !getScriptReturn() && !quit()); + } while (getScriptCondition() != flag && !getScriptReturn() && !shouldQuit()); - return (quit()) ? 1 : getScriptReturn(); + return (shouldQuit()) ? 1 : getScriptReturn(); } Child *nextSub(Child *sub, int16 key) { @@ -1066,7 +1066,7 @@ void AGOSEngine::waitForSync(uint a) { _exitCutscene = false; _rightButtonDown = false; - while (_vgaWaitFor != 0 && !quit()) { + while (_vgaWaitFor != 0 && !shouldQuit()) { if (_rightButtonDown) { if (_vgaWaitFor == 200 && (getGameType() == GType_FF || !getBitFlag(14))) { skipSpeech(); diff --git a/engines/agos/script_e1.cpp b/engines/agos/script_e1.cpp index 8705755df6..dbb633ff66 100644 --- a/engines/agos/script_e1.cpp +++ b/engines/agos/script_e1.cpp @@ -1052,11 +1052,11 @@ uint AGOSEngine::confirmYesOrNo(uint16 x, uint16 y) { ha->priority = 999; ha->window = 0; - while (!quit()) { + while (!shouldQuit()) { _lastHitArea = NULL; _lastHitArea3 = NULL; - while (!quit()) { + while (!shouldQuit()) { if (_lastHitArea3 != 0) break; delay(1); @@ -1101,11 +1101,11 @@ uint AGOSEngine::continueOrQuit() { ha->priority = 999; ha->window = 0; - while (!quit()) { + while (!shouldQuit()) { _lastHitArea = NULL; _lastHitArea3 = NULL; - while (!quit()) { + while (!shouldQuit()) { if (_lastHitArea3 != 0) break; delay(1); diff --git a/engines/agos/script_e2.cpp b/engines/agos/script_e2.cpp index 05e457579d..59c5132b0a 100644 --- a/engines/agos/script_e2.cpp +++ b/engines/agos/script_e2.cpp @@ -370,11 +370,11 @@ void AGOSEngine_Elvira2::oe2_pauseGame() { uint32 pauseTime = getTime(); haltAnimation(); - while (!quit()) { + while (!shouldQuit()) { _lastHitArea = NULL; _lastHitArea3 = NULL; - while (!quit()) { + while (!shouldQuit()) { if (processSpecialKeys() != 0 || _lastHitArea3 != 0) break; delay(1); diff --git a/engines/agos/script_s1.cpp b/engines/agos/script_s1.cpp index d07f682937..145d4a2694 100644 --- a/engines/agos/script_s1.cpp +++ b/engines/agos/script_s1.cpp @@ -338,7 +338,7 @@ void AGOSEngine_Simon1::os1_pauseGame() { break; } - while (!quit()) { + while (!shouldQuit()) { delay(1); if (_keyPressed.keycode == keyYes) quitGame(); diff --git a/engines/agos/script_ww.cpp b/engines/agos/script_ww.cpp index f0da324fbd..d5da9afe95 100644 --- a/engines/agos/script_ww.cpp +++ b/engines/agos/script_ww.cpp @@ -368,11 +368,11 @@ void AGOSEngine_Waxworks::oww_pauseGame() { uint32 pauseTime = getTime(); haltAnimation(); - while (!quit()) { + while (!shouldQuit()) { _lastHitArea = NULL; _lastHitArea3 = NULL; - while (!quit()) { + while (!shouldQuit()) { if (_lastHitArea3 != 0) break; delay(1); diff --git a/engines/agos/subroutine.cpp b/engines/agos/subroutine.cpp index 488ebf4edf..1d4f2e8ba6 100644 --- a/engines/agos/subroutine.cpp +++ b/engines/agos/subroutine.cpp @@ -555,7 +555,7 @@ int AGOSEngine::startSubroutine(Subroutine *sub) { _currentTable = sub; restart: - if (quit()) + if (shouldQuit()) return result; while ((byte *)sl != (byte *)sub) { diff --git a/engines/agos/verb.cpp b/engines/agos/verb.cpp index 9fd128d764..41e7fee5e1 100644 --- a/engines/agos/verb.cpp +++ b/engines/agos/verb.cpp @@ -343,7 +343,7 @@ void AGOSEngine::handleVerbClicked(uint verb) { Subroutine *sub; int result; - if (quit()) + if (shouldQuit()) return; _objectItem = _hitAreaObjectItem; diff --git a/engines/agos/window.cpp b/engines/agos/window.cpp index 87db49e46b..3fb8e9ae5c 100644 --- a/engines/agos/window.cpp +++ b/engines/agos/window.cpp @@ -298,11 +298,11 @@ void AGOSEngine::waitWindow(WindowBlock *window) { ha->id = 0x7FFF; ha->priority = 999; - while (!quit()) { + while (!shouldQuit()) { _lastHitArea = NULL; _lastHitArea3 = NULL; - while (!quit()) { + while (!shouldQuit()) { if (_lastHitArea3 != 0) break; delay(1); diff --git a/engines/cine/main_loop.cpp b/engines/cine/main_loop.cpp index 04c6f5c769..abebe90299 100644 --- a/engines/cine/main_loop.cpp +++ b/engines/cine/main_loop.cpp @@ -419,7 +419,7 @@ void CineEngine::mainLoop(int bootScriptIdx) { manageEvents(); - } while (!quit() && _danKeysPressed != 7); + } while (!shouldQuit() && _danKeysPressed != 7); hideMouse(); g_sound->stopMusic(); diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp index c1449ea2c9..fce4fa73c6 100644 --- a/engines/drascula/drascula.cpp +++ b/engines/drascula/drascula.cpp @@ -55,7 +55,7 @@ static const GameSettings drasculaSettings[] = { DrasculaEngine::DrasculaEngine(OSystem *syst, const DrasculaGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc) { // Setup mixer - _mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume")); + _mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, ConfMan.getInt("speech_volume")); _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, ConfMan.getInt("music_volume")); _rnd = new Common::RandomSource(); @@ -220,7 +220,7 @@ int DrasculaEngine::go() { allocMemory(); - withVoices = 0; + _subtitlesDisabled = !ConfMan.getBool("subtitles"); selectionMade = 0; if (currentChapter != 3) @@ -560,12 +560,16 @@ bool DrasculaEngine::runCurrentChapter() { } else if (key == Common::KEYCODE_F8) { selectVerb(0); } else if (key == Common::KEYCODE_v) { - withVoices = 1; + _subtitlesDisabled = true; + ConfMan.setBool("subtitles", !_subtitlesDisabled); + print_abc(_textsys[2], 96, 86); updateScreen(); delay(1410); } else if (key == Common::KEYCODE_t) { - withVoices = 0; + _subtitlesDisabled = false; + ConfMan.setBool("subtitles", !_subtitlesDisabled); + print_abc(_textsys[3], 94, 86); updateScreen(); delay(1460); diff --git a/engines/drascula/drascula.h b/engines/drascula/drascula.h index 3b499f27a0..4a00d35d10 100644 --- a/engines/drascula/drascula.h +++ b/engines/drascula/drascula.h @@ -380,7 +380,7 @@ public: int _destX[40], _destY[40], trackCharacter_alkeva[40], roomExits[40]; int x1[40], y1[40], x2[40], y2[40]; int takeObject, pickedObject; - int withVoices; + bool _subtitlesDisabled; int menuBar, menuScreen, hasName; char textName[20]; int curExcuseLook; diff --git a/engines/drascula/sound.cpp b/engines/drascula/sound.cpp index 6a3d83cae6..51517280ba 100644 --- a/engines/drascula/sound.cpp +++ b/engines/drascula/sound.cpp @@ -26,6 +26,7 @@ #include "sound/mixer.h" #include "sound/voc.h" #include "sound/audiocd.h" +#include "common/config-manager.h" #include "drascula/drascula.h" @@ -52,7 +53,7 @@ void DrasculaEngine::volumeControls() { for (;;) { int masterVolume = CLIP((_mixer->getVolumeForSoundType(Audio::Mixer::kPlainSoundType) / 16), 0, 15); - int voiceVolume = CLIP((_mixer->getVolumeForSoundType(Audio::Mixer::kSFXSoundType) / 16), 0, 15); + int voiceVolume = CLIP((_mixer->getVolumeForSoundType(Audio::Mixer::kSpeechSoundType) / 16), 0, 15); int musicVolume = CLIP((_mixer->getVolumeForSoundType(Audio::Mixer::kMusicSoundType) / 16), 0, 15); int masterVolumeY = 72 + 61 - masterVolume * 4; @@ -82,7 +83,7 @@ void DrasculaEngine::volumeControls() { } if (mouseX > 136 && mouseX < 178) { - updateVolume(Audio::Mixer::kSFXSoundType, voiceVolumeY); + updateVolume(Audio::Mixer::kSpeechSoundType, voiceVolumeY); } if (mouseX > 192 && mouseX < 233) { @@ -173,7 +174,11 @@ void DrasculaEngine::playFile(const char *fname) { _arj.read(soundData, soundSize); _arj.close(); - _mixer->playRaw(Audio::Mixer::kSFXSoundType, &_soundHandle, soundData, soundSize - 64, + _subtitlesDisabled = !ConfMan.getBool("subtitles"); + if (ConfMan.getBool("speech_mute")) + memset(soundData, 0x80, soundSize); // Mute speech but keep the pause + + _mixer->playRaw(Audio::Mixer::kSpeechSoundType, &_soundHandle, soundData, soundSize - 64, 11025, Audio::Mixer::FLAG_AUTOFREE | Audio::Mixer::FLAG_UNSIGNED); } else warning("playFile: Could not open %s", fname); diff --git a/engines/drascula/talk.cpp b/engines/drascula/talk.cpp index 7bf55b7c40..4ecc3e20f2 100644 --- a/engines/drascula/talk.cpp +++ b/engines/drascula/talk.cpp @@ -82,7 +82,7 @@ void DrasculaEngine::talk_igor(int index, int talkerType) { copyBackground(igorX + 17, igorY, igorX + 17, igorY, 37, 24, bgSurface, screenSurface); copyRect(x_talk0[face], 148, igorX + 17, igorY, 25, 24, frontSurface, screenSurface); updateRefresh(); - if (withVoices == 0) + if (!_subtitlesDisabled) centerText(said, igorX + 26, igorY); updateScreen(); pause(3); @@ -95,13 +95,13 @@ void DrasculaEngine::talk_igor(int index, int talkerType) { copyBackground(igorX, igorY, igorX, igorY, 29, 25, bgSurface, screenSurface); copyRect(x_talk1[face], 173, igorX, igorY, 29, 25, frontSurface, screenSurface); updateRefresh(); - if (withVoices == 0) + if (!_subtitlesDisabled) centerText(said, igorX + 26, igorY); updateScreen(); pause(3); } else if (talkerType == kIgorDoor) { updateRoom(); - if (withVoices == 0) + if (!_subtitlesDisabled) centerText(said, 87, 66); updateScreen(); } else if (talkerType == kIgorSeated || talkerType == kIgorWig) { @@ -111,7 +111,7 @@ void DrasculaEngine::talk_igor(int index, int talkerType) { copyBackground(x_talk4[face], 78, 199, 94, 38, 27, drawSurface3, screenSurface); moveCharacters(); updateRefresh(); - if (withVoices == 0) + if (!_subtitlesDisabled) centerText(said, 221, 102); updateScreen(); @@ -166,7 +166,7 @@ void DrasculaEngine::talk_drascula(int index, int talkerType) { updateRefresh(); - if (withVoices == 0) + if (!_subtitlesDisabled) centerText(said, drasculaX + 19, drasculaY); updateScreen(); @@ -211,7 +211,7 @@ void DrasculaEngine::talk_drascula_big(int index) { if (l == 7) l = 0; - if (withVoices == 0) + if (!_subtitlesDisabled) centerText(said, 191, 69); updateScreen(); @@ -237,7 +237,7 @@ void DrasculaEngine::talk_solo(const char *said, const char *filename) { copyBackground(); do { - if (withVoices == 0) { + if (!_subtitlesDisabled) { if (currentChapter == 1) centerText(said, 156, 90); else if (currentChapter == 6) @@ -300,7 +300,7 @@ void DrasculaEngine::talk_bartender(int index, int talkerType) { moveCharacters(); updateRefresh(); - if (withVoices == 0) + if (!_subtitlesDisabled) centerText(said, 132, 45); updateScreen(); @@ -339,7 +339,7 @@ void DrasculaEngine::talk_bj(int index) { moveCharacters(); updateRefresh(); - if (withVoices == 0) + if (!_subtitlesDisabled) centerText(said, bjX + 7, bjY); updateScreen(); @@ -348,7 +348,7 @@ void DrasculaEngine::talk_bj(int index) { } else { updateRoom(); - if (withVoices == 0) + if (!_subtitlesDisabled) centerText(said, 93, 80); updateScreen(); @@ -463,7 +463,7 @@ void DrasculaEngine::talk(const char *said, const char *filename) { updateRefresh(); } - if (withVoices == 0) + if (!_subtitlesDisabled) centerText(said, curX, curY); updateScreen(); @@ -555,7 +555,7 @@ void DrasculaEngine::talk_vonBraun(int index, int talkerType) { updateRefresh(); } - if (withVoices == 0) + if (!_subtitlesDisabled) centerText(said, vonBraunX, 66); updateScreen(); @@ -563,7 +563,7 @@ void DrasculaEngine::talk_vonBraun(int index, int talkerType) { } else { updateRoom(); - if (withVoices == 0) + if (!_subtitlesDisabled) centerText(said, 150, 80); updateScreen(); @@ -617,7 +617,7 @@ void DrasculaEngine::talk_blind(int index) { copyRect(bX, 2, 73, 1, 126, h, frontSurface, screenSurface); } - if (withVoices == 0) + if (!_subtitlesDisabled) centerText(said, 260, 71); updateScreen(); @@ -639,7 +639,7 @@ void DrasculaEngine::talk_hacker(int index) { talkInit(filename); do { - if (withVoices == 0) + if (!_subtitlesDisabled) centerText(said, 156, 170); updateScreen(); } while (!isTalkFinished()); @@ -700,7 +700,7 @@ void DrasculaEngine::talk_pen(const char *said, const char *filename, int talker updateRefresh(); - if (withVoices == 0) { + if (!_subtitlesDisabled) { if (talkerType == 0) centerText(said, 160, 105); else @@ -741,7 +741,7 @@ void DrasculaEngine::talk_bj_bed(int index) { moveCharacters(); updateRefresh(); - if (withVoices == 0) + if (!_subtitlesDisabled) centerText(said, 104, 102); updateScreen(); @@ -777,7 +777,7 @@ void DrasculaEngine::talk_htel(int index) { else copyBackground(x_talk[face], 1, 45, 24, 92, 108, backSurface, screenSurface); - if (withVoices == 0) + if (!_subtitlesDisabled) centerText(said, 90, 50); updateScreen(); @@ -857,7 +857,7 @@ void DrasculaEngine::talk_sync(const char *said, const char *filename, const cha updateRefresh(); } - if (withVoices == 0) + if (!_subtitlesDisabled) centerText(said, curX, curY); updateScreen(); @@ -890,7 +890,7 @@ void DrasculaEngine::talk_trunk(int index) { flags[19] = face; updateRoom(); - if (withVoices == 0) + if (!_subtitlesDisabled) centerText(said, 263, 69); updateScreen(); @@ -917,7 +917,7 @@ void DrasculaEngine::talk_generic(const char* said, const char* filename, int* f moveCharacters(); updateRefresh(); - if (withVoices == 0) + if (!_subtitlesDisabled) centerText(said, coords[5], coords[6]); updateScreen(); @@ -938,7 +938,7 @@ void DrasculaEngine::grr() { updateRoom(); copyBackground(253, 110, 150, 65, 20, 30, drawSurface3, screenSurface); - if (withVoices == 0) + if (!_subtitlesDisabled) centerText("groaaarrrrgghhhh!", 153, 65); updateScreen(); diff --git a/engines/engine.cpp b/engines/engine.cpp index 1d3368b10d..57efad5c19 100644 --- a/engines/engine.cpp +++ b/engines/engine.cpp @@ -61,7 +61,6 @@ Engine::Engine(OSystem *syst) _mainMenuDialog(NULL) { g_engine = this; - _autosavePeriod = ConfMan.getInt("autosave_period"); // FIXME: Get rid of the following again. It is only here temporarily. // We really should never run with a non-working Mixer, so ought to handle @@ -81,7 +80,7 @@ Engine::~Engine() { g_engine = NULL; } -void Engine::initCommonGFX(bool defaultTo1XScaler) { +void initCommonGFX(bool defaultTo1XScaler) { const Common::ConfigManager::Domain *transientDomain = ConfMan.getDomain(Common::ConfigManager::kTransientDomain); const Common::ConfigManager::Domain *gameDomain = ConfMan.getActiveDomain(); @@ -101,11 +100,11 @@ void Engine::initCommonGFX(bool defaultTo1XScaler) { // FIXME: As a hack, we use "1x" here. Would be nicer to use // getDefaultGraphicsMode() instead, but right now, we do not specify // whether that is a 1x scaler or not... - _system->setGraphicsMode("1x"); + g_system->setGraphicsMode("1x"); } else { // Override global scaler with any game-specific define if (ConfMan.hasKey("gfx_mode")) { - _system->setGraphicsMode(ConfMan.get("gfx_mode").c_str()); + g_system->setGraphicsMode(ConfMan.get("gfx_mode").c_str()); } } @@ -118,11 +117,22 @@ void Engine::initCommonGFX(bool defaultTo1XScaler) { // (De)activate aspect-ratio correction as determined by the config settings if (gameDomain && gameDomain->contains("aspect_ratio")) - _system->setFeatureState(OSystem::kFeatureAspectRatioCorrection, ConfMan.getBool("aspect_ratio")); + g_system->setFeatureState(OSystem::kFeatureAspectRatioCorrection, ConfMan.getBool("aspect_ratio")); // (De)activate fullscreen mode as determined by the config settings if (gameDomain && gameDomain->contains("fullscreen")) - _system->setFeatureState(OSystem::kFeatureFullscreenMode, ConfMan.getBool("fullscreen")); + g_system->setFeatureState(OSystem::kFeatureFullscreenMode, ConfMan.getBool("fullscreen")); +} + +void GUIErrorMessage(const Common::String msg) { + g_system->setWindowCaption("Error"); + g_system->beginGFXTransaction(); + initCommonGFX(false); + g_system->initSize(320, 200); + g_system->endGFXTransaction(); + + GUI::MessageDialog dialog(msg); + dialog.runModal(); } void Engine::checkCD() { @@ -168,7 +178,7 @@ void Engine::checkCD() { GUI::MessageDialog dialog( "You appear to be playing this game directly\n" "from the CD. This is known to cause problems,\n" - "and it's therefore recommended that you copy\n" + "and it is therefore recommended that you copy\n" "the data files to your hard disk instead.\n" "See the README file for details.", "OK"); dialog.runModal(); @@ -178,24 +188,14 @@ void Engine::checkCD() { bool Engine::shouldPerformAutoSave(int lastSaveTime) { const int diff = _system->getMillis() - lastSaveTime; - return _autosavePeriod != 0 && diff > _autosavePeriod * 1000; + const int autosavePeriod = ConfMan.getInt("autosave_period"); + return autosavePeriod != 0 && diff > autosavePeriod * 1000; } void Engine::errorString(const char *buf1, char *buf2) { strcpy(buf2, buf1); } -void Engine::GUIErrorMessage(const Common::String msg) { - _system->setWindowCaption("Error"); - _system->beginGFXTransaction(); - initCommonGFX(false); - _system->initSize(320, 200); - _system->endGFXTransaction(); - - GUI::MessageDialog dialog(msg); - dialog.runModal(); -} - void Engine::pauseEngine(bool pause) { assert((pause && _pauseLevel >= 0) || (!pause && _pauseLevel)); @@ -216,19 +216,16 @@ void Engine::pauseEngineIntern(bool pause) { _mixer->pauseAll(pause); } -void Engine::mainMenuDialog() { +void Engine::openMainMenuDialog() { if (!_mainMenuDialog) _mainMenuDialog = new MainMenuDialog(this); runDialog(*_mainMenuDialog); syncSoundSettings(); } -int Engine::runDialog(Dialog &dialog) { - +int Engine::runDialog(GUI::Dialog &dialog) { pauseEngine(true); - int result = dialog.runModal(); - pauseEngine(false); return result; @@ -254,6 +251,7 @@ void Engine::quitGame() { } bool Engine::hasFeature(int f) { + // TODO: In each engine, keep a ref to the corresponding MetaEngine? const EnginePlugin *plugin = 0; Common::String gameid = ConfMan.get("gameid"); gameid.toLowercase(); diff --git a/engines/engine.h b/engines/engine.h index 81e4e6187c..dec85885d8 100644 --- a/engines/engine.h +++ b/engines/engine.h @@ -25,9 +25,9 @@ #ifndef ENGINES_ENGINE_H #define ENGINES_ENGINE_H +#include "common/scummsys.h" #include "common/events.h" #include "common/fs.h" -#include "common/scummsys.h" #include "common/str.h" class OSystem; @@ -45,7 +45,16 @@ namespace GUI { class Dialog; } -using GUI::Dialog; +/** + * Setup the backend's graphics mode. + */ +void initCommonGFX(bool defaultTo1XScaler); + +/** + * Initialized graphics and shows error message. + */ +void GUIErrorMessage(const Common::String msg); + class Engine { public: @@ -57,20 +66,15 @@ protected: Common::EventManager *_eventMan; Common::SaveFileManager *_saveFileMan; - Dialog *_mainMenuDialog; - virtual int runDialog(Dialog &dialog); + GUI::Dialog *_mainMenuDialog; + virtual int runDialog(GUI::Dialog &dialog); const Common::String _targetName; // target name for saves - const Common::FilesystemNode _gameDataDir; + const Common::FSNode _gameDataDir; private: /** - * The autosave interval, given in second. Used by shouldPerformAutoSave. - */ - int _autosavePeriod; - - /** * The pause level, 0 means 'running', a positive value indicates * how often the engine has been paused (and hence how often it has * to be un-paused before it resumes running). This makes it possible @@ -79,6 +83,13 @@ private: int _pauseLevel; public: + + /** @name Overloadable methods + * + * All Engine subclasses should consider overloading some or all of the following methods. + */ + //@{ + Engine(OSystem *syst); virtual ~Engine(); @@ -96,7 +107,9 @@ public: */ virtual int go() = 0; - /** Specific for each engine: prepare error string. */ + /** + * Prepare an error string, which is printed by the error() function. + */ virtual void errorString(const char *buf_input, char *buf_output); /** @@ -106,6 +119,39 @@ public: virtual GUI::Debugger *getDebugger() { return 0; } /** + * Notify the engine that the sound settings in the config manager may have + * changed and that it hence should adjust any internal volume etc. values + * accordingly. + * @todo find a better name for this + */ + virtual void syncSoundSettings(); + +protected: + + /** + * Actual implementation of pauseEngine by subclasses. See there + * for details. + */ + virtual void pauseEngineIntern(bool pause); + + //@} + + +public: + + /** + * Request the engine to quit. Sends a EVENT_QUIT event to the Event + * Manager. + */ + void quitGame(); + + /** + * Return whether the ENGINE should quit respectively should return to the + * launcher. + */ + bool shouldQuit() const { return (_eventMan->shouldQuit() || _eventMan->shouldRTL()); } + + /** * Pause or resume the engine. This should stop/resume any audio playback * and other stuff. Called right before the system runs a global dialog * (like a global pause, main menu, options or 'confirm exit' dialog). @@ -119,51 +165,32 @@ public: void pauseEngine(bool pause); /** - * Quit the engine, sends a Quit event to the Event Manager - */ - void quitGame(); - - /** * Return whether the engine is currently paused or not. */ bool isPaused() const { return _pauseLevel != 0; } /** - * Return whether or not the ENGINE should quit - */ - bool quit() const { return (_eventMan->shouldQuit() || _eventMan->shouldRTL()); } - - /** Run the Global Main Menu Dialog - */ - virtual void mainMenuDialog(); - - /** Sync the engine's sound settings with the config manager + * Run the Global Main Menu Dialog */ - virtual void syncSoundSettings(); + void openMainMenuDialog(); - /** Determine whether the engine supports the specified MetaEngine feature + /** + * Determine whether the engine supports the specified MetaEngine feature. */ - virtual bool hasFeature(int f); + bool hasFeature(int f); public: - /** Setup the backend's graphics mode. */ - void initCommonGFX(bool defaultTo1XScaler); - /** On some systems, check if the game appears to be run from CD. */ void checkCD(); - /** Indicate whether an autosave should be performed. */ - bool shouldPerformAutoSave(int lastSaveTime); - - /** Initialized graphics and shows error message. */ - void GUIErrorMessage(const Common::String msg); +protected: /** - * Actual implementation of pauseEngine by subclasses. See there - * for details. + * Indicate whether an autosave should be performed. */ - virtual void pauseEngineIntern(bool pause); + bool shouldPerformAutoSave(int lastSaveTime); + }; extern Engine *g_engine; diff --git a/engines/gob/detection.cpp b/engines/gob/detection.cpp index 2b0c015677..c871bdb976 100644 --- a/engines/gob/detection.cpp +++ b/engines/gob/detection.cpp @@ -992,6 +992,19 @@ static const GOBGameDescription gameDescriptions[] = { kFeaturesAdlib, "intro" }, + { // Supplied by goodoldgeorg in bug report #2105220 + { + "lostintime", + "", + AD_ENTRY1s("intro.stk", "cd322cb3c64ef2ba2f2134aa2122cfe9", 3936700), + ES_ESP, + kPlatformPC, + Common::ADGF_NO_FLAGS + }, + kGameTypeLostInTime, + kFeaturesAdlib, + "intro" + }, { { "lostintime", diff --git a/engines/gob/game_v1.cpp b/engines/gob/game_v1.cpp index 0ecbc81358..aecdde4309 100644 --- a/engines/gob/game_v1.cpp +++ b/engines/gob/game_v1.cpp @@ -63,7 +63,7 @@ void Game_v1::playTot(int16 skipPlay) { strcpy(savedTotName, _curTotFile); if (skipPlay <= 0) { - while (!_vm->quit()) { + while (!_vm->shouldQuit()) { for (int i = 0; i < 4; i++) { _vm->_draw->_fontToSprite[i].sprite = -1; _vm->_draw->_fontToSprite[i].base = -1; @@ -997,7 +997,7 @@ void Game_v1::collisionsBlock(void) { WRITE_VAR(16, 0); _activeCollResId = 0; } - while ((_activeCollResId == 0) && !_vm->_inter->_terminate && !_vm->quit()); + while ((_activeCollResId == 0) && !_vm->_inter->_terminate && !_vm->shouldQuit()); if (((uint16) _activeCollResId & ~0x8000) == collResId) { collStackPos = 0; diff --git a/engines/gob/game_v2.cpp b/engines/gob/game_v2.cpp index 7d9419b592..9d09fac425 100644 --- a/engines/gob/game_v2.cpp +++ b/engines/gob/game_v2.cpp @@ -70,7 +70,7 @@ void Game_v2::playTot(int16 skipPlay) { strcpy(savedTotName, _curTotFile); if (skipPlay <= 0) { - while (!_vm->quit()) { + while (!_vm->shouldQuit()) { if (_vm->_inter->_variables) _vm->_draw->animateCursor(4); @@ -438,7 +438,7 @@ int16 Game_v2::checkCollisions(byte handleMouse, int16 deltaTime, int16 *pResId, timeKey = _vm->_util->getTimeKey(); while (1) { - if (_vm->_inter->_terminate || _vm->quit()) { + if (_vm->_inter->_terminate || _vm->shouldQuit()) { if (handleMouse) _vm->_draw->blitCursor(); return 0; @@ -1043,7 +1043,7 @@ void Game_v2::collisionsBlock(void) { WRITE_VAR(16, 0); _activeCollResId = 0; } - while ((_activeCollResId == 0) && !_vm->_inter->_terminate && !_vm->quit()); + while ((_activeCollResId == 0) && !_vm->_inter->_terminate && !_vm->shouldQuit()); if ((_activeCollResId & 0xFFF) == collResId) { collStackPos = 0; @@ -1465,7 +1465,7 @@ int16 Game_v2::inputArea(int16 xPos, int16 yPos, int16 width, int16 height, key = checkCollisions(handleMouse, -300, collResId, collIndex); if ((key != 0) || (*collResId != 0) || - _vm->_inter->_terminate || _vm->quit()) + _vm->_inter->_terminate || _vm->shouldQuit()) break; if (*pTotTime > 0) { @@ -1479,7 +1479,7 @@ int16 Game_v2::inputArea(int16 xPos, int16 yPos, int16 width, int16 height, } if ((key == 0) || (*collResId != 0) || - _vm->_inter->_terminate || _vm->quit()) + _vm->_inter->_terminate || _vm->shouldQuit()) return 0; switch (key) { diff --git a/engines/gob/inter.cpp b/engines/gob/inter.cpp index 4973bd756d..fef4c8453d 100644 --- a/engines/gob/inter.cpp +++ b/engines/gob/inter.cpp @@ -259,7 +259,7 @@ void Inter::funcBlock(int16 retFlag) { if (executeFuncOpcode(cmd2, cmd, params)) return; - if (_vm->quit()) + if (_vm->shouldQuit()) break; if (_break) { @@ -279,7 +279,7 @@ void Inter::funcBlock(int16 retFlag) { void Inter::callSub(int16 retFlag) { byte block; - while (!_vm->quit() && _vm->_global->_inter_execPtr && + while (!_vm->shouldQuit() && _vm->_global->_inter_execPtr && (_vm->_global->_inter_execPtr != _vm->_game->_totFileData)) { block = *_vm->_global->_inter_execPtr; diff --git a/engines/gob/inter_bargon.cpp b/engines/gob/inter_bargon.cpp index d23841efd6..0ee7dfaf24 100644 --- a/engines/gob/inter_bargon.cpp +++ b/engines/gob/inter_bargon.cpp @@ -750,7 +750,7 @@ void Inter_Bargon::oBargon_intro2(OpGobParams ¶ms) { for (i = 320; i >= 0; i--) { _vm->_util->setScrollOffset(i, 0); if ((_vm->_game->checkKeys(&mouseX, &mouseY, &buttons, 0) == 0x11B) || - _vm->quit()) { + _vm->shouldQuit()) { _vm->_palAnim->fade(0, -2, 0); _vm->_video->clearSurf(_vm->_draw->_frontSurface); memset((char *) _vm->_draw->_vgaPalette, 0, 768); @@ -760,7 +760,7 @@ void Inter_Bargon::oBargon_intro2(OpGobParams ¶ms) { break; } } - if (!_vm->quit()) + if (!_vm->shouldQuit()) _vm->_util->setScrollOffset(0, 0); surface = 0; if (VAR(57) == ((uint32) -1)) @@ -799,7 +799,7 @@ void Inter_Bargon::oBargon_intro3(OpGobParams ¶ms) { _vm->_util->longDelay(_vm->_util->getRandom(200)); } if ((_vm->_game->checkKeys(&mouseX, &mouseY, &buttons, 0) == 0x11B) || - _vm->quit()) { + _vm->shouldQuit()) { _vm->_sound->blasterStop(10); _vm->_palAnim->fade(0, -2, 0); _vm->_video->clearSurf(_vm->_draw->_frontSurface); diff --git a/engines/gob/inter_v1.cpp b/engines/gob/inter_v1.cpp index 1e01cd9048..0355091c77 100644 --- a/engines/gob/inter_v1.cpp +++ b/engines/gob/inter_v1.cpp @@ -1234,7 +1234,7 @@ bool Inter_v1::o1_repeatUntil(OpFuncParams ¶ms) { funcBlock(1); _vm->_global->_inter_execPtr = blockPtr + size + 1; flag = evalBoolResult(); - } while (!flag && !_break && !_terminate && !_vm->quit()); + } while (!flag && !_break && !_terminate && !_vm->shouldQuit()); _nestLevel[0]--; @@ -1269,7 +1269,7 @@ bool Inter_v1::o1_whileDo(OpFuncParams ¶ms) { } else _vm->_global->_inter_execPtr += size; - if (_break || _terminate || _vm->quit()) { + if (_break || _terminate || _vm->shouldQuit()) { _vm->_global->_inter_execPtr = blockPtr; _vm->_global->_inter_execPtr += size; break; diff --git a/engines/gob/inter_v2.cpp b/engines/gob/inter_v2.cpp index b245001653..3f1ffba7c1 100644 --- a/engines/gob/inter_v2.cpp +++ b/engines/gob/inter_v2.cpp @@ -1490,7 +1490,7 @@ void Inter_v2::o2_scroll() { curX = startX; curY = startY; - while (!_vm->quit() && ((curX != endX) || (curY != endY))) { + while (!_vm->shouldQuit() && ((curX != endX) || (curY != endY))) { curX = stepX > 0 ? MIN(curX + stepX, (int) endX) : MAX(curX + stepX, (int) endX); curY = stepY > 0 ? MIN(curY + stepY, (int) endY) : diff --git a/engines/gob/mult.cpp b/engines/gob/mult.cpp index a502e92188..11ef43280f 100644 --- a/engines/gob/mult.cpp +++ b/engines/gob/mult.cpp @@ -209,7 +209,7 @@ void Mult::playMult(int16 startFrame, int16 endFrame, char checkEscape, _frame++; _vm->_util->waitEndFrame(); - } while (!stop && !stopNoClear && !_vm->quit()); + } while (!stop && !stopNoClear && !_vm->shouldQuit()); if (!stopNoClear) { if (_animDataAllocated) { diff --git a/engines/gob/palanim.cpp b/engines/gob/palanim.cpp index 4f2e921dcb..564f7a1a9a 100644 --- a/engines/gob/palanim.cpp +++ b/engines/gob/palanim.cpp @@ -132,7 +132,7 @@ void PalAnim::fade(Video::PalDesc *palDesc, int16 fadeV, int16 allColors) { bool stop; int16 i; - if (_vm->quit()) + if (_vm->shouldQuit()) return; _fadeValue = (fadeV < 0) ? -fadeV : 2; diff --git a/engines/gob/sound/sound.cpp b/engines/gob/sound/sound.cpp index 7b93003791..78ef69c912 100644 --- a/engines/gob/sound/sound.cpp +++ b/engines/gob/sound/sound.cpp @@ -369,7 +369,7 @@ void Sound::blasterWaitEndPlay(bool interruptible, bool stopComp) { if (stopComp) _blaster->endComposition(); - while (_blaster->isPlaying() && !_vm->quit()) { + while (_blaster->isPlaying() && !_vm->shouldQuit()) { if (interruptible && (_vm->_util->checkKey() == 0x11B)) { WRITE_VAR(57, (uint32) -1); return; diff --git a/engines/gob/util.cpp b/engines/gob/util.cpp index fcf19f03dd..c3c874b2fb 100644 --- a/engines/gob/util.cpp +++ b/engines/gob/util.cpp @@ -71,7 +71,7 @@ void Util::longDelay(uint16 msecs) { _vm->_video->waitRetrace(); processInput(); delay(15); - } while (!_vm->quit() && + } while (!_vm->shouldQuit() && ((g_system->getMillis() * _vm->_global->_speedFactor) < time)); } diff --git a/engines/gob/video.cpp b/engines/gob/video.cpp index 453613d1ae..30994cf4a7 100644 --- a/engines/gob/video.cpp +++ b/engines/gob/video.cpp @@ -171,7 +171,7 @@ void Video::clearScreen() { void Video::setSize(bool defaultTo1XScaler) { _vm->_system->beginGFXTransaction(); _vm->_system->initSize(_vm->_width, _vm->_height); - _vm->initCommonGFX(defaultTo1XScaler); + initCommonGFX(defaultTo1XScaler); _vm->_system->endGFXTransaction(); } diff --git a/engines/gob/videoplayer.cpp b/engines/gob/videoplayer.cpp index daf7bdd801..e36dc19596 100644 --- a/engines/gob/videoplayer.cpp +++ b/engines/gob/videoplayer.cpp @@ -569,7 +569,7 @@ bool VideoPlayer::doPlay(int16 frame, int16 breakKey, _vm->_util->processInput(); - if (_vm->quit()) { + if (_vm->shouldQuit()) { _primaryVideo->getVideo()->disableSound(); return true; } diff --git a/engines/kyra/gui.cpp b/engines/kyra/gui.cpp index 6864bd9c4d..06d7f1783a 100644 --- a/engines/kyra/gui.cpp +++ b/engines/kyra/gui.cpp @@ -427,7 +427,7 @@ int MainMenu::handle(int dim) { Common::Rect menuRect(x + 16, y + 4, x + width - 16, y + 4 + fh * 4); - while (!_vm->quit()) { + while (!_vm->shouldQuit()) { updateAnimation(); bool mousePressed = getInput(); @@ -458,7 +458,7 @@ int MainMenu::handle(int dim) { _system->delayMillis(10); } - if (_vm->quit()) + if (_vm->shouldQuit()) command = -1; _screen->copyRegion(backUpX, backUpY, backUpX, backUpY, backUpWidth, backUpHeight, 3, 0); diff --git a/engines/kyra/gui_hof.cpp b/engines/kyra/gui_hof.cpp index a1391320f4..79db2b8b80 100644 --- a/engines/kyra/gui_hof.cpp +++ b/engines/kyra/gui_hof.cpp @@ -514,7 +514,7 @@ void KyraEngine_HoF::bookLoop() { showBookPage(); _bookShown = true; - while (_bookShown && !quit()) { + while (_bookShown && !shouldQuit()) { checkInput(buttonList); removeInputTop(); diff --git a/engines/kyra/gui_lok.cpp b/engines/kyra/gui_lok.cpp index 4efffb0eda..e097a422f2 100644 --- a/engines/kyra/gui_lok.cpp +++ b/engines/kyra/gui_lok.cpp @@ -473,7 +473,7 @@ int GUI_LoK::buttonMenuCallback(Button *caller) { updateAllMenuButtons(); } - while (_displayMenu && !_vm->quit()) { + while (_displayMenu && !_vm->shouldQuit()) { Common::Point mouse = _vm->getMousePos(); processHighlights(_menu[_toplevelMenu], mouse.x, mouse.y); processButtonList(_menuButtonList, 0, 0); @@ -593,7 +593,7 @@ int GUI_LoK::saveGameMenu(Button *button) { _displaySubMenu = true; _cancelSubMenu = false; - while (_displaySubMenu && !_vm->quit()) { + while (_displaySubMenu && !_vm->shouldQuit()) { getInput(); Common::Point mouse = _vm->getMousePos(); processHighlights(_menu[2], mouse.x, mouse.y); @@ -642,7 +642,7 @@ int GUI_LoK::loadGameMenu(Button *button) { _vm->_gameToLoad = -1; - while (_displaySubMenu && !_vm->quit()) { + while (_displaySubMenu && !_vm->shouldQuit()) { getInput(); Common::Point mouse = _vm->getMousePos(); processHighlights(_menu[2], mouse.x, mouse.y); @@ -730,7 +730,7 @@ int GUI_LoK::saveGame(Button *button) { } redrawTextfield(); - while (_displaySubMenu && !_vm->quit()) { + while (_displaySubMenu && !_vm->shouldQuit()) { getInput(); updateSavegameString(); Common::Point mouse = _vm->getMousePos(); @@ -810,7 +810,7 @@ bool GUI_LoK::quitConfirm(const char *str) { _displaySubMenu = true; _cancelSubMenu = true; - while (_displaySubMenu && !_vm->quit()) { + while (_displaySubMenu && !_vm->shouldQuit()) { getInput(); Common::Point mouse = _vm->getMousePos(); processHighlights(_menu[1], mouse.x, mouse.y); @@ -876,7 +876,7 @@ int GUI_LoK::gameControlsMenu(Button *button) { _displaySubMenu = true; _cancelSubMenu = false; - while (_displaySubMenu && !_vm->quit()) { + while (_displaySubMenu && !_vm->shouldQuit()) { getInput(); Common::Point mouse = _vm->getMousePos(); processHighlights(_menu[5], mouse.x, mouse.y); diff --git a/engines/kyra/gui_mr.cpp b/engines/kyra/gui_mr.cpp index 72f214f001..9f6748cd9b 100644 --- a/engines/kyra/gui_mr.cpp +++ b/engines/kyra/gui_mr.cpp @@ -870,7 +870,7 @@ void KyraEngine_MR::processAlbum() { albumNewPage(); _album.running = true; - while (_album.running && !quit()) { + while (_album.running && !shouldQuit()) { updateInput(); checkInput(buttonList); removeInputTop(); diff --git a/engines/kyra/gui_v2.cpp b/engines/kyra/gui_v2.cpp index 077e49ebcf..9c5e86ad98 100644 --- a/engines/kyra/gui_v2.cpp +++ b/engines/kyra/gui_v2.cpp @@ -409,7 +409,7 @@ void GUI_v2::getInput() { _vm->checkInput(_menuButtonList); _vm->removeInputTop(); - if (_vm->quit()) { + if (_vm->shouldQuit()) { _displayMenu = false; _isLoadMenu = false; _isSaveMenu = false; @@ -749,7 +749,7 @@ const char *GUI_v2::nameInputProcess(char *buffer, int x, int y, uint8 c1, uint8 _keyPressed.reset(); _cancelNameInput = _finishNameInput = false; - while (running && !_vm->quit()) { + while (running && !_vm->shouldQuit()) { processHighlights(_savenameMenu, _vm->_mouseX, _vm->_mouseY); checkTextfieldInput(); if (_keyPressed.keycode == Common::KEYCODE_RETURN || _keyPressed.keycode == Common::KEYCODE_KP_ENTER || _finishNameInput) { diff --git a/engines/kyra/kyra_hof.cpp b/engines/kyra/kyra_hof.cpp index 76d6f6ea05..e5043f0c4e 100644 --- a/engines/kyra/kyra_hof.cpp +++ b/engines/kyra/kyra_hof.cpp @@ -317,7 +317,7 @@ int KyraEngine_HoF::go() { if (_menuChoice & 1) { startup(); - if (!quit()) + if (!shouldQuit()) runLoop(); cleanup(); @@ -455,7 +455,7 @@ void KyraEngine_HoF::runLoop() { _screen->updateScreen(); _runFlag = true; - while (!quit() && _runFlag) { + while (!shouldQuit() && _runFlag) { if (_deathHandler >= 0) { removeHandItem(); delay(5); @@ -463,7 +463,7 @@ void KyraEngine_HoF::runLoop() { _gui->optionsButton(0); _deathHandler = -1; - if (!_runFlag || !quit()) + if (!_runFlag || !shouldQuit()) break; } @@ -1630,7 +1630,7 @@ void KyraEngine_HoF::loadInvWsa(const char *filename, int run, int delayTime, in _invWsa.timer = _system->getMillis(); if (run) { - while (_invWsa.running && !skipFlag() && !quit()) { + while (_invWsa.running && !skipFlag() && !shouldQuit()) { update(); _system->delayMillis(10); } @@ -2004,7 +2004,7 @@ void KyraEngine_HoF::playTim(const char *filename) { return; _tim->resetFinishedFlag(); - while (!quit() && !_tim->finished()) { + while (!shouldQuit() && !_tim->finished()) { _tim->exec(tim, 0); if (_chatText) updateWithText(); diff --git a/engines/kyra/kyra_lok.cpp b/engines/kyra/kyra_lok.cpp index f71cc8f409..5a3376a3e6 100644 --- a/engines/kyra/kyra_lok.cpp +++ b/engines/kyra/kyra_lok.cpp @@ -303,7 +303,7 @@ int KyraEngine_LoK::go() { if (_gameToLoad == -1) { setGameFlag(0xEF); seq_intro(); - if (quit()) + if (shouldQuit()) return 0; if (_skipIntroFlag && _abortIntroFlag) resetGameFlag(0xEF); @@ -402,7 +402,7 @@ void KyraEngine_LoK::startup() { void KyraEngine_LoK::mainLoop() { debugC(9, kDebugLevelMain, "KyraEngine_LoK::mainLoop()"); - while (!quit()) { + while (!shouldQuit()) { int32 frameTime = (int32)_system->getMillis(); _skipFlag = false; @@ -449,7 +449,7 @@ void KyraEngine_LoK::mainLoop() { } void KyraEngine_LoK::delayUntil(uint32 timestamp, bool updateTimers, bool update, bool isMainLoop) { - while (_system->getMillis() < timestamp && !quit()) { + while (_system->getMillis() < timestamp && !shouldQuit()) { if (updateTimers) _timer->update(); @@ -531,19 +531,19 @@ void KyraEngine_LoK::delay(uint32 amount, bool update, bool isMainLoop) { if (_skipFlag && !_abortIntroFlag && !queryGameFlag(0xFE)) _skipFlag = false; - if (amount > 0 && !_skipFlag && !quit()) + if (amount > 0 && !_skipFlag && !shouldQuit()) _system->delayMillis(10); if (_skipFlag) _sound->voiceStop(); - } while (!_skipFlag && _system->getMillis() < start + amount && !quit()); + } while (!_skipFlag && _system->getMillis() < start + amount && !shouldQuit()); } void KyraEngine_LoK::waitForEvent() { bool finished = false; Common::Event event; - while (!finished && !quit()) { + while (!finished && !shouldQuit()) { while (_eventMan->pollEvent(event)) { switch (event.type) { case Common::EVENT_KEYDOWN: diff --git a/engines/kyra/kyra_mr.cpp b/engines/kyra/kyra_mr.cpp index 9d3171e723..7dea56a5fa 100644 --- a/engines/kyra/kyra_mr.cpp +++ b/engines/kyra/kyra_mr.cpp @@ -263,7 +263,7 @@ int KyraEngine_MR::go() { running = false; } - while (running && !quit()) { + while (running && !shouldQuit()) { _screen->_curPage = 0; _screen->clearPage(0); @@ -272,14 +272,14 @@ int KyraEngine_MR::go() { // XXX playMenuAudioFile(); - for (int i = 0; i < 64 && !quit(); ++i) { + for (int i = 0; i < 64 && !shouldQuit(); ++i) { uint32 nextRun = _system->getMillis() + 3 * _tickLength; _menuAnim->displayFrame(i, 0); _screen->updateScreen(); delayUntil(nextRun); } - for (int i = 64; i > 29 && !quit(); --i) { + for (int i = 64; i > 29 && !shouldQuit(); --i) { uint32 nextRun = _system->getMillis() + 3 * _tickLength; _menuAnim->displayFrame(i, 0); _screen->updateScreen(); @@ -1001,7 +1001,7 @@ void KyraEngine_MR::runLoop() { _eventList.clear(); _runFlag = true; - while (_runFlag && !quit()) { + while (_runFlag && !shouldQuit()) { if (_deathHandler >= 0) { removeHandItem(); delay(5); @@ -1009,7 +1009,7 @@ void KyraEngine_MR::runLoop() { _gui->optionsButton(0); _deathHandler = -1; - if (quit()) + if (shouldQuit()) break; } diff --git a/engines/kyra/kyra_v1.cpp b/engines/kyra/kyra_v1.cpp index 8162232935..2a6cfb6f06 100644 --- a/engines/kyra/kyra_v1.cpp +++ b/engines/kyra/kyra_v1.cpp @@ -235,7 +235,7 @@ int KyraEngine_v1::resetGameFlag(int flag) { } void KyraEngine_v1::delayUntil(uint32 timestamp, bool updateTimers, bool update, bool isMainLoop) { - while (_system->getMillis() < timestamp && !quit()) { + while (_system->getMillis() < timestamp && !shouldQuit()) { if (timestamp - _system->getMillis() >= 10) delay(10, update, isMainLoop); } diff --git a/engines/kyra/kyra_v2.cpp b/engines/kyra/kyra_v2.cpp index e9ed91b539..a1124bf98d 100644 --- a/engines/kyra/kyra_v2.cpp +++ b/engines/kyra/kyra_v2.cpp @@ -159,7 +159,7 @@ void KyraEngine_v2::delay(uint32 amount, bool updateGame, bool isMainLoop) { if (amount > 0) _system->delayMillis(amount > 10 ? 10 : amount); - } while (!skipFlag() && _system->getMillis() < start + amount && !quit()); + } while (!skipFlag() && _system->getMillis() < start + amount && !shouldQuit()); } int KyraEngine_v2::checkInput(Button *buttonList, bool mainLoop) { diff --git a/engines/kyra/lol.cpp b/engines/kyra/lol.cpp index 053d8a4de9..91c9b65d1e 100644 --- a/engines/kyra/lol.cpp +++ b/engines/kyra/lol.cpp @@ -297,7 +297,7 @@ void LoLEngine::showIntro() { _screen->hideMouse(); uint32 palNextFadeStep = 0; - while (!_tim->finished() && !quit() && !skipFlag()) { + while (!_tim->finished() && !shouldQuit() && !skipFlag()) { updateInput(); _tim->exec(intro, false); _screen->checkedPageUpdate(8, 4); @@ -375,14 +375,14 @@ int LoLEngine::chooseCharacter() { _screen->fadePalette(_screen->getPalette(0), 30, 0); bool kingIntro = true; - while (!quit()) { + while (!shouldQuit()) { if (kingIntro) kingSelectionIntro(); if (_charSelection < 0) processCharacterSelection(); - if (quit()) + if (shouldQuit()) break; if (_charSelection == 100) { @@ -403,11 +403,11 @@ int LoLEngine::chooseCharacter() { } } - if (quit()) + if (shouldQuit()) return -1; uint32 waitTime = _system->getMillis() + 420 * _tickLength; - while (waitTime > _system->getMillis() && !skipFlag() && !quit()) { + while (waitTime > _system->getMillis() && !skipFlag() && !shouldQuit()) { updateInput(); _system->delayMillis(10); } @@ -439,7 +439,7 @@ void LoLEngine::kingSelectionIntro() { _chargenWSA->setDrawPage(0); int index = 4; - while (_sound->voiceIsPlaying("KING01") && _charSelection == -1 && !quit() && !skipFlag()) { + while (_sound->voiceIsPlaying("KING01") && _charSelection == -1 && !shouldQuit() && !skipFlag()) { index = MAX(index, 4); _chargenWSA->displayFrame(_chargenFrameTable[index], 0, 0, 0); @@ -450,7 +450,7 @@ void LoLEngine::kingSelectionIntro() { _screen->updateScreen(); uint32 waitEnd = _system->getMillis() + 7 * _tickLength; - while (waitEnd > _system->getMillis() && _charSelection == -1 && !quit() && !skipFlag()) { + while (waitEnd > _system->getMillis() && _charSelection == -1 && !shouldQuit() && !skipFlag()) { _charSelection = getCharSelection(); _system->delayMillis(10); } @@ -481,7 +481,7 @@ void LoLEngine::kingSelectionReminder() { _chargenWSA->setDrawPage(0); int index = 0; - while (_sound->voiceIsPlaying("KING02") && _charSelection == -1 && !quit() && index < 15) { + while (_sound->voiceIsPlaying("KING02") && _charSelection == -1 && !shouldQuit() && index < 15) { _chargenWSA->displayFrame(_chargenFrameTable[index+9], 0, 0, 0); _screen->copyRegion(_selectionPosTable[_reminderChar1IdxTable[index]*2+0], _selectionPosTable[_reminderChar1IdxTable[index]*2+1], _charPreviews[0].x, _charPreviews[0].y, 32, 32, 4, 0); _screen->copyRegion(_selectionPosTable[_reminderChar2IdxTable[index]*2+0], _selectionPosTable[_reminderChar2IdxTable[index]*2+1], _charPreviews[1].x, _charPreviews[1].y, 32, 32, 4, 0); @@ -490,7 +490,7 @@ void LoLEngine::kingSelectionReminder() { _screen->updateScreen(); uint32 waitEnd = _system->getMillis() + 8 * _tickLength; - while (waitEnd > _system->getMillis() && !quit()) { + while (waitEnd > _system->getMillis() && !shouldQuit()) { _charSelection = getCharSelection(); _system->delayMillis(10); } @@ -511,14 +511,14 @@ void LoLEngine::kingSelectionOutro() { _chargenWSA->setDrawPage(0); int index = 0; - while (_sound->voiceIsPlaying("KING03") && !quit() && !skipFlag()) { + while (_sound->voiceIsPlaying("KING03") && !shouldQuit() && !skipFlag()) { index = MAX(index, 4); _chargenWSA->displayFrame(_chargenFrameTable[index], 0, 0, 0); _screen->updateScreen(); uint32 waitEnd = _system->getMillis() + 8 * _tickLength; - while (waitEnd > _system->getMillis() && !quit() && !skipFlag()) { + while (waitEnd > _system->getMillis() && !shouldQuit() && !skipFlag()) { updateInput(); _system->delayMillis(10); } @@ -537,10 +537,10 @@ void LoLEngine::processCharacterSelection() { debugC(9, kDebugLevelMain, "LoLEngine::processCharacterSelection()"); _charSelection = -1; - while (!quit() && _charSelection == -1) { + while (!shouldQuit() && _charSelection == -1) { uint32 nextKingMessage = _system->getMillis() + 900 * _tickLength; - while (nextKingMessage > _system->getMillis() && _charSelection == -1 && !quit()) { + while (nextKingMessage > _system->getMillis() && _charSelection == -1 && !shouldQuit()) { updateSelectionAnims(); _charSelection = getCharSelection(); _system->delayMillis(10); @@ -659,12 +659,12 @@ void LoLEngine::selectionCharInfoIntro(char *file) { int index = 0; file[4] = '0'; - while (_charSelectionInfoResult == -1 && !quit()) { + while (_charSelectionInfoResult == -1 && !shouldQuit()) { if (!_sound->voicePlay(file)) break; int i = 0; - while (_sound->voiceIsPlaying(file) && _charSelectionInfoResult == -1 && !quit()) { + while (_sound->voiceIsPlaying(file) && _charSelectionInfoResult == -1 && !shouldQuit()) { _screen->drawShape(0, _screen->getPtrToShape(_screen->getCPagePtr(9), _charInfoFrameTable[i]), 11, 130, 0, 0); _screen->updateScreen(); diff --git a/engines/kyra/resource.cpp b/engines/kyra/resource.cpp index 0f0a643017..798290b16c 100644 --- a/engines/kyra/resource.cpp +++ b/engines/kyra/resource.cpp @@ -57,14 +57,14 @@ Resource::~Resource() { bool Resource::reset() { unloadAllPakFiles(); - Common::FilesystemNode dir(ConfMan.get("path")); + Common::FSNode dir(ConfMan.get("path")); if (!dir.exists() || !dir.isDirectory()) error("invalid game path '%s'", dir.getPath().c_str()); if (!loadPakFile(StaticResource::staticDataFilename()) || !StaticResource::checkKyraDat(this)) { Common::String errorMessage = "You're missing the '" + StaticResource::staticDataFilename() + "' file or it got corrupted, (re)get it from the ScummVM website"; - _vm->GUIErrorMessage(errorMessage); + GUIErrorMessage(errorMessage); error(errorMessage.c_str()); } @@ -103,7 +103,7 @@ bool Resource::reset() { } Common::FSList fslist; - if (!dir.getChildren(fslist, Common::FilesystemNode::kListFilesOnly)) + if (!dir.getChildren(fslist, Common::FSNode::kListFilesOnly)) error("can't list files inside game path '%s'", dir.getPath().c_str()); if (_vm->game() == GI_KYRA1 && _vm->gameFlags().isTalkie) { diff --git a/engines/kyra/saveload.cpp b/engines/kyra/saveload.cpp index 76089fdb2c..d094dd1ccb 100644 --- a/engines/kyra/saveload.cpp +++ b/engines/kyra/saveload.cpp @@ -179,7 +179,7 @@ Common::SeekableReadStream *KyraEngine_v1::openSaveForReading(const char *filena Common::WriteStream *KyraEngine_v1::openSaveForWriting(const char *filename, const char *saveName, const Graphics::Surface *thumbnail) const { debugC(9, kDebugLevelMain, "KyraEngine_v1::openSaveForWriting('%s', '%s', %p)", filename, saveName, (const void *)thumbnail); - if (quit()) + if (shouldQuit()) return 0; Common::WriteStream *out = 0; diff --git a/engines/kyra/saveload_lok.cpp b/engines/kyra/saveload_lok.cpp index f0d9f1ba82..051b844703 100644 --- a/engines/kyra/saveload_lok.cpp +++ b/engines/kyra/saveload_lok.cpp @@ -221,7 +221,7 @@ void KyraEngine_LoK::loadGame(const char *fileName) { void KyraEngine_LoK::saveGame(const char *fileName, const char *saveName, const Graphics::Surface *thumb) { debugC(9, kDebugLevelMain, "KyraEngine_LoK::saveGame('%s', '%s', %p)", fileName, saveName, (const void *)thumb); - if (quit()) + if (shouldQuit()) return; Common::OutSaveFile *out = openSaveForWriting(fileName, saveName, thumb); diff --git a/engines/kyra/scene_hof.cpp b/engines/kyra/scene_hof.cpp index df9fccaab9..4785b039d7 100644 --- a/engines/kyra/scene_hof.cpp +++ b/engines/kyra/scene_hof.cpp @@ -277,7 +277,7 @@ int KyraEngine_HoF::trySceneChange(int *moveTable, int unk1, int updateChar) { int changedScene = 0; const int *moveTableStart = moveTable; _unk4 = 0; - while (running && !quit()) { + while (running && !shouldQuit()) { if (*moveTable >= 0 && *moveTable <= 7) { _mainCharacter.facing = getOppositeFacingDirection(*moveTable); unkFlag = true; diff --git a/engines/kyra/scene_mr.cpp b/engines/kyra/scene_mr.cpp index ad4ce63b6c..1ceb47155d 100644 --- a/engines/kyra/scene_mr.cpp +++ b/engines/kyra/scene_mr.cpp @@ -654,7 +654,7 @@ int KyraEngine_MR::trySceneChange(int *moveTable, int unk1, int updateChar) { const int *moveTableStart = moveTable; _unk4 = 0; - while (running && !quit()) { + while (running && !shouldQuit()) { if (*moveTable >= 0 && *moveTable <= 7) { _mainCharacter.facing = getOppositeFacingDirection(*moveTable); unkFlag = true; diff --git a/engines/kyra/screen.cpp b/engines/kyra/screen.cpp index 4bcde9a679..0b859f5032 100644 --- a/engines/kyra/screen.cpp +++ b/engines/kyra/screen.cpp @@ -192,7 +192,7 @@ void Screen::setResolution() { _system->initSize(960, 400); else _system->initSize(640, 400); - _vm->initCommonGFX(true); + initCommonGFX(true); _system->endGFXTransaction(); } else { _system->beginGFXTransaction(); @@ -200,7 +200,7 @@ void Screen::setResolution() { _system->initSize(640, 200); else _system->initSize(320, 200); - _vm->initCommonGFX(false); + initCommonGFX(false); _system->endGFXTransaction(); } @@ -384,7 +384,7 @@ void Screen::fadePalette(const uint8 *palData, int delay, const UpdateFunctor *u getFadeParams(palData, delay, delayInc, diff); int delayAcc = 0; - while (!_vm->quit()) { + while (!_vm->shouldQuit()) { delayAcc += delayInc; int refreshed = fadePalStep(palData, diff); @@ -401,7 +401,7 @@ void Screen::fadePalette(const uint8 *palData, int delay, const UpdateFunctor *u delayAcc &= 0xFF; } - if (_vm->quit()) { + if (_vm->shouldQuit()) { setScreenPalette(palData); if (upFunc && upFunc->isValid()) (*upFunc)(); @@ -750,7 +750,7 @@ void Screen::shuffleScreen(int sx, int sy, int w, int h, int srcPage, int dstPag int32 start, now; int wait; - for (y = 0; y < h && !_vm->quit(); ++y) { + for (y = 0; y < h && !_vm->shouldQuit(); ++y) { start = (int32)_system->getMillis(); int y_cur = y; for (x = 0; x < w; ++x) { @@ -775,7 +775,7 @@ void Screen::shuffleScreen(int sx, int sy, int w, int h, int srcPage, int dstPag copyOverlayRegion(sx, sy, sx, sy, w, h, srcPage, dstPage); - if (_vm->quit()) { + if (_vm->shouldQuit()) { copyRegion(sx, sy, sx, sy, w, h, srcPage, dstPage); _system->updateScreen(); } diff --git a/engines/kyra/script.cpp b/engines/kyra/script.cpp index dba09f08ef..9635b0b29a 100644 --- a/engines/kyra/script.cpp +++ b/engines/kyra/script.cpp @@ -178,7 +178,7 @@ bool EMCInterpreter::start(EMCState *script, int function) { } bool EMCInterpreter::isValid(EMCState *script) { - if (!script->ip || !script->dataPtr || _vm->quit()) + if (!script->ip || !script->dataPtr || _vm->shouldQuit()) return false; return true; } diff --git a/engines/kyra/script_lok.cpp b/engines/kyra/script_lok.cpp index e965a075bd..b0fc4b860c 100644 --- a/engines/kyra/script_lok.cpp +++ b/engines/kyra/script_lok.cpp @@ -23,7 +23,6 @@ * */ - #include "common/endian.h" #include "common/system.h" diff --git a/engines/kyra/script_mr.cpp b/engines/kyra/script_mr.cpp index bc71e72ce4..3e709d45e5 100644 --- a/engines/kyra/script_mr.cpp +++ b/engines/kyra/script_mr.cpp @@ -786,7 +786,7 @@ int KyraEngine_MR::o3_daggerWarning(EMCState *script) { _screen->_curPage = curPageBackUp; _screen->showMouse(); - while (!quit()) { + while (!shouldQuit()) { int keys = checkInput(0); removeInputTop(); diff --git a/engines/kyra/seqplayer.cpp b/engines/kyra/seqplayer.cpp index dfda5bf859..3391c51ab7 100644 --- a/engines/kyra/seqplayer.cpp +++ b/engines/kyra/seqplayer.cpp @@ -625,7 +625,7 @@ bool SeqPlayer::playSequence(const uint8 *seqData, bool skipSeq) { memset(_seqMovies, 0, sizeof(_seqMovies)); _screen->_curPage = 0; - while (!_seqQuitFlag && !_vm->quit()) { + while (!_seqQuitFlag && !_vm->shouldQuit()) { if (skipSeq && _vm->seq_skipSequence()) { while (1) { uint8 code = *_seqData; diff --git a/engines/kyra/sequences_hof.cpp b/engines/kyra/sequences_hof.cpp index 7915a33996..718c8dadfa 100644 --- a/engines/kyra/sequences_hof.cpp +++ b/engines/kyra/sequences_hof.cpp @@ -75,7 +75,7 @@ void KyraEngine_HoF::seq_playSequences(int startSeq, int endSeq) { _seqEndTime = 0; _menuChoice = 0; - for (int seqNum = startSeq; seqNum <= endSeq && !((skipFlag() && allowSkip) || quit() || (_abortIntroFlag && allowSkip) || _menuChoice); seqNum++) { + for (int seqNum = startSeq; seqNum <= endSeq && !((skipFlag() && allowSkip) || shouldQuit() || (_abortIntroFlag && allowSkip) || _menuChoice); seqNum++) { _screen->clearPage(0); _screen->clearPage(8); memcpy(_screen->getPalette(1), _screen->getPalette(0), 0x300); @@ -131,7 +131,7 @@ void KyraEngine_HoF::seq_playSequences(int startSeq, int endSeq) { seq_sequenceCommand(cseq.startupCommand); - if (!((skipFlag() && allowSkip) || quit() || (_abortIntroFlag && allowSkip) || _menuChoice)) { + if (!((skipFlag() && allowSkip) || shouldQuit() || (_abortIntroFlag && allowSkip) || _menuChoice)) { _screen->copyPage(2, 0); _screen->updateScreen(); } @@ -165,7 +165,7 @@ void KyraEngine_HoF::seq_playSequences(int startSeq, int endSeq) { _seqWsaCurrentFrame = cseq.startFrame; bool loop = true; - while (loop && !((skipFlag() && allowSkip) || quit() || (_abortIntroFlag && allowSkip) || _menuChoice)) { + while (loop && !((skipFlag() && allowSkip) || shouldQuit() || (_abortIntroFlag && allowSkip) || _menuChoice)) { _seqEndTime = _system->getMillis() + _seqFrameDelay * _tickLength; if (_seqWsa || !cb) @@ -189,16 +189,16 @@ void KyraEngine_HoF::seq_playSequences(int startSeq, int endSeq) { seq_processWSAs(); seq_processText(); - if ((_seqWsa || !cb) && !((skipFlag() && allowSkip) || quit() || (_abortIntroFlag && allowSkip) || _menuChoice)) { + if ((_seqWsa || !cb) && !((skipFlag() && allowSkip) || shouldQuit() || (_abortIntroFlag && allowSkip) || _menuChoice)) { _screen->copyPage(2, 0); _screen->updateScreen(); } bool loop2 = true; - while (loop2 && !((skipFlag() && allowSkip) || quit() || (_abortIntroFlag && allowSkip) || _menuChoice)) { + while (loop2 && !((skipFlag() && allowSkip) || shouldQuit() || (_abortIntroFlag && allowSkip) || _menuChoice)) { if (_seqWsa) { seq_processText(); - if (!((skipFlag() && allowSkip) || quit() || (_abortIntroFlag && allowSkip) || _menuChoice)) { + if (!((skipFlag() && allowSkip) || shouldQuit() || (_abortIntroFlag && allowSkip) || _menuChoice)) { _screen->copyPage(2, 0); _screen->updateScreen(); } @@ -230,7 +230,7 @@ void KyraEngine_HoF::seq_playSequences(int startSeq, int endSeq) { } else { _seqFrameDelay = cseq.frameDelay; _seqEndTime = _system->getMillis() + _seqFrameDelay * _tickLength; - while (!((skipFlag() && allowSkip) || quit() || (_abortIntroFlag && allowSkip) || _menuChoice)) { + while (!((skipFlag() && allowSkip) || shouldQuit() || (_abortIntroFlag && allowSkip) || _menuChoice)) { _seqSubFrameStartTime = _system->getMillis(); seq_processWSAs(); if (cb) @@ -262,7 +262,7 @@ void KyraEngine_HoF::seq_playSequences(int startSeq, int endSeq) { dl = ct; _seqEndTime = _system->getMillis() + dl; - while (!((skipFlag() && allowSkip) || quit() || (_abortIntroFlag && allowSkip) || _menuChoice)) { + while (!((skipFlag() && allowSkip) || shouldQuit() || (_abortIntroFlag && allowSkip) || _menuChoice)) { _seqSubFrameStartTime = _system->getMillis(); seq_processWSAs(); @@ -2267,7 +2267,7 @@ void KyraEngine_HoF::seq_loadNestedSequence(int wsaNum, int seqNum) { void KyraEngine_HoF::seq_nestedSequenceFrame(int command, int wsaNum) { int xa = 0, ya = 0; command--; - if (!_activeWSA[wsaNum].movie || skipFlag() || quit() || _abortIntroFlag) + if (!_activeWSA[wsaNum].movie || skipFlag() || shouldQuit() || _abortIntroFlag) return; switch (command) { @@ -2467,7 +2467,7 @@ bool KyraEngine_HoF::seq_processNextSubFrame(int wsaNum) { void KyraEngine_HoF::seq_printCreditsString(uint16 strIndex, int x, int y, const uint8 *colorMap, uint8 textcolor) { uint8 colormap[16]; - if (skipFlag() || quit() || _abortIntroFlag || _menuChoice) + if (skipFlag() || shouldQuit() || _abortIntroFlag || _menuChoice) return; memset(&_screen->getPalette(0)[0x2fa], 0x3f, 6); @@ -2957,7 +2957,7 @@ void KyraEngine_HoF::seq_makeBookAppear() { ++_invWsa.curFrame; - if (_invWsa.curFrame >= _invWsa.lastFrame && !quit()) + if (_invWsa.curFrame >= _invWsa.lastFrame && !shouldQuit()) break; switch (_invWsa.curFrame) { diff --git a/engines/kyra/sequences_lok.cpp b/engines/kyra/sequences_lok.cpp index 77cfbed2d0..c9c1a05842 100644 --- a/engines/kyra/sequences_lok.cpp +++ b/engines/kyra/sequences_lok.cpp @@ -163,7 +163,7 @@ void KyraEngine_LoK::seq_introLogos() { _screen->updateScreen(); _screen->fadeFromBlack(); - if (_seq->playSequence(_seq_WestwoodLogo, _skipFlag) || quit()) { + if (_seq->playSequence(_seq_WestwoodLogo, _skipFlag) || shouldQuit()) { _screen->fadeToBlack(); _screen->clearPage(0); return; @@ -175,14 +175,14 @@ void KyraEngine_LoK::seq_introLogos() { _screen->setScreenPalette(_screen->_currentPalette); } - if ((_seq->playSequence(_seq_KyrandiaLogo, _skipFlag) && !seq_skipSequence()) || quit()) { + if ((_seq->playSequence(_seq_KyrandiaLogo, _skipFlag) && !seq_skipSequence()) || shouldQuit()) { _screen->fadeToBlack(); _screen->clearPage(0); return; } _screen->fillRect(0, 179, 319, 199, 0); - if (quit()) + if (shouldQuit()) return; if (_flags.platform == Common::kPlatformAmiga) { @@ -222,10 +222,10 @@ void KyraEngine_LoK::seq_introLogos() { oldDistance = distance; delay(10); - } while (!doneFlag && !quit() && !_abortIntroFlag); + } while (!doneFlag && !shouldQuit() && !_abortIntroFlag); } - if (quit()) + if (shouldQuit()) return; _seq->playSequence(_seq_Forest, true); @@ -1029,7 +1029,7 @@ void KyraEngine_LoK::seq_brandonToStone() { void KyraEngine_LoK::seq_playEnding() { debugC(9, kDebugLevelMain, "KyraEngine_LoK::seq_playEnding()"); - if (quit()) + if (shouldQuit()) return; _screen->hideMouse(); _screen->_curPage = 0; @@ -1210,7 +1210,7 @@ void KyraEngine_LoK::seq_playCredits() { bool KyraEngine_LoK::seq_skipSequence() const { debugC(9, kDebugLevelMain, "KyraEngine_LoK::seq_skipSequence()"); - return quit() || _abortIntroFlag; + return shouldQuit() || _abortIntroFlag; } int KyraEngine_LoK::handleMalcolmFlag() { diff --git a/engines/kyra/staticres.cpp b/engines/kyra/staticres.cpp index bfffefb70a..ba8de9c57f 100644 --- a/engines/kyra/staticres.cpp +++ b/engines/kyra/staticres.cpp @@ -361,7 +361,7 @@ void StaticResource::deinit() { void StaticResource::outputError(const Common::String &error) { Common::String errorMessage = "Your '" + StaticResource::staticDataFilename() + "' file " + error + ", reget a correct version from the ScummVM website"; - _vm->GUIErrorMessage(errorMessage); + GUIErrorMessage(errorMessage); ::error(errorMessage.c_str()); } diff --git a/engines/kyra/text.cpp b/engines/kyra/text.cpp index eecb617942..379772365c 100644 --- a/engines/kyra/text.cpp +++ b/engines/kyra/text.cpp @@ -23,8 +23,6 @@ * */ - - #include "kyra/kyra_v1.h" #include "kyra/screen.h" #include "kyra/text.h" diff --git a/engines/kyra/text_hof.cpp b/engines/kyra/text_hof.cpp index b94b8a6258..15681e074c 100644 --- a/engines/kyra/text_hof.cpp +++ b/engines/kyra/text_hof.cpp @@ -335,7 +335,7 @@ void KyraEngine_HoF::objectChatWaitToFinish() { const uint32 endTime = _chatEndTime; resetSkipFlag(); - while (running && !quit()) { + while (running && !shouldQuit()) { if (!_emc->isValid(&_chatScriptState)) _emc->start(&_chatScriptState, 1); @@ -353,7 +353,7 @@ void KyraEngine_HoF::objectChatWaitToFinish() { uint32 nextFrame = _system->getMillis() + delayTime * _tickLength; - while (_system->getMillis() < nextFrame && !quit()) { + while (_system->getMillis() < nextFrame && !shouldQuit()) { updateWithText(); const uint32 curTime = _system->getMillis(); @@ -593,7 +593,7 @@ void KyraEngine_HoF::initTalkObject(int index) { if (_currentTalkSections.STATim) { _tim->resetFinishedFlag(); - while (!quit() && !_tim->finished()) { + while (!shouldQuit() && !_tim->finished()) { _tim->exec(_currentTalkSections.STATim, false); if (_chatText) updateWithText(); @@ -609,7 +609,7 @@ void KyraEngine_HoF::deinitTalkObject(int index) { if (_currentTalkSections.ENDTim) { _tim->resetFinishedFlag(); - while (!quit() && !_tim->finished()) { + while (!shouldQuit() && !_tim->finished()) { _tim->exec(_currentTalkSections.ENDTim, false); if (_chatText) updateWithText(); @@ -647,10 +647,10 @@ void KyraEngine_HoF::npcChatSequence(const char *str, int objectId, int vocHigh, _chatVocHigh = _chatVocLow = -1; } - while (((textEnabled() && _chatEndTime > _system->getMillis()) || (speechEnabled() && snd_voiceIsPlaying())) && !(quit() || skipFlag())) { + while (((textEnabled() && _chatEndTime > _system->getMillis()) || (speechEnabled() && snd_voiceIsPlaying())) && !(shouldQuit() || skipFlag())) { if ((!speechEnabled() && chatAnimEndTime > _system->getMillis()) || (speechEnabled() && snd_voiceIsPlaying())) { _tim->resetFinishedFlag(); - while (!_tim->finished() && !skipFlag() && !quit()) { + while (!_tim->finished() && !skipFlag() && !shouldQuit()) { if (_currentTalkSections.TLKTim) _tim->exec(_currentTalkSections.TLKTim, false); else diff --git a/engines/kyra/text_mr.cpp b/engines/kyra/text_mr.cpp index be306ceec1..41b4c30245 100644 --- a/engines/kyra/text_mr.cpp +++ b/engines/kyra/text_mr.cpp @@ -349,7 +349,7 @@ void KyraEngine_MR::objectChatWaitToFinish() { const uint32 endTime = _chatEndTime; resetSkipFlag(); - while (running && !quit()) { + while (running && !shouldQuit()) { if (!_emc->isValid(&_chatScriptState)) _emc->start(&_chatScriptState, 1); @@ -367,7 +367,7 @@ void KyraEngine_MR::objectChatWaitToFinish() { uint32 nextFrame = _system->getMillis() + delayTime * _tickLength; - while (_system->getMillis() < nextFrame && !quit()) { + while (_system->getMillis() < nextFrame && !shouldQuit()) { updateWithText(); const uint32 curTime = _system->getMillis(); @@ -419,7 +419,7 @@ void KyraEngine_MR::badConscienceChatWaitToFinish() { uint32 nextFrame = _system->getMillis() + _rnd.getRandomNumberRng(4, 8) * _tickLength; int frame = _badConscienceFrameTable[_badConscienceAnim+24]; - while (running && !quit()) { + while (running && !shouldQuit()) { if (nextFrame < _system->getMillis()) { ++frame; if (_badConscienceFrameTable[_badConscienceAnim+32] < frame) @@ -477,7 +477,7 @@ void KyraEngine_MR::goodConscienceChatWaitToFinish() { uint32 nextFrame = _system->getMillis() + _rnd.getRandomNumberRng(3, 6) * _tickLength; int frame = _goodConscienceFrameTable[_goodConscienceAnim+15]; - while (running && !quit()) { + while (running && !shouldQuit()) { if (nextFrame < _system->getMillis()) { ++frame; if (_goodConscienceFrameTable[_goodConscienceAnim+20] < frame) @@ -597,7 +597,7 @@ void KyraEngine_MR::albumChatWaitToFinish() { uint32 nextFrame = 0; int frame = 12; - while (running && !quit()) { + while (running && !shouldQuit()) { if (nextFrame < _system->getMillis()) { ++frame; if (frame > 22) diff --git a/engines/lure/events.cpp b/engines/lure/events.cpp index e244f69097..5ca82a9be4 100644 --- a/engines/lure/events.cpp +++ b/engines/lure/events.cpp @@ -141,9 +141,9 @@ void Mouse::waitForRelease() { LureEngine &engine = LureEngine::getReference(); do { - while (e.pollEvent() && !engine.quit()) ; + while (e.pollEvent() && !engine.shouldQuit()) ; g_system->delayMillis(20); - } while (!engine.quit() && (lButton() || rButton() || mButton())); + } while (!engine.shouldQuit() && (lButton() || rButton() || mButton())); } /*--------------------------------------------------------------------------*/ @@ -211,7 +211,7 @@ bool Events::interruptableDelay(uint32 milliseconds) { uint32 delayCtr = g_system->getMillis() + milliseconds; while (g_system->getMillis() < delayCtr) { - if (engine.quit()) return true; + if (engine.shouldQuit()) return true; if (events.pollEvent()) { if (((events.type() == Common::EVENT_KEYDOWN) && (events.event().kbd.ascii != 0)) || diff --git a/engines/lure/fights.cpp b/engines/lure/fights.cpp index 51fce850e6..6ff7339c02 100644 --- a/engines/lure/fights.cpp +++ b/engines/lure/fights.cpp @@ -117,7 +117,7 @@ void FightsManager::fightLoop() { uint32 timerVal = g_system->getMillis(); // Loop for the duration of the battle - while (!engine.quit() && (playerFight.fwhits != GENERAL_MAGIC_ID)) { + while (!engine.shouldQuit() && (playerFight.fwhits != GENERAL_MAGIC_ID)) { checkEvents(); if (g_system->getMillis() > timerVal + GAME_FRAME_DELAY) { diff --git a/engines/lure/game.cpp b/engines/lure/game.cpp index 479877f229..cf3d4ac125 100644 --- a/engines/lure/game.cpp +++ b/engines/lure/game.cpp @@ -151,7 +151,7 @@ void Game::execute() { bool initialRestart = true; - while (!engine.quit()) { + while (!engine.shouldQuit()) { if ((_state & GS_RESTART) != 0) { res.reset(); @@ -171,7 +171,7 @@ void Game::execute() { mouse.cursorOn(); // Main game loop - while (!engine.quit() && ((_state & GS_RESTART) == 0)) { + while (!engine.shouldQuit() && ((_state & GS_RESTART) == 0)) { // If time for next frame, allow everything to update if (system.getMillis() > timerVal + GAME_FRAME_DELAY) { timerVal = system.getMillis(); @@ -1025,7 +1025,7 @@ bool Game::getYN() { } g_system->delayMillis(10); - } while (!engine.quit() && !breakFlag); + } while (!engine.shouldQuit() && !breakFlag); screen.update(); if (!vKbdFlag) diff --git a/engines/lure/intro.cpp b/engines/lure/intro.cpp index b4cbf4a833..a4676984c6 100644 --- a/engines/lure/intro.cpp +++ b/engines/lure/intro.cpp @@ -60,13 +60,13 @@ bool Introduction::showScreen(uint16 screenId, uint16 paletteId, uint16 delaySiz screen.update(); Palette p(paletteId); - if (LureEngine::getReference().quit()) return true; + if (LureEngine::getReference().shouldQuit()) return true; if (isEGA) screen.setPalette(&p); else screen.paletteFadeIn(&p); bool result = interruptableDelay(delaySize); - if (LureEngine::getReference().quit()) return true; + if (LureEngine::getReference().shouldQuit()) return true; if (!isEGA) screen.paletteFadeOut(); @@ -84,7 +84,7 @@ bool Introduction::interruptableDelay(uint32 milliseconds) { if (events.interruptableDelay(milliseconds)) { if (events.type() == Common::EVENT_KEYDOWN) return events.event().kbd.keycode == 27; - else if (LureEngine::getReference().quit()) + else if (LureEngine::getReference().shouldQuit()) return true; else if (events.type() == Common::EVENT_LBUTTONDOWN) return false; diff --git a/engines/lure/lure.cpp b/engines/lure/lure.cpp index 8cd76cbc73..32eb0dbe21 100644 --- a/engines/lure/lure.cpp +++ b/engines/lure/lure.cpp @@ -23,8 +23,6 @@ * */ - - #include "common/config-manager.h" #include "common/system.h" #include "common/savefile.h" @@ -136,7 +134,7 @@ int LureEngine::go() { CopyProtectionDialog *dialog = new CopyProtectionDialog(); bool result = dialog->show(); delete dialog; - if (quit()) + if (shouldQuit()) return 0; if (!result) @@ -153,7 +151,7 @@ int LureEngine::go() { } // Play the game - if (!quit()) { + if (!shouldQuit()) { // Play the game Sound.loadSection(Sound.isRoland() ? ROLAND_MAIN_SOUND_RESOURCE_ID : ADLIB_MAIN_SOUND_RESOURCE_ID); gameInstance->execute(); @@ -251,7 +249,7 @@ void LureEngine::GUIError(const char *msg, ...) { vsnprintf(buffer, STRINGBUFLEN, msg, va); va_end(va); - Engine::GUIErrorMessage(buffer); + GUIErrorMessage(buffer); } void LureEngine::syncSoundSettings() { diff --git a/engines/lure/menu.cpp b/engines/lure/menu.cpp index 562f54da20..112e6116a2 100644 --- a/engines/lure/menu.cpp +++ b/engines/lure/menu.cpp @@ -131,7 +131,7 @@ uint8 Menu::execute() { while (mouse.lButton() || mouse.rButton()) { while (events.pollEvent()) { - if (engine.quit()) return MENUITEM_NONE; + if (engine.shouldQuit()) return MENUITEM_NONE; if (mouse.y() < MENUBAR_Y_SIZE) { MenuRecord *p = getMenuAt(mouse.x()); @@ -547,7 +547,7 @@ uint16 PopupMenu::Show(int numEntries, const char *actions[]) { } while (e.pollEvent()) { - if (engine.quit()) { + if (engine.shouldQuit()) { selectedIndex = 0xffff; goto bail_out; diff --git a/engines/lure/scripts.cpp b/engines/lure/scripts.cpp index 495f8046bb..9b073fc1bc 100644 --- a/engines/lure/scripts.cpp +++ b/engines/lure/scripts.cpp @@ -221,7 +221,7 @@ void Script::endgameSequence(uint16 v1, uint16 v2, uint16 v3) { anim->show(); if (!events.interruptableDelay(30000)) { // No key yet pressed, so keep waiting - while (Sound.musicInterface_CheckPlaying(6) && !engine.quit()) { + while (Sound.musicInterface_CheckPlaying(6) && !engine.shouldQuit()) { if (events.interruptableDelay(20)) break; } diff --git a/engines/lure/surface.cpp b/engines/lure/surface.cpp index 23cc9043cf..01746f39d5 100644 --- a/engines/lure/surface.cpp +++ b/engines/lure/surface.cpp @@ -534,7 +534,7 @@ bool Surface::getString(Common::String &line, int maxSize, bool isNumeric, bool // Loop until the input string changes refreshFlag = false; while (!refreshFlag && !abortFlag) { - abortFlag = engine.quit(); + abortFlag = engine.shouldQuit(); if (abortFlag) break; while (events.pollEvent()) { @@ -976,7 +976,7 @@ bool SaveRestoreDialog::show(bool saveDialog) { // Provide highlighting of lines to select a save slot while (!abortFlag && !(mouse.lButton() && (selectedLine != -1)) && !mouse.rButton() && !mouse.mButton()) { - abortFlag = engine.quit(); + abortFlag = engine.shouldQuit(); if (abortFlag) break; while (events.pollEvent()) { @@ -1179,7 +1179,7 @@ bool RestartRestoreDialog::show() { // Event loop for making selection bool buttonPressed = false; - while (!engine.quit()) { + while (!engine.shouldQuit()) { // Handle events while (events.pollEvent()) { if ((events.type() == Common::EVENT_LBUTTONDOWN) && (highlightedButton != -1)) { @@ -1231,7 +1231,7 @@ bool RestartRestoreDialog::show() { Sound.killSounds(); - if (!restartFlag && !engine.quit()) { + if (!restartFlag && !engine.shouldQuit()) { // Need to show Restore game dialog if (!SaveRestoreDialog::show(false)) // User cancelled, so fall back on Restart @@ -1351,7 +1351,7 @@ bool CopyProtectionDialog::show() { // Clear any prior try _charIndex = 0; - while (!engine.quit()) { + while (!engine.shouldQuit()) { while (events.pollEvent() && (_charIndex < 4)) { if (events.type() == Common::EVENT_KEYDOWN) { if ((events.event().kbd.keycode == Common::KEYCODE_BACKSPACE) && (_charIndex > 0)) { @@ -1385,7 +1385,7 @@ bool CopyProtectionDialog::show() { break; } - if (engine.quit()) + if (engine.shouldQuit()) return false; // At this point, two page numbers have been entered - validate them diff --git a/engines/made/scriptfuncs.cpp b/engines/made/scriptfuncs.cpp index d697e24b04..0051b80dae 100644 --- a/engines/made/scriptfuncs.cpp +++ b/engines/made/scriptfuncs.cpp @@ -571,7 +571,7 @@ int16 ScriptFunctions::sfGetCdTime(int16 argc, int16 *argv) { // This one is called loads of times, so it has been commented out to reduce spam //warning("Unimplemented opcode: sfGetCdTime"); // TODO - return 0; + return 32000; } int16 ScriptFunctions::sfPlayCdSegment(int16 argc, int16 *argv) { diff --git a/engines/metaengine.h b/engines/metaengine.h index 3a9f930eec..fc75344f00 100644 --- a/engines/metaengine.h +++ b/engines/metaengine.h @@ -115,7 +115,9 @@ public: * @param target name of a config manager target * @param slot slot number of the save state */ - virtual SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const { return SaveStateDescriptor(); } + virtual SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const { + return SaveStateDescriptor(); + } /** @name MetaEngineFeature flags */ //@{ @@ -177,7 +179,9 @@ public: * Determine whether the engine supports the specified MetaEngine feature. * Used by e.g. the launcher to determine whether to enable the "Load" button. */ - virtual bool hasFeature(MetaEngineFeature f) const { return false; }; + virtual bool hasFeature(MetaEngineFeature f) const { + return false; + } //@} }; diff --git a/engines/parallaction/balloons.cpp b/engines/parallaction/balloons.cpp index 290aa5e625..70c3d5789e 100644 --- a/engines/parallaction/balloons.cpp +++ b/engines/parallaction/balloons.cpp @@ -79,7 +79,7 @@ public: token = tokenizer.nextToken(); token = expand(token); - if (token == '/') { + if (token == "/") { tokenWidth = 0; action(); textNewLine(); diff --git a/engines/parallaction/disk.h b/engines/parallaction/disk.h index 30d820c6d2..3fe8014f94 100644 --- a/engines/parallaction/disk.h +++ b/engines/parallaction/disk.h @@ -211,21 +211,21 @@ protected: Parallaction *_vm; - Common::FilesystemNode _baseDir; - Common::FilesystemNode _partDir; - - Common::FilesystemNode _aniDir; - Common::FilesystemNode _bkgDir; - Common::FilesystemNode _mscDir; - Common::FilesystemNode _mskDir; - Common::FilesystemNode _pthDir; - Common::FilesystemNode _rasDir; - Common::FilesystemNode _scrDir; - Common::FilesystemNode _sfxDir; - Common::FilesystemNode _talDir; + Common::FSNode _baseDir; + Common::FSNode _partDir; + + Common::FSNode _aniDir; + Common::FSNode _bkgDir; + Common::FSNode _mscDir; + Common::FSNode _mskDir; + Common::FSNode _pthDir; + Common::FSNode _rasDir; + Common::FSNode _scrDir; + Common::FSNode _sfxDir; + Common::FSNode _talDir; protected: - void errorFileNotFound(const Common::FilesystemNode &dir, const Common::String &filename); + void errorFileNotFound(const Common::FSNode &dir, const Common::String &filename); Font *createFont(const char *name, Common::ReadStream &stream); Sprites* createSprites(Common::ReadStream &stream); void loadBitmap(Common::SeekableReadStream &stream, Graphics::Surface &surf, byte *palette); @@ -273,14 +273,14 @@ protected: Font *createFont(const char *name, Common::SeekableReadStream &stream); void loadBackground(BackgroundInfo& info, Common::SeekableReadStream &stream); - Common::FilesystemNode _baseBkgDir; - Common::FilesystemNode _fntDir; - Common::FilesystemNode _commonAniDir; - Common::FilesystemNode _commonBkgDir; - Common::FilesystemNode _commonMscDir; - Common::FilesystemNode _commonMskDir; - Common::FilesystemNode _commonPthDir; - Common::FilesystemNode _commonTalDir; + Common::FSNode _baseBkgDir; + Common::FSNode _fntDir; + Common::FSNode _commonAniDir; + Common::FSNode _commonBkgDir; + Common::FSNode _commonMscDir; + Common::FSNode _commonMskDir; + Common::FSNode _commonPthDir; + Common::FSNode _commonTalDir; public: AmigaDisk_br(Parallaction *vm); diff --git a/engines/parallaction/disk_br.cpp b/engines/parallaction/disk_br.cpp index 24893b7b05..0009b48a3a 100644 --- a/engines/parallaction/disk_br.cpp +++ b/engines/parallaction/disk_br.cpp @@ -91,7 +91,7 @@ struct Sprites : public Frames { -void DosDisk_br::errorFileNotFound(const Common::FilesystemNode &dir, const Common::String &filename) { +void DosDisk_br::errorFileNotFound(const Common::FSNode &dir, const Common::String &filename) { error("File '%s' not found in directory '%s'", filename.c_str(), dir.getDisplayName().c_str()); } @@ -134,7 +134,7 @@ GfxObj* DosDisk_br::loadTalk(const char *name) { debugC(5, kDebugDisk, "DosDisk_br::loadTalk(%s)", name); Common::String path(name); - Common::FilesystemNode node = _talDir.getChild(path); + Common::FSNode node = _talDir.getChild(path); if (!node.exists()) { path += ".tal"; node = _talDir.getChild(path); @@ -160,11 +160,11 @@ Script* DosDisk_br::loadLocation(const char *name) { debugC(5, kDebugDisk, "DosDisk_br::loadLocation"); Common::String langs[4] = { "it", "fr", "en", "ge" }; - Common::FilesystemNode locDir = _partDir.getChild(langs[_language]); + Common::FSNode locDir = _partDir.getChild(langs[_language]); Common::String path(name); path += ".slf"; - Common::FilesystemNode node = locDir.getChild(path); + Common::FSNode node = locDir.getChild(path); if (!node.exists()) { path = Common::String(name) + ".loc"; node = locDir.getChild(path); @@ -183,7 +183,7 @@ Script* DosDisk_br::loadScript(const char* name) { Common::String path(name); path += ".scr"; - Common::FilesystemNode node = _scrDir.getChild(path); + Common::FSNode node = _scrDir.getChild(path); if (!node.exists()) { errorFileNotFound(_scrDir, path); } @@ -221,7 +221,7 @@ Frames* DosDisk_br::loadPointer(const char *name) { Common::String path(name); path += ".ras"; - Common::FilesystemNode node = _baseDir.getChild(path); + Common::FSNode node = _baseDir.getChild(path); if (!node.exists()) { errorFileNotFound(_baseDir, path); } @@ -240,7 +240,7 @@ Font* DosDisk_br::loadFont(const char* name) { Common::String path(name); path += ".fnt"; - Common::FilesystemNode node = _baseDir.getChild(path); + Common::FSNode node = _baseDir.getChild(path); if (!node.exists()) { errorFileNotFound(_baseDir, path); } @@ -255,7 +255,7 @@ GfxObj* DosDisk_br::loadObjects(const char *name) { debugC(5, kDebugDisk, "DosDisk_br::loadObjects"); Common::String path(name); - Common::FilesystemNode node = _partDir.getChild(path); + Common::FSNode node = _partDir.getChild(path); if (!node.exists()) { errorFileNotFound(_partDir, path); } @@ -274,7 +274,7 @@ GfxObj* DosDisk_br::loadStatic(const char* name) { debugC(5, kDebugDisk, "DosDisk_br::loadStatic"); Common::String path(name); - Common::FilesystemNode node = _rasDir.getChild(path); + Common::FSNode node = _rasDir.getChild(path); if (!node.exists()) { errorFileNotFound(_rasDir, path); } @@ -312,7 +312,7 @@ Frames* DosDisk_br::loadFrames(const char* name) { debugC(5, kDebugDisk, "DosDisk_br::loadFrames"); Common::String path(name); - Common::FilesystemNode node = _aniDir.getChild(path); + Common::FSNode node = _aniDir.getChild(path); if (!node.exists()) { path += ".ani"; node = _aniDir.getChild(path); @@ -336,7 +336,7 @@ void DosDisk_br::loadSlide(BackgroundInfo& info, const char *name) { Common::String path(name); path += ".bmp"; - Common::FilesystemNode node = _baseDir.getChild(path); + Common::FSNode node = _baseDir.getChild(path); if (!node.exists()) { errorFileNotFound(_baseDir, path); } @@ -363,7 +363,7 @@ void DosDisk_br::loadMask(const char *name, MaskBuffer &buffer) { } Common::String filepath; - Common::FilesystemNode node; + Common::FSNode node; Common::File stream; filepath = Common::String(name) + ".msk"; @@ -384,7 +384,7 @@ void DosDisk_br::loadScenery(BackgroundInfo& info, const char *name, const char debugC(5, kDebugDisk, "DosDisk_br::loadScenery"); Common::String filepath; - Common::FilesystemNode node; + Common::FSNode node; Common::File stream; if (name) { @@ -447,7 +447,7 @@ Table* DosDisk_br::loadTable(const char* name) { Common::String path(name); path += ".tab"; - Common::FilesystemNode node = _partDir.getChild(path); + Common::FSNode node = _partDir.getChild(path); if (!node.exists()) { errorFileNotFound(_partDir, path); } @@ -518,7 +518,7 @@ AmigaDisk_br::AmigaDisk_br(Parallaction *vm) : DosDisk_br(vm) { _baseBkgDir = _baseDir.getChild("backs"); - Common::FilesystemNode commonDir = _baseDir.getChild("common"); + Common::FSNode commonDir = _baseDir.getChild("common"); _commonAniDir = commonDir.getChild("anims"); _commonBkgDir = commonDir.getChild("backs"); _commonMscDir = commonDir.getChild("msc"); @@ -566,7 +566,7 @@ void AmigaDisk_br::loadScenery(BackgroundInfo& info, const char* name, const cha debugC(1, kDebugDisk, "AmigaDisk_br::loadScenery '%s', '%s' '%s'", name, mask, path); Common::String filepath; - Common::FilesystemNode node; + Common::FSNode node; Common::File stream; if (name) { @@ -630,7 +630,7 @@ void AmigaDisk_br::loadSlide(BackgroundInfo& info, const char *name) { Common::String path(name); path += ".bkg"; - Common::FilesystemNode node = _baseBkgDir.getChild(path); + Common::FSNode node = _baseBkgDir.getChild(path); if (!node.exists()) { errorFileNotFound(_baseBkgDir, path); } @@ -644,7 +644,7 @@ GfxObj* AmigaDisk_br::loadStatic(const char* name) { debugC(1, kDebugDisk, "AmigaDisk_br::loadStatic '%s'", name); Common::String path(name); - Common::FilesystemNode node = _rasDir.getChild(path); + Common::FSNode node = _rasDir.getChild(path); if (!node.exists()) { errorFileNotFound(_rasDir, path); } @@ -687,7 +687,7 @@ Frames* AmigaDisk_br::loadFrames(const char* name) { debugC(1, kDebugDisk, "AmigaDisk_br::loadFrames '%s'", name); Common::String path(name); - Common::FilesystemNode node = _aniDir.getChild(path); + Common::FSNode node = _aniDir.getChild(path); if (!node.exists()) { path += ".ani"; node = _aniDir.getChild(path); @@ -713,7 +713,7 @@ GfxObj* AmigaDisk_br::loadTalk(const char *name) { debugC(1, kDebugDisk, "AmigaDisk_br::loadTalk '%s'", name); Common::String path(name); - Common::FilesystemNode node = _talDir.getChild(path); + Common::FSNode node = _talDir.getChild(path); if (!node.exists()) { path += ".tal"; node = _talDir.getChild(path); @@ -740,7 +740,7 @@ Font* AmigaDisk_br::loadFont(const char* name) { Common::String path(name); path += ".font"; - Common::FilesystemNode node = _fntDir.getChild(path); + Common::FSNode node = _fntDir.getChild(path); if (!node.exists()) { errorFileNotFound(_fntDir, path); } @@ -773,7 +773,7 @@ Common::SeekableReadStream* AmigaDisk_br::loadMusic(const char* name) { debugC(5, kDebugDisk, "AmigaDisk_br::loadMusic"); Common::String path(name); - Common::FilesystemNode node = _mscDir.getChild(path); + Common::FSNode node = _mscDir.getChild(path); if (!node.exists()) { // TODO (Kirben): error out when music file is not found? return 0; @@ -789,7 +789,7 @@ Common::ReadStream* AmigaDisk_br::loadSound(const char* name) { debugC(5, kDebugDisk, "AmigaDisk_br::loadSound"); Common::String path(name); - Common::FilesystemNode node = _sfxDir.getChild(path); + Common::FSNode node = _sfxDir.getChild(path); if (!node.exists()) { errorFileNotFound(_sfxDir, path); } @@ -803,7 +803,7 @@ GfxObj* AmigaDisk_br::loadObjects(const char *name) { debugC(5, kDebugDisk, "AmigaDisk_br::loadObjects"); Common::String path(name); - Common::FilesystemNode node = _partDir.getChild(path); + Common::FSNode node = _partDir.getChild(path); if (!node.exists()) { errorFileNotFound(_partDir, path); } diff --git a/engines/parallaction/exec_ns.cpp b/engines/parallaction/exec_ns.cpp index 2ce50f498e..9cbb5c33b4 100644 --- a/engines/parallaction/exec_ns.cpp +++ b/engines/parallaction/exec_ns.cpp @@ -357,7 +357,7 @@ void CommandExec::runList(CommandList::iterator first, CommandList::iterator las _ctxt.suspend = false; for ( ; first != last; first++) { - if (_vm->quit()) + if (_vm->shouldQuit()) break; CommandPtr cmd = *first; diff --git a/engines/parallaction/graphics.cpp b/engines/parallaction/graphics.cpp index 2bd3935f01..5526ecc64d 100644 --- a/engines/parallaction/graphics.cpp +++ b/engines/parallaction/graphics.cpp @@ -750,8 +750,8 @@ Gfx::Gfx(Parallaction* vm) : _vm(vm), _disk(vm->_disk) { _vm->_system->beginGFXTransaction(); - _vm->_system->initSize(_vm->_screenWidth, _vm->_screenHeight); - _vm->initCommonGFX(_vm->getGameType() == GType_BRA); + _vm->_system->initSize(_vm->_screenWidth, _vm->_screenHeight); + initCommonGFX(_vm->getGameType() == GType_BRA); _vm->_system->endGFXTransaction(); setPalette(_palette); diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp index 828cb4d021..b52c4cfba8 100644 --- a/engines/parallaction/parallaction.cpp +++ b/engines/parallaction/parallaction.cpp @@ -326,7 +326,7 @@ void Parallaction::processInput(int event) { void Parallaction::runGame() { int event = _input->updateInput(); - if (quit()) + if (shouldQuit()) return; runGuiFrame(); @@ -337,7 +337,7 @@ void Parallaction::runGame() { processInput(event); runPendingZones(); - if (quit()) + if (shouldQuit()) return; if (_engineFlags & kEngineChangeLocation) { diff --git a/engines/parallaction/parallaction_br.cpp b/engines/parallaction/parallaction_br.cpp index a06fba43f9..8929efdcbc 100644 --- a/engines/parallaction/parallaction_br.cpp +++ b/engines/parallaction/parallaction_br.cpp @@ -104,7 +104,7 @@ int Parallaction_br::go() { bool splash = true; - while (!quit()) { + while (!shouldQuit()) { if (getFeatures() & GF_DEMO) { scheduleLocationSwitch("camalb.1"); @@ -117,7 +117,7 @@ int Parallaction_br::go() { // initCharacter(); - while (((_engineFlags & kEngineReturn) == 0) && (!quit())) { + while (((_engineFlags & kEngineReturn) == 0) && (!shouldQuit())) { runGame(); } _engineFlags &= ~kEngineReturn; diff --git a/engines/parallaction/parallaction_ns.cpp b/engines/parallaction/parallaction_ns.cpp index 8e11931c28..f4a1ef03ec 100644 --- a/engines/parallaction/parallaction_ns.cpp +++ b/engines/parallaction/parallaction_ns.cpp @@ -231,7 +231,7 @@ int Parallaction_ns::go() { startGui(); - while (!quit()) { + while (!shouldQuit()) { runGame(); } diff --git a/engines/queen/logic.cpp b/engines/queen/logic.cpp index 7fcc761018..053312c584 100644 --- a/engines/queen/logic.cpp +++ b/engines/queen/logic.cpp @@ -2076,7 +2076,7 @@ bool LogicDemo::changeToSpecialRoom() { displayRoom(currentRoom(), RDM_FADE_NOJOE, 100, 2, true); playCutaway("CLOGO.CUT"); sceneReset(); - if (_vm->quit()) + if (_vm->shouldQuit()) return true; currentRoom(ROOM_HOTEL_LOBBY); entryObj(584); @@ -2131,10 +2131,10 @@ bool LogicGame::changeToSpecialRoom() { } else if (currentRoom() == FOTAQ_LOGO && gameState(VAR_INTRO_PLAYED) == 0) { displayRoom(currentRoom(), RDM_FADE_NOJOE, 100, 2, true); playCutaway("COPY.CUT"); - if (_vm->quit()) + if (_vm->shouldQuit()) return true; playCutaway("CLOGO.CUT"); - if (_vm->quit()) + if (_vm->shouldQuit()) return true; if (_vm->resource()->getPlatform() != Common::kPlatformAmiga) { if (ConfMan.getBool("alt_intro") && _vm->resource()->isCD()) { @@ -2143,10 +2143,10 @@ bool LogicGame::changeToSpecialRoom() { playCutaway("CDINT.CUT"); } } - if (_vm->quit()) + if (_vm->shouldQuit()) return true; playCutaway("CRED.CUT"); - if (_vm->quit()) + if (_vm->shouldQuit()) return true; _vm->display()->palSetPanel(); sceneReset(); diff --git a/engines/queen/queen.cpp b/engines/queen/queen.cpp index 6cdd020b8f..e242614ad9 100644 --- a/engines/queen/queen.cpp +++ b/engines/queen/queen.cpp @@ -437,7 +437,7 @@ int QueenEngine::go() { } _lastSaveTime = _lastUpdateTime = _system->getMillis(); - while (!quit()) { + while (!shouldQuit()) { if (_logic->newRoom() > 0) { _logic->update(); _logic->oldRoom(_logic->currentRoom()); diff --git a/engines/queen/talk.cpp b/engines/queen/talk.cpp index fa2ca669cd..9955ebb856 100644 --- a/engines/queen/talk.cpp +++ b/engines/queen/talk.cpp @@ -807,7 +807,7 @@ void Talk::speakSegment( switch (command) { case SPEAK_PAUSE: - for (i = 0; i < 10 && !_vm->input()->talkQuit() && !_vm->quit(); i++) { + for (i = 0; i < 10 && !_vm->input()->talkQuit() && !_vm->shouldQuit(); i++) { _vm->update(); } return; diff --git a/engines/saga/detection.cpp b/engines/saga/detection.cpp index a31e9b755a..4a10261d9b 100644 --- a/engines/saga/detection.cpp +++ b/engines/saga/detection.cpp @@ -50,7 +50,6 @@ struct SAGAGameDescription { const GameFontDescription *fontDescriptions; const GameSoundInfo *voiceInfo; const GameSoundInfo *sfxInfo; - int patchesCount; const GamePatchDescription *patchDescriptions; }; @@ -95,7 +94,6 @@ Common::Platform SagaEngine::getPlatform() const { return _gameDescription->desc int SagaEngine::getGameNumber() const { return _gameNumber; } int SagaEngine::getStartSceneNumber() const { return _gameDescription->startSceneNumber; } -int SagaEngine::getPatchesCount() const { return _gameDescription->patchesCount; } const GamePatchDescription *SagaEngine::getPatchDescriptions() const { return _gameDescription->patchDescriptions; } const Common::ADGameFileDescription *SagaEngine::getFilesDescriptions() const { return _gameDescription->desc.filesDescriptions; } diff --git a/engines/saga/detection_tables.h b/engines/saga/detection_tables.h index cbc3152f70..9a82d513b3 100644 --- a/engines/saga/detection_tables.h +++ b/engines/saga/detection_tables.h @@ -160,7 +160,8 @@ static const GamePatchDescription ITEPatch_Files[] = { { "credit4n.dlt", GAME_RESOURCEFILE, 1797, NULL}, // PC { "credit4m.dlt", GAME_RESOURCEFILE, 1797, NULL}, // Macintosh { "p2_a.voc", GAME_VOICEFILE, 4, NULL}, - { "p2_a.iaf", GAME_VOICEFILE, 4, &ITEPC_GameSound} + { "p2_a.iaf", GAME_VOICEFILE, 4, &ITEPC_GameSound}, + { NULL, 0, 0, NULL} }; static const GamePatchDescription ITEMacPatch_Files[] = { @@ -171,7 +172,8 @@ static const GamePatchDescription ITEMacPatch_Files[] = { { "wyrm4.dlt", GAME_RESOURCEFILE, 1533, NULL}, { "credit3m.dlt", GAME_RESOURCEFILE, 1796, NULL}, { "credit4m.dlt", GAME_RESOURCEFILE, 1797, NULL}, - { "p2_a.iaf", GAME_VOICEFILE, 4, &MAC_GameSound} + { "p2_a.iaf", GAME_VOICEFILE, 4, &MAC_GameSound}, + { NULL, 0, 0, NULL} }; static const SAGAGameDescription gameDescriptions[] = { @@ -209,7 +211,6 @@ static const SAGAGameDescription gameDescriptions[] = { ITEDEMO_GameFonts, &ITEDISK_GameSound, &ITEDISK_GameSound, - 0, NULL, }, @@ -237,7 +238,6 @@ static const SAGAGameDescription gameDescriptions[] = { ITEWINDEMO_GameFonts, &ITEDEMO_GameVoice, &MAC_GameSound, - ARRAYSIZE(ITEMacPatch_Files), ITEMacPatch_Files, }, @@ -266,7 +266,6 @@ static const SAGAGameDescription gameDescriptions[] = { ITEWINDEMO_GameFonts, &ITEDEMO_GameVoice, &MAC_GameSound, - ARRAYSIZE(ITEMacPatch_Files), ITEMacPatch_Files, }, @@ -295,7 +294,6 @@ static const SAGAGameDescription gameDescriptions[] = { ITEWINDEMO_GameFonts, &ITEDEMO_GameVoice, &ITEPC_GameSound, - ARRAYSIZE(ITEPatch_Files), ITEPatch_Files, }, @@ -324,7 +322,6 @@ static const SAGAGameDescription gameDescriptions[] = { ITEWINDEMO_GameFonts, &ITEWINDEMO1_GameSound, &ITEWINDEMO1_GameSound, - ARRAYSIZE(ITEPatch_Files), ITEPatch_Files, }, @@ -360,7 +357,6 @@ static const SAGAGameDescription gameDescriptions[] = { ITEWINDEMO_GameFonts, &ITEMACCD_G_GameSound, &ITEMACCD_G_GameSound, - 0, NULL, }, @@ -387,7 +383,6 @@ static const SAGAGameDescription gameDescriptions[] = { ITEWINDEMO_GameFonts, &MAC_GameSound, &MAC_GameSound, - ARRAYSIZE(ITEMacPatch_Files), ITEMacPatch_Files, }, @@ -422,7 +417,6 @@ static const SAGAGameDescription gameDescriptions[] = { ITE_GameFonts, &MAC_GameSound, &ITEPC_GameSound, - 0, NULL, }, @@ -454,7 +448,6 @@ static const SAGAGameDescription gameDescriptions[] = { ITE_GameFonts, &MAC_GameSound, &ITEPC_GameSound, - 0, NULL, }, @@ -481,7 +474,6 @@ static const SAGAGameDescription gameDescriptions[] = { ITE_GameFonts, &ITEPC_GameSound, &ITEPC_GameSound, - ARRAYSIZE(ITEPatch_Files), ITEPatch_Files, }, @@ -508,7 +500,6 @@ static const SAGAGameDescription gameDescriptions[] = { ITE_GameFonts, &ITEPC_GameSound, &ITEPC_GameSound, - ARRAYSIZE(ITEPatch_Files), ITEPatch_Files, }, @@ -535,7 +526,6 @@ static const SAGAGameDescription gameDescriptions[] = { ITE_GameFonts, &ITEPC_GameSound, &ITEPC_GameSound, - ARRAYSIZE(ITEPatch_Files), ITEPatch_Files, }, @@ -563,7 +553,6 @@ static const SAGAGameDescription gameDescriptions[] = { ITE_GameFonts, &ITEPC_GameSound, &ITEPC_GameSound, - 0, NULL, }, @@ -593,7 +582,6 @@ static const SAGAGameDescription gameDescriptions[] = { ITE_GameFonts, &ITEDISK_GameSound, &ITEDISK_GameSound, - 0, NULL, }, @@ -620,7 +608,6 @@ static const SAGAGameDescription gameDescriptions[] = { ITE_GameFonts, &ITEDISK_GameSound, &ITEDISK_GameSound, - ARRAYSIZE(ITEPatch_Files), ITEPatch_Files, }, @@ -647,7 +634,6 @@ static const SAGAGameDescription gameDescriptions[] = { ITE_GameFonts, &ITEDISK_GameSound, &ITEDISK_GameSound, - ARRAYSIZE(ITEPatch_Files), ITEPatch_Files, }, @@ -683,7 +669,6 @@ static const SAGAGameDescription gameDescriptions[] = { IHNMDEMO_GameFonts, &IHNM_GameSound, &IHNM_GameSound, - 0, NULL, }, @@ -718,7 +703,6 @@ static const SAGAGameDescription gameDescriptions[] = { IHNMCD_GameFonts, &IHNM_GameSound, &IHNM_GameSound, - 0, NULL, }, @@ -751,7 +735,6 @@ static const SAGAGameDescription gameDescriptions[] = { IHNMCD_GameFonts, &IHNM_GameSound, &IHNM_GameSound, - 0, NULL, }, @@ -782,7 +765,6 @@ static const SAGAGameDescription gameDescriptions[] = { IHNMCD_GameFonts, &IHNM_GameSound, &IHNM_GameSound, - 0, NULL, }, @@ -813,7 +795,6 @@ static const SAGAGameDescription gameDescriptions[] = { IHNMCD_GameFonts, &IHNM_GameSound, &IHNM_GameSound, - 0, NULL, }, @@ -845,7 +826,6 @@ static const SAGAGameDescription gameDescriptions[] = { IHNMCD_GameFonts, &IHNM_GameSound, &IHNM_GameSound, - 0, NULL, }, @@ -876,7 +856,6 @@ static const SAGAGameDescription gameDescriptions[] = { IHNMCD_GameFonts, &IHNM_GameSound, &IHNM_GameSound, - 0, NULL, }, // I Have No Mouth And I Must Scream - Mac English CD @@ -904,10 +883,9 @@ static const SAGAGameDescription gameDescriptions[] = { IHNMCD_GameFonts, &MAC_GameSound, &MAC_GameSound, - 0, NULL, }, - { AD_TABLE_END_MARKER, 0, 0, 0, 0, NULL, 0, NULL, NULL, NULL, 0, NULL } + { AD_TABLE_END_MARKER, 0, 0, 0, 0, NULL, 0, NULL, NULL, NULL, NULL } }; } // End of namespace Saga diff --git a/engines/saga/gfx.cpp b/engines/saga/gfx.cpp index 85416991db..2cc4e8c095 100644 --- a/engines/saga/gfx.cpp +++ b/engines/saga/gfx.cpp @@ -41,7 +41,7 @@ namespace Saga { Gfx::Gfx(SagaEngine *vm, OSystem *system, int width, int height) : _vm(vm), _system(system) { _system->beginGFXTransaction(); - _vm->initCommonGFX(width > 320); + initCommonGFX(width > 320); _system->initSize(width, height); _system->endGFXTransaction(); diff --git a/engines/saga/introproc_ihnm.cpp b/engines/saga/introproc_ihnm.cpp index aaa428ca53..685cc5a961 100644 --- a/engines/saga/introproc_ihnm.cpp +++ b/engines/saga/introproc_ihnm.cpp @@ -59,11 +59,11 @@ int Scene::IHNMStartProc() { // Play Cyberdreams logo for 168 frames if (!playTitle(0, logoLength, true)) { - if (_vm->quit()) + if (_vm->shouldQuit()) return !SUCCESS; // Play Dreamers Guild logo for 10 seconds if (!playLoopingTitle(1, 10)) { - if (_vm->quit()) + if (_vm->shouldQuit()) return !SUCCESS; // Play the title music _vm->_music->play(1, MUSIC_NORMAL); @@ -74,7 +74,7 @@ int Scene::IHNMStartProc() { } else { _vm->_music->play(1, MUSIC_NORMAL); playTitle(0, 10); - if (_vm->quit()) + if (_vm->shouldQuit()) return !SUCCESS; playTitle(2, 12); } @@ -193,7 +193,7 @@ bool Scene::playTitle(int title, int time, int mode) { _vm->_gfx->getCurrentPal(pal_cut); - while (!done && !_vm->quit()) { + while (!done && !_vm->shouldQuit()) { curTime = _vm->_system->getMillis(); switch (phase) { diff --git a/engines/saga/module.mk b/engines/saga/module.mk index b1929361a2..e124e642a9 100644 --- a/engines/saga/module.mk +++ b/engines/saga/module.mk @@ -12,14 +12,16 @@ MODULE_OBJS := \ font_map.o \ gfx.o \ image.o \ + input.o \ interface.o \ introproc_ihnm.o \ introproc_ite.o \ isomap.o \ itedata.o \ + music.o \ objectmap.o \ - puzzle.o \ palanim.o \ + puzzle.o \ render.o \ rscfile.o \ saga.o \ @@ -28,11 +30,9 @@ MODULE_OBJS := \ script.o \ sfuncs.o \ sndres.o \ + sound.o \ sprite.o \ - sthread.o \ - input.o \ - music.o \ - sound.o + sthread.o # This module can be built as a plugin ifeq ($(ENABLE_SAGA), DYNAMIC_PLUGIN) diff --git a/engines/saga/music.cpp b/engines/saga/music.cpp index 5bf0c0ec03..d022768957 100644 --- a/engines/saga/music.cpp +++ b/engines/saga/music.cpp @@ -86,7 +86,7 @@ DigitalMusicInputStream::DigitalMusicInputStream(SagaEngine *vm, ResourceContext byte compressedHeader[10]; - resourceData = _vm->_resource->getResourceData(context, resourceId); + resourceData = context->getResourceData(resourceId); _file = context->getFile(resourceData); _musicInfo = _vm->getMusicInfo(); @@ -96,7 +96,12 @@ DigitalMusicInputStream::DigitalMusicInputStream(SagaEngine *vm, ResourceContext _compressedStream = NULL; - if (scumm_stricmp(_file->name(), "music.cmp") == 0 || scumm_stricmp(_file->name(), "musicd.cmp") == 0) { + // FIXME: It is a bad idea to use the File::getName() method to distinguish + // files here (note that it is for debugging purposes only, though that was + // not correctly documented in the past). + // A better way is to keep track of this via some flag, which indicates + // whether the music file contains compressed data. + if (scumm_stricmp(_file->getName(), "music.cmp") == 0 || scumm_stricmp(_file->getName(), "musicd.cmp") == 0) { // Read compressed header to determine compression type _file->seek((long)resourceData->offset, SEEK_SET); _file->read(compressedHeader, 9); diff --git a/engines/saga/rscfile.cpp b/engines/saga/rscfile.cpp index 05b1162973..1c035df825 100644 --- a/engines/saga/rscfile.cpp +++ b/engines/saga/rscfile.cpp @@ -263,7 +263,6 @@ bool Resource::loadMacContext(ResourceContext *context) { bool Resource::loadContext(ResourceContext *context) { size_t i; - int j; const GamePatchDescription *patchDescription; ResourceData *resourceData; uint16 subjectResourceType; @@ -310,8 +309,8 @@ bool Resource::loadContext(ResourceContext *context) { for (i = 0; i < tableSize / 8; i++) { subjectResourceId = readS2.readUint32(); patchResourceId = readS2.readUint32(); - subjectResourceData = getResourceData(subjectContext, subjectResourceId); - resourceData = getResourceData(context, patchResourceId); + subjectResourceData = subjectContext->getResourceData(subjectResourceId); + resourceData = context->getResourceData(patchResourceId); subjectResourceData->patchData = new PatchData(context->file); subjectResourceData->offset = resourceData->offset; subjectResourceData->size = resourceData->size; @@ -320,8 +319,7 @@ bool Resource::loadContext(ResourceContext *context) { } //process external patch files - for (j = 0; j < _vm->getPatchesCount(); j++) { - patchDescription = &_vm->getPatchDescriptions()[j]; + for (patchDescription = _vm->getPatchDescriptions(); patchDescription && patchDescription->fileName; ++patchDescription) { if ((patchDescription->fileType & context->fileType) != 0) { if (patchDescription->resourceId < context->count) { resourceData = &context->table[patchDescription->resourceId]; @@ -634,7 +632,7 @@ void Resource::loadResource(ResourceContext *context, uint32 resourceId, byte*&r debug(8, "loadResource %d", resourceId); - resourceData = getResourceData(context, resourceId); + resourceData = context->getResourceData(resourceId); file = context->getFile(resourceData); diff --git a/engines/saga/rscfile.h b/engines/saga/rscfile.h index ee2181ae09..27d13d8835 100644 --- a/engines/saga/rscfile.h +++ b/engines/saga/rscfile.h @@ -90,6 +90,18 @@ struct ResourceContext { return file; } } + + bool validResourceId(uint32 resourceId) const { + return (resourceId < count); + } + + ResourceData *getResourceData(uint32 resourceId) const { + if (resourceId >= count) { + error("ResourceContext::getResourceData() wrong resourceId %d", resourceId); + } + return &table[resourceId]; + } + }; struct MetaResource { @@ -122,7 +134,6 @@ public: bool createContexts(); void clearContexts(); void loadResource(ResourceContext *context, uint32 resourceId, byte*&resourceBuffer, size_t &resourceSize); - size_t getResourceSize(ResourceContext *context, uint32 resourceId); uint32 convertResourceId(uint32 resourceId); void loadGlobalResources(int chapter, int actorsEntrance); @@ -137,26 +148,6 @@ public: return NULL; } - bool validResourceId(ResourceContext *context, uint32 resourceId) const { - return (resourceId < context->count); - } - - size_t getResourceSize(ResourceContext *context, uint32 resourceId) const { - return getResourceData(context, resourceId)->size; - } - - size_t getResourceOffset(ResourceContext *context, uint32 resourceId) const { - return getResourceData(context, resourceId)->offset; - } - - ResourceData *getResourceData(ResourceContext *context, uint32 resourceId) const { - if (!validResourceId(context, resourceId)) { - warning("Resource::getResourceData() wrong resourceId %d", resourceId); - assert(0); - } - return &context->table[resourceId]; - } - private: SagaEngine *_vm; ResourceContext *_contexts; diff --git a/engines/saga/saga.cpp b/engines/saga/saga.cpp index 5ce5d6ab93..7904e60d1c 100644 --- a/engines/saga/saga.cpp +++ b/engines/saga/saga.cpp @@ -270,7 +270,7 @@ int SagaEngine::go() { uint32 currentTicks; - while (!quit()) { + while (!shouldQuit()) { if (_console->isAttached()) _console->onFrame(); diff --git a/engines/saga/saga.h b/engines/saga/saga.h index 0b6b3b1478..2be74e1766 100644 --- a/engines/saga/saga.h +++ b/engines/saga/saga.h @@ -643,7 +643,6 @@ public: int getGameNumber() const; int getStartSceneNumber() const; - int getPatchesCount() const; const GamePatchDescription *getPatchDescriptions() const; const Common::ADGameFileDescription *getFilesDescriptions() const; diff --git a/engines/saga/scene.cpp b/engines/saga/scene.cpp index 074b4c933a..e6afb8241c 100644 --- a/engines/saga/scene.cpp +++ b/engines/saga/scene.cpp @@ -957,7 +957,7 @@ void Scene::loadSceneResourceList(uint32 resourceId) { _resourceList[i].resourceId = readS.readUint16(); _resourceList[i].resourceType = readS.readUint16(); // demo version may contain invalid resourceId - _resourceList[i].invalid = !_vm->_resource->validResourceId(_sceneContext, _resourceList[i].resourceId); + _resourceList[i].invalid = !_sceneContext->validResourceId(_resourceList[i].resourceId); } } diff --git a/engines/saga/sndres.cpp b/engines/saga/sndres.cpp index b990b8ddf7..29de6f6be1 100644 --- a/engines/saga/sndres.cpp +++ b/engines/saga/sndres.cpp @@ -205,7 +205,7 @@ bool SndRes::load(ResourceContext *context, uint32 resourceId, SoundBuffer &buff soundResourceLength = file->size(); } else { - ResourceData* resourceData = _vm->_resource->getResourceData(context, resourceId); + ResourceData* resourceData = context->getResourceData(resourceId); file = context->getFile(resourceData); file->seek(resourceData->offset); @@ -373,7 +373,7 @@ bool SndRes::load(ResourceContext *context, uint32 resourceId, SoundBuffer &buff case kSoundOGG: case kSoundFLAC: ResourceData *resourceData; - resourceData = _vm->_resource->getResourceData(context, resourceId); + resourceData = context->getResourceData(resourceId); // Read compressed sfx header readS.seek(1); // Skip compression identifier byte diff --git a/engines/scumm/actor.cpp b/engines/scumm/actor.cpp index b2bb8be9c9..1ea0da86d8 100644 --- a/engines/scumm/actor.cpp +++ b/engines/scumm/actor.cpp @@ -1475,7 +1475,7 @@ void Actor::prepareDrawActorCostume(BaseCostumeRenderer *bcr) { bcr->_shadow_table = _vm->_shadowPalette; } - bcr->setCostume(_costume, _heXmapNum); + bcr->setCostume(_costume, (_vm->_game.heversion == 0) ? 0 : _heXmapNum); bcr->setPalette(_palette); bcr->setFacing(this); diff --git a/engines/scumm/detection.cpp b/engines/scumm/detection.cpp index d3397fe208..0a54f2d29b 100644 --- a/engines/scumm/detection.cpp +++ b/engines/scumm/detection.cpp @@ -25,6 +25,7 @@ #include "base/plugins.h" +#include "common/archive.h" #include "common/config-manager.h" #include "common/fs.h" #include "common/list.h" @@ -177,7 +178,7 @@ static Common::String generateFilenameForDetection(const char *pattern, Filename } struct DetectorDesc { - Common::FilesystemNode node; + Common::FSNode node; Common::String md5; const MD5Table *md5Entry; // Entry of the md5 table corresponding to this file, if any. }; @@ -191,7 +192,7 @@ static bool testGame(const GameSettings *g, const DescMap &fileMD5Map, const Com // when performing the matching. The first match is returned, so if you // search for "resource" and two nodes "RESOURE and "resource" are present, // the first match is used. -static bool searchFSNode(const Common::FSList &fslist, const Common::String &name, Common::FilesystemNode &result) { +static bool searchFSNode(const Common::FSList &fslist, const Common::String &name, Common::FSNode &result) { for (Common::FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) { if (!scumm_stricmp(file->getName().c_str(), name.c_str())) { result = *file; @@ -211,21 +212,23 @@ static Common::Language detectLanguage(const Common::FSList &fslist, byte id) { // ever determine that this is insufficient, we can still // switch to MD5 based detection). const char *filename = (id == GID_CMI) ? "LANGUAGE.TAB" : "LANGUAGE.BND"; - Common::File tmp; - Common::FilesystemNode langFile; - if (!searchFSNode(fslist, filename, langFile) || !tmp.open(langFile)) { + Common::FilePtr tmp; + Common::FSNode langFile; + if (searchFSNode(fslist, filename, langFile)) + tmp = Common::FilePtr(langFile.openForReading()); + if (!tmp) { // try loading in RESOURCE sub dir... - Common::FilesystemNode resDir; + Common::FSNode resDir; Common::FSList tmpList; if (searchFSNode(fslist, "RESOURCE", resDir) && resDir.isDirectory() - && resDir.getChildren(tmpList, Common::FilesystemNode::kListFilesOnly) + && resDir.getChildren(tmpList, Common::FSNode::kListFilesOnly) && searchFSNode(tmpList, filename, langFile)) { - tmp.open(langFile); + tmp = Common::FilePtr(langFile.openForReading()); } } - if (tmp.isOpen()) { - uint size = tmp.size(); + if (tmp) { + uint size = tmp->size(); if (id == GID_CMI) { switch (size) { case 439080: // 2daf3db71d23d99d19fc9a544fcf6431 @@ -450,8 +453,8 @@ static bool testGame(const GameSettings *g, const DescMap &fileMD5Map, const Com // To do this, we take a close look at the detection file and // try to filter out some cases. - Common::File tmp; - if (!tmp.open(d.node)) { + Common::FilePtr tmp(d.node.openForReading()); + if (!tmp) { warning("SCUMM testGame: failed to open '%s' for read access", d.node.getPath().c_str()); return false; } @@ -465,7 +468,7 @@ static bool testGame(const GameSettings *g, const DescMap &fileMD5Map, const Com // Read a few bytes to narrow down the game. byte buf[6]; - tmp.read(buf, 6); + tmp->read(buf, 6); if (buf[0] == 0xbc && buf[1] == 0xb9) { // The NES version of MM @@ -784,8 +787,8 @@ PluginError ScummMetaEngine::createInstance(OSystem *syst, Engine **engine) cons // Fetch the list of files in the current directory Common::FSList fslist; - Common::FilesystemNode dir(ConfMan.get("path")); - if (!dir.getChildren(fslist, Common::FilesystemNode::kListFilesOnly)) { + Common::FSNode dir(ConfMan.get("path")); + if (!dir.getChildren(fslist, Common::FSNode::kListFilesOnly)) { return kInvalidPathError; } diff --git a/engines/scumm/file.cpp b/engines/scumm/file.cpp index f258ddd420..38c7a1a180 100644 --- a/engines/scumm/file.cpp +++ b/engines/scumm/file.cpp @@ -125,15 +125,15 @@ bool ScummFile::openSubFile(const Common::String &filename) { } -bool ScummFile::eos() { +bool ScummFile::eos() const { return _subFileLen ? (pos() >= _subFileLen) : File::eos(); // FIXME } -int32 ScummFile::pos() { +int32 ScummFile::pos() const { return File::pos() - _subFileStart; } -int32 ScummFile::size() { +int32 ScummFile::size() const { return _subFileLen ? _subFileLen : File::size(); } diff --git a/engines/scumm/file.h b/engines/scumm/file.h index 336f3cde12..e0ba7badff 100644 --- a/engines/scumm/file.h +++ b/engines/scumm/file.h @@ -39,9 +39,9 @@ public: virtual bool open(const Common::String &filename) = 0; virtual bool openSubFile(const Common::String &filename) = 0; - virtual bool eos() = 0; - virtual int32 pos() = 0; - virtual int32 size() = 0; + virtual bool eos() const = 0; + virtual int32 pos() const = 0; + virtual int32 size() const = 0; virtual bool seek(int32 offs, int whence = SEEK_SET) = 0; virtual uint32 read(void *dataPtr, uint32 dataSize) = 0; }; @@ -66,9 +66,9 @@ public: bool ioFailed() const { return _myIoFailed || BaseScummFile::ioFailed(); } void clearIOFailed() { _myIoFailed = false; BaseScummFile::clearIOFailed(); } - bool eos(); - int32 pos(); - int32 size(); + bool eos() const; + int32 pos() const; + int32 size() const; bool seek(int32 offs, int whence = SEEK_SET); uint32 read(void *dataPtr, uint32 dataSize); }; @@ -111,9 +111,9 @@ public: bool openSubFile(const Common::String &filename); void close(); - bool eos() { return _stream->eos(); } - int32 pos() { return _stream->pos(); } - int32 size() { return _stream->size(); } + bool eos() const { return _stream->eos(); } + int32 pos() const { return _stream->pos(); } + int32 size() const { return _stream->size(); } bool seek(int32 offs, int whence = SEEK_SET) { return _stream->seek(offs, whence); } uint32 read(void *dataPtr, uint32 dataSize) { return _stream->read(dataPtr, dataSize); } }; diff --git a/engines/scumm/file_nes.h b/engines/scumm/file_nes.h index f1a07f8085..0a26ed9027 100644 --- a/engines/scumm/file_nes.h +++ b/engines/scumm/file_nes.h @@ -68,9 +68,9 @@ public: bool openSubFile(const Common::String &filename); void close(); - bool eos() { return _stream->eos(); } - int32 pos() { return _stream->pos(); } - int32 size() { return _stream->size(); } + bool eos() const { return _stream->eos(); } + int32 pos() const { return _stream->pos(); } + int32 size() const { return _stream->size(); } bool seek(int32 offs, int whence = SEEK_SET) { return _stream->seek(offs, whence); } uint32 read(void *dataPtr, uint32 dataSize) { return _stream->read(dataPtr, dataSize); } }; diff --git a/engines/scumm/he/cup_player_he.cpp b/engines/scumm/he/cup_player_he.cpp index 685bd00065..51176c5df9 100644 --- a/engines/scumm/he/cup_player_he.cpp +++ b/engines/scumm/he/cup_player_he.cpp @@ -99,7 +99,7 @@ void CUP_Player::play() { debug(1, "rate %d width %d height %d", _playbackRate, _width, _height); int ticks = _system->getMillis(); - while (_dataSize != 0 && !_vm->quit()) { + while (_dataSize != 0 && !_vm->shouldQuit()) { while (parseNextBlockTag(_fileStream)) { if (_fileStream.ioFailed()) { return; @@ -190,7 +190,7 @@ void CUP_Player::waitForSfxChannel(int channel) { CUP_SfxChannel *sfxChannel = &_sfxChannels[channel]; debug(1, "waitForSfxChannel %d", channel); if ((sfxChannel->flags & kSfxFlagLoop) == 0) { - while (_mixer->isSoundHandleActive(sfxChannel->handle) && !_vm->quit()) { + while (_mixer->isSoundHandleActive(sfxChannel->handle) && !_vm->shouldQuit()) { _vm->parseEvents(); _system->delayMillis(10); } diff --git a/engines/scumm/he/resource_he.cpp b/engines/scumm/he/resource_he.cpp index f8fb1efca2..9858206209 100644 --- a/engines/scumm/he/resource_he.cpp +++ b/engines/scumm/he/resource_he.cpp @@ -159,33 +159,33 @@ int Win32ResExtractor::extractResource_(const char *resType, char *resName, byte /* initiate stuff */ fi.memory = NULL; - fi.file = new Common::File; + fi.file = NULL; if (_fileName.empty()) { // We are running for the first time _fileName = _vm->generateFilename(-3); } - /* get file size */ - fi.file->open(_fileName); - if (!fi.file->isOpen()) { + Common::FSNode node(_fileName); + fi.file = node.openForReading(); + if (!fi.file) { error("Cannot open file %s", _fileName.c_str()); } fi.total_size = fi.file->size(); if (fi.total_size == -1) { - error("Cannot get size of file %s", fi.file->name()); + error("Cannot get size of file %s", _fileName.c_str()); goto cleanup; } if (fi.total_size == 0) { - error("%s: file has a size of 0", fi.file->name()); + error("%s: file has a size of 0", _fileName.c_str()); goto cleanup; } /* read all of file */ fi.memory = (byte *)malloc(fi.total_size); if (fi.file->read(fi.memory, fi.total_size) == 0) { - error("Cannot read from file %s", fi.file->name()); + error("Cannot read from file %s", _fileName.c_str()); goto cleanup; } @@ -200,10 +200,8 @@ int Win32ResExtractor::extractResource_(const char *resType, char *resName, byte /* free stuff and close file */ cleanup: - if (fi.file != NULL) - fi.file->close(); - if (fi.memory != NULL) - free(fi.memory); + delete fi.file; + free(fi.memory); return ressize; } @@ -371,19 +369,19 @@ byte *Win32ResExtractor::extract_group_icon_cursor_resource(WinLibrary *fi, WinR fwr = find_resource(fi, (is_icon ? "-3" : "-1"), name, lang, &level); if (fwr == NULL) { error("%s: could not find `%s' in `%s' resource.", - fi->file->name(), &name[1], (is_icon ? "group_icon" : "group_cursor")); + _fileName.c_str(), &name[1], (is_icon ? "group_icon" : "group_cursor")); return NULL; } if (get_resource_entry(fi, fwr, &iconsize) != NULL) { if (iconsize == 0) { - debugC(DEBUG_RESOURCE, "%s: icon resource `%s' is empty, skipping", fi->file->name(), name); + debugC(DEBUG_RESOURCE, "%s: icon resource `%s' is empty, skipping", _fileName.c_str(), name); skipped++; continue; } if ((uint32)iconsize != FROM_LE_32(icondir->entries[c].bytes_in_res)) { debugC(DEBUG_RESOURCE, "%s: mismatch of size in icon resource `%s' and group (%d != %d)", - fi->file->name(), name, iconsize, FROM_LE_32(icondir->entries[c].bytes_in_res)); + _fileName.c_str(), name, iconsize, FROM_LE_32(icondir->entries[c].bytes_in_res)); } size += iconsize; /* size += FROM_LE_32(icondir->entries[c].bytes_in_res); */ @@ -419,7 +417,7 @@ byte *Win32ResExtractor::extract_group_icon_cursor_resource(WinLibrary *fi, WinR fwr = find_resource(fi, (is_icon ? "-3" : "-1"), name, lang, &level); if (fwr == NULL) { error("%s: could not find `%s' in `%s' resource.", - fi->file->name(), &name[1], (is_icon ? "group_icon" : "group_cursor")); + _fileName.c_str(), &name[1], (is_icon ? "group_icon" : "group_cursor")); return NULL; } @@ -675,7 +673,7 @@ bool Win32ResExtractor::read_library(WinLibrary *fi) { LE32(mz_header->lfanew); if (mz_header->lfanew < sizeof(DOSImageHeader)) { - error("%s: not a Windows library", fi->file->name()); + error("%s: not a Windows library", _fileName.c_str()); return false; } } @@ -724,7 +722,7 @@ bool Win32ResExtractor::read_library(WinLibrary *fi) { RETURN_IF_BAD_POINTER(false, pe_header->optional_header.data_directory[IMAGE_DIRECTORY_ENTRY_RESOURCE]); Win32ImageDataDirectory *dir = pe_header->optional_header.data_directory + IMAGE_DIRECTORY_ENTRY_RESOURCE; if (dir->size == 0) { - error("%s: file contains no resources", fi->file->name()); + error("%s: file contains no resources", _fileName.c_str()); return false; } @@ -735,7 +733,7 @@ bool Win32ResExtractor::read_library(WinLibrary *fi) { } /* other (unknown) header signature was found */ - error("%s: not a Windows library", fi->file->name()); + error("%s: not a Windows library", _fileName.c_str()); return false; } diff --git a/engines/scumm/he/resource_he.h b/engines/scumm/he/resource_he.h index a3237e7b3b..cbe19a4fdf 100644 --- a/engines/scumm/he/resource_he.h +++ b/engines/scumm/he/resource_he.h @@ -102,10 +102,10 @@ namespace Scumm { #endif #define RETURN_IF_BAD_POINTER(r, x) \ - if (!check_offset(fi->memory, fi->total_size, fi->file->name(), &(x), sizeof(x))) \ + if (!check_offset(fi->memory, fi->total_size, _fileName.c_str(), &(x), sizeof(x))) \ return (r); #define RETURN_IF_BAD_OFFSET(r, x, s) \ - if (!check_offset(fi->memory, fi->total_size, fi->file->name(), x, s)) \ + if (!check_offset(fi->memory, fi->total_size, _fileName.c_str(), x, s)) \ return (r); class ScummEngine_v70he; @@ -168,7 +168,7 @@ class Win32ResExtractor : public ResExtractor { #include "common/pack-start.h" // START STRUCT PACKING struct WinLibrary { - Common::File *file; + Common::SeekableReadStream *file; byte *memory; byte *first_resource; int total_size; diff --git a/engines/scumm/he/script_v60he.cpp b/engines/scumm/he/script_v60he.cpp index 7f36d53791..f60bbdd84b 100644 --- a/engines/scumm/he/script_v60he.cpp +++ b/engines/scumm/he/script_v60he.cpp @@ -1010,12 +1010,8 @@ void ScummEngine_v60he::o60_openFile() { // TODO / FIXME: Consider using listSavefiles to avoid unneccessary openForLoading calls _hInFileTable[slot] = _saveFileMan->openForLoading(filename); if (_hInFileTable[slot] == 0) { - Common::File *f = new Common::File(); - f->open(filename); - if (!f->isOpen()) - delete f; - else - _hInFileTable[slot] = f; + Common::FSNode node(filename); + _hInFileTable[slot] = node.openForReading(); } break; case 2: diff --git a/engines/scumm/resource.cpp b/engines/scumm/resource.cpp index 50e0d221ca..87ded6723b 100644 --- a/engines/scumm/resource.cpp +++ b/engines/scumm/resource.cpp @@ -676,7 +676,7 @@ int ScummEngine::loadResource(int type, int idx) { if (tag != _res->tags[type] && _game.heversion < 70) { error("%s %d not in room %d at %d+%d in file %s", _res->name[type], idx, roomNr, - _fileOffset, fileOffs, _fileHandle->name()); + _fileOffset, fileOffs, _fileHandle->getName()); } size = _fileHandle->readUint32BE(); diff --git a/engines/scumm/scumm-md5.h b/engines/scumm/scumm-md5.h index b220779c55..68570b4df0 100644 --- a/engines/scumm/scumm-md5.h +++ b/engines/scumm/scumm-md5.h @@ -1,5 +1,5 @@ /* - This file was generated by the md5table tool on Tue Sep 23 12:32:31 2008 + This file was generated by the md5table tool on Thu Oct 02 14:37:52 2008 DO NOT EDIT MANUALLY! */ @@ -187,7 +187,7 @@ static const MD5Table md5table[] = { { "47e75b1bdcb44c78cb94883d1731ccf8", "fbear", "HE 61", "Demo", 6203, Common::EN_ANY, Common::kPlatformPC }, { "48b9f04b348bc5013327753f0d12a144", "loom", "EGA", "EGA", -1, Common::ES_ESP, Common::kPlatformAmiga }, { "49210e124e4c2b30f1290a9ef6306301", "monkey", "EGA", "EGA", 8357, Common::EN_ANY, Common::kPlatformPC }, - { "4973bbc3899e3826dbf316e1d7271ec7", "zak", "V1", "", -1, Common::DE_DEU, Common::kPlatformC64 }, + { "4973bbc3899e3826dbf316e1d7271ec7", "zak", "V1", "", 196608, Common::DE_DEU, Common::kPlatformC64 }, { "499c958affc394f2a3868f1eb568c3ee", "freddi4", "HE 99", "Demo", -1, Common::NL_NLD, Common::kPlatformWindows }, { "49a1739981a89066b1121fac04b710f4", "spyfox2", "HE CUP", "Preview", 5756234, Common::UNK_LANG, Common::kPlatformUnknown }, { "4aa93cb30e485b728504ba3a693f12bf", "pajama", "HE 100", "", -1, Common::RU_RUS, Common::kPlatformWindows }, @@ -223,10 +223,10 @@ static const MD5Table md5table[] = { { "53e94115b55dd51d4b8ff0871aa1df1e", "spyfox", "", "Demo", 20103, Common::EN_ANY, Common::kPlatformUnknown }, { "54a936ad06161ff7bfefcb96200f7bff", "monkey", "VGA", "VGA Demo", -1, Common::EN_ANY, Common::kPlatformAmiga }, { "55518cd73cf9c6d23ea29c51ee06bdfe", "ft", "", "", -1, Common::IT_ITA, Common::kPlatformUnknown }, - { "55d3987641bf229c83bc729210173383", "zak", "V1", "", -1, Common::EN_ANY, Common::kPlatformC64 }, + { "55d3987641bf229c83bc729210173383", "zak", "V1", "", 174848, Common::EN_ANY, Common::kPlatformC64 }, { "55e4cc866ff9046824e1c638ba2b8c7f", "ft", "", "", -1, Common::RU_RUS, Common::kPlatformUnknown }, { "566165a7338fa11029e7c14d94fa70d0", "freddi", "HE 73", "Demo", 9800, Common::EN_ANY, Common::kPlatformWindows }, - { "5719fc8a13b4638b78d9d8d12f091f94", "puttrace", "HE 98.5", "", -1, Common::FR_FRA, Common::kPlatformWindows }, + { "5719fc8a13b4638b78d9d8d12f091f94", "puttrace", "HE 99", "", -1, Common::FR_FRA, Common::kPlatformWindows }, { "5798972220cd458be2626d54c80f71d7", "atlantis", "", "Floppy", -1, Common::IT_ITA, Common::kPlatformAmiga }, { "57a17febe2183f521250e55d55b83e60", "PuttTime", "HE 99", "", -1, Common::FR_FRA, Common::kPlatformWindows }, { "57a5cfec9ef231a007043cc1917e8988", "freddi", "HE 100", "", -1, Common::EN_ANY, Common::kPlatformWii }, @@ -321,6 +321,7 @@ static const MD5Table md5table[] = { { "78bd5f036ea35a878b74e4f47941f784", "freddi4", "HE 99", "", -1, Common::RU_RUS, Common::kPlatformWindows }, { "78c07ca088526d8d4446a4c2cb501203", "freddi3", "HE 99", "", -1, Common::FR_FRA, Common::kPlatformUnknown }, { "7974365d3dc0f43a2748c975f91ff042", "monkey2", "", "", -1, Common::ES_ESP, Common::kPlatformPC }, + { "7b60620558b8d6b7d7313b8ac7bb5a98", "zak", "V1", "", 174848, Common::IT_ITA, Common::kPlatformC64 }, { "7bad72e332a59f9fcc1d437f4edad32a", "puttcircus", "", "", -1, Common::RU_RUS, Common::kPlatformUnknown }, { "7c2e76087027eeee9c8f8985f93a1cc5", "freddi4", "", "Demo", 13584, Common::EN_ANY, Common::kPlatformUnknown }, { "7c8100e360e8ef05f88069d4cfa0afd1", "puttrace", "HE 99", "Demo", 13108, Common::EN_GRB, Common::kPlatformWindows }, diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp index a10af41145..bb22ee6381 100644 --- a/engines/scumm/scumm.cpp +++ b/engines/scumm/scumm.cpp @@ -24,7 +24,6 @@ */ - #include "common/config-manager.h" #include "common/md5.h" #include "common/events.h" @@ -1017,7 +1016,7 @@ int ScummEngine::init() { // We now have to determine the correct _filenamePattern. To do this - // we simply hardcode the possibilites. + // we simply hardcode the possibilities. const char *p1 = 0, *p2 = 0; switch (_game.id) { case GID_INDY4: @@ -1726,7 +1725,7 @@ int ScummEngine::go() { int diff = 0; // Duration of one loop iteration - while (!quit()) { + while (!shouldQuit()) { if (_debugger->isAttached()) _debugger->onFrame(); @@ -1759,7 +1758,7 @@ int ScummEngine::go() { diff = _system->getMillis() - diff; - if (quit()) { + if (shouldQuit()) { // TODO: Maybe perform an autosave on exit? } } @@ -1777,7 +1776,7 @@ void ScummEngine::waitForTimer(int msec_delay) { start_time = _system->getMillis(); - while (!quit()) { + while (!shouldQuit()) { _sound->updateCD(); // Loop CD Audio if needed parseEvents(); _system->updateScreen(); @@ -1900,7 +1899,7 @@ load_game: checkExecVerbs(); checkAndRunSentenceScript(); - if (quit()) + if (shouldQuit()) return; // HACK: If a load was requested, immediately perform it. This avoids diff --git a/engines/scumm/smush/smush_player.cpp b/engines/scumm/smush/smush_player.cpp index 6b79b7e2c4..55cdc2a25e 100644 --- a/engines/scumm/smush/smush_player.cpp +++ b/engines/scumm/smush/smush_player.cpp @@ -1017,16 +1017,17 @@ void SmushPlayer::parseNextFrame() { } assert(_base); + + const uint32 subType = _base->readUint32BE(); + const int32 subSize = _base->readUint32BE(); + const int32 subOffset = _base->pos(); + if (_base->eos()) { _vm->_smushVideoShouldFinish = true; _endOfFile = true; return; } - const uint32 subType = _base->readUint32BE(); - const int32 subSize = _base->readUint32BE(); - const int32 subOffset = _base->pos(); - switch (subType) { case MKID_BE('AHDR'): // FT INSANE may seek file to the beginning handleAnimHeader(subSize, *_base); @@ -1253,7 +1254,7 @@ void SmushPlayer::play(const char *filename, int32 speed, int32 offset, int32 st } if (_endOfFile) break; - if (_vm->quit() || _vm->_saveLoadFlag || _vm->_smushVideoShouldFinish) { + if (_vm->shouldQuit() || _vm->_saveLoadFlag || _vm->_smushVideoShouldFinish) { _smixer->stop(); _vm->_mixer->stopHandle(_compressedFileSoundHandle); _vm->_mixer->stopHandle(_IACTchannel); diff --git a/engines/sky/control.cpp b/engines/sky/control.cpp index 8699c893e4..ed2902fe47 100644 --- a/engines/sky/control.cpp +++ b/engines/sky/control.cpp @@ -496,7 +496,7 @@ void Control::doControlPanel(void) { _curButtonText = 0; uint16 clickRes = 0; - while (!quitPanel && !g_engine->quit()) { + while (!quitPanel && !g_engine->shouldQuit()) { _text->drawToScreen(WITH_MASK); _system->updateScreen(); _mouseClicked = false; @@ -528,7 +528,7 @@ void Control::doControlPanel(void) { } memset(_screenBuf, 0, GAME_SCREEN_WIDTH * FULL_SCREEN_HEIGHT); _system->copyRectToScreen(_screenBuf, GAME_SCREEN_WIDTH, 0, 0, GAME_SCREEN_WIDTH, FULL_SCREEN_HEIGHT); - if (!g_engine->quit()) + if (!g_engine->shouldQuit()) _system->updateScreen(); _skyScreen->forceRefresh(); _skyScreen->setPaletteEndian((uint8 *)_skyCompact->fetchCpt(SkyEngine::_systemVars.currentPalette)); @@ -879,7 +879,7 @@ uint16 Control::saveRestorePanel(bool allowSave) { bool refreshNames = true; bool refreshAll = true; uint16 clickRes = 0; - while (!quitPanel && !g_engine->quit()) { + while (!quitPanel && !g_engine->shouldQuit()) { clickRes = 0; if (refreshNames || refreshAll) { if (refreshAll) { diff --git a/engines/sky/sky.cpp b/engines/sky/sky.cpp index 0900ba5617..ac6773c80c 100644 --- a/engines/sky/sky.cpp +++ b/engines/sky/sky.cpp @@ -161,7 +161,7 @@ GameList SkyMetaEngine::detectGames(const Common::FSList &fslist) const { if (0 == scumm_stricmp("sky.dsk", fileName)) { Common::File dataDisk; - if (dataDisk.open(file->getPath())) { + if (dataDisk.open(*file)) { hasSkyDsk = true; dataDiskSize = dataDisk.size(); } @@ -169,7 +169,7 @@ GameList SkyMetaEngine::detectGames(const Common::FSList &fslist) const { if (0 == scumm_stricmp("sky.dnr", fileName)) { Common::File dinner; - if (dinner.open(file->getPath())) { + if (dinner.open(*file)) { hasSkyDnr = true; dinnerTableEntries = dinner.readUint32LE(); } @@ -365,7 +365,7 @@ int SkyEngine::go() { introSkipped = !_skyIntro->doIntro(_floppyIntro); } - if (!quit()) { + if (!shouldQuit()) { _skyLogic->initScreen0(); if (introSkipped) _skyControl->restartGame(); @@ -375,7 +375,7 @@ int SkyEngine::go() { _lastSaveTime = _system->getMillis(); uint32 delayCount = _system->getMillis(); - while (!quit()) { + while (!shouldQuit()) { if (_debugger->isAttached()) _debugger->onFrame(); diff --git a/engines/sword1/animation.cpp b/engines/sword1/animation.cpp index 3e15429e44..36dbadee40 100644 --- a/engines/sword1/animation.cpp +++ b/engines/sword1/animation.cpp @@ -66,8 +66,8 @@ static const char *sequenceList[20] = { // Basic movie player /////////////////////////////////////////////////////////////////////////////// -MoviePlayer::MoviePlayer(Screen *screen, Text *textMan, Audio::Mixer *snd, OSystem *system) - : _screen(screen), _textMan(textMan), _snd(snd), _system(system) { +MoviePlayer::MoviePlayer(SwordEngine *vm, Screen *screen, Text *textMan, Audio::Mixer *snd, OSystem *system) + : _vm(vm), _screen(screen), _textMan(textMan), _snd(snd), _system(system) { _bgSoundStream = NULL; _ticks = 0; _textSpriteBuf = NULL; @@ -295,17 +295,20 @@ void MoviePlayer::play(void) { handleScreenChanged(); break; case Common::EVENT_KEYDOWN: - if (event.kbd.keycode == Common::KEYCODE_ESCAPE) { - _snd->stopHandle(_bgSoundHandle); + if (event.kbd.keycode == Common::KEYCODE_ESCAPE) terminated = true; - } break; default: break; } } + if (_vm->shouldQuit()) + terminated = true; } + if (terminated) + _snd->stopHandle(_bgSoundHandle); + while (!_movieTexts.empty()) { delete _movieTexts.remove_at(_movieTexts.size() - 1); } @@ -390,8 +393,8 @@ int SplittedAudioStream::readBuffer(int16 *buffer, const int numSamples) { // Movie player for the new DXA movies /////////////////////////////////////////////////////////////////////////////// -MoviePlayerDXA::MoviePlayerDXA(Screen *screen, Text *textMan, Audio::Mixer *snd, OSystem *system) - : MoviePlayer(screen, textMan, snd, system) { +MoviePlayerDXA::MoviePlayerDXA(SwordEngine *vm, Screen *screen, Text *textMan, Audio::Mixer *snd, OSystem *system) + : MoviePlayer(vm, screen, textMan, snd, system) { debug(0, "Creating DXA cutscene player"); } @@ -438,7 +441,7 @@ bool MoviePlayerDXA::decodeFrame(void) { void MoviePlayerDXA::processFrame(void) { // TODO: Handle the advanced cutscene packs. Do they really exist? - // We cannot draw the text to _drawBuffer, sinzce ethat's one of the + // We cannot draw the text to _drawBuffer, since that's one of the // decoder's internal buffers. Instead, we copy part of _drawBuffer // to the text sprite. @@ -492,8 +495,8 @@ void MoviePlayerDXA::updateScreen(void) { // Movie player for the old MPEG movies /////////////////////////////////////////////////////////////////////////////// -MoviePlayerMPEG::MoviePlayerMPEG(Screen *screen, Text *textMan, Audio::Mixer *snd, OSystem *system) - : MoviePlayer(screen, textMan, snd, system) { +MoviePlayerMPEG::MoviePlayerMPEG(SwordEngine *vm, Screen *screen, Text *textMan, Audio::Mixer *snd, OSystem *system) + : MoviePlayer(vm, screen, textMan, snd, system) { #ifdef BACKEND_8BIT debug(0, "Creating MPEG cutscene player (8-bit)"); #else @@ -625,7 +628,7 @@ Audio::AudioStream *AnimationState::createAudioStream(const char *name, void *ar // Factory function for creating the appropriate cutscene player /////////////////////////////////////////////////////////////////////////////// -MoviePlayer *makeMoviePlayer(uint32 id, Screen *screen, Text *textMan, Audio::Mixer *snd, OSystem *system) { +MoviePlayer *makeMoviePlayer(uint32 id, SwordEngine *vm, Screen *screen, Text *textMan, Audio::Mixer *snd, OSystem *system) { #if defined(USE_ZLIB) || defined(USE_MPEG2) char filename[20]; #endif @@ -634,7 +637,7 @@ MoviePlayer *makeMoviePlayer(uint32 id, Screen *screen, Text *textMan, Audio::Mi snprintf(filename, sizeof(filename), "%s.dxa", sequenceList[id]); if (Common::File::exists(filename)) { - return new MoviePlayerDXA(screen, textMan, snd, system); + return new MoviePlayerDXA(vm, screen, textMan, snd, system); } #endif @@ -642,7 +645,7 @@ MoviePlayer *makeMoviePlayer(uint32 id, Screen *screen, Text *textMan, Audio::Mi snprintf(filename, sizeof(filename), "%s.mp2", sequenceList[id]); if (Common::File::exists(filename)) { - return new MoviePlayerMPEG(screen, textMan, snd, system); + return new MoviePlayerMPEG(vm, screen, textMan, snd, system); } #endif diff --git a/engines/sword1/animation.h b/engines/sword1/animation.h index 0837814c69..fd9c774190 100644 --- a/engines/sword1/animation.h +++ b/engines/sword1/animation.h @@ -78,7 +78,7 @@ public: class MoviePlayer { public: - MoviePlayer(Screen *screen, Text *textMan, Audio::Mixer *snd, OSystem *system); + MoviePlayer(SwordEngine *vm, Screen *screen, Text *textMan, Audio::Mixer *snd, OSystem *system); virtual ~MoviePlayer(void); virtual bool load(uint32 id); void play(void); @@ -86,6 +86,7 @@ public: private: bool checkSkipFrame(void); protected: + SwordEngine *_vm; Screen *_screen; Text *_textMan; Audio::Mixer *_snd; @@ -122,7 +123,7 @@ class MoviePlayerDXA : public MoviePlayer, ::Graphics::DXAPlayer { protected: virtual void setPalette(byte *pal); public: - MoviePlayerDXA(Screen *screen, Text *textMan, Audio::Mixer *snd, OSystem *system); + MoviePlayerDXA(SwordEngine *vm, Screen *screen, Text *textMan, Audio::Mixer *snd, OSystem *system); virtual ~MoviePlayerDXA(void); bool load(uint32 id); protected: @@ -159,7 +160,7 @@ protected: class MoviePlayerMPEG : public MoviePlayer { public: - MoviePlayerMPEG(Screen *screen, Text *textMan, Audio::Mixer *snd, OSystem *system); + MoviePlayerMPEG(SwordEngine *vm, Screen *screen, Text *textMan, Audio::Mixer *snd, OSystem *system); virtual ~MoviePlayerMPEG(void); bool load(uint32 id); protected: @@ -195,7 +196,7 @@ private: FileQueue *_queue; }; -MoviePlayer *makeMoviePlayer(uint32 id, Screen *screen, Text *textMan, Audio::Mixer *snd, OSystem *system); +MoviePlayer *makeMoviePlayer(uint32 id, SwordEngine *vm, Screen *screen, Text *textMan, Audio::Mixer *snd, OSystem *system); } // End of namespace Sword1 diff --git a/engines/sword1/control.cpp b/engines/sword1/control.cpp index d0808d3ece..2e283915fb 100644 --- a/engines/sword1/control.cpp +++ b/engines/sword1/control.cpp @@ -215,7 +215,7 @@ void Control::askForCd(void) { notAccepted = false; } } - } while (notAccepted && (!g_engine->quit())); + } while (notAccepted && (!g_engine->shouldQuit())); _resMan->resClose(fontId); free(_screenBuf); @@ -317,7 +317,7 @@ uint8 Control::runPanel(void) { } delay(1000 / 12); newMode = getClicks(mode, &retVal); - } while ((newMode != BUTTON_DONE) && (retVal == 0) && (!g_engine->quit())); + } while ((newMode != BUTTON_DONE) && (retVal == 0) && (!g_engine->shouldQuit())); if (SwordEngine::_systemVars.controlPanelMode == CP_NORMAL) { uint8 volL, volR; diff --git a/engines/sword1/credits.cpp b/engines/sword1/credits.cpp index 258784ab53..a3ce402711 100644 --- a/engines/sword1/credits.cpp +++ b/engines/sword1/credits.cpp @@ -125,7 +125,7 @@ void CreditsPlayer::play(void) { uint16 renderY = BUFSIZE_Y / 2; uint16 clearY = 0xFFFF; bool clearLine = false; - while (((*textData != FNT_EOB) || (scrollY != renderY)) && !g_engine->quit()) { + while (((*textData != FNT_EOB) || (scrollY != renderY)) && !g_engine->shouldQuit()) { if ((int32)_mixer->getSoundElapsedTime(bgSound) - relDelay < (SCROLL_TIMING * 2)) { // sync to audio if (scrollY < BUFSIZE_Y - CREDITS_Y) _system->copyRectToScreen(screenBuf + scrollY * CREDITS_X, CREDITS_X, START_X, START_Y, CREDITS_X, CREDITS_Y); @@ -175,7 +175,7 @@ void CreditsPlayer::play(void) { uint8 *revoBuf = credFile.decompressFile(REVO_LOGO); uint8 *revoPal = credFile.fetchFile(REVO_PAL, &_palLen); _palLen /= 3; - while ((_mixer->getSoundElapsedTime(bgSound) < LOGO_FADEUP_TIME) && !g_engine->quit()) { + while ((_mixer->getSoundElapsedTime(bgSound) < LOGO_FADEUP_TIME) && !g_engine->shouldQuit()) { delay(100); } memset(_palette, 0, 256 * 4); @@ -184,13 +184,13 @@ void CreditsPlayer::play(void) { _system->updateScreen(); fadePalette(revoPal, true, _palLen); - while ((_mixer->getSoundElapsedTime(bgSound) < LOGO_FADEDOWN_TIME) && !g_engine->quit()) { + while ((_mixer->getSoundElapsedTime(bgSound) < LOGO_FADEDOWN_TIME) && !g_engine->shouldQuit()) { delay(100); } fadePalette(revoPal, false, _palLen); delay(3000); - if (g_engine->quit()) + if (g_engine->shouldQuit()) _mixer->stopAll(); free(revoBuf); } @@ -200,7 +200,7 @@ void CreditsPlayer::fadePalette(uint8 *srcPal, bool fadeup, uint16 len) { int fadeStart = fadeup ? 0 : 12; int relDelay = _system->getMillis(); - for (int fadeStep = fadeStart; (fadeStep >= 0) && (fadeStep <= 12) && !g_engine->quit(); fadeStep += fadeDir) { + for (int fadeStep = fadeStart; (fadeStep >= 0) && (fadeStep <= 12) && !g_engine->shouldQuit(); fadeStep += fadeDir) { for (uint16 cnt = 0; cnt < len * 3; cnt++) _palette[(cnt / 3) * 4 + (cnt % 3)] = (srcPal[cnt] * fadeStep) / 12; _system->setPalette(_palette, 0, 256); @@ -293,7 +293,7 @@ void CreditsPlayer::delay(int msecs) { if (msecs > 0) _system->delayMillis(10); - } while ((_system->getMillis() < start + msecs) && !g_engine->quit()); + } while ((_system->getMillis() < start + msecs) && !g_engine->shouldQuit()); } ArcFile::ArcFile(void) { diff --git a/engines/sword1/logic.cpp b/engines/sword1/logic.cpp index 2fa108ebdd..8950986b09 100644 --- a/engines/sword1/logic.cpp +++ b/engines/sword1/logic.cpp @@ -55,9 +55,10 @@ namespace Sword1 { uint32 Logic::_scriptVars[NUM_SCRIPT_VARS]; -Logic::Logic(ObjectMan *pObjMan, ResMan *resMan, Screen *pScreen, Mouse *pMouse, Sound *pSound, Music *pMusic, Menu *pMenu, OSystem *system, Audio::Mixer *mixer) { +Logic::Logic(SwordEngine *vm, ObjectMan *pObjMan, ResMan *resMan, Screen *pScreen, Mouse *pMouse, Sound *pSound, Music *pMusic, Menu *pMenu, OSystem *system, Audio::Mixer *mixer) { g_system->getEventManager()->registerRandomSource(_rnd, "sword1"); + _vm = vm; _objMan = pObjMan; _resMan = resMan; _screen = pScreen; @@ -963,7 +964,7 @@ int Logic::fnPlaySequence(Object *cpt, int32 id, int32 sequenceId, int32 d, int3 CreditsPlayer player(_system, _mixer); player.play(); } else { - MoviePlayer *player = makeMoviePlayer(sequenceId, _screen, _textMan, _mixer, _system); + MoviePlayer *player = makeMoviePlayer(sequenceId, _vm, _screen, _textMan, _mixer, _system); if (player) { if (player->load(sequenceId)) player->play(); diff --git a/engines/sword1/logic.h b/engines/sword1/logic.h index 8e2f24ac83..6e3f08c4af 100644 --- a/engines/sword1/logic.h +++ b/engines/sword1/logic.h @@ -37,6 +37,7 @@ namespace Sword1 { #define NON_ZERO_SCRIPT_VARS 95 #define NUM_SCRIPT_VARS 1179 +class SwordEngine; class Text; class Sound; class EventManager; @@ -51,7 +52,7 @@ typedef int (Logic::*BSMcodeTable)(Object *, int32, int32, int32, int32, int32, class Logic { public: - Logic(ObjectMan *pObjMan, ResMan *resMan, Screen *pScreen, Mouse *pMouse, Sound *pSound, Music *pMusic, Menu *pMenu, OSystem *system, Audio::Mixer *mixer); + Logic(SwordEngine *vm, ObjectMan *pObjMan, ResMan *resMan, Screen *pScreen, Mouse *pMouse, Sound *pSound, Music *pMusic, Menu *pMenu, OSystem *system, Audio::Mixer *mixer); ~Logic(void); void initialize(void); void newScreen(uint32 screen); @@ -64,6 +65,7 @@ public: // public for mouse (menu looking) int cfnPresetScript (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x); private: + SwordEngine *_vm; ObjectMan *_objMan; OSystem *_system; Audio::Mixer *_mixer; diff --git a/engines/sword1/sword1.cpp b/engines/sword1/sword1.cpp index 9b79f59a32..4b402ffe97 100644 --- a/engines/sword1/sword1.cpp +++ b/engines/sword1/sword1.cpp @@ -143,7 +143,7 @@ void Sword1CheckDirectory(const Common::FSList &fslist, bool *filesFound) { for (int cnt = 0; cnt < ARRAYSIZE(g_dirNames); cnt++) if (scumm_stricmp(file->getName().c_str(), g_dirNames[cnt]) == 0) { Common::FSList fslist2; - if (file->getChildren(fslist2, Common::FilesystemNode::kListFilesOnly)) + if (file->getChildren(fslist2, Common::FSNode::kListFilesOnly)) Sword1CheckDirectory(fslist2, filesFound); } } @@ -303,7 +303,7 @@ int SwordEngine::init() { _music = new Music(_mixer); _sound = new Sound("", _mixer, _resMan); _menu = new Menu(_screen, _mouse); - _logic = new Logic(_objectMan, _resMan, _screen, _mouse, _sound, _music, _menu, _system, _mixer); + _logic = new Logic(this, _objectMan, _resMan, _screen, _mouse, _sound, _music, _menu, _system, _mixer); _mouse->useLogicAndMenu(_logic, _menu); syncSoundSettings(); @@ -703,7 +703,7 @@ int SwordEngine::go() { _systemVars.controlPanelMode = CP_NEWGAME; if (_control->runPanel() == CONTROL_GAME_RESTORED) _control->doRestore(); - else if (!quit()) + else if (!shouldQuit()) _logic->startPositions(0); } else { // no savegames, start new game. @@ -712,10 +712,10 @@ int SwordEngine::go() { } _systemVars.controlPanelMode = CP_NORMAL; - while (!quit()) { + while (!shouldQuit()) { uint8 action = mainLoop(); - if (!quit()) { + if (!shouldQuit()) { // the mainloop was left, we have to reinitialize. reinitialize(); if (action == CONTROL_GAME_RESTORED) @@ -756,7 +756,7 @@ uint8 SwordEngine::mainLoop(void) { uint8 retCode = 0; _keyPressed.reset(); - while ((retCode == 0) && (!quit())) { + while ((retCode == 0) && (!shouldQuit())) { // do we need the section45-hack from sword.c here? checkCd(); @@ -805,9 +805,9 @@ uint8 SwordEngine::mainLoop(void) { } _mouseState = 0; _keyPressed.reset(); - } while ((Logic::_scriptVars[SCREEN] == Logic::_scriptVars[NEW_SCREEN]) && (retCode == 0) && (!quit())); + } while ((Logic::_scriptVars[SCREEN] == Logic::_scriptVars[NEW_SCREEN]) && (retCode == 0) && (!shouldQuit())); - if ((retCode == 0) && (Logic::_scriptVars[SCREEN] != 53) && _systemVars.wantFade && (!quit())) { + if ((retCode == 0) && (Logic::_scriptVars[SCREEN] != 53) && _systemVars.wantFade && (!shouldQuit())) { _screen->fadeDownPalette(); int32 relDelay = (int32)_system->getMillis(); while (_screen->stillFading()) { diff --git a/engines/sword2/animation.cpp b/engines/sword2/animation.cpp index 76f14851e7..fb5642a816 100644 --- a/engines/sword2/animation.cpp +++ b/engines/sword2/animation.cpp @@ -379,7 +379,7 @@ void MoviePlayer::play(SequenceTextInfo *textList, uint32 numLines, int32 leadIn bool startNextText = false; // This happens if the user quits during the "eye" cutscene. - if (_vm->quit()) + if (_vm->shouldQuit()) return; _numSpeechLines = numLines; diff --git a/engines/sword2/controls.cpp b/engines/sword2/controls.cpp index dcacbc78d4..2596fe594e 100644 --- a/engines/sword2/controls.cpp +++ b/engines/sword2/controls.cpp @@ -396,7 +396,7 @@ int Dialog::runModal() { _vm->_system->delayMillis(20); - if (_vm->quit()) + if (_vm->shouldQuit()) setResult(0); } @@ -842,7 +842,7 @@ int StartDialog::runModal() { if (startDialog.runModal()) return 1; - if (_vm->quit()) + if (_vm->shouldQuit()) return 0; RestoreDialog restoreDialog(_vm); @@ -850,7 +850,7 @@ int StartDialog::runModal() { if (restoreDialog.runModal()) return 0; - if (_vm->quit()) + if (_vm->shouldQuit()) return 0; } diff --git a/engines/sword2/palette.cpp b/engines/sword2/palette.cpp index b66a3c9a81..b020359e36 100644 --- a/engines/sword2/palette.cpp +++ b/engines/sword2/palette.cpp @@ -212,7 +212,7 @@ uint8 Screen::getFadeStatus() { } void Screen::waitForFade() { - while (getFadeStatus() != RDFADE_NONE && getFadeStatus() != RDFADE_BLACK && !_vm->quit()) { + while (getFadeStatus() != RDFADE_NONE && getFadeStatus() != RDFADE_BLACK && !_vm->shouldQuit()) { updateDisplay(); _vm->_system->delayMillis(20); } diff --git a/engines/sword2/resman.cpp b/engines/sword2/resman.cpp index 326f90cd82..a30c6301cc 100644 --- a/engines/sword2/resman.cpp +++ b/engines/sword2/resman.cpp @@ -106,7 +106,7 @@ bool ResourceManager::init() { Common::File file; if (!file.open("resource.inf")) { - _vm->GUIErrorMessage("Broken Sword 2: Cannot open resource.inf"); + GUIErrorMessage("Broken Sword 2: Cannot open resource.inf"); return false; } @@ -117,7 +117,7 @@ bool ResourceManager::init() { _resFiles[_totalClusters].numEntries = -1; _resFiles[_totalClusters].entryTab = NULL; if (++_totalClusters >= MAX_res_files) { - _vm->GUIErrorMessage("Broken Sword 2: Too many entries in resource.inf"); + GUIErrorMessage("Broken Sword 2: Too many entries in resource.inf"); return false; } } @@ -126,7 +126,7 @@ bool ResourceManager::init() { // Now load in the binary id to res conversion table if (!file.open("resource.tab")) { - _vm->GUIErrorMessage("Broken Sword 2: Cannot open resource.tab"); + GUIErrorMessage("Broken Sword 2: Cannot open resource.tab"); return false; } @@ -143,14 +143,14 @@ bool ResourceManager::init() { if (file.ioFailed()) { file.close(); - _vm->GUIErrorMessage("Broken Sword 2: Cannot read resource.tab"); + GUIErrorMessage("Broken Sword 2: Cannot read resource.tab"); return false; } file.close(); if (!file.open("cd.inf")) { - _vm->GUIErrorMessage("Broken Sword 2: Cannot open cd.inf"); + GUIErrorMessage("Broken Sword 2: Cannot open cd.inf"); return false; } @@ -164,7 +164,7 @@ bool ResourceManager::init() { if (file.ioFailed()) { delete cdInf; file.close(); - _vm->GUIErrorMessage("Broken Sword 2: Cannot read cd.inf"); + GUIErrorMessage("Broken Sword 2: Cannot read cd.inf"); return false; } @@ -190,7 +190,7 @@ bool ResourceManager::init() { // the resource manager will print a fatal error. if (cdInf[i].cd == 0 && !Common::File::exists((char *)cdInf[i].clusterName)) { - _vm->GUIErrorMessage("Broken Sword 2: Cannot find " + Common::String((char *)cdInf[i].clusterName)); + GUIErrorMessage("Broken Sword 2: Cannot find " + Common::String((char *)cdInf[i].clusterName)); delete[] cdInf; return false; } @@ -206,7 +206,7 @@ bool ResourceManager::init() { if (j == _totalClusters) { delete[] cdInf; - _vm->GUIErrorMessage(Common::String(_resFiles[i].fileName) + " is not in cd.inf"); + GUIErrorMessage(Common::String(_resFiles[i].fileName) + " is not in cd.inf"); return false; } @@ -412,7 +412,7 @@ Common::File *ResourceManager::openCluFile(uint16 fileNum) { // quit while the game is asking for the user to insert a CD. // But recovering from this situation gracefully is just too // much trouble, so quit now. - if (_vm->quit()) + if (_vm->shouldQuit()) g_system->quit(); // If the file is supposed to be on hard disk, or we're diff --git a/engines/sword2/screen.cpp b/engines/sword2/screen.cpp index 1faef01939..8319a6731a 100644 --- a/engines/sword2/screen.cpp +++ b/engines/sword2/screen.cpp @@ -389,7 +389,7 @@ void Screen::displayMsg(byte *text, int time) { uint32 targetTime = _vm->getMillis() + (time * 1000); _vm->sleepUntil(targetTime); } else { - while (!_vm->quit()) { + while (!_vm->shouldQuit()) { MouseEvent *me = _vm->mouseEvent(); if (me && (me->buttons & (RD_LEFTBUTTONDOWN | RD_RIGHTBUTTONDOWN))) break; @@ -1035,7 +1035,7 @@ void Screen::rollCredits() { uint32 musicLength = MAX((int32)(1000 * (_vm->_sound->musicTimeRemaining() - 3)), 25 * (int32)scrollSteps); - while (scrollPos < scrollSteps && !_vm->quit()) { + while (scrollPos < scrollSteps && !_vm->shouldQuit()) { clearScene(); for (i = startLine; i < lineCount; i++) { @@ -1123,13 +1123,13 @@ void Screen::rollCredits() { // The music should either have stopped or be about to stop, so // wait for it to really happen. - while (_vm->_sound->musicTimeRemaining() && !_vm->quit()) { + while (_vm->_sound->musicTimeRemaining() && !_vm->shouldQuit()) { updateDisplay(false); _vm->_system->delayMillis(100); } } - if (_vm->quit()) + if (_vm->shouldQuit()) return; waitForFade(); diff --git a/engines/sword2/sword2.cpp b/engines/sword2/sword2.cpp index dc884eaacb..73e7c49a0d 100644 --- a/engines/sword2/sword2.cpp +++ b/engines/sword2/sword2.cpp @@ -152,7 +152,7 @@ GameList Sword2MetaEngine::detectGames(const Common::FSList &fslist) const { if (0 == scumm_stricmp("clusters", fileName)) { Common::FSList recList; - if (file->getChildren(recList, Common::FilesystemNode::kListAll)) { + if (file->getChildren(recList, Common::FSNode::kListAll)) { GameList recGames(detectGames(recList)); if (!recGames.empty()) { detectedGames.push_back(recGames); @@ -212,8 +212,8 @@ PluginError Sword2MetaEngine::createInstance(OSystem *syst, Engine **engine) con assert(engine); Common::FSList fslist; - Common::FilesystemNode dir(ConfMan.get("path")); - if (!dir.getChildren(fslist, Common::FilesystemNode::kListAll)) { + Common::FSNode dir(ConfMan.get("path")); + if (!dir.getChildren(fslist, Common::FSNode::kListAll)) { return kInvalidPathError; } @@ -421,7 +421,7 @@ int Sword2Engine::init() { // player will kill the music for us. Otherwise, the restore // will either have killed the music, or done a crossfade. - if (quit()) + if (shouldQuit()) return 0; if (result) @@ -493,7 +493,7 @@ int Sword2Engine::go() { // because we want the break to happen before updating the // screen again. - if (quit()) + if (shouldQuit()) break; // creates the debug text blocks diff --git a/engines/tinsel/tinsel.cpp b/engines/tinsel/tinsel.cpp index 7fb949704a..1ac36efb13 100644 --- a/engines/tinsel/tinsel.cpp +++ b/engines/tinsel/tinsel.cpp @@ -740,7 +740,7 @@ int TinselEngine::go() { // Foreground loop - while (!quit()) { + while (!shouldQuit()) { assert(_console); if (_console->isAttached()) _console->onFrame(); diff --git a/engines/touche/menu.cpp b/engines/touche/menu.cpp index 82490fca38..9da76dadde 100644 --- a/engines/touche/menu.cpp +++ b/engines/touche/menu.cpp @@ -433,7 +433,7 @@ void ToucheEngine::handleOptions(int forceDisplay) { _system->delayMillis(10); } _fullRedrawCounter = 2; - if (!menuData.exit && quit()) { + if (!menuData.exit && shouldQuit()) { if (displayQuitDialog()) quitGame(); } diff --git a/engines/touche/touche.cpp b/engines/touche/touche.cpp index e122187dcd..26170e2734 100644 --- a/engines/touche/touche.cpp +++ b/engines/touche/touche.cpp @@ -268,7 +268,7 @@ void ToucheEngine::mainLoop() { } uint32 frameTimeStamp = _system->getMillis(); - for (uint32 cycleCounter = 0; !quit(); ++cycleCounter) { + for (uint32 cycleCounter = 0; !shouldQuit(); ++cycleCounter) { if ((cycleCounter % 3) == 0) { runCycle(); } @@ -1837,7 +1837,7 @@ int ToucheEngine::handleActionMenuUnderCursor(const int16 *actions, int offs, in _menuRedrawCounter = 2; Common::Rect rect(0, y, kScreenWidth, y + h); i = -1; - while (_inp_rightMouseButtonPressed && !quit()) { + while (_inp_rightMouseButtonPressed && !shouldQuit()) { Common::Point mousePos = getMousePos(); if (rect.contains(mousePos)) { int c = (mousePos.y - y) / kTextHeight; diff --git a/gui/browser.cpp b/gui/browser.cpp index 978187c17e..e417a03688 100644 --- a/gui/browser.cpp +++ b/gui/browser.cpp @@ -107,7 +107,7 @@ int BrowserDialog::runModal() { err = FSRefMakePath(&ref, (UInt8*)buf, sizeof(buf)-1); assert(err == noErr); - _choice = Common::FilesystemNode(buf); + _choice = Common::FSNode(buf); choiceMade = true; } @@ -160,9 +160,9 @@ BrowserDialog::BrowserDialog(const char *title, bool dirBrowser) void BrowserDialog::open() { if (ConfMan.hasKey("browser_lastpath")) - _node = Common::FilesystemNode(ConfMan.get("browser_lastpath")); + _node = Common::FSNode(ConfMan.get("browser_lastpath")); if (!_node.isDirectory()) - _node = Common::FilesystemNode("."); + _node = Common::FSNode("."); // Alway refresh file list updateListing(); @@ -227,9 +227,9 @@ void BrowserDialog::updateListing() { ConfMan.set("browser_lastpath", _node.getPath()); // Read in the data from the file system - Common::FilesystemNode::ListMode listMode = - _isDirBrowser ? Common::FilesystemNode::kListDirectoriesOnly - : Common::FilesystemNode::kListAll; + Common::FSNode::ListMode listMode = + _isDirBrowser ? Common::FSNode::kListDirectoriesOnly + : Common::FSNode::kListAll; if (!_node.getChildren(_nodeContent, listMode)) { _nodeContent.clear(); } else { diff --git a/gui/browser.h b/gui/browser.h index c8bdec26a2..8dc7eda43a 100644 --- a/gui/browser.h +++ b/gui/browser.h @@ -50,7 +50,7 @@ public: virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data); #endif - const Common::FilesystemNode &getResult() { return _choice; } + const Common::FSNode &getResult() { return _choice; } protected: #ifdef MACOSX @@ -58,10 +58,10 @@ protected: #else ListWidget *_fileList; StaticTextWidget *_currentPath; - Common::FilesystemNode _node; + Common::FSNode _node; Common::FSList _nodeContent; #endif - Common::FilesystemNode _choice; + Common::FSNode _choice; bool _isDirBrowser; #ifndef MACOSX diff --git a/gui/launcher.cpp b/gui/launcher.cpp index e9f718f4f0..c37a412440 100644 --- a/gui/launcher.cpp +++ b/gui/launcher.cpp @@ -395,7 +395,7 @@ void EditGameDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat if (browser.runModal() > 0) { // User made this choice... - Common::FilesystemNode file(browser.getResult()); + Common::FSNode file(browser.getResult()); _soundFont->setLabel(file.getPath()); if (!file.getPath().empty() && (file.getPath() != "None")) @@ -413,11 +413,11 @@ void EditGameDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat BrowserDialog browser("Select directory with game data", true); if (browser.runModal() > 0) { // User made his choice... - Common::FilesystemNode dir(browser.getResult()); + Common::FSNode dir(browser.getResult()); // TODO: Verify the game can be found in the new directory... Best // done with optional specific gameid to pluginmgr detectgames? - // FSList files = dir.listDir(FilesystemNode::kListFilesOnly); + // FSList files = dir.listDir(FSNode::kListFilesOnly); _gamePathWidget->setLabel(dir.getPath()); draw(); @@ -431,7 +431,7 @@ void EditGameDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat BrowserDialog browser("Select additional game directory", true); if (browser.runModal() > 0) { // User made his choice... - Common::FilesystemNode dir(browser.getResult()); + Common::FSNode dir(browser.getResult()); _extraPathWidget->setLabel(dir.getPath()); draw(); } @@ -443,7 +443,7 @@ void EditGameDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat BrowserDialog browser("Select directory for saved games", true); if (browser.runModal() > 0) { // User made his choice... - Common::FilesystemNode dir(browser.getResult()); + Common::FSNode dir(browser.getResult()); _savePathWidget->setLabel(dir.getPath()); draw(); } @@ -953,9 +953,9 @@ void LauncherDialog::addGame() { if (_browser->runModal() > 0) { // User made his choice... - Common::FilesystemNode dir(_browser->getResult()); + Common::FSNode dir(_browser->getResult()); Common::FSList files; - if (!dir.getChildren(files, Common::FilesystemNode::kListAll)) { + if (!dir.getChildren(files, Common::FSNode::kListAll)) { error("browser returned a node that is not a directory: '%s'", dir.getPath().c_str()); } diff --git a/gui/massadd.cpp b/gui/massadd.cpp index c34c190776..6d40c4e78b 100644 --- a/gui/massadd.cpp +++ b/gui/massadd.cpp @@ -58,7 +58,7 @@ enum { -MassAddDialog::MassAddDialog(const Common::FilesystemNode &startDir) +MassAddDialog::MassAddDialog(const Common::FSNode &startDir) : Dialog("massadddialog"), _dirsScanned(0), _okButton(0), @@ -156,10 +156,10 @@ void MassAddDialog::handleTickle() { // Perform a breadth-first scan of the filesystem. while (!_scanStack.empty() && (g_system->getMillis() - t) < kMaxScanTime) { - Common::FilesystemNode dir = _scanStack.pop(); + Common::FSNode dir = _scanStack.pop(); Common::FSList files; - if (!dir.getChildren(files, Common::FilesystemNode::kListAll)) { + if (!dir.getChildren(files, Common::FSNode::kListAll)) { error("browser returned a node that is not a directory: '%s'", dir.getPath().c_str()); } diff --git a/gui/massadd.h b/gui/massadd.h index 733559cf37..c2a0eff2ba 100644 --- a/gui/massadd.h +++ b/gui/massadd.h @@ -38,14 +38,14 @@ class StaticTextWidget; class MassAddDialog : public Dialog { public: - MassAddDialog(const Common::FilesystemNode &startDir); + MassAddDialog(const Common::FSNode &startDir); //void open(); void handleCommand(CommandSender *sender, uint32 cmd, uint32 data); void handleTickle(); private: - Common::Stack<Common::FilesystemNode> _scanStack; + Common::Stack<Common::FSNode> _scanStack; GameList _games; /** diff --git a/gui/options.cpp b/gui/options.cpp index 335d4bc3d0..6797e4a80c 100644 --- a/gui/options.cpp +++ b/gui/options.cpp @@ -835,7 +835,7 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3 BrowserDialog browser("Select directory for savegames", true); if (browser.runModal() > 0) { // User made his choice... - Common::FilesystemNode dir(browser.getResult()); + Common::FSNode dir(browser.getResult()); if (dir.isWritable()) { _savePath->setLabel(dir.getPath()); } else { @@ -851,7 +851,7 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3 BrowserDialog browser("Select directory for GUI themes", true); if (browser.runModal() > 0) { // User made his choice... - Common::FilesystemNode dir(browser.getResult()); + Common::FSNode dir(browser.getResult()); _themePath->setLabel(dir.getPath()); draw(); } @@ -861,7 +861,7 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3 BrowserDialog browser("Select directory for extra files", true); if (browser.runModal() > 0) { // User made his choice... - Common::FilesystemNode dir(browser.getResult()); + Common::FSNode dir(browser.getResult()); _extraPath->setLabel(dir.getPath()); draw(); } @@ -872,7 +872,7 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3 BrowserDialog browser("Select directory for plugins", true); if (browser.runModal() > 0) { // User made his choice... - Common::FilesystemNode dir(browser.getResult()); + Common::FSNode dir(browser.getResult()); _pluginsPath->setLabel(dir.getPath()); draw(); } @@ -883,7 +883,7 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3 BrowserDialog browser("Select SoundFont", false); if (browser.runModal() > 0) { // User made his choice... - Common::FilesystemNode file(browser.getResult()); + Common::FSNode file(browser.getResult()); _soundFont->setLabel(file.getPath()); if (!file.getPath().empty() && (file.getPath() != "None")) diff --git a/gui/theme.cpp b/gui/theme.cpp index 8928d2f467..39dedd3875 100644 --- a/gui/theme.cpp +++ b/gui/theme.cpp @@ -71,9 +71,10 @@ const Graphics::Font *Theme::loadFont(const char *filename) { #ifdef USE_ZLIB Common::ZipArchive zipArchive(_stylefile + ".zip"); - if (zipArchive.hasFile(cacheFilename)) { - Common::FilePtr stream(zipArchive.openFile(cacheFilename)); - font = Graphics::NewFont::loadFromCache(*stream.get()); + Common::SeekableReadStream *stream(zipArchive.openFile(cacheFilename)); + if (stream) { + font = Graphics::NewFont::loadFromCache(*stream); + delete stream; } #endif if (font) @@ -88,9 +89,10 @@ const Graphics::Font *Theme::loadFont(const char *filename) { #ifdef USE_ZLIB if (!font) { Common::ZipArchive zipArchive(_stylefile + ".zip"); - if (zipArchive.hasFile(filename)) { - Common::FilePtr stream(zipArchive.openFile(filename)); - font = Graphics::NewFont::loadFont(*stream.get()); + Common::SeekableReadStream *stream(zipArchive.openFile(filename)); + if (stream) { + font = Graphics::NewFont::loadFont(*stream); + delete stream; } } #endif @@ -139,10 +141,9 @@ bool Theme::loadConfigFile(const Common::String &stylefile) { #ifdef USE_ZLIB // Maybe find a nicer solution to this Common::ZipArchive zipArchive(stylefile + ".zip"); - if (zipArchive.hasFile(stylefile + ".ini")) { - Common::FilePtr stream(zipArchive.openFile(stylefile + ".ini")); - if (_configFile.loadFromStream(*stream.get())) - return true; + Common::File file; + if (file.open(stylefile + ".ini", zipArchive)) { + return _configFile.loadFromStream(file); } #endif diff --git a/gui/themebrowser.cpp b/gui/themebrowser.cpp index bf718d5e4a..2c1c542319 100644 --- a/gui/themebrowser.cpp +++ b/gui/themebrowser.cpp @@ -101,10 +101,10 @@ void ThemeBrowser::updateListing() { // files in other places are ignored in this dialog // TODO: let the user browse the complete FS too/only the FS? if (ConfMan.hasKey("themepath")) - addDir(_themes, ConfMan.get("themepath"), 0); + addDir(_themes, Common::FSNode(ConfMan.get("themepath")), 0); #ifdef DATA_PATH - addDir(_themes, DATA_PATH); + addDir(_themes, Common::FSNode(DATA_PATH)); #endif #ifdef MACOSX @@ -112,7 +112,7 @@ void ThemeBrowser::updateListing() { if (resourceUrl) { char buf[256]; if (CFURLGetFileSystemRepresentation(resourceUrl, true, (UInt8 *)buf, 256)) { - Common::String resourcePath = buf; + Common::FSNode resourcePath(buf); addDir(_themes, resourcePath, 0); } CFRelease(resourceUrl); @@ -120,9 +120,9 @@ void ThemeBrowser::updateListing() { #endif if (ConfMan.hasKey("extrapath")) - addDir(_themes, ConfMan.get("extrapath")); + addDir(_themes, Common::FSNode(ConfMan.get("extrapath"))); - addDir(_themes, ".", 0); + addDir(_themes, Common::FSNode("."), 0); // Populate the ListWidget Common::StringList list; @@ -137,22 +137,20 @@ void ThemeBrowser::updateListing() { draw(); } -void ThemeBrowser::addDir(ThList &list, const Common::String &dir, int level) { +void ThemeBrowser::addDir(ThList &list, const Common::FSNode &node, int level) { if (level < 0) return; - Common::FilesystemNode node(dir); - if (!node.exists() || !node.isReadable()) return; Common::FSList fslist; - if (!node.getChildren(fslist, Common::FilesystemNode::kListAll)) + if (!node.getChildren(fslist, Common::FSNode::kListAll)) return; for (Common::FSList::const_iterator i = fslist.begin(); i != fslist.end(); ++i) { if (i->isDirectory()) { - addDir(list, i->getPath(), level-1); + addDir(list, *i, level-1); } else { Entry th; if (isTheme(*i, th)) { @@ -171,15 +169,22 @@ void ThemeBrowser::addDir(ThList &list, const Common::String &dir, int level) { } } -bool ThemeBrowser::isTheme(const Common::FilesystemNode &node, Entry &out) { +bool ThemeBrowser::isTheme(const Common::FSNode &node, Entry &out) { Common::ConfigFile cfg; Common::String type; out.file = node.getName(); - for (int i = out.file.size()-1; out.file[i] != '.' && i > 0; --i) { + + // Only accept .ini and .zip fies + if (!out.file.hasSuffix(".ini") && !out.file.hasSuffix(".zip")) + return false; + + // Remove the filename extension + while (!out.file.empty() && out.file.lastChar() != '.') { out.file.deleteLastChar(); } - out.file.deleteLastChar(); + if (out.file.lastChar() == '.') + out.file.deleteLastChar(); if (out.file.empty()) return false; diff --git a/gui/themebrowser.h b/gui/themebrowser.h index e16a329c0e..509e9dc2eb 100644 --- a/gui/themebrowser.h +++ b/gui/themebrowser.h @@ -57,8 +57,8 @@ private: void updateListing(); - void addDir(ThList &list, const Common::String &dir, int level = 4); - bool isTheme(const Common::FilesystemNode &node, Entry &out); + void addDir(ThList &list, const Common::FSNode &node, int level = 4); + bool isTheme(const Common::FSNode &node, Entry &out); }; } // end of namespace GUI diff --git a/tools/scumm-md5.txt b/tools/scumm-md5.txt index 1196ef9cc8..f16ebe5b4b 100644 --- a/tools/scumm-md5.txt +++ b/tools/scumm-md5.txt @@ -89,8 +89,9 @@ maniac Maniac Mansion 40564ec47da48a67787d1f9bd043902a 1988 en DOS V2 Demo V2 Demo non-interactive Fingolfin zak Zak McKracken and the Alien Mindbenders - 55d3987641bf229c83bc729210173383 -1 en C64 V1 - - - 4973bbc3899e3826dbf316e1d7271ec7 -1 de C64 V1 - - + 55d3987641bf229c83bc729210173383 174848 en C64 V1 - - + 4973bbc3899e3826dbf316e1d7271ec7 196608 de C64 V1 - - + 7b60620558b8d6b7d7313b8ac7bb5a98 174848 it C64 V1 - - 7020931d5a2be0a49d68e7a1882363e4 1896 en DOS V1 V1 - Fingolfin b23f7cd7c304d7dff08e92a96120d5b4 -1 en DOS V1 V1 alt? Andrea Petrucci @@ -660,8 +661,8 @@ puttrace Putt-Putt Enters the Race 981e1e1891f2be7e25a01f50ae55a5af -1 us All HE 98 - - Kirben 1ed22f601f8b3695804a6583cc3083f1 -1 nl All HE 98.5 - - daniel9 33e989f85da700e2014d00f345cab3d7 -1 fr Windows HE 98.5 - - gist974 - 5719fc8a13b4638b78d9d8d12f091f94 -1 fr Windows HE 98.5 - - thyphoon b47be81e39a9710f6f595f7b527b60f8 -1 gb Windows HE 99 - - Reckless + 5719fc8a13b4638b78d9d8d12f091f94 -1 fr Windows HE 99 - - thyphoon 055ffe4f47753e47594ac67823220c54 -1 de All HE 99 - - Joachim Eberhard 62050da376483d8edcbd98cd26b6cb57 -1 ru Windows HE 99 - - sev |