aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorEugene Sandulenko2017-01-15 21:13:00 +0100
committerEugene Sandulenko2017-01-15 21:15:45 +0100
commit7b666dc1ca368f6323807be5efae31b689b6ca93 (patch)
tree8a4760bb03a0cc167791e8268c216c1b955e1875 /engines
parent5d22cc438f4a8182c66a534efa92eae40dab508a (diff)
downloadscummvm-rg350-7b666dc1ca368f6323807be5efae31b689b6ca93.tar.gz
scummvm-rg350-7b666dc1ca368f6323807be5efae31b689b6ca93.tar.bz2
scummvm-rg350-7b666dc1ca368f6323807be5efae31b689b6ca93.zip
DIRECTOR: Cleanup main movie loading
Diffstat (limited to 'engines')
-rw-r--r--engines/director/director.cpp2
-rw-r--r--engines/director/director.h7
-rw-r--r--engines/director/resource.cpp37
3 files changed, 26 insertions, 20 deletions
diff --git a/engines/director/director.cpp b/engines/director/director.cpp
index 5e523de11d..83708e0028 100644
--- a/engines/director/director.cpp
+++ b/engines/director/director.cpp
@@ -134,7 +134,7 @@ Common::Error DirectorEngine::run() {
loadSharedCastsFrom(_sharedCastFile);
- loadMainArchive();
+ loadInitialMovie(getEXEName());
_currentScore = new Score(this, _mainArchive);
debug(0, "Score name %s", _currentScore->getMacName().c_str());
diff --git a/engines/director/director.h b/engines/director/director.h
index f80329e5b4..a2cc1fa9db 100644
--- a/engines/director/director.h
+++ b/engines/director/director.h
@@ -86,7 +86,8 @@ public:
void loadPatterns();
Graphics::MacPatterns &getPatterns();
- void loadMainArchive();
+ void loadInitialMovie(const Common::String movie);
+ Archive *openMainArchive(const Common::String movie);
Archive *createArchive();
void cleanupMainArchive();
@@ -114,13 +115,13 @@ private:
const DirectorGameDescription *_gameDescription;
Common::HashMap<Common::String, Score *> *scanMovies(const Common::String &folder);
- void loadEXE();
+ void loadEXE(const Common::String movie);
void loadEXEv3(Common::SeekableReadStream *stream);
void loadEXEv4(Common::SeekableReadStream *stream);
void loadEXEv5(Common::SeekableReadStream *stream);
void loadEXEv7(Common::SeekableReadStream *stream);
void loadEXERIFX(Common::SeekableReadStream *stream, uint32 offset);
- void loadMac();
+ void loadMac(const Common::String movie);
Common::HashMap<int, Cast *> *_sharedCasts;
Common::HashMap<int, Common::SeekableSubReadStreamEndian *> *_sharedDIB;
diff --git a/engines/director/resource.cpp b/engines/director/resource.cpp
index f43118d10b..ae2eae844f 100644
--- a/engines/director/resource.cpp
+++ b/engines/director/resource.cpp
@@ -39,11 +39,22 @@ Archive *DirectorEngine::createArchive() {
}
}
-void DirectorEngine::loadMainArchive() {
+void DirectorEngine::loadInitialMovie(const Common::String movie) {
if (getPlatform() == Common::kPlatformWindows)
- loadEXE();
+ loadEXE(movie);
else
- loadMac();
+ loadMac(movie);
+}
+
+Archive *DirectorEngine::openMainArchive(const Common::String movie) {
+ delete _mainArchive;
+
+ _mainArchive = createArchive();
+
+ if (!_mainArchive->openFile(movie))
+ error("Could not open '%s'", movie.c_str());
+
+ return _mainArchive;
}
void DirectorEngine::cleanupMainArchive() {
@@ -51,8 +62,8 @@ void DirectorEngine::cleanupMainArchive() {
delete _macBinary;
}
-void DirectorEngine::loadEXE() {
- Common::SeekableReadStream *exeStream = SearchMan.createReadStreamForMember(getEXEName());
+void DirectorEngine::loadEXE(const Common::String movie) {
+ Common::SeekableReadStream *exeStream = SearchMan.createReadStreamForMember(movie);
if (!exeStream)
error("Failed to open EXE '%s'", getEXEName().c_str());
@@ -93,10 +104,7 @@ void DirectorEngine::loadEXEv3(Common::SeekableReadStream *stream) {
debugC(1, kDebugLoading, "Main MMM: '%s'", mmmFileName.c_str());
debugC(1, kDebugLoading, "Directory Name: '%s'", directoryName.c_str());
- _mainArchive = new RIFFArchive();
-
- if (!_mainArchive->openFile(mmmFileName))
- error("Could not open '%s'", mmmFileName.c_str());
+ openMainArchive(mmmFileName);
delete stream;
}
@@ -154,19 +162,16 @@ void DirectorEngine::loadEXERIFX(Common::SeekableReadStream *stream, uint32 offs
error("Failed to load RIFX from EXE");
}
-void DirectorEngine::loadMac() {
+void DirectorEngine::loadMac(const Common::String movie) {
if (getVersion() < 4) {
// The data is part of the resource fork of the executable
- _mainArchive = new MacArchive();
-
- if (!_mainArchive->openFile(getEXEName()))
- error("Failed to open Mac binary '%s'", getEXEName().c_str());
+ openMainArchive(movie);
} else {
// The RIFX is located in the data fork of the executable
_macBinary = new Common::MacResManager();
- if (!_macBinary->open(getEXEName()) || !_macBinary->hasDataFork())
- error("Failed to open Mac binary '%s'", getEXEName().c_str());
+ if (!_macBinary->open(movie) || !_macBinary->hasDataFork())
+ error("Failed to open Mac binary '%s'", movie.c_str());
Common::SeekableReadStream *dataFork = _macBinary->getDataFork();
_mainArchive = new RIFXArchive();