diff options
author | Sven Hesse | 2009-06-23 23:55:35 +0000 |
---|---|---|
committer | Sven Hesse | 2009-06-23 23:55:35 +0000 |
commit | 82f1ebcafed7e565ac4dce610f7bc098f45ee67d (patch) | |
tree | e90eb9b36ffdc1f699bafb3b52bf2793892f16f1 | |
parent | 04d4ce4a8be24bde70933c7e4a1dc41f374a75ad (diff) | |
download | scummvm-rg350-82f1ebcafed7e565ac4dce610f7bc098f45ee67d.tar.gz scummvm-rg350-82f1ebcafed7e565ac4dce610f7bc098f45ee67d.tar.bz2 scummvm-rg350-82f1ebcafed7e565ac4dce610f7bc098f45ee67d.zip |
Putting TOT filename generation and LOM checking into TOTFile
svn-id: r41822
-rw-r--r-- | engines/gob/script.cpp | 25 | ||||
-rw-r--r-- | engines/gob/script.h | 2 | ||||
-rw-r--r-- | engines/gob/totfile.cpp | 16 | ||||
-rw-r--r-- | engines/gob/totfile.h | 5 |
4 files changed, 25 insertions, 23 deletions
diff --git a/engines/gob/script.cpp b/engines/gob/script.cpp index c41da6cc2c..2cb719db26 100644 --- a/engines/gob/script.cpp +++ b/engines/gob/script.cpp @@ -319,33 +319,16 @@ char *Script::getResultStr() const { return _expression->getResultStr(); } -bool Script::load(const char *fileName) { +bool Script::load(const Common::String &fileName) { unload(); _finished = false; - bool lom = false; + bool isLOM; - Common::String *fileBase; + _totFile = TOTFile::createFileName(fileName, isLOM); - const char *dot; - if ((dot = strrchr(fileName, '.'))) { - // fileName includes an extension - - fileBase = new Common::String(fileName, dot); - - // Is it a LOM file? - if (!scumm_stricmp(dot + 1, "LOM")) - lom = true; - } else - fileBase = new Common::String(fileName); - - // If it's a LOM file, it includes the TOT file - _totFile = *fileBase + (lom ? ".lom" : ".tot"); - - delete fileBase; - - if (lom) { + if (isLOM) { if (!loadLOM(_totFile)) { unload(); return false; diff --git a/engines/gob/script.h b/engines/gob/script.h index 19fe2696ee..64a04503b1 100644 --- a/engines/gob/script.h +++ b/engines/gob/script.h @@ -99,7 +99,7 @@ public: byte *getData(); /** Load a script file. */ - bool load(const char *fileName); + bool load(const Common::String &fileName); /** Unload the script. */ void unload(); /** Was a script loaded? */ diff --git a/engines/gob/totfile.cpp b/engines/gob/totfile.cpp index b8882ba588..46d422d44d 100644 --- a/engines/gob/totfile.cpp +++ b/engines/gob/totfile.cpp @@ -98,4 +98,20 @@ bool TOTFile::getProperties(Properties &props) const { return true; } +Common::String TOTFile::createFileName(const Common::String &base, bool &isLOM) { + isLOM = false; + + const char *dot; + if ((dot = strrchr(base.c_str(), '.'))) { + // fileName includes an extension + + if (!scumm_stricmp(dot + 1, "LOM")) + isLOM = true; + + return base; + } + + return base + ".tot"; +} + } // End of namespace Gob diff --git a/engines/gob/totfile.h b/engines/gob/totfile.h index a79cb715cc..3a82706a7d 100644 --- a/engines/gob/totfile.h +++ b/engines/gob/totfile.h @@ -26,8 +26,9 @@ #ifndef GOB_TOTFILE_H #define GOB_TOTFILE_H +#include "common/str.h" + namespace Common { - class String; class SeekableReadStream; } @@ -62,6 +63,8 @@ public: Common::SeekableReadStream *getStream() const; bool getProperties(Properties &props) const; + static Common::String createFileName(const Common::String &base, bool &isLOM); + private: GobEngine *_vm; |