[Scummvm-git-logs] scummvm master -> edfd14f805bb3f29d842c5e063a5060db930ebf2

sev- sev at scummvm.org
Thu Feb 20 22:01:28 UTC 2020


This automated email contains information about 6 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
e4d05b5323 DIRECTOR: Safety check for palette size
f5c899aae6 DIRECTOR: Improved debug output
3c454eb282 DIRECTOR: Read start movie name from Mac Projector file
0a04aac01e DIRECTOR: Convert paths loaded from projector file
21615c9e50 DIRECTOR: Try to decrease depth level when opening director files
edfd14f805 DIRECTOR: Generalized path conversion


Commit: e4d05b53239d23800399a85170b16f40c04a074f
    https://github.com/scummvm/scummvm/commit/e4d05b53239d23800399a85170b16f40c04a074f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-02-20T22:56:21+01:00

Commit Message:
DIRECTOR: Safety check for palette size

Changed paths:
    engines/director/score.cpp


diff --git a/engines/director/score.cpp b/engines/director/score.cpp
index 04ffc05..ab5585e 100644
--- a/engines/director/score.cpp
+++ b/engines/director/score.cpp
@@ -391,9 +391,15 @@ Score::~Score() {
 void Score::loadPalette(Common::SeekableSubReadStreamEndian &stream) {
 	uint16 steps = stream.size() / 6;
 	uint16 index = (steps * 3) - 1;
-	uint16 _paletteColorCount = steps;
 	byte *_palette = new byte[index + 1];
 
+	debugC(3, kDebugLoading, "Score::loadPalette(): %d steps, %d bytes", steps, stream.size());
+
+	if (steps > 256) {
+		warning("Score::loadPalette(): steps > 256: %d", steps);
+		steps = 256;
+	}
+
 	for (int i = 0; i < steps; i++) {
 		_palette[index - 2] = stream.readByte();
 		stream.readByte();
@@ -405,7 +411,7 @@ void Score::loadPalette(Common::SeekableSubReadStreamEndian &stream) {
 		stream.readByte();
 		index -= 3;
 	}
-	_vm->setPalette(_palette, _paletteColorCount);
+	_vm->setPalette(_palette, steps);
 }
 
 void Score::loadFrames(Common::SeekableSubReadStreamEndian &stream) {


Commit: f5c899aae6aa8b9f5b1254d80dac12546ace8d02
    https://github.com/scummvm/scummvm/commit/f5c899aae6aa8b9f5b1254d80dac12546ace8d02
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-02-20T22:56:21+01:00

Commit Message:
DIRECTOR: Improved debug output

Changed paths:
    engines/director/score.cpp


diff --git a/engines/director/score.cpp b/engines/director/score.cpp
index ab5585e..9a17267 100644
--- a/engines/director/score.cpp
+++ b/engines/director/score.cpp
@@ -130,7 +130,7 @@ void Score::loadArchive() {
 	} else {
 		Common::SeekableSubReadStreamEndian *pal = _movieArchive->getResource(MKTAG('C', 'L', 'U', 'T'), clutList[0]);
 
-		debugC(2, kDebugLoading, "****** Loading Palette CLUT");
+		debugC(2, kDebugLoading, "****** Loading Palette CLUT, #%d", clutList[0]);
 		loadPalette(*pal);
 	}
 


Commit: 3c454eb28203cb9639017f6637dc7fa4565e472c
    https://github.com/scummvm/scummvm/commit/3c454eb28203cb9639017f6637dc7fa4565e472c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-02-20T22:56:21+01:00

Commit Message:
DIRECTOR: Read start movie name from Mac Projector file

Changed paths:
    engines/director/director.cpp


diff --git a/engines/director/director.cpp b/engines/director/director.cpp
index 02f8e51..6a873ac 100644
--- a/engines/director/director.cpp
+++ b/engines/director/director.cpp
@@ -23,6 +23,7 @@
 #include "common/config-manager.h"
 #include "common/debug-channels.h"
 #include "common/error.h"
+#include "common/substream.h"
 
 #include "audio/mixer.h"
 
@@ -182,6 +183,33 @@ Common::Error DirectorEngine::run() {
 		loadInitialMovie(_nextMovie.movie);
 	} else {
 		loadInitialMovie(getEXEName());
+
+		// Let's check if it is a projector file
+		// So far tested with Spaceship Warlock, D2
+		if (_mainArchive->hasResource(MKTAG('B', 'N', 'D', 'L'), "Projector")) {
+			warning("Detected Projector file");
+
+			if (_mainArchive->hasResource(MKTAG('S', 'T', 'R', '#'), 0)) {
+				_currentScore->setArchive(_mainArchive);
+
+				Common::SeekableSubReadStreamEndian *name = _mainArchive->getResource(MKTAG('S', 'T', 'R', '#'), 0);
+				int num = name->readUint16();
+				if (num != 1) {
+					warning("Incorrect number of strings in Projector file");
+				}
+
+				if (num == 0)
+					error("No strings in Projector file");
+
+				_nextMovie.movie = name->readPascalString();
+				warning("Replaced score name with: %s", _nextMovie.movie.c_str());
+
+				delete _currentScore;
+				_currentScore = nullptr;
+
+				delete name;
+			}
+		}
 	}
 
 	if (_currentScore)


Commit: 0a04aac01eb2e2628fb9defbd21f08c165497406
    https://github.com/scummvm/scummvm/commit/0a04aac01eb2e2628fb9defbd21f08c165497406
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-02-20T22:56:21+01:00

Commit Message:
DIRECTOR: Convert paths loaded from projector file

Changed paths:
    engines/director/director.cpp


diff --git a/engines/director/director.cpp b/engines/director/director.cpp
index 6a873ac..556c992 100644
--- a/engines/director/director.cpp
+++ b/engines/director/director.cpp
@@ -201,8 +201,9 @@ Common::Error DirectorEngine::run() {
 				if (num == 0)
 					error("No strings in Projector file");
 
-				_nextMovie.movie = name->readPascalString();
-				warning("Replaced score name with: %s", _nextMovie.movie.c_str());
+				Common::String sname = ":" + name->readPascalString();
+				_nextMovie.movie = convertPath(sname);
+				warning("Replaced score name with: %s (from %s)", _nextMovie.movie.c_str(), sname.c_str());
 
 				delete _currentScore;
 				_currentScore = nullptr;


Commit: 21615c9e50e06e3f0f8c5cacf5772e435cb6bf10
    https://github.com/scummvm/scummvm/commit/21615c9e50e06e3f0f8c5cacf5772e435cb6bf10
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-02-20T22:56:21+01:00

Commit Message:
DIRECTOR: Try to decrease depth level when opening director files

Changed paths:
    engines/director/archive.cpp


diff --git a/engines/director/archive.cpp b/engines/director/archive.cpp
index 3f0591a..1d15d17 100644
--- a/engines/director/archive.cpp
+++ b/engines/director/archive.cpp
@@ -43,13 +43,30 @@ Archive::~Archive() {
 
 bool Archive::openFile(const Common::String &fileName) {
 	Common::File *file = new Common::File();
+	Common::String fName = fileName;
 
-	if (!file->open(fileName)) {
-		delete file;
-		return false;
+	if (!file->open(fName)) {
+		bool opened = false;
+		// Try to drop components
+		while (fName.contains('/')) {
+			int pos = fName.find('/');
+			fName = Common::String(&fName.c_str()[pos + 1]);
+
+			if (!file->open(fName))
+				continue;
+
+			warning("Archive::openFile(): Path converted %s -> %s", fileName.c_str(), fName.c_str());
+
+			opened = true;
+		}
+
+		if (!opened) {
+			delete file;
+			return false;
+		}
 	}
 
-	_fileName = fileName;
+	_fileName = fName;
 
 	if (!openStream(file)) {
 		close();
@@ -209,7 +226,31 @@ bool MacArchive::openFile(const Common::String &fileName) {
 
 	_resFork = new Common::MacResManager();
 
-	if (!_resFork->open(fileName) || !_resFork->hasResFork()) {
+	Common::String fName = fileName;
+
+	if (!_resFork->open(fName)) {
+		// Try to drop components
+		bool opened = false;
+		while (fName.contains('/')) {
+			int pos = fName.find('/');
+			fName = Common::String(&fName.c_str()[pos + 1]);
+
+			warning("Trying %s", fName.c_str());
+
+			if (!_resFork->open(fName))
+				continue;
+
+			warning("MacArchive::openFile(): Path converted %s -> %s", fileName.c_str(), fName.c_str());
+			opened = true;
+		}
+
+		if (!opened) {
+			close();
+			return false;
+		}
+	}
+
+	if (!_resFork->hasResFork()) {
 		close();
 		return false;
 	}


Commit: edfd14f805bb3f29d842c5e063a5060db930ebf2
    https://github.com/scummvm/scummvm/commit/edfd14f805bb3f29d842c5e063a5060db930ebf2
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-02-20T22:56:21+01:00

Commit Message:
DIRECTOR: Generalized path conversion

Changed paths:
    engines/director/archive.cpp
    engines/director/director.cpp
    engines/director/lingo/lingo-funcs.cpp
    engines/director/util.cpp
    engines/director/util.h


diff --git a/engines/director/archive.cpp b/engines/director/archive.cpp
index 1d15d17..659d743 100644
--- a/engines/director/archive.cpp
+++ b/engines/director/archive.cpp
@@ -43,30 +43,13 @@ Archive::~Archive() {
 
 bool Archive::openFile(const Common::String &fileName) {
 	Common::File *file = new Common::File();
-	Common::String fName = fileName;
-
-	if (!file->open(fName)) {
-		bool opened = false;
-		// Try to drop components
-		while (fName.contains('/')) {
-			int pos = fName.find('/');
-			fName = Common::String(&fName.c_str()[pos + 1]);
-
-			if (!file->open(fName))
-				continue;
-
-			warning("Archive::openFile(): Path converted %s -> %s", fileName.c_str(), fName.c_str());
 
-			opened = true;
-		}
-
-		if (!opened) {
-			delete file;
-			return false;
-		}
+	if (!file->open(fileName)) {
+		delete file;
+		return false;
 	}
 
-	_fileName = fName;
+	_fileName = fileName;
 
 	if (!openStream(file)) {
 		close();
@@ -228,29 +211,7 @@ bool MacArchive::openFile(const Common::String &fileName) {
 
 	Common::String fName = fileName;
 
-	if (!_resFork->open(fName)) {
-		// Try to drop components
-		bool opened = false;
-		while (fName.contains('/')) {
-			int pos = fName.find('/');
-			fName = Common::String(&fName.c_str()[pos + 1]);
-
-			warning("Trying %s", fName.c_str());
-
-			if (!_resFork->open(fName))
-				continue;
-
-			warning("MacArchive::openFile(): Path converted %s -> %s", fileName.c_str(), fName.c_str());
-			opened = true;
-		}
-
-		if (!opened) {
-			close();
-			return false;
-		}
-	}
-
-	if (!_resFork->hasResFork()) {
+	if (!_resFork->open(fName) || !_resFork->hasResFork()) {
 		close();
 		return false;
 	}
diff --git a/engines/director/director.cpp b/engines/director/director.cpp
index 556c992..5f37776 100644
--- a/engines/director/director.cpp
+++ b/engines/director/director.cpp
@@ -201,8 +201,12 @@ Common::Error DirectorEngine::run() {
 				if (num == 0)
 					error("No strings in Projector file");
 
-				Common::String sname = ":" + name->readPascalString();
-				_nextMovie.movie = convertPath(sname);
+				Common::String sname = name->readPascalString();
+
+				if (!sname.hasPrefix(":"))
+					sname = ":" + sname;
+
+				_nextMovie.movie = pathMakeRelative(sname);
 				warning("Replaced score name with: %s (from %s)", _nextMovie.movie.c_str(), sname.c_str());
 
 				delete _currentScore;
diff --git a/engines/director/lingo/lingo-funcs.cpp b/engines/director/lingo/lingo-funcs.cpp
index 5253c57..07dd652 100644
--- a/engines/director/lingo/lingo-funcs.cpp
+++ b/engines/director/lingo/lingo-funcs.cpp
@@ -183,7 +183,7 @@ void Lingo::func_goto(Datum &frame, Datum &movie) {
 	if (movie.type != VOID) {
 		movie.toString();
 
-		Common::String movieFilename = Common::normalizePath(g_director->getCurrentPath() + convertPath(*movie.u.s), '/');
+		Common::String movieFilename = pathMakeRelative(*movie.u.s);
 		Common::String cleanedFilename;
 
 		bool fileExists = false;
diff --git a/engines/director/util.cpp b/engines/director/util.cpp
index f3db3ff..6d129f6 100644
--- a/engines/director/util.cpp
+++ b/engines/director/util.cpp
@@ -20,9 +20,11 @@
  *
  */
 
+#include "common/file.h"
 #include "common/str.h"
 #include "common/textconsole.h"
 
+#include "director/director.h"
 #include "director/util.h"
 
 namespace Director {
@@ -151,4 +153,39 @@ Common::String getPath(Common::String path, Common::String cwd) {
 	return cwd; // The path is not altered
 }
 
+Common::String pathMakeRelative(Common::String path) {
+	warning("path: %s", path.c_str());
+	Common::String initialPath = Common::normalizePath(g_director->getCurrentPath() + convertPath(path), '/');
+	Common::File f;
+	Common::String convPath = initialPath;
+
+	if (f.open(initialPath))
+		return initialPath;
+
+	// Now try to search the file
+	bool opened = false;
+	while (convPath.contains('/')) {
+		int pos = convPath.find('/');
+		convPath = Common::String(&convPath.c_str()[pos + 1]);
+
+		warning("Trying %s", convPath.c_str());
+
+		if (!f.open(convPath))
+			continue;
+
+		warning("pathMakeRelative(): Path converted %s -> %s", path.c_str(), convPath.c_str());
+
+		opened = true;
+
+		break;
+	}
+
+	if (!opened)
+		return initialPath;	// Anyway nothing good is happening
+
+	f.close();
+
+	return convPath;
+}
+
 } // End of namespace Director
diff --git a/engines/director/util.h b/engines/director/util.h
index c6d2cf8..fad016e 100644
--- a/engines/director/util.h
+++ b/engines/director/util.h
@@ -38,6 +38,8 @@ Common::String convertPath(Common::String &path);
 
 Common::String getPath(Common::String path, Common::String cwd);
 
+Common::String pathMakeRelative(Common::String path);
+
 void processQuitEvent(); // events.cpp
 
 } // End of namespace Director




More information about the Scummvm-git-logs mailing list