/** * @brief Checks if the necessary subsystems for the application to run are correctly init * If they are not -> it inits them. */ void Application::checkSubsystemsInit() { if ( isValid() ) return; initSubSystems(); }
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; }