diff options
author | Eugene Sandulenko | 2005-10-14 04:28:20 +0000 |
---|---|---|
committer | Eugene Sandulenko | 2005-10-14 04:28:20 +0000 |
commit | 7f6402ef0631cb044ce957c2a019367b29249ab8 (patch) | |
tree | 0a9e1a3e147799908b4b37a2e53e6e8add52a5ba | |
parent | 05457402f59afac71d97d2aec31c4a229fa1db2d (diff) | |
download | scummvm-rg350-7f6402ef0631cb044ce957c2a019367b29249ab8.tar.gz scummvm-rg350-7f6402ef0631cb044ce957c2a019367b29249ab8.tar.bz2 scummvm-rg350-7f6402ef0631cb044ce957c2a019367b29249ab8.zip |
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.
svn-id: r19074
-rw-r--r-- | saga/game.cpp | 122 | ||||
-rw-r--r-- | saga/saga.cpp | 2 | ||||
-rw-r--r-- | saga/saga.h | 2 |
3 files changed, 107 insertions, 19 deletions
diff --git a/saga/game.cpp b/saga/game.cpp index 8002e10a07..6d64f739d4 100644 --- a/saga/game.cpp +++ b/saga/game.cpp @@ -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 @@ static GameDescription gameDescriptions[] = { // 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 @@ static GameDescription gameDescriptions[] = { // Inherit the earth - MAC Demo version { - "ite-demo", + "ite", GType_ITE, GID_ITE_MACDEMO2, "Inherit the Earth (MAC Demo)", @@ -910,7 +911,7 @@ static GameDescription gameDescriptions[] = { // 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 @@ static GameDescription gameDescriptions[] = { // 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 @@ static GameDescription gameDescriptions[] = { 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 @@ static GameDescription gameDescriptions[] = { // 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 @@ static GameDescription gameDescriptions[] = { 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 @@ static GameDescription gameDescriptions[] = { // 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 @@ static GameDescription gameDescriptions[] = { }; -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 @@ bool SagaEngine::initGame(void) { 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; diff --git a/saga/saga.cpp b/saga/saga.cpp index 0636eae4c3..5a30ff5633 100644 --- a/saga/saga.cpp +++ b/saga/saga.cpp @@ -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} }; diff --git a/saga/saga.h b/saga/saga.h index bca7f4bc42..f1a57b0dcd 100644 --- a/saga/saga.h +++ b/saga/saga.h @@ -542,7 +542,7 @@ inline uint16 objectIndexToId(int type, int index) { } -DetectedGameList GAME_ProbeGame(const FSList &fslist); +DetectedGameList GAME_ProbeGame(const FSList &fslist, int **matches = NULL); class SagaEngine : public Engine { friend class Scene; |