[Scummvm-git-logs] scummvm master -> 0592520ddf2a83b0003ada8230b4f1b3a772bfe9
djsrv
dservilla at gmail.com
Fri Jul 16 20:22:06 UTC 2021
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
0592520ddf DIRECTOR: Test multiple possible paths for shared cast
Commit: 0592520ddf2a83b0003ada8230b4f1b3a772bfe9
https://github.com/scummvm/scummvm/commit/0592520ddf2a83b0003ada8230b4f1b3a772bfe9
Author: djsrv (dservilla at gmail.com)
Date: 2021-07-16T16:22:06-04:00
Commit Message:
DIRECTOR: Test multiple possible paths for shared cast
Changed paths:
engines/director/director.cpp
engines/director/director.h
engines/director/resource.cpp
engines/director/tests.cpp
engines/director/window.cpp
engines/director/window.h
diff --git a/engines/director/director.cpp b/engines/director/director.cpp
index 08d8fe1226..8017769a21 100644
--- a/engines/director/director.cpp
+++ b/engines/director/director.cpp
@@ -187,20 +187,6 @@ Common::Error DirectorEngine::run() {
if (getPlatform() == Common::kPlatformWindows)
_machineType = 256; // IBM PC-type machine
- if (getVersion() < 400) {
- if (getPlatform() == Common::kPlatformWindows) {
- _sharedCastFile = "SHARDCST.MMM";
- } else {
- _sharedCastFile = "Shared Cast";
- }
- } else if (getVersion() == 500) {
- if (getPlatform() == Common::kPlatformWindows) {
- _sharedCastFile = "SHARED.Cxt";
- }
- } else {
- _sharedCastFile = "Shared.dir";
- }
-
Common::Error err = _currentWindow->loadInitialMovie();
if (err.getCode() != Common::kNoError)
return err;
diff --git a/engines/director/director.h b/engines/director/director.h
index 542439ffd8..f73bd9c73f 100644
--- a/engines/director/director.h
+++ b/engines/director/director.h
@@ -248,7 +248,6 @@ public:
bool _centerStage;
Common::HashMap<Common::String, Archive *, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> _openResFiles;
- Common::String _sharedCastFile;
protected:
Common::Error run() override;
diff --git a/engines/director/resource.cpp b/engines/director/resource.cpp
index 635b8882e0..4289901226 100644
--- a/engines/director/resource.cpp
+++ b/engines/director/resource.cpp
@@ -71,8 +71,8 @@ Common::Error Window::loadInitialMovie() {
_currentMovie = new Movie(this);
_currentPath = getPath(movie, _currentPath);
- Common::String sharedCastPath = _currentPath + g_director->_sharedCastFile;
- if (sharedCastPath != movie)
+ Common::String sharedCastPath = getSharedCastPath();
+ if (!sharedCastPath.empty() && sharedCastPath != movie)
_currentMovie->loadSharedCastsFrom(sharedCastPath);
_currentMovie->setArchive(_mainArchive);
diff --git a/engines/director/tests.cpp b/engines/director/tests.cpp
index dde632f9c9..649655af42 100644
--- a/engines/director/tests.cpp
+++ b/engines/director/tests.cpp
@@ -160,8 +160,6 @@ Common::HashMap<Common::String, Movie *> *Window::scanMovies(const Common::Strin
debugC(2, kDebugLoading, "File: %s", i->getName().c_str());
if (Common::matchString(i->getName().c_str(), sharedMMMname, true)) {
- _vm->_sharedCastFile = i->getName();
-
debugC(2, kDebugLoading, "Shared cast detected: %s", i->getName().c_str());
continue;
}
diff --git a/engines/director/window.cpp b/engines/director/window.cpp
index fd2c704ebf..6ed60a1d52 100644
--- a/engines/director/window.cpp
+++ b/engines/director/window.cpp
@@ -480,14 +480,19 @@ bool Window::step() {
debug(0, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
g_lingo->resetLingo();
- if (sharedCast && sharedCast->_castArchive
- && sharedCast->_castArchive->getPathName().equalsIgnoreCase(_currentPath + _vm->_sharedCastFile)) {
- // if we are not deleting shared cast, then we need to clear those previous widget pointer
- sharedCast->releaseCastMemberWidget();
- _currentMovie->_sharedCast = sharedCast;
+ Common::String sharedCastPath = getSharedCastPath();
+ if (!sharedCastPath.empty()) {
+ if (sharedCast && sharedCast->_castArchive
+ && sharedCast->_castArchive->getPathName().equalsIgnoreCase(sharedCastPath)) {
+ // if we are not deleting shared cast, then we need to clear those previous widget pointer
+ sharedCast->releaseCastMemberWidget();
+ _currentMovie->_sharedCast = sharedCast;
+ } else {
+ delete sharedCast;
+ _currentMovie->loadSharedCastsFrom(sharedCastPath);
+ }
} else {
delete sharedCast;
- _currentMovie->loadSharedCastsFrom(_currentPath + _vm->_sharedCastFile);
}
_nextMovie.movie.clear();
@@ -541,4 +546,32 @@ bool Window::step() {
return false;
}
+Common::String Window::getSharedCastPath() {
+ Common::Array<Common::String> namesToTry;
+ if (_vm->getVersion() < 400) {
+ if (g_director->getPlatform() == Common::kPlatformWindows) {
+ namesToTry.push_back("SHARDCST.MMM");
+ } else {
+ namesToTry.push_back("Shared Cast");
+ }
+ } else if (_vm->getVersion() < 500) {
+ namesToTry.push_back("Shared.dir");
+ namesToTry.push_back("Shared.dxr");
+ } else {
+ // TODO: Does D5 actually support D4-style shared cast?
+ namesToTry.push_back("Shared.cst");
+ namesToTry.push_back("Shared.cxt");
+ }
+
+ for (uint i = 0; i < namesToTry.size(); i++) {
+ Common::File f;
+ if (f.open(_currentPath + namesToTry[i])) {
+ f.close();
+ return _currentPath + namesToTry[i];
+ }
+ }
+
+ return Common::String();
+}
+
} // End of namespace Director
diff --git a/engines/director/window.h b/engines/director/window.h
index 3d278aa2d5..c2a4266070 100644
--- a/engines/director/window.h
+++ b/engines/director/window.h
@@ -129,6 +129,8 @@ public:
bool step();
+ Common::String getSharedCastPath();
+
// events.cpp
virtual bool processEvent(Common::Event &event) override;
More information about the Scummvm-git-logs
mailing list