BASE: Add function EngineManager::generateUniqueDomain

This commit is contained in:
Roberto Sánchez 2022-12-07 10:14:59 +01:00 committed by Eugene Sandulenko
parent bc7b67555a
commit e2b0259d29
2 changed files with 12 additions and 0 deletions

View File

@ -757,6 +757,15 @@ void addStringToConf(const Common::String &key, const Common::String &value, con
} // End of anonymous namespace
Common::String EngineManager::generateUniqueDomain(const Common::String gameId) {
Common::String domainName(gameId);
int suffixN = 1;
while (ConfMan.hasGameDomain(domainName)) {
domainName = gameId + Common::String::format("-%d", suffixN++);
}
return domainName;
}
Common::String EngineManager::createTargetForGame(const DetectedGame &game) {
// The auto detector or the user made a choice.
// Pick a domain name which does not yet exist (after all, we

View File

@ -610,6 +610,9 @@ public:
/** Upgrade a target to the current configuration format. */
void upgradeTargetIfNecessary(const Common::String &target) const;
/** Generate valid, non-repeated domainName for game*/
Common::String generateUniqueDomain(const Common::String gameId);
private:
/** Find a game across all loaded plugins. */
QualifiedGameList findGameInLoadedPlugins(const Common::String &gameId) const;