[Scummvm-cvs-logs] scummvm master -> da3fff8ab38bce529ed6cbd1dea2731c93314030

fingolfin max at quendi.de
Fri Jun 17 10:42:34 CEST 2011


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

Summary:
520b18d2ac SCI: Use ScopedPtr to handle temporary resMan instance on the heap
da3fff8ab3 COMMON: Make use of Common::parseBool


Commit: 520b18d2ac183c4d671b9bd59935bec2aea0d4c6
    https://github.com/scummvm/scummvm/commit/520b18d2ac183c4d671b9bd59935bec2aea0d4c6
Author: Max Horn (max at quendi.de)
Date: 2011-06-17T01:38:16-07:00

Commit Message:
SCI: Use ScopedPtr to handle temporary resMan instance on the heap

Changed paths:
    engines/sci/detection.cpp



diff --git a/engines/sci/detection.cpp b/engines/sci/detection.cpp
index 7bc9699..10c27b2 100644
--- a/engines/sci/detection.cpp
+++ b/engines/sci/detection.cpp
@@ -23,6 +23,7 @@
 #include "engines/advancedDetector.h"
 #include "base/plugins.h"
 #include "common/file.h"
+#include "common/ptr.h"
 #include "common/savefile.h"
 #include "common/system.h"
 #include "graphics/thumbnail.h"
@@ -485,7 +486,7 @@ const ADGameDescription *SciMetaEngine::fallbackDetect(const FileMap &allFiles,
 		return 0;
 	}
 
-	ResourceManager *resMan = new ResourceManager();
+	Common::ScopedPtr<ResourceManager> resMan(new ResourceManager());
 	assert(resMan);
 	resMan->addAppropriateSources(fslist);
 	resMan->init(true);
@@ -495,7 +496,6 @@ const ADGameDescription *SciMetaEngine::fallbackDetect(const FileMap &allFiles,
 	// Is SCI32 compiled in? If not, and this is a SCI32 game,
 	// stop here
 	if (getSciVersion() >= SCI_VERSION_2) {
-		delete resMan;
 		return (const ADGameDescription *)&s_fallbackDesc;
 	}
 #endif
@@ -506,7 +506,6 @@ const ADGameDescription *SciMetaEngine::fallbackDetect(const FileMap &allFiles,
 	// Can't be SCI (or unsupported SCI views). Pinball Creep by sierra also uses resource.map/resource.000 files
 	//  but doesnt share sci format at all, if we dont return 0 here we will detect this game as SCI
 	if (gameViews == kViewUnknown) {
-		delete resMan;
 		return 0;
 	}
 
@@ -519,7 +518,6 @@ const ADGameDescription *SciMetaEngine::fallbackDetect(const FileMap &allFiles,
 
 	// If we don't have a game id, the game is not SCI
 	if (sierraGameId.empty()) {
-		delete resMan;
 		return 0;
 	}
 
@@ -575,8 +573,6 @@ const ADGameDescription *SciMetaEngine::fallbackDetect(const FileMap &allFiles,
 	if (s_fallbackDesc.flags & ADGF_DEMO)
 		s_fallbackDesc.extra = (gameId.hasSuffix("sci")) ? "SCI/Demo" : "Demo";
 
-	delete resMan;
-
 	return (const ADGameDescription *)&s_fallbackDesc;
 }
 


Commit: da3fff8ab38bce529ed6cbd1dea2731c93314030
    https://github.com/scummvm/scummvm/commit/da3fff8ab38bce529ed6cbd1dea2731c93314030
Author: Max Horn (max at quendi.de)
Date: 2011-06-17T01:38:16-07:00

Commit Message:
COMMON: Make use of Common::parseBool

Changed paths:
    common/config-manager.cpp
    gui/ThemeParser.cpp



diff --git a/common/config-manager.cpp b/common/config-manager.cpp
index 03fcb20..3941e27 100644
--- a/common/config-manager.cpp
+++ b/common/config-manager.cpp
@@ -491,11 +491,9 @@ int ConfigManager::getInt(const String &key, const String &domName) const {
 
 bool ConfigManager::getBool(const String &key, const String &domName) const {
 	String value(get(key, domName));
-
-	if ((value == "true") || (value == "yes") || (value == "1"))
-		return true;
-	if ((value == "false") || (value == "no") || (value == "0"))
-		return false;
+	bool val;
+	if (Common::parseBool(value, val))
+		return val;
 
 	error("ConfigManager::getBool(%s,%s): '%s' is not a valid bool",
 	      key.c_str(), domName.c_str(), value.c_str());
diff --git a/gui/ThemeParser.cpp b/gui/ThemeParser.cpp
index 5b1faa4..55a76e8 100644
--- a/gui/ThemeParser.cpp
+++ b/gui/ThemeParser.cpp
@@ -352,11 +352,8 @@ bool ThemeParser::parserCallback_drawdata(ParserNode *node) {
 	}
 
 	if (node->values.contains("cache")) {
-		if (node->values["cache"] == "true")
-			cached = true;
-		else if (node->values["cache"] == "false")
-			cached = false;
-		else return parserError("'Parsed' value must be either true or false.");
+		if (!Common::parseBool(node->values["cache"], cached))
+			return parserError("'Parsed' value must be either true or false.");
 	}
 
 	if (_theme->addDrawData(node->values["id"], cached) == false)
@@ -595,9 +592,7 @@ bool ThemeParser::parserCallback_widget(ParserNode *node) {
 		bool enabled = true;
 
 		if (node->values.contains("enabled")) {
-			if (node->values["enabled"] == "false")
-				enabled = false;
-			else if (node->values["enabled"] != "true")
+			if (!Common::parseBool(node->values["enabled"], enabled))
 				return parserError("Invalid value for Widget enabling (expecting true/false)");
 		}
 
@@ -641,9 +636,7 @@ bool ThemeParser::parserCallback_dialog(ParserNode *node) {
 	}
 
 	if (node->values.contains("enabled")) {
-		if (node->values["enabled"] == "false")
-			enabled = false;
-		else if (node->values["enabled"] != "true")
+		if (!Common::parseBool(node->values["enabled"], enabled))
 			return parserError("Invalid value for Dialog enabling (expecting true/false)");
 	}
 
@@ -677,16 +670,19 @@ bool ThemeParser::parserCallback_import(ParserNode *node) {
 
 bool ThemeParser::parserCallback_layout(ParserNode *node) {
 	int spacing = -1;
+	bool center;
 
 	if (node->values.contains("spacing")) {
 		if (!parseIntegerKey(node->values["spacing"], 1, &spacing))
 			return false;
 	}
 
+	Common::parseBool(node->values["center"], center);
+
 	if (node->values["type"] == "vertical")
-		_theme->getEvaluator()->addLayout(GUI::ThemeLayout::kLayoutVertical, spacing, node->values["center"] == "true");
+		_theme->getEvaluator()->addLayout(GUI::ThemeLayout::kLayoutVertical, spacing, center);
 	else if (node->values["type"] == "horizontal")
-		_theme->getEvaluator()->addLayout(GUI::ThemeLayout::kLayoutHorizontal, spacing, node->values["center"] == "true");
+		_theme->getEvaluator()->addLayout(GUI::ThemeLayout::kLayoutHorizontal, spacing, center);
 	else
 		return parserError("Invalid layout type. Only 'horizontal' and 'vertical' layouts allowed.");
 






More information about the Scummvm-git-logs mailing list