[Scummvm-git-logs] scummvm master -> 5630dd5ecc4b136b50ce67b7d08a47187b2b46ad

neuromancer neuromancer at users.noreply.github.com
Fri Sep 17 06:39: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:
5630dd5ecc PRIVATE: removed and refactored assertions with side effects


Commit: 5630dd5ecc4b136b50ce67b7d08a47187b2b46ad
    https://github.com/scummvm/scummvm/commit/5630dd5ecc4b136b50ce67b7d08a47187b2b46ad
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2021-09-17T08:35:51+02:00

Commit Message:
PRIVATE: removed and refactored assertions with side effects

Changed paths:
    engines/private/funcs.cpp
    engines/private/private.cpp


diff --git a/engines/private/funcs.cpp b/engines/private/funcs.cpp
index db1844b5f5..54b0464627 100644
--- a/engines/private/funcs.cpp
+++ b/engines/private/funcs.cpp
@@ -748,7 +748,8 @@ static void fTimer(ArgArray args) {
 	// This pointer is necessary since installTimer needs one
 	Common::String *s = new Common::String(args[1].u.sym->name->c_str());
 	if (delay > 0) {
-		assert(g_private->installTimer(delay, s));
+		if (!g_private->installTimer(delay, s))
+			error("Timer installation failed!");
 	} else if (delay == 0) {
 		g_private->_nextSetting = *s;
 		// No need to keep the pointer alive
diff --git a/engines/private/private.cpp b/engines/private/private.cpp
index 7395419599..52571b77de 100644
--- a/engines/private/private.cpp
+++ b/engines/private/private.cpp
@@ -146,7 +146,8 @@ Common::SeekableReadStream *PrivateEngine::loadAssets() {
 		file = test;
 	} else {
 		delete test;
-		assert(_installerArchive.open("SUPPORT/ASSETS.Z"));
+		if (!_installerArchive.open("SUPPORT/ASSETS.Z"))
+			error("Failed to open SUPPORT/ASSETS.Z");
 		// if the full game is used
 		if (!isDemo()) {
 			if (_installerArchive.hasFile("GAME.DAT"))
@@ -170,7 +171,8 @@ Common::SeekableReadStream *PrivateEngine::loadAssets() {
 			}
 		}
 	}
-	assert(file != NULL);
+	if (file == NULL)
+		error("Unknown version");
 	return file;
 }
 
@@ -199,7 +201,8 @@ Common::Error PrivateEngine::run() {
 	initFuncs();
 	parse(scripts.c_str());
 	delete file;
-	assert(maps.constants.size() > 0);
+	if (maps.constants.size() == 0)
+		error("Failed to parse game script");
 
 	// Initialize graphics
 
@@ -772,7 +775,7 @@ void PrivateEngine::loadDossier() {
 	} else if (_dossierPage == 1) {
 		loadImage(m.page2, x, y);
 	} else {
-		assert(0);
+		error("Invalid page");
 	}
 }
 
@@ -1270,7 +1273,8 @@ void PrivateEngine::loadImage(const Common::String &name, int x, int y) {
 void PrivateEngine::composeImagePalette(const Graphics::Surface *surf, const byte *palette) {
 	int i,j,v;
 	uint32 c;
-	assert(_colorToIndex.size() == 1);
+	if (_colorToIndex.size() != 1)
+		error("colorToIndex had some elements");
 
 	for (i = 0; i < surf->w; i++)
 		for (j = 0; j < surf->h; j++) {




More information about the Scummvm-git-logs mailing list