aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/gob/script.cpp25
-rw-r--r--engines/gob/script.h2
-rw-r--r--engines/gob/totfile.cpp16
-rw-r--r--engines/gob/totfile.h5
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;