예제 #1
0
GameList AdvancedMetaEngine::detectGames(const Common::FSList &fslist) const {
    ADGameDescList matches = detectGame(fslist, params, Common::UNK_LANG, Common::kPlatformUnknown, "");
    GameList detectedGames;

    if (cleanupPirated(matches))
        return detectedGames;

    if (matches.empty()) {
        // Use fallback detector if there were no matches by other means
        const ADGameDescription *fallbackDesc = fallbackDetect(fslist);
        if (fallbackDesc != 0) {
            GameDescriptor desc(toGameDescriptor(*fallbackDesc, params.list));
            updateGameDescriptor(desc, fallbackDesc, params);
            detectedGames.push_back(desc);
        }
    } else {
        // Otherwise use the found matches
        for (uint i = 0; i < matches.size(); i++) {
            GameDescriptor desc(toGameDescriptor(*matches[i], params.list));
            updateGameDescriptor(desc, matches[i], params);
            detectedGames.push_back(desc);
        }
    }

    return detectedGames;
}
예제 #2
0
GameList AdvancedMetaEngine::detectGames(const Common::FSList &fslist) const {
	ADGameDescList matches;
	GameList detectedGames;
	FileMap allFiles;

	if (fslist.empty())
		return detectedGames;

	// Compose a hashmap of all files in fslist.
	composeFileHashMap(allFiles, fslist, (_maxScanDepth == 0 ? 1 : _maxScanDepth));

	// Run the detector on this
	matches = detectGame(fslist.begin()->getParent(), allFiles, Common::UNK_LANG, Common::kPlatformUnknown, "");

	if (matches.empty()) {
		// Use fallback detector if there were no matches by other means
		const ADGameDescription *fallbackDesc = fallbackDetect(allFiles, fslist);
		if (fallbackDesc != 0) {
			GameDescriptor desc(toGameDescriptor(*fallbackDesc, _gameIds));
			updateGameDescriptor(desc, fallbackDesc);
			detectedGames.push_back(desc);
		}
	} else {
		// Otherwise use the found matches
		cleanupPirated(matches);
		for (uint i = 0; i < matches.size(); i++) {
			GameDescriptor desc(toGameDescriptor(*matches[i], _gameIds));
			updateGameDescriptor(desc, matches[i]);
			detectedGames.push_back(desc);
		}
	}

	return detectedGames;
}
예제 #3
0
Common::Error AdvancedMetaEngine::createInstance(OSystem *syst, Engine **engine) const {
    assert(engine);
    upgradeTargetIfNecessary(params);

    const ADGameDescription *agdDesc = 0;
    Common::Language language = Common::UNK_LANG;
    Common::Platform platform = Common::kPlatformUnknown;
    Common::String extra;

    if (ConfMan.hasKey("language"))
        language = Common::parseLanguage(ConfMan.get("language"));
    if (ConfMan.hasKey("platform"))
        platform = Common::parsePlatform(ConfMan.get("platform"));
    if (params.flags & kADFlagUseExtraAsHint)
        if (ConfMan.hasKey("extra"))
            extra = ConfMan.get("extra");

    Common::String gameid = ConfMan.get("gameid");

    Common::String path;
    if (ConfMan.hasKey("path")) {
        path = ConfMan.get("path");
    } else {
        path = ".";

        // This situation may happen only when game was
        // launched from a command line with wrong target and
        // no path was provided.
        //
        // A dummy entry will get created and will keep game path
        // We mark this entry, so it will not be added to the
        // config file.
        //
        // Fixes bug #1544799
        ConfMan.setBool("autoadded", true);

        warning("No path was provided. Assuming the data files are in the current directory");
    }
    Common::FSNode dir(path);
    Common::FSList files;
    if (!dir.isDirectory() || !dir.getChildren(files, Common::FSNode::kListAll)) {
        warning("Game data path does not exist or is not a directory (%s)", path.c_str());
        return Common::kNoGameDataFoundError;
    }

    ADGameDescList matches = detectGame(files, params, language, platform, extra);

    if (cleanupPirated(matches))
        return Common::kNoGameDataFoundError;

    if (params.singleid == NULL) {
        for (uint i = 0; i < matches.size(); i++) {
            if (matches[i]->gameid == gameid) {
                agdDesc = matches[i];
                break;
            }
        }
    } else if (matches.size() > 0) {
        agdDesc = matches[0];
    }

    if (agdDesc == 0) {
        // Use fallback detector if there were no matches by other means
        agdDesc = fallbackDetect(files);
        if (agdDesc != 0) {
            // Seems we found a fallback match. But first perform a basic
            // sanity check: the gameid must match.
            if (params.singleid == NULL && agdDesc->gameid != gameid)
                agdDesc = 0;
        }
    }

    if (agdDesc == 0)
        return Common::kNoGameDataFoundError;

    // If the GUI options were updated, we catch this here and update them in the users config
    // file transparently.
    Common::String lang = getGameGUIOptionsDescriptionLanguage(agdDesc->language);
    if (agdDesc->flags & ADGF_ADDENGLISH)
        lang += " " + getGameGUIOptionsDescriptionLanguage(Common::EN_ANY);

    Common::updateGameGUIOptions(agdDesc->guioptions | params.guioptions, lang);


    debug(2, "Running %s", toGameDescriptor(*agdDesc, params.list).description().c_str());
    if (!createInstance(syst, engine, agdDesc))
        return Common::kNoGameDataFoundError;
    else
        return Common::kNoError;
}
예제 #4
0
Common::Error AdvancedMetaEngine::createInstance(OSystem *syst, Engine **engine) const {
	assert(engine);

	const ADGameDescription *agdDesc = 0;
	Common::Language language = Common::UNK_LANG;
	Common::Platform platform = Common::kPlatformUnknown;
	Common::String extra;

	if (ConfMan.hasKey("language"))
		language = Common::parseLanguage(ConfMan.get("language"));
	if (ConfMan.hasKey("platform"))
		platform = Common::parsePlatform(ConfMan.get("platform"));
	if (_flags & kADFlagUseExtraAsHint) {
		if (ConfMan.hasKey("extra"))
			extra = ConfMan.get("extra");
	}

	Common::String gameid = ConfMan.get("gameid");

	Common::String path;
	if (ConfMan.hasKey("path")) {
		path = ConfMan.get("path");
	} else {
		path = ".";

		// This situation may happen only when game was
		// launched from a command line with wrong target and
		// no path was provided.
		//
		// A dummy entry will get created and will keep game path
		// We mark this entry, so it will not be added to the
		// config file.
		//
		// Fixes bug #1544799
		ConfMan.setBool("autoadded", true);

		warning("No path was provided. Assuming the data files are in the current directory");
	}
	Common::FSNode dir(path);
	Common::FSList files;
	if (!dir.isDirectory() || !dir.getChildren(files, Common::FSNode::kListAll, true)) {
		warning("Game data path does not exist or is not a directory (%s)", path.c_str());
		return Common::kNoGameDataFoundError;
	}

	if (files.empty())
		return Common::kNoGameDataFoundError;

	// Compose a hashmap of all files in fslist.
	FileMap allFiles;
	composeFileHashMap(allFiles, files, (_maxScanDepth == 0 ? 1 : _maxScanDepth));

	// Run the detector on this
	ADGameDescList matches = detectGame(files.begin()->getParent(), allFiles, language, platform, extra);

	if (cleanupPirated(matches))
		return Common::kNoGameDataFoundError;

	if (_singleId == NULL) {
		// Find the first match with correct gameid.
		for (uint i = 0; i < matches.size(); i++) {
			if (matches[i]->gameId == gameid) {
				agdDesc = matches[i];
				break;
			}
		}
	} else if (matches.size() > 0) {
		agdDesc = matches[0];
	}

	if (agdDesc == 0) {
		// Use fallback detector if there were no matches by other means
		agdDesc = fallbackDetect(allFiles, files);
		if (agdDesc != 0) {
			// Seems we found a fallback match. But first perform a basic
			// sanity check: the gameid must match.
			if (_singleId == NULL && agdDesc->gameId != gameid)
				agdDesc = 0;
		}
	}

	if (agdDesc == 0)
		return Common::kNoGameDataFoundError;

	// If the GUI options were updated, we catch this here and update them in the users config
	// file transparently.
	Common::String lang = getGameGUIOptionsDescriptionLanguage(agdDesc->language);
	if (agdDesc->flags & ADGF_ADDENGLISH)
		lang += " " + getGameGUIOptionsDescriptionLanguage(Common::EN_ANY);

	Common::updateGameGUIOptions(agdDesc->guiOptions + _guiOptions, lang);

	GameDescriptor gameDescriptor = toGameDescriptor(*agdDesc, _gameIds);

	bool showTestingWarning = false;

#ifdef RELEASE_BUILD
	showTestingWarning = true;
#endif

	if (((gameDescriptor.getSupportLevel() == kUnstableGame
			|| (gameDescriptor.getSupportLevel() == kTestingGame
					&& showTestingWarning)))
			&& !Engine::warnUserAboutUnsupportedGame())
		return Common::kUserCanceled;

	debug(2, "Running %s", gameDescriptor.description().c_str());
	initSubSystems(agdDesc);
	if (!createInstance(syst, engine, agdDesc))
		return Common::kNoGameDataFoundError;
	else
		return Common::kNoError;
}