[Scummvm-cvs-logs] CVS: scummvm config-file.cpp,1.13,1.14 config-file.h,1.6,1.7 gameDetector.cpp,1.84,1.85

Max Horn fingolfin at users.sourceforge.net
Sun Aug 18 16:30:03 CEST 2002


Update of /cvsroot/scummvm/scummvm
In directory usw-pr-cvs1:/tmp/cvs-serv8845

Modified Files:
	config-file.cpp config-file.h gameDetector.cpp 
Log Message:
added getBool and set(bool) to the Config class; made GameDetector take advantage of these; also, -A/-F/-N will turn OFF amiga/fullscreen/nosubtitles modes (so you can override the config file for these settings if desired)

Index: config-file.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/config-file.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- config-file.cpp	27 Jul 2002 14:55:40 -0000	1.13
+++ config-file.cpp	18 Aug 2002 23:29:40 -0000	1.14
@@ -234,20 +234,19 @@
 
 const int Config::getInt(const char *key, int def, const char *d) const
 {
-	int i;
-
-	if (!d)
-		d = domain;
-
-	for (i = 0; i < ndomains; i++) {
-		if (hash[i]->is_domain(d)) {
-			const char *val = hash[i]->get(key);
-			if (val)
-				return atoi(val);
-			break;
-		}
-	}
+	const char *value = get(key, d);
+	
+	if (value)
+		return atoi(value);
+	return def;
+}
 
+const bool Config::getBool(const char *key, bool def, const char *d) const
+{
+	const char *value = get(key, d);
+	
+	if (value)
+		return !scumm_stricmp(value, "true");
 	return def;
 }
 
@@ -273,25 +272,15 @@
 
 const char *Config::set(const char *key, int value_i, const char *d)
 {
-	int i;
 	char value[MAXLINELEN];
-
 	sprintf(value, "%i", value_i);
+	return set(key, value, d);
+}
 
-	if (!d)
-		d = domain;
-
-	for (i = 0; i < ndomains; i++) {
-		if (hash[i]->is_domain(d)) {
-			return hash[i]->set(key, value);
-		}
-	}
-
-	ndomains++;
-	hash = (hashconfig **)realloc(hash, ndomains * sizeof(hashconfig *));
-	hash[ndomains - 1] = new hashconfig (d);
-
-	return hash[ndomains - 1]->set(key, value);
+const char *Config::set(const char *key, bool value_b, const char *d)
+{
+	const char *value = value_b ? "true" : "false";
+	return set(key, value, d);
 }
 
 void Config::set_domain(const char *d)

Index: config-file.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/config-file.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- config-file.h	27 Jul 2002 14:55:40 -0000	1.6
+++ config-file.h	18 Aug 2002 23:29:40 -0000	1.7
@@ -31,8 +31,12 @@
 	 ~Config ();
 	const char *get(const char *key, const char *dom = 0) const;
 	const int getInt(const char *key, int def = 0, const char *dom = 0) const;
+	const bool getBool(const char *key, bool def = false, const char *dom = 0) const;
+
 	const char *set(const char *key, const char *value, const char *dom = 0);
 	const char *set(const char *key, int value, const char *dom = 0);
+	const char *set(const char *key, bool value, const char *dom = 0);
+
 	void set_domain(const char *);
 	void flush() const;
 	void rename_domain(const char *);

Index: gameDetector.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gameDetector.cpp,v
retrieving revision 1.84
retrieving revision 1.85
diff -u -d -r1.84 -r1.85
--- gameDetector.cpp	15 Aug 2002 20:20:55 -0000	1.84
+++ gameDetector.cpp	18 Aug 2002 23:29:40 -0000	1.85
@@ -71,16 +71,11 @@
 {
 	const char * val;
 
-	if ((val = scummcfg->get("amiga")))
-		if (!scumm_stricmp(val, "true"))
-			_amiga = true;
-		else
-			_amiga = false;
-	if ((val = scummcfg->get("save_slot")))
-		_save_slot = atoi(val);
+	_amiga = scummcfg->getBool("amiga", _amiga);
 
-	if ((val = scummcfg->get("cdrom")))
-		_cdrom = atoi(val);
+	_save_slot = scummcfg->getInt("save_slot", _save_slot);
+
+	_cdrom = scummcfg->getInt("cdrom", _cdrom);
 
 	if ((val = scummcfg->get("music_driver")))
 		if (!parseMusicDriver(val)) {
@@ -89,11 +84,7 @@
 			exit(-1);
 		}
 
-	if ((val = scummcfg->get("fullscreen", "scummvm")))
-		if (!scumm_stricmp(val, "true"))
-			_fullScreen = true;
-		else
-			_fullScreen = false;
+	_fullScreen = scummcfg->getBool("fullscreen", _fullScreen);
 
 	if ((val = scummcfg->get("gfx_mode")))
 		if ((_gfx_mode = parseGraphicsMode(val)) == -1) {
@@ -102,35 +93,29 @@
 			exit(-1);
 		}
 
-	if ((val = scummcfg->get("music_volume")))
-		_music_volume = atoi(val);
+	_music_volume = scummcfg->getInt("music_volume", _music_volume);
 
-	if ((val = scummcfg->get("nosubtitles")))
-		if (!scumm_stricmp(val, "true"))
-			_noSubtitles = true;
-		else
-			_noSubtitles = false;
+	_noSubtitles = scummcfg->getBool("nosubtitles", _noSubtitles);
 
 	if ((val = scummcfg->get("path")))
 		_gameDataPath = strdup(val);
 
-	if ((val = scummcfg->get("sfx_volume")))
-		_sfx_volume = atoi(val);
+	_sfx_volume = scummcfg->getInt("sfx_volume", _sfx_volume);
 
+	// We use strtol for the tempo to allow it to be specified in hex.
 	if ((val = scummcfg->get("tempo")))
 		_gameTempo = strtol(val, NULL, 0);
 
-	if ((val = scummcfg->get("talkspeed")))
-		_talkSpeed = atoi(val);
+	_talkSpeed = scummcfg->getInt("talkspeed", _talkSpeed);
 }
 
 void GameDetector::parseCommandLine(int argc, char **argv)
 {
-#if !defined(MACOS_CARBON)
 	int i;
 	char *s;
 	char *current_option = NULL;
 	char *option = NULL;
+	char c;
 	_save_slot = -1;
 
 	// check for arguments
@@ -146,11 +131,12 @@
 
 		if (s[0] == '-') {
 			s++;
-			switch (tolower(*s++)) {
+			c = *s++;
+			switch (tolower(c)) {
 			case 'a':
 				CHECK_OPTION();
-				_amiga = true;
-				scummcfg->set("amiga", "true");
+				_amiga = (c == 'a');
+				scummcfg->set("amiga", _amiga);
 				break;
 			case 'b':
 				HANDLE_OPTION();
@@ -176,8 +162,8 @@
 				break;
 			case 'f':
 				CHECK_OPTION();
-				_fullScreen = true;
-				scummcfg->set("fullscreen", "true", "scummvm");
+				_fullScreen = (c == 'f');
+				scummcfg->set("fullscreen", _fullScreen, "scummvm");
 				break;
 			case 'g':
 				HANDLE_OPTION();
@@ -203,8 +189,8 @@
 				break;
 			case 'n':
 				CHECK_OPTION();
-				_noSubtitles = true;
-				scummcfg->set("nosubtitles", "true");
+				_noSubtitles = (c == 'n');
+				scummcfg->set("nosubtitles", _noSubtitles);
 				break;
 			case 'p':
 				HANDLE_OPTION();
@@ -280,14 +266,6 @@
  ShowHelpAndExit:
 	printf(USAGE_STRING);
 	exit(1);
-
-#else
-	_midi_driver = MD_QTMUSIC;
-	_exe_name = *argv;
-	_gameDataPath = (char *)malloc(strlen(_exe_name) + 3);
-	sprintf(_gameDataPath, ":%s:", _exe_name);
-#endif
-
 }
 
 int GameDetector::parseGraphicsMode(const char *s) {
@@ -377,20 +355,16 @@
 //      {"indy3",       "Indiana Jones and the Last Crusade",           GID_INDY3,   2, 0, 0,},
 
 	/* Scumm Version 3 */
-	{"indy3", "Indiana Jones and the Last Crusade (256)", GID_INDY3_256, 3, 0,
-	 22,
-	 GF_SMALL_HEADER | GF_USE_KEY | GF_SMALL_NAMES | GF_OLD256 |
-	 GF_NO_SCALLING},
-	{"zak256", "Zak McKracken and the Alien Mindbenders (256)", GID_ZAK256, 3,
-	 0, 0,
-	 GF_SMALL_HEADER | GF_USE_KEY | GF_SMALL_NAMES | GF_OLD256 | GF_AUDIOTRACKS
-	 | GF_NO_SCALLING},
+	{"indy3", "Indiana Jones and the Last Crusade (256)", GID_INDY3_256, 3, 0, 22,
+	 GF_SMALL_HEADER | GF_USE_KEY | GF_SMALL_NAMES | GF_OLD256 | GF_NO_SCALLING},
+	{"zak256", "Zak McKracken and the Alien Mindbenders (256)", GID_ZAK256, 3, 0, 0,
+	 GF_SMALL_HEADER | GF_USE_KEY | GF_SMALL_NAMES | GF_OLD256 | GF_AUDIOTRACKS | GF_NO_SCALLING},
 	{"loom", "Loom", GID_LOOM, 3, 5, 40,
-	 GF_SMALL_HEADER | GF_USE_KEY | GF_SMALL_NAMES | GF_OLD_BUNDLE | GF_16COLOR
-	 | GF_NO_SCALLING},
+	 GF_SMALL_HEADER | GF_USE_KEY | GF_SMALL_NAMES | GF_OLD_BUNDLE | GF_16COLOR | GF_NO_SCALLING},
 
 	/* Scumm Version 4 */
-	{"monkeyEGA", "Monkey Island 1 (EGA)", GID_MONKEY_EGA, 4, 0, 67, GF_SMALL_HEADER | GF_USE_KEY | GF_16COLOR},	// EGA version
+	{"monkeyEGA", "Monkey Island 1 (EGA)", GID_MONKEY_EGA, 4, 0, 67,
+	 GF_SMALL_HEADER | GF_USE_KEY | GF_16COLOR},	// EGA version
 
 	/* Scumm version 5 */
 	{"monkeyVGA", "Monkey Island 1 (256 color Floppy version)", GID_MONKEY_VGA,  5, 0, 16,
@@ -405,10 +379,10 @@
 	 GF_USE_KEY | GF_ADLIB_DEFAULT},
 	{"atlantis", "Indiana Jones and the Fate of Atlantis", GID_INDY4, 5, 5, 0,
 	 GF_USE_KEY | GF_ADLIB_DEFAULT},
-	{"playfate", "Indiana Jones and the Fate of Atlantis (Demo)", GID_INDY4,
-	 5, 5, 0, GF_USE_KEY | GF_ADLIB_DEFAULT},
-	{"fate", "Indiana Jones and the Fate of Atlantis (Demo)", GID_INDY4,
-	 5, 5, 0, GF_USE_KEY | GF_ADLIB_DEFAULT},
+	{"playfate", "Indiana Jones and the Fate of Atlantis (Demo)", GID_INDY4, 5, 5, 0,
+	 GF_USE_KEY | GF_ADLIB_DEFAULT},
+	{"fate", "Indiana Jones and the Fate of Atlantis (Demo)", GID_INDY4, 5, 5, 0,
+	 GF_USE_KEY | GF_ADLIB_DEFAULT},
 
 	/* Scumm Version 6 */
 	{"tentacle", "Day Of The Tentacle", GID_TENTACLE, 6, 4, 2,
@@ -418,12 +392,12 @@
 	{"samnmax", "Sam & Max", GID_SAMNMAX, 6, 4, 2,
 	 GF_NEW_OPCODES | GF_AFTER_V6 | GF_USE_KEY | GF_DRAWOBJ_OTHER_ORDER},
 	{"samdemo", "Sam & Max (Demo)", GID_SAMNMAX, 6, 3, 0,
-	GF_NEW_OPCODES | GF_AFTER_V6 | GF_USE_KEY  | GF_DRAWOBJ_OTHER_ORDER | GF_ADLIB_DEFAULT},
+	 GF_NEW_OPCODES | GF_AFTER_V6 | GF_USE_KEY  | GF_DRAWOBJ_OTHER_ORDER | GF_ADLIB_DEFAULT},
 	{"snmdemo", "Sam & Max (Demo)", GID_SAMNMAX, 6, 3, 0,
-	GF_NEW_OPCODES | GF_AFTER_V6 | GF_USE_KEY  | GF_DRAWOBJ_OTHER_ORDER | GF_ADLIB_DEFAULT},
+	 GF_NEW_OPCODES | GF_AFTER_V6 | GF_USE_KEY  | GF_DRAWOBJ_OTHER_ORDER | GF_ADLIB_DEFAULT},
 	
 	{"puttdemo", "Putt Putt joins the parade (demo)", GID_SAMNMAX, 6, 3, 0,
-	GF_NEW_OPCODES | GF_AFTER_V6 | GF_USE_KEY  | GF_ADLIB_DEFAULT | GF_HUMONGOUS},
+	 GF_NEW_OPCODES | GF_AFTER_V6 | GF_USE_KEY  | GF_ADLIB_DEFAULT | GF_HUMONGOUS},
 	{"moondemo", "Putt Putt goes to the moon (demo)", GID_SAMNMAX, 6, 3, 0,
 	 GF_NEW_OPCODES | GF_AFTER_V6 | GF_USE_KEY  | GF_ADLIB_DEFAULT | GF_HUMONGOUS},
 
@@ -437,12 +411,14 @@
 
 	/* Simon the Sorcerer 1 & 2 (not SCUMM games) */
 	{"simon1dos", "Simon the Sorcerer 1 for DOS", GID_SIMON_FIRST+0, 99, 99, 99, 0},
-	{"simon2dos", "Simon the Sorcerer 2 for Dos", GID_SIMON_FIRST+1, 99, 99, 99, 0},
+	{"simon2dos", "Simon the Sorcerer 2 for DOS", GID_SIMON_FIRST+1, 99, 99, 99, 0},
 	{"simon1win", "Simon the Sorcerer 1 for Windows", GID_SIMON_FIRST+2, 99, 99, 99, 0},	
 	{"simon2win", "Simon the Sorcerer 2 for Windows", GID_SIMON_FIRST+3, 99, 99, 99, 0},
 
 	/* Scumm Version 8 */
-	{"comi", "The Curse of Monkey Island", GID_CMI, 8, 1, 0, GF_NEW_OPCODES|GF_AFTER_V6|GF_AFTER_V7|GF_AFTER_V8},
+	{"comi", "The Curse of Monkey Island", GID_CMI, 8, 1, 0,
+	 GF_NEW_OPCODES | GF_AFTER_V6 | GF_AFTER_V7 | GF_AFTER_V8},
+
 	{NULL, NULL}
 };
 
@@ -643,7 +619,7 @@
 #if defined(__APPLE__) || defined(macintosh)
 	case MD_QTMUSIC:	return MidiDriver_QT_create();
 #endif
-#if defined(__APPLE__)
+#if defined(MACOSX)
 	case MD_COREAUDIO:	return MidiDriver_CORE_create();
 #endif
 #if defined(UNIX) && defined(USE_ALSA)





More information about the Scummvm-git-logs mailing list