[Scummvm-git-logs] scummvm master -> 5d8f1896fbe5af351d8ea984b0f28bc13c7e4c1b

mduggan mgithub at guarana.org
Tue Oct 20 12:35:58 UTC 2020


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

Summary:
16a105cdbb ULTIMA8: Be more robust to missing/broken data
e1bff1cbb3 ANDROID: Avoid crash if version no is not int
5d8f1896fb ULTIMA8: Avoid trying to make empty path name


Commit: 16a105cdbbf7b12d233df69e9c9fad916150bc7d
    https://github.com/scummvm/scummvm/commit/16a105cdbbf7b12d233df69e9c9fad916150bc7d
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2020-10-20T20:37:47+09:00

Commit Message:
ULTIMA8: Be more robust to missing/broken data

Changed paths:
    engines/ultima/ultima8/kernel/core_app.h
    engines/ultima/ultima8/ultima8.cpp
    engines/ultima/ultima8/ultima8.h


diff --git a/engines/ultima/ultima8/kernel/core_app.h b/engines/ultima/ultima8/kernel/core_app.h
index d87d1022e6..7fc43f73ef 100644
--- a/engines/ultima/ultima8/kernel/core_app.h
+++ b/engines/ultima/ultima8/kernel/core_app.h
@@ -54,7 +54,7 @@ public:
 		return _application;
 	};
 
-	virtual void runGame() = 0;
+	virtual bool runGame() = 0;
 	virtual void paint() = 0; // probably shouldn't exist
 	virtual bool isPainting() {
 		return false;
diff --git a/engines/ultima/ultima8/ultima8.cpp b/engines/ultima/ultima8/ultima8.cpp
index 88be4868eb..aefb6d54e1 100644
--- a/engines/ultima/ultima8/ultima8.cpp
+++ b/engines/ultima/ultima8/ultima8.cpp
@@ -174,15 +174,20 @@ Ultima8Engine::~Ultima8Engine() {
 }
 
 Common::Error Ultima8Engine::run() {
+	bool result = true;
 	if (initialize()) {
-		startup();
-		runGame();
+		result = startup();
+		if (result)
+			result = runGame();
 
 		deinitialize();
 		shutdown();
 	}
 
-	return Common::kNoError;
+	if (result)
+		return Common::kNoError;
+	else
+		return Common::kNoGameDataFoundError;
 }
 
 
@@ -199,7 +204,7 @@ bool Ultima8Engine::initialize() {
 void Ultima8Engine::deinitialize() {
 }
 
-void Ultima8Engine::startup() {
+bool Ultima8Engine::startup() {
 	setDebugger(new Debugger());
 	pout << "-- Initializing Pentagram -- " << Std::endl;
 
@@ -316,15 +321,17 @@ void Ultima8Engine::startup() {
 
 	if (setupGame(info)) {
 		GraphicSysInit();
-		startupGame();
+		if (!startupGame())
+			return false;
 	} else {
 		// Couldn't setup the game, should never happen?
 		CANT_HAPPEN_MSG("default game failed to initialize");
 	}
 	paint();
+	return true;
 }
 
-void Ultima8Engine::startupGame() {
+bool Ultima8Engine::startupGame() {
 	pout  << Std::endl << "-- Initializing Game: " << _gameInfo->_name << " --" << Std::endl;
 
 	GraphicSysInit();
@@ -365,7 +372,9 @@ void Ultima8Engine::startupGame() {
 	_settingMan->setDefault("cheat", false);
 	_settingMan->get("cheat", _cheatsEnabled);
 
-	_game->loadFiles();
+	bool loaded = _game->loadFiles();
+	if (!loaded)
+		return false;
 	_gameData->setupFontOverrides();
 
 	// Create Midi Driver for Ultima 8
@@ -379,6 +388,7 @@ void Ultima8Engine::startupGame() {
 	newGame(saveSlot);
 
 	pout << "-- Game Initialized --" << Std::endl << Std::endl;
+	return true;
 }
 
 void Ultima8Engine::shutdown() {
@@ -480,7 +490,7 @@ void Ultima8Engine::menuInitMinimal(istring gamename) {
 	pout << "-- Finished loading minimal--" << Std::endl << Std::endl;
 }
 
-void Ultima8Engine::runGame() {
+bool Ultima8Engine::runGame() {
 	_isRunning = true;
 
 	int32 next_ticks = g_system->getMillis() * 3;  // Next time is right now!
@@ -550,10 +560,12 @@ void Ultima8Engine::runGame() {
 
 				_changeGameName.clear();
 
-				if (setupGame(info))
-					startupGame();
-				else
+				if (setupGame(info)) {
+					if (!startupGame())
+						return false;
+				} else {
 					CANT_HAPPEN_MSG("Failed to start up game with valid info.");
+				}
 			} else {
 				perr << "Game '" << _changeGameName << "' not found" << Std::endl;
 				_changeGameName.clear();
@@ -569,6 +581,7 @@ void Ultima8Engine::runGame() {
 		// Do a delay
 		g_system->delayMillis(5);
 	}
+	return true;
 }
 
 // Paint the _screen
diff --git a/engines/ultima/ultima8/ultima8.h b/engines/ultima/ultima8/ultima8.h
index be8f34cf71..1bdb7d29cb 100644
--- a/engines/ultima/ultima8/ultima8.h
+++ b/engines/ultima/ultima8/ultima8.h
@@ -179,10 +179,10 @@ public:
 		return dynamic_cast<Ultima8Engine *>(_application);
 	}
 
-	void startup();
+	bool startup();
 	void shutdown();
 
-	void startupGame();
+	bool startupGame();
 	void startupPentagramMenu();
 	void shutdownGame(bool reloading = true);
 	void changeGame(istring newgame);
@@ -199,7 +199,7 @@ public:
 
 	Graphics::Screen *getScreen() const override;
 
-	void runGame() override;
+	bool runGame() override;
 	virtual void handleEvent(const Common::Event &event);
 
 	void paint() override;


Commit: e1bff1cbb3b51f18dac28a8432fc5be3d5783b2c
    https://github.com/scummvm/scummvm/commit/e1bff1cbb3b51f18dac28a8432fc5be3d5783b2c
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2020-10-20T20:41:38+09:00

Commit Message:
ANDROID: Avoid crash if version no is not int

This can happen during development - shouldn't happen for any official release,
but even if it does let's just assume versions are different and default to
upgrading the config.

Changed paths:
    backends/platform/android/org/scummvm/scummvm/Version.java


diff --git a/backends/platform/android/org/scummvm/scummvm/Version.java b/backends/platform/android/org/scummvm/scummvm/Version.java
index 165c845e46..69b5b1be42 100644
--- a/backends/platform/android/org/scummvm/scummvm/Version.java
+++ b/backends/platform/android/org/scummvm/scummvm/Version.java
@@ -36,15 +36,19 @@ public class Version implements Comparable<Version> {
 		String[] thisParts = this.get().split("\\.");
 		String[] thatParts = that.get().split("\\.");
 		int length = Math.max(thisParts.length, thatParts.length);
-		for(int i = 0; i < length; i++) {
-			int thisPart = i < thisParts.length ?
-				Integer.parseInt(thisParts[i]) : 0;
-			int thatPart = i < thatParts.length ?
-				Integer.parseInt(thatParts[i]) : 0;
-			if(thisPart < thatPart)
-				return -1;
-			if(thisPart > thatPart)
-				return 1;
+		try {
+			for (int i = 0; i < length; i++) {
+				int thisPart = i < thisParts.length ?
+					Integer.parseInt(thisParts[i]) : 0;
+				int thatPart = i < thatParts.length ?
+					Integer.parseInt(thatParts[i]) : 0;
+				if (thisPart < thatPart)
+					return -1;
+				if (thisPart > thatPart)
+					return 1;
+			}
+		} catch (NumberFormatException e) {
+			return 1;
 		}
 		return 0;
 	}


Commit: 5d8f1896fbe5af351d8ea984b0f28bc13c7e4c1b
    https://github.com/scummvm/scummvm/commit/5d8f1896fbe5af351d8ea984b0f28bc13c7e4c1b
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2020-10-20T21:34:50+09:00

Commit Message:
ULTIMA8: Avoid trying to make empty path name

This has no impact on most platforms, but it breaks Android.

Changed paths:
    engines/ultima/ultima8/filesys/file_system.cpp


diff --git a/engines/ultima/ultima8/filesys/file_system.cpp b/engines/ultima/ultima8/filesys/file_system.cpp
index b2c143c84c..1992010c52 100644
--- a/engines/ultima/ultima8/filesys/file_system.cpp
+++ b/engines/ultima/ultima8/filesys/file_system.cpp
@@ -220,7 +220,7 @@ bool FileSystem::AddVirtualPath(const string &vpath, const string &realpath, con
 #ifdef DEBUG
 	debugN(MM_INFO, "virtual path \"%s\": %s\n", vp.c_str(), fullpath.c_str());
 #endif
-	if (!(fullpath.substr(0, 8) == "@memory/")) {
+	if (!(fullpath.substr(0, 8) == "@memory/") && rp.length()) {
 		if (!IsDir(fullpath)) {
 			if (!create) {
 #ifdef DEBUG
@@ -271,7 +271,7 @@ bool FileSystem::rewrite_virtual_path(string &vfn) const {
 	string::size_type pos = vfn.size();
 
 	while ((pos = vfn.rfind('/', pos)) != Std::string::npos) {
-//		perr << vfn << ", " << vfn.substr(0, pos) << ", " << pos << Std::endl;
+//		perr << vfn << ", '" << vfn.substr(0, pos) << "', " << pos << Std::endl;
 		Std::map<Common::String, string>::const_iterator p = _virtualPaths.find(
 		            vfn.substr(0, pos));
 




More information about the Scummvm-git-logs mailing list