[Scummvm-cvs-logs] SF.net SVN: scummvm:[50273] scummvm/trunk/engines/sci

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Fri Jun 25 18:16:29 CEST 2010


Revision: 50273
          http://scummvm.svn.sourceforge.net/scummvm/?rev=50273&view=rev
Author:   fingolfin
Date:     2010-06-25 16:16:29 +0000 (Fri, 25 Jun 2010)

Log Message:
-----------
SCI: Introduce SciGameId enum

Modified Paths:
--------------
    scummvm/trunk/engines/sci/console.cpp
    scummvm/trunk/engines/sci/detection.cpp
    scummvm/trunk/engines/sci/engine/kernel.cpp
    scummvm/trunk/engines/sci/engine/kgraphics.cpp
    scummvm/trunk/engines/sci/engine/kmisc.cpp
    scummvm/trunk/engines/sci/engine/kpathing.cpp
    scummvm/trunk/engines/sci/engine/segment.cpp
    scummvm/trunk/engines/sci/engine/static_selectors.cpp
    scummvm/trunk/engines/sci/engine/vm.cpp
    scummvm/trunk/engines/sci/graphics/paint16.cpp
    scummvm/trunk/engines/sci/graphics/picture.cpp
    scummvm/trunk/engines/sci/graphics/ports.cpp
    scummvm/trunk/engines/sci/graphics/screen.cpp
    scummvm/trunk/engines/sci/resource.h
    scummvm/trunk/engines/sci/resource_audio.cpp
    scummvm/trunk/engines/sci/sci.cpp
    scummvm/trunk/engines/sci/sci.h

Modified: scummvm/trunk/engines/sci/console.cpp
===================================================================
--- scummvm/trunk/engines/sci/console.cpp	2010-06-25 16:12:38 UTC (rev 50272)
+++ scummvm/trunk/engines/sci/console.cpp	2010-06-25 16:16:29 UTC (rev 50273)
@@ -425,7 +425,7 @@
 
 	bool hasVocab997 = g_sci->getResMan()->testResource(ResourceId(kResourceTypeVocab, VOCAB_RESOURCE_SELECTORS)) ? true : false;
 
-	DebugPrintf("Game ID: %s\n", _engine->getGameId().c_str());
+	DebugPrintf("Game ID: %s\n", _engine->getGameIdStr());
 	DebugPrintf("Emulated interpreter version: %s\n", getSciVersionDesc(getSciVersion()));
 	DebugPrintf("\n");
 	DebugPrintf("Detected features:\n");

Modified: scummvm/trunk/engines/sci/detection.cpp
===================================================================
--- scummvm/trunk/engines/sci/detection.cpp	2010-06-25 16:12:38 UTC (rev 50272)
+++ scummvm/trunk/engines/sci/detection.cpp	2010-06-25 16:16:29 UTC (rev 50273)
@@ -40,7 +40,7 @@
 namespace Sci {
 
 // Titles of the games
-static const PlainGameDescriptor SciGameTitles[] = {
+static const PlainGameDescriptor s_sciGameTitles[] = {
 	{"sci",             "Sierra SCI Game"},
 	{"sci-fanmade",     "Fanmade SCI Game"},
 	// === SCI0 games =========================================================
@@ -119,6 +119,80 @@
 	{0, 0}
 };
 
+struct GameIdStrToEnum {
+	const char *gameidStr;
+	SciGameId gameidEnum;
+};
+
+static const GameIdStrToEnum s_gameIdStrToEnum[] = {
+	{ "astrochicken",    GID_ASTROCHICKEN },
+	{ "camelot",         GID_CAMELOT },
+	{ "castlebrain",     GID_CASTLEBRAIN },
+	{ "christmas1988",   GID_CHRISTMAS1988 },
+	{ "christmas1990",   GID_CHRISTMAS1990 },
+	{ "christmas1992",   GID_CHRISTMAS1992 },
+	{ "cnick-kq",        GID_CNICK_KQ },
+	{ "cnick-laurabow",  GID_CNICK_LAURABOW },
+	{ "cnick-longbow",   GID_CNICK_LONGBOW },
+	{ "cnick-lsl",       GID_CNICK_LSL },
+	{ "cnick-sq",        GID_CNICK_SQ },
+	{ "ecoquest",        GID_ECOQUEST },
+	{ "ecoquest2",       GID_ECOQUEST2 },
+	{ "fairytales",      GID_FAIRYTALES },
+	{ "freddypharkas",   GID_FREDDYPHARKAS },
+	{ "funseeker",       GID_FUNSEEKER },
+	{ "gk1",             GID_GK1 },
+	{ "gk2",             GID_GK2 },
+	{ "hoyle1",          GID_HOYLE1 },
+	{ "hoyle2",          GID_HOYLE2 },
+	{ "hoyle3",          GID_HOYLE3 },
+	{ "hoyle4",          GID_HOYLE4 },
+	{ "iceman",          GID_ICEMAN },
+	{ "islandbrain",     GID_ISLANDBRAIN },
+	{ "jones",           GID_JONES },
+	{ "kq1sci",          GID_KQ1 },
+	{ "kq4sci",          GID_KQ4 },
+	{ "kq5",             GID_KQ5 },
+	{ "kq6",             GID_KQ6 },
+	{ "kq7",             GID_KQ7 },
+	{ "laurabow",        GID_LAURABOW },
+	{ "laurabow2",       GID_LAURABOW2 },
+	{ "lighthouse",      GID_LIGHTHOUSE },
+	{ "longbow",         GID_LONGBOW },
+	{ "lsl1sci",         GID_LSL1 },
+	{ "lsl2",            GID_LSL2 },
+	{ "lsl3",            GID_LSL3 },
+	{ "lsl5",            GID_LSL5 },
+	{ "lsl6",            GID_LSL6 },
+	{ "lsl7",            GID_LSL7 },
+	{ "mothergoose",     GID_MOTHERGOOSE },
+	{ "msastrochicken",  GID_MSASTROCHICKEN },
+	{ "pepper",          GID_PEPPER },
+	{ "phantasmagoria",  GID_PHANTASMAGORIA },
+	{ "phantasmagoria2", GID_PHANTASMAGORIA2 },
+	{ "pq1sci",          GID_PQ1 },
+	{ "pq2",             GID_PQ2 },
+	{ "pq3",             GID_PQ3 },
+	{ "pq4",             GID_PQ4 },
+	{ "pqswat",          GID_PQSWAT },
+	{ "qfg1",            GID_QFG1 },
+	{ "qfg2",            GID_QFG2 },
+	{ "qfg3",            GID_QFG3 },
+	{ "qfg4",            GID_QFG4 },
+	{ "rama",            GID_RAMA },
+	{ "sci-fanmade",     GID_FANMADE },	// FIXME: Do we really need/want this?
+	{ "shivers",         GID_SHIVERS },
+	{ "shivers2",        GID_SHIVERS2 },
+	{ "slater",          GID_SLATER },
+	{ "sq1sci",          GID_SQ1 },
+	{ "sq3",             GID_SQ3 },
+	{ "sq4",             GID_SQ4 },
+	{ "sq5",             GID_SQ5 },
+	{ "sq6",             GID_SQ6 },
+	{ "torin",           GID_TORIN },
+	{ NULL, (SciGameId)-1 }
+};
+
 struct OldNewIdTableEntry {
 	const char *oldId;
 	const char *newId;
@@ -300,7 +374,7 @@
 	// Number of bytes to compute MD5 sum for
 	5000,
 	// List of all engine targets
-	SciGameTitles,
+	s_sciGameTitles,
 	// Structure for autoupgrading obsolete targets
 	0,
 	// Name of single gameid (optional)
@@ -523,12 +597,16 @@
 	return (const ADGameDescription *)&s_fallbackDesc;
 }
 
-bool SciMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *gd) const {
-	const ADGameDescription *desc = (const ADGameDescription *)gd;
+bool SciMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
+	const GameIdStrToEnum *g = s_gameIdStrToEnum;
+	for (; g->gameidStr; ++g) {
+		if (0 == strcmp(desc->gameid, g->gameidStr)) {
+			*engine = new SciEngine(syst, desc, g->gameidEnum);
+			return true;
+		}
+	}
 
-	*engine = new SciEngine(syst, desc);
-
-	return true;
+	return false;
 }
 
 bool SciMetaEngine::hasFeature(MetaEngineFeature f) const {

Modified: scummvm/trunk/engines/sci/engine/kernel.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kernel.cpp	2010-06-25 16:12:38 UTC (rev 50272)
+++ scummvm/trunk/engines/sci/engine/kernel.cpp	2010-06-25 16:16:29 UTC (rev 50273)
@@ -745,7 +745,7 @@
 		// In SCI1.1, kSetSynonyms is an empty function
 		_kernelNames[0x26] = "Empty";
 
-		if (g_sci->getGameId() == "kq6") {
+		if (g_sci->getGameId() == GID_KQ6) {
 			// In the Windows version of KQ6 CD, the empty kSetSynonyms
 			// function has been replaced with kPortrait. In KQ6 Mac,
 			// kPlayBack has been replaced by kShowMovie.
@@ -753,7 +753,7 @@
 				_kernelNames[0x26] = "Portrait";
 			else if (g_sci->getPlatform() == Common::kPlatformMacintosh)
 				_kernelNames[0x84] = "ShowMovie";
-		} else if (g_sci->getGameId() == "qfg4" && g_sci->isDemo()) {
+		} else if (g_sci->getGameId() == GID_QFG4 && g_sci->isDemo()) {
 			_kernelNames[0x7b] = "RemapColors"; // QFG4 Demo has this SCI2 function instead of StrSplit
 		}
 

Modified: scummvm/trunk/engines/sci/engine/kgraphics.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kgraphics.cpp	2010-06-25 16:12:38 UTC (rev 50272)
+++ scummvm/trunk/engines/sci/engine/kgraphics.cpp	2010-06-25 16:16:29 UTC (rev 50273)
@@ -541,7 +541,7 @@
 
 	// WORKAROUND for a problem in LSL1VGA. This allows the casino door to be opened,
 	// till the actual problem is found
-	if (s->currentRoomNumber() == 300 && g_sci->getGameId() == "lsl1sci") {
+	if (s->currentRoomNumber() == 300 && g_sci->getGameId() == GID_LSL1) {
 		int top = readSelectorValue(s->_segMan, object, SELECTOR(brTop));
 		writeSelectorValue(s->_segMan, object, SELECTOR(brTop), top + 2);
 	}

Modified: scummvm/trunk/engines/sci/engine/kmisc.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kmisc.cpp	2010-06-25 16:12:38 UTC (rev 50272)
+++ scummvm/trunk/engines/sci/engine/kmisc.cpp	2010-06-25 16:16:29 UTC (rev 50273)
@@ -60,9 +60,9 @@
 	// throttling resulting in having to do 1000 pushups or something. Another
 	// way of handling this would be delaying incrementing of "machineSpeed"
 	// selector.
-	if (g_sci->getGameId() == "lsl3" && s->currentRoomNumber() == 290)
+	if (g_sci->getGameId() == GID_LSL3 && s->currentRoomNumber() == 290)
 		s->_throttleTrigger = true;
-	else if (g_sci->getGameId() == "iceman" && s->currentRoomNumber() == 27) {
+	else if (g_sci->getGameId() == GID_ICEMAN && s->currentRoomNumber() == 27) {
 		s->_throttleTrigger = true;
 		neededSleep = 60;
 	}

Modified: scummvm/trunk/engines/sci/engine/kpathing.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kpathing.cpp	2010-06-25 16:12:38 UTC (rev 50272)
+++ scummvm/trunk/engines/sci/engine/kpathing.cpp	2010-06-25 16:16:29 UTC (rev 50273)
@@ -1090,7 +1090,7 @@
 
 	// WORKAROUND: broken polygon in lsl1sci, room 350, after opening elevator
 	// Polygon has 17 points but size is set to 19
-	if ((size == 19) && g_sci->getGameId() == "lsl1sci") {
+	if ((size == 19) && g_sci->getGameId() == GID_LSL1) {
 		if ((s->currentRoomNumber() == 350)
 		&& (read_point(segMan, points, 18) == Common::Point(108, 137))) {
 			debug(1, "Applying fix for broken polygon in lsl1sci, room 350");
@@ -1212,7 +1212,7 @@
 
 		// WORKAROUND LSL5 room 660. Priority glitch due to us choosing a different path
 		// than SSCI. Happens when Patti walks to the control room.
-		if (g_sci->getGameId() == "lsl5" && (s->currentRoomNumber() == 660) && (Common::Point(67, 131) == *new_start) && (Common::Point(229, 101) == *new_end)) {
+		if (g_sci->getGameId() == GID_LSL5 && (s->currentRoomNumber() == 660) && (Common::Point(67, 131) == *new_start) && (Common::Point(229, 101) == *new_end)) {
 			debug(1, "[avoidpath] Applying fix for priority problem in LSL5, room 660");
 			pf_s->_prependPoint = new_start;
 			new_start = new Common::Point(77, 107);

Modified: scummvm/trunk/engines/sci/engine/segment.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/segment.cpp	2010-06-25 16:12:38 UTC (rev 50272)
+++ scummvm/trunk/engines/sci/engine/segment.cpp	2010-06-25 16:16:29 UTC (rev 50273)
@@ -465,7 +465,7 @@
 		ret.reg = &_locals[pointer.offset / 2];
 	} else {
 		if ((g_sci->getEngineState()->currentRoomNumber() == 660 || g_sci->getEngineState()->currentRoomNumber() == 660)
-			&& g_sci->getGameId() == "laurabow2") {
+			&& g_sci->getGameId() == GID_LAURABOW2) {
 			// Happens in two places during the intro of LB2CD, both from kMemory(peek):
 			// - room 160: Heap 160 has 83 local variables (0-82), and the game
 			//   asks for variables at indices 83 - 90 too.
@@ -520,7 +520,7 @@
 	if (isValidOffset(pointer.offset))
 		ret.raw = (byte *)(_strings[pointer.offset]._value);
 	else {
-		if (g_sci->getGameId() == "kq5") {
+		if (g_sci->getGameId() == GID_KQ5) {
 			// This occurs in KQ5CD when interacting with certain objects
 		} else {
 			error("SystemStrings::dereference(): Attempt to dereference invalid pointer %04x:%04x", PRINT_REG(pointer));

Modified: scummvm/trunk/engines/sci/engine/static_selectors.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/static_selectors.cpp	2010-06-25 16:12:38 UTC (rev 50272)
+++ scummvm/trunk/engines/sci/engine/static_selectors.cpp	2010-06-25 16:16:29 UTC (rev 50273)
@@ -158,7 +158,7 @@
 			}
 		}
 
-		if (g_sci->getGameId() == "hoyle4") {
+		if (g_sci->getGameId() == GID_HOYLE4) {
 			// The demo of Hoyle 4 is one of the few demos with lip syncing and no selector vocabulary.
 			// This needs two selectors, "syncTime" and "syncCue", which keep changing positions in each
 			// game. Usually, games with speech and lip sync have a selector vocabulary, so we don't need

Modified: scummvm/trunk/engines/sci/engine/vm.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/vm.cpp	2010-06-25 16:12:38 UTC (rev 50272)
+++ scummvm/trunk/engines/sci/engine/vm.cpp	2010-06-25 16:16:29 UTC (rev 50273)
@@ -169,7 +169,7 @@
 			} else {
 				// WORKAROUND: Mixed-Up Mother Goose tries to use an invalid parameter in Event::new().
 				// Just skip around it here so we don't error out in validate_arithmetic.
-				if (g_sci->getGameId() == "mothergoose" && getSciVersion() <= SCI_VERSION_1_1 && type == VAR_PARAM && index == 1)
+				if (g_sci->getGameId() == GID_MOTHERGOOSE && getSciVersion() <= SCI_VERSION_1_1 && type == VAR_PARAM && index == 1)
 					return false;
 
 				debugC(2, kDebugLevelVM, "%s", txt.c_str());
@@ -184,22 +184,24 @@
 }
 
 struct UninitializedReadWorkaround {
-	const char *gameId;
+	SciGameId gameId;
 	int scriptNr;
 	const char *objectName;
 	const char *methodName;
 	int index;
 	uint16 newValue;
-} static const uninitializedReadWorkarounds[] = {
-	{ "laurabow2",       24,    "gcWin", "open",		 5, 0xf }, // is used as priority for game menu
-	{ "freddypharkas",   24,    "gcWin", "open",		 5, 0xf }, // is used as priority for game menu
-	{ "freddypharkas",   31,  "quitWin", "open",		 5, 0xf }, // is used as priority for game menu
-	{ "lsl1sci",        720,    "rm720", "init",		 0,   0 }, // age check room
-	{ "islandbrain",    140,    "piece", "init",		 3,   1 }, // some initialization variable. bnt is done on it, and it should be non-0
-	{ "sq4",			928, "Narrator", "startText", 1000,   1 }, // sq4cd: method returns this to the caller
-	{ NULL,              -1,       NULL,   NULL,		 0,   0 }
 };
 
+static const UninitializedReadWorkaround uninitializedReadWorkarounds[] = {
+	{ GID_LAURABOW2,      24,    "gcWin", "open",		 5, 0xf }, // is used as priority for game menu
+	{ GID_FREDDYPHARKAS,  24,    "gcWin", "open",		 5, 0xf }, // is used as priority for game menu
+	{ GID_FREDDYPHARKAS,  31,  "quitWin", "open",		 5, 0xf }, // is used as priority for game menu
+	{ GID_LSL1,          720,    "rm720", "init",		 0,   0 }, // age check room
+	{ GID_ISLANDBRAIN,   140,    "piece", "init",		 3,   1 }, // some initialization variable. bnt is done on it, and it should be non-0
+	{ GID_SQ4,           928, "Narrator", "startText", 1000,   1 }, // sq4cd: method returns this to the caller
+	{ (SciGameId)0,       -1,       NULL,   NULL,		 0,   0 }
+};
+
 static reg_t validate_read_var(reg_t *r, reg_t *stack_base, int type, int max, int index, int line, reg_t default_value) {
 	if (validate_variable(r, stack_base, type, max, index, line)) {
 		if (type == VAR_TEMP && r[index].segment == 0xffff) {
@@ -218,14 +220,14 @@
 
 			Common::String curObjectName = state->_segMan->getObjectName(call.sendp);
 			Common::String curMethodName;
-			Common::String gameId = g_sci->getGameId();
+			const SciGameId gameId = g_sci->getGameId();
 
 			if (call.type == EXEC_STACK_TYPE_CALL)
 				curMethodName = g_sci->getKernel()->getSelectorName(call.selector);
 
 			// Search if this is a known uninitialized read
 			const UninitializedReadWorkaround *workaround = uninitializedReadWorkarounds;
-			while (workaround->gameId) {
+			while (workaround->objectName) {
 				if (workaround->gameId == gameId && workaround->scriptNr == curScriptNr && workaround->objectName == curObjectName
 						&& workaround->methodName == curMethodName && workaround->index == index) {
 					// Workaround found
@@ -481,7 +483,7 @@
 				if (!strcmp(objectName, "Sq4GlobalNarrator") && selector == 606) {
 					// SQ4 has a script bug in the Sq4GlobalNarrator object when invoking the
 					// returnVal selector, which doesn't affect gameplay, thus don't diplay it
-				} else if (!strcmp(objectName, "longSong") && selector == 3 && g_sci->getGameId() == "qfg1") {
+				} else if (!strcmp(objectName, "longSong") && selector == 3 && g_sci->getGameId() == GID_QFG1) {
 					// QFG1VGA has a script bug in the longSong object when invoking the
 					// loop selector, which doesn't affect gameplay, thus don't diplay it
 				} else {

Modified: scummvm/trunk/engines/sci/graphics/paint16.cpp
===================================================================
--- scummvm/trunk/engines/sci/graphics/paint16.cpp	2010-06-25 16:12:38 UTC (rev 50272)
+++ scummvm/trunk/engines/sci/graphics/paint16.cpp	2010-06-25 16:16:29 UTC (rev 50273)
@@ -524,7 +524,7 @@
 		// 2 Dummy functions, longbow-demo is using those several times but sierra sci doesn't support them at all
 		case SCI_DISPLAY_DUMMY1:
 		case SCI_DISPLAY_DUMMY2:
-			if (!((g_sci->getGameId() == "longbow") && (g_sci->isDemo())))
+			if (!((g_sci->getGameId() == GID_LONGBOW) && (g_sci->isDemo())))
 				error("Unknown kDisplay argument %X", displayArg);
 			if (displayArg == SCI_DISPLAY_DUMMY2) {
 				if (argc) {

Modified: scummvm/trunk/engines/sci/graphics/picture.cpp
===================================================================
--- scummvm/trunk/engines/sci/graphics/picture.cpp	2010-06-25 16:12:38 UTC (rev 50272)
+++ scummvm/trunk/engines/sci/graphics/picture.cpp	2010-06-25 16:16:29 UTC (rev 50273)
@@ -437,7 +437,7 @@
 			memcpy(&EGApalettes[i], &vector_defaultEGApalette, sizeof(vector_defaultEGApalette));
 		memcpy(&EGApriority, &vector_defaultEGApriority, sizeof(vector_defaultEGApriority));
 
-		if (g_sci->getGameId() == "iceman") {
+		if (g_sci->getGameId() == GID_ICEMAN) {
 			// WORKAROUND: we remove certain visual&priority lines in underwater rooms of iceman, when not dithering the
 			//              picture. Normally those lines aren't shown, because they share the same color as the dithered
 			//              fill color combination. When not dithering, those lines would appear and get distracting.
@@ -532,7 +532,7 @@
 		//  inside picture data for such games
 		case PIC_OP_SET_PATTERN:
 			if (_resourceType >= SCI_PICTURE_TYPE_SCI11) {
-				if (g_sci->getGameId() == "sq4") {
+				if (g_sci->getGameId() == GID_SQ4) {
 					// WORKAROUND: For SQ4 / for some pictures handle this like a terminator
 					//  This picture includes garbage data, first a set pattern w/o parameter and then short pattern
 					//  I guess that garbage is a left over from the sq4-floppy (sci1) to sq4-cd (sci1.1) conversion

Modified: scummvm/trunk/engines/sci/graphics/ports.cpp
===================================================================
--- scummvm/trunk/engines/sci/graphics/ports.cpp	2010-06-25 16:12:38 UTC (rev 50272)
+++ scummvm/trunk/engines/sci/graphics/ports.cpp	2010-06-25 16:16:29 UTC (rev 50273)
@@ -55,7 +55,7 @@
 }
 
 void GfxPorts::init(bool usesOldGfxFunctions, GfxPaint16 *paint16, GfxText16 *text16) {
-	int16 offTop = 10;
+	int16 offTop;
 
 	_usesOldGfxFunctions = usesOldGfxFunctions;
 	_paint16 = paint16;
@@ -84,15 +84,33 @@
 	else
 		_styleUser = SCI_WINDOWMGR_STYLE_USER | SCI_WINDOWMGR_STYLE_TRANSPARENT;
 
-	// Jones, Slater, Hoyle 3&4 and Crazy Nicks Laura Bow/Kings Quest were called with parameter -Nw 0 0 200 320.
-	// Mother Goose (SCI1) uses -Nw 0 0 159 262. The game will later use SetPort so we don't need to set the other fields.
+	// Jones, Slater, Hoyle 3&4 and Crazy Nicks Laura Bow/Kings Quest were
+	// called with parameter -Nw 0 0 200 320.
+	// Mother Goose (SCI1) uses -Nw 0 0 159 262. The game will later use
+	// SetPort so we don't need to set the other fields.
 	// This actually meant not skipping the first 10 pixellines in windowMgrPort
-	Common::String gameId = g_sci->getGameId();
-	if (gameId == "jones" || gameId == "slater" || gameId == "hoyle3" || gameId == "hoyle4" || gameId == "cnick-laurabow" || gameId == "cnick-kq" || (gameId == "mothergoose" && getSciVersion() == SCI_VERSION_1_EARLY))
+	switch (g_sci->getGameId()) {
+	case GID_JONES:
+	case GID_SLATER:
+	case GID_HOYLE3:
+	case GID_HOYLE4:
+	case GID_CNICK_LAURABOW:
+	case GID_CNICK_KQ:
 		offTop = 0;
-	// Mixed-Up Fairy Tales (& its demo) uses -w 26 0 200 320. If we don't also do this we will get not-fully-removed windows everywhere
-	if (gameId == "fairytales")
+		break;
+	case GID_MOTHERGOOSE:
+		if (getSciVersion() == SCI_VERSION_1_EARLY)
+			offTop = 0;
+		break;
+	case GID_FAIRYTALES:
+		// Mixed-Up Fairy Tales (& its demo) uses -w 26 0 200 320. If we don't
+		// also do this we will get not-fully-removed windows everywhere.
 		offTop = 26;
+		break;
+	default:
+		offTop = 10;
+		break;
+	}
 
 	openPort(_wmgrPort);
 	setPort(_wmgrPort);

Modified: scummvm/trunk/engines/sci/graphics/screen.cpp
===================================================================
--- scummvm/trunk/engines/sci/graphics/screen.cpp	2010-06-25 16:12:38 UTC (rev 50272)
+++ scummvm/trunk/engines/sci/graphics/screen.cpp	2010-06-25 16:16:29 UTC (rev 50273)
@@ -97,9 +97,9 @@
 	if (_resMan->isSci11Mac() && getSciVersion() == SCI_VERSION_1_1) {
 		// For SCI1.1 Mac, we need to expand the screen to accommodate for
 		// the icon bar. Of course, both KQ6 and QFG1 VGA differ in size.
-		if (g_sci->getGameId() == "kq6")
+		if (g_sci->getGameId() == GID_KQ6)
 			initGraphics(_displayWidth, _displayHeight + 26, _displayWidth > 320);
-		else if (g_sci->getGameId() == "qfg1")
+		else if (g_sci->getGameId() == GID_QFG1)
 			initGraphics(_displayWidth, _displayHeight + 20, _displayWidth > 320);
 		else
 			error("Unknown SCI1.1 Mac game");

Modified: scummvm/trunk/engines/sci/resource.h
===================================================================
--- scummvm/trunk/engines/sci/resource.h	2010-06-25 16:12:38 UTC (rev 50272)
+++ scummvm/trunk/engines/sci/resource.h	2010-06-25 16:16:29 UTC (rev 50273)
@@ -323,7 +323,7 @@
 	 * archive can be extracted in the extras directory, and the GM patches can be
 	 * applied per game, if applicable.
 	 */
-	void addNewGMPatch(const Common::String &gameId);
+	void addNewGMPatch(SciGameId gameId);
 
 	bool detectHires();
 	// Detects, if standard font of current game includes extended characters (>0x80)

Modified: scummvm/trunk/engines/sci/resource_audio.cpp
===================================================================
--- scummvm/trunk/engines/sci/resource_audio.cpp	2010-06-25 16:12:38 UTC (rev 50272)
+++ scummvm/trunk/engines/sci/resource_audio.cpp	2010-06-25 16:16:29 UTC (rev 50273)
@@ -143,27 +143,37 @@
 	return true;
 }
 
-void ResourceManager::addNewGMPatch(const Common::String &gameId) {
+void ResourceManager::addNewGMPatch(SciGameId gameId) {
 	Common::String gmPatchFile;
 
-	if (gameId == "ecoquest")
+	switch (gameId) {
+	case GID_ECOQUEST:
 		gmPatchFile = "ECO1GM.PAT";
-	else if (gameId == "hoyle3")
+		break;
+	case GID_HOYLE3:
 		gmPatchFile = "HOY3GM.PAT";
-	else if (gameId == "hoyle3")
-		gmPatchFile = "HOY3GM.PAT";
-	else if (gameId == "lsl1sci")
+		break;
+	case GID_LSL1:
 		gmPatchFile = "LL1_GM.PAT";
-	else if (gameId == "lsl5")
+		break;
+	case GID_LSL5:
 		gmPatchFile = "LL5_GM.PAT";
-	else if (gameId == "longbow")
+		break;
+	case GID_LONGBOW:
 		gmPatchFile = "ROBNGM.PAT";
-	else if (gameId == "sq1sci")
+		break;
+	case GID_SQ1:
 		gmPatchFile = "SQ1_GM.PAT";
-	else if (gameId == "sq4")
+		break;
+	case GID_SQ4:
 		gmPatchFile = "SQ4_GM.PAT";
-	else if (gameId == "fairytales")
+		break;
+	case GID_FAIRYTALES:
 		gmPatchFile = "TALEGM.PAT";
+		break;
+	default:
+		break;
+	}
 
 	if (!gmPatchFile.empty() && Common::File::exists(gmPatchFile)) {
 		ResourceSource *psrcPatch = new PatchResourceSource(gmPatchFile);

Modified: scummvm/trunk/engines/sci/sci.cpp
===================================================================
--- scummvm/trunk/engines/sci/sci.cpp	2010-06-25 16:12:38 UTC (rev 50272)
+++ scummvm/trunk/engines/sci/sci.cpp	2010-06-25 16:16:29 UTC (rev 50273)
@@ -71,8 +71,8 @@
 
 class GfxDriver;
 
-SciEngine::SciEngine(OSystem *syst, const ADGameDescription *desc)
-		: Engine(syst), _gameDescription(desc), _gameId(_gameDescription->gameid) {
+SciEngine::SciEngine(OSystem *syst, const ADGameDescription *desc, SciGameId gameId)
+		: Engine(syst), _gameDescription(desc), _gameId(gameId) {
 
 	assert(g_sci == 0);
 	g_sci = this;
@@ -128,7 +128,7 @@
 
 	// Add the patches directory, except for KQ6CD; The patches folder in some versions of KQ6CD
 	// is for the demo of Phantasmagoria, included in the disk
-	if (_gameId != "kq6")
+	if (_gameId != GID_KQ6)
 		SearchMan.addSubDirectoryMatching(gameDataDir, "patches");	// resource patches
 }
 
@@ -179,10 +179,10 @@
 	//  gk1/floppy does support upscaled hires scriptswise, but doesn't actually have the hires content we need to limit
 	//  it to platform windows.
 	if (getPlatform() == Common::kPlatformWindows) {
-		if (_gameId == "kq6")
+		if (_gameId == GID_KQ6)
 			upscaledHires = GFX_SCREEN_UPSCALED_640x440;
 #ifdef ENABLE_SCI32
-		if (_gameId == "gk1")
+		if (_gameId == GID_GK1)
 			upscaledHires = GFX_SCREEN_UPSCALED_640x480;
 #endif
 	}
@@ -503,6 +503,10 @@
 	return _console;
 }
 
+const char *SciEngine::getGameIdStr() const {
+	return _gameDescription->gameid;
+}
+
 Common::Language SciEngine::getLanguage() const {
 	return _gameDescription->language;
 }
@@ -524,12 +528,12 @@
 }
 
 Common::String SciEngine::getFilePrefix() const {
-	if (_gameId == "qfg2") {
+	if (_gameId == GID_QFG2) {
 		// Quest for Glory 2 wants to read files from Quest for Glory 1 (EGA/VGA) to import character data
 		if (_gamestate->currentRoomNumber() == 805)
 			return "qfg1";
 		// TODO: Include import-room for qfg1vga
-	} else if (_gameId == "qfg3") {
+	} else if (_gameId == GID_QFG3) {
 		// Quest for Glory 3 wants to read files from Quest for Glory 2 to import character data
 		if (_gamestate->currentRoomNumber() == 54)
 			return "qfg2";

Modified: scummvm/trunk/engines/sci/sci.h
===================================================================
--- scummvm/trunk/engines/sci/sci.h	2010-06-25 16:12:38 UTC (rev 50272)
+++ scummvm/trunk/engines/sci/sci.h	2010-06-25 16:16:29 UTC (rev 50273)
@@ -104,6 +104,75 @@
 	kDebugLevelOnStartup  = 1 << 23
 };
 
+enum SciGameId {
+	GID_ASTROCHICKEN,
+	GID_CAMELOT,
+	GID_CASTLEBRAIN,
+	GID_CHRISTMAS1988,
+	GID_CHRISTMAS1990,
+	GID_CHRISTMAS1992,
+	GID_CNICK_KQ,
+	GID_CNICK_LAURABOW,
+	GID_CNICK_LONGBOW,
+	GID_CNICK_LSL,
+	GID_CNICK_SQ,
+	GID_ECOQUEST,
+	GID_ECOQUEST2,
+	GID_FAIRYTALES,
+	GID_FREDDYPHARKAS,
+	GID_FUNSEEKER,
+	GID_GK1,
+	GID_GK2,
+	GID_HOYLE1,
+	GID_HOYLE2,
+	GID_HOYLE3,
+	GID_HOYLE4,
+	GID_ICEMAN,
+	GID_ISLANDBRAIN,
+	GID_JONES,
+	GID_KQ1,
+	GID_KQ4,
+	GID_KQ5,
+	GID_KQ6,
+	GID_KQ7,
+	GID_LAURABOW,
+	GID_LAURABOW2,
+	GID_LIGHTHOUSE,
+	GID_LONGBOW,
+	GID_LSL1,
+	GID_LSL2,
+	GID_LSL3,
+	GID_LSL5,
+	GID_LSL6,
+	GID_LSL7,
+	GID_MOTHERGOOSE,
+	GID_MSASTROCHICKEN,
+	GID_PEPPER,
+	GID_PHANTASMAGORIA,
+	GID_PHANTASMAGORIA2,
+	GID_PQ1,
+	GID_PQ2,
+	GID_PQ3,
+	GID_PQ4,
+	GID_PQSWAT,
+	GID_QFG1,
+	GID_QFG2,
+	GID_QFG3,
+	GID_QFG4,
+	GID_RAMA,
+	GID_SHIVERS,
+	GID_SHIVERS2,
+	GID_SLATER,
+	GID_SQ1,
+	GID_SQ3,
+	GID_SQ4,
+	GID_SQ5,
+	GID_SQ6,
+	GID_TORIN,
+
+	GID_FANMADE	// FIXME: Do we really need/want this?
+};
+
 /** SCI versions */
 enum SciVersion {
 	SCI_VERSION_NONE,
@@ -136,7 +205,7 @@
 class SciEngine : public Engine {
 	friend class Console;
 public:
-	SciEngine(OSystem *syst, const ADGameDescription *desc);
+	SciEngine(OSystem *syst, const ADGameDescription *desc, SciGameId gameId);
 	~SciEngine();
 
 	// Engine APIs
@@ -151,7 +220,8 @@
 	bool canSaveGameStateCurrently();
 	void syncSoundSettings();
 
-	const Common::String &getGameId() const { return _gameId; }
+	const SciGameId &getGameId() const { return _gameId; }
+	const char *getGameIdStr() const;
 	int getResourceVersion() const;
 	Common::Language getLanguage() const;
 	Common::Platform getPlatform() const;
@@ -264,7 +334,7 @@
 	void initStackBaseWithSelector(Selector selector);
 
 	const ADGameDescription *_gameDescription;
-	const Common::String _gameId;
+	const SciGameId _gameId;
 	ResourceManager *_resMan; /**< The resource manager */
 	EngineState *_gamestate;
 	Kernel *_kernel;


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list