[Scummvm-cvs-logs] CVS: scummvm/saga game.cpp,1.116,1.117 saga.cpp,1.144,1.145 saga.h,1.132,1.133

Eugene Sandulenko sev at users.sourceforge.net
Thu Oct 13 21:29:06 CEST 2005


Update of /cvsroot/scummvm/scummvm/saga
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24831

Modified Files:
	game.cpp saga.cpp saga.h 
Log Message:
Eliminate ite-demo and ihnm-demo targets as we do in SAGA. Just use plain
ite and ihnm respectively. Sorry, but I had to do it before release, no
autoupgrade as games weren't supported only in developer's version.

Fix bug #1297365 "ITE: Game detection is broken".

Now it distinguishes between DOS CD and Win CD, though it uses platform and 
language settings from .ini to do the choice. I.e current games need to be
redetected. Though only these 2 games are affected. I.e. they have exactly
same resource files, just Windows release adds up external patches. These
patches cannot be added to detection as they're stored in subdirectories.

Also I resolved problem between ite-demo-win and ite-demo-linux where latter
is a superset of former. I.e. it has all files which win demo has plus one 
additional. And if you try to detect Linux demo it shows you both. Of course
this could be handled by upper solution, but to make sure I count number of
required files for matched versions and remove those which do not have max
number of files. I.e. if 2 games matched and one requires 4 and another one
requires 5 files, then we have 5 files matched which certainly points to
second game not the first.


Index: game.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/game.cpp,v
retrieving revision 1.116
retrieving revision 1.117
diff -u -d -r1.116 -r1.117
--- game.cpp	14 Oct 2005 00:56:52 -0000	1.116
+++ game.cpp	14 Oct 2005 04:28:19 -0000	1.117
@@ -28,6 +28,7 @@
 #include "common/file.h"
 #include "common/md5.h"
 #include "common/map.h"
+#include "common/config-manager.h"
 #include "base/plugins.h"
 #include "base/gameDetector.h"
 #include "backends/fs/fs.h"
@@ -864,7 +865,7 @@
 	// Inherit the earth - DOS Demo version
 	// sound unchecked
 	{
-		"ite-demo",
+		"ite",
 		GType_ITE,
 		GID_ITE_DEMO_G, // Game id
 		"Inherit the Earth (DOS Demo)", // Game title
@@ -887,7 +888,7 @@
 
 	// Inherit the earth - MAC Demo version
 	{
-		"ite-demo",
+		"ite",
 		GType_ITE,
 		GID_ITE_MACDEMO2,
 		"Inherit the Earth (MAC Demo)",
@@ -910,7 +911,7 @@
 
 	// Inherit the earth - early MAC Demo version
 	{
-		"ite-demo",
+		"ite",
 		GType_ITE,
 		GID_ITE_MACDEMO1,
 		"Inherit the Earth (early MAC Demo)",
@@ -980,7 +981,7 @@
 	// Inherit the earth - Linux Demo version
 	// Note: it should be before GID_ITE_WINDEMO2 version
 	{
-		"ite-demo",
+		"ite",
 		GType_ITE,
 		GID_ITE_LINDEMO,
 		"Inherit the Earth (Linux Demo)",
@@ -998,12 +999,12 @@
 		ITELinPatch_Files,
 		GF_WYRMKEEP | GF_CD_FX | GF_SCENE_SUBSTITUTES,
 		Common::EN_USA,
-		Common::kPlatformPC,
+		Common::kPlatformLinux,
 	},
 
 	// Inherit the earth - Win32 Demo version
 	{
-		"ite-demo",
+		"ite",
 		GType_ITE,
 		GID_ITE_WINDEMO2,
 		"Inherit the Earth (Win32 Demo)",
@@ -1026,7 +1027,7 @@
 
 	// Inherit the earth - early Win32 Demo version
 	{
-		"ite-demo",
+		"ite",
 		GType_ITE,
 		GID_ITE_WINDEMO1,
 		"Inherit the Earth (early Win32 Demo)",
@@ -1092,8 +1093,8 @@
 		ARRAYSIZE(ITELinPatch_Files),
 		ITELinPatch_Files,
 		GF_WYRMKEEP | GF_CD_FX,
-		Common::DE_DEU,
-		Common::kPlatformPC,
+		Common::EN_USA,
+		Common::kPlatformLinux,
 	},
 
 	// Inherit the earth - Wyrmkeep Windows CD version
@@ -1240,7 +1241,7 @@
 
 	// I Have No Mouth And I Must Scream - Demo version
 	{
-		"ihnm-demo",
+		"ihnm",
 		GType_IHNM,
 		GID_IHNM_DEMO,
 		"I Have No Mouth and I Must Scream (DOS Demo)",
@@ -1331,16 +1332,59 @@
 
 };
 
-bool SagaEngine::initGame(void) {
+bool SagaEngine::initGame() {
 	uint16 gameCount = ARRAYSIZE(gameDescriptions);
 	int gameNumber;
 	FSList dummy;
+	DetectedGameList detectedGames;
+	int *matches;
+	Common::Language language = Common::UNK_LANG;
+	Common::Platform platform = Common::kPlatformUnknown;
 
-	if ((gameNumber = detectGame(dummy)) == -1) {
+	if (ConfMan.hasKey("language"))
+		language = Common::parseLanguage(ConfMan.get("language"));
+	if (ConfMan.hasKey("platform"))
+		platform = Common::parsePlatform(ConfMan.get("platform"));
+
+
+	detectedGames = GAME_ProbeGame(dummy, &matches);
+
+	if (detectedGames.size() == 0) {
 		warning("No valid games were found in the specified directory.");
 		return false;
 	}
 
+	// If we have more than one match then try to match by platform and
+	// language
+	int count = 0;
+	if (detectedGames.size() > 1) {
+		for (int i = 0; i < ARRAYSIZE(gameDescriptions); i++)
+			if (matches[i] != -1) {
+				if ((gameDescriptions[matches[i]].language != language &&
+					 language != Common::UNK_LANG) ||
+					(gameDescriptions[matches[i]].platform != platform &&
+					 platform != Common::kPlatformUnknown))
+					matches[i] = -1;
+				else
+					count++;
+			}
+	} else
+		count = 1;
+
+	if (count != 1)
+		warning("Conflicting targets detected (%d)", count);
+
+	for (int i = 0; i < ARRAYSIZE(gameDescriptions); i++)
+		if (matches[i] != -1) {
+			gameNumber = matches[i];
+			break;
+		}
+
+	free(matches);
+
+	if ((gameNumber = detectGame(dummy)) == -1) {
+	}
+
 	if (gameNumber >= gameCount) {
 		error("SagaEngine::loadGame wrong gameNumber");
 	}
@@ -1357,18 +1401,64 @@
 	return true;
 }
 
-DetectedGameList GAME_ProbeGame(const FSList &fslist) {
+DetectedGameList GAME_ProbeGame(const FSList &fslist, int **retmatches) {
 	DetectedGameList detectedGames;
 	int game_n;
+	int index = 0, i, j;
+	int matches[ARRAYSIZE(gameDescriptions)];
+	bool mode = retmatches ? false : true;
 
 	game_n = -1;
+	for (i = 0; i < ARRAYSIZE(gameDescriptions); i++)
+		matches[i] = -1;
 
 	while (1) {
-		game_n = detectGame(fslist, true, game_n);
+		game_n = detectGame(fslist, mode, game_n);
 		if (game_n == -1)
 			break;
-		detectedGames.push_back(DetectedGame(gameDescriptions[game_n].toGameSettings(),
-					 gameDescriptions[game_n].language, gameDescriptions[game_n].platform));
+		matches[index++] = game_n;
+	}
+
+	// We have some resource sets which are superpositions of other
+	// Particularly it is ite-demo-linux vs ite-demo-win
+	// Now remove lesser set if bigger matches too
+
+	if (index > 1) {
+		// Search max number
+		int maxcount = 0;
+		for (i = 0; i < index; i++) {
+			int count = 0;
+			for (j = 0; j < ARRAYSIZE(gameMD5); j++)
+				if (gameMD5[j].id == gameDescriptions[matches[i]].gameId)
+					count++;
+			maxcount = MAX(maxcount, count);
+		}
+
+		// Now purge targets with number of files lesser than max
+		for (i = 0; i < index; i++) {
+			int count = 0;
+			for (j = 0; j < ARRAYSIZE(gameMD5); j++)
+				if (gameMD5[j].id == gameDescriptions[matches[i]].gameId)
+					count++;
+			if (count < maxcount) {
+				debug(0, "Purged: %s", gameDescriptions[matches[i]].title);
+				matches[i] = -1;
+			}
+		}
+
+	}
+
+	// and now push them into list of detected games
+	for (i = 0; i < index; i++)
+		if (matches[i] != -1)
+			detectedGames.push_back(DetectedGame(gameDescriptions[matches[i]].toGameSettings(),
+							 gameDescriptions[matches[i]].language,
+							 gameDescriptions[matches[i]].platform));
+		
+	if (retmatches) {
+		*retmatches = (int *)calloc(ARRAYSIZE(gameDescriptions), sizeof(int));
+		for (i = 0; i < ARRAYSIZE(gameDescriptions); i++)
+			(*retmatches)[i] = matches[i];
 	}
 
 	return detectedGames;

Index: saga.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/saga.cpp,v
retrieving revision 1.144
retrieving revision 1.145
diff -u -d -r1.144 -r1.145
--- saga.cpp	14 Oct 2005 00:56:52 -0000	1.144
+++ saga.cpp	14 Oct 2005 04:28:20 -0000	1.145
@@ -57,9 +57,7 @@
 
 static const GameSettings saga_games[] = {
 	{"ite", "Inherit the Earth", 0},
-	{"ite-demo", "Inherit the Earth (Demo)", 0},
 	{"ihnm", "I Have No Mouth and I Must Scream", GF_DEFAULT_TO_1X_SCALER },
-	{"ihnm-demo", "I Have No Mouth and I Must Scream (Demo)", GF_DEFAULT_TO_1X_SCALER },
 	{0, 0, 0}
 };
 

Index: saga.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/saga.h,v
retrieving revision 1.132
retrieving revision 1.133
diff -u -d -r1.132 -r1.133
--- saga.h	14 Oct 2005 00:56:52 -0000	1.132
+++ saga.h	14 Oct 2005 04:28:20 -0000	1.133
@@ -542,7 +542,7 @@
 }
 
 
-DetectedGameList GAME_ProbeGame(const FSList &fslist);
+DetectedGameList GAME_ProbeGame(const FSList &fslist, int **matches = NULL);
 
 class SagaEngine : public Engine {
 	friend class Scene;





More information about the Scummvm-git-logs mailing list