aboutsummaryrefslogtreecommitdiff
path: root/engines/scumm/detection.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/scumm/detection.cpp')
-rw-r--r--engines/scumm/detection.cpp87
1 files changed, 36 insertions, 51 deletions
diff --git a/engines/scumm/detection.cpp b/engines/scumm/detection.cpp
index bba26961c7..e5c5906404 100644
--- a/engines/scumm/detection.cpp
+++ b/engines/scumm/detection.cpp
@@ -69,26 +69,26 @@ static const MD5Table *findInMD5Table(const char *md5) {
Common::String ScummEngine::generateFilename(const int room) const {
const int diskNumber = (room > 0) ? _res->_types[rtRoom][room]._roomno : 0;
- char buf[128];
+ Common::String result;
if (_game.version == 4) {
if (room == 0 || room >= 900) {
- snprintf(buf, sizeof(buf), "%03d.lfl", room);
+ result = Common::String::format("%03d.lfl", room);
} else {
- snprintf(buf, sizeof(buf), "disk%02d.lec", diskNumber);
+ result = Common::String::format("disk%02d.lec", diskNumber);
}
} else {
switch (_filenamePattern.genMethod) {
case kGenDiskNum:
- snprintf(buf, sizeof(buf), _filenamePattern.pattern, diskNumber);
+ result = Common::String::format(_filenamePattern.pattern, diskNumber);
break;
case kGenRoomNum:
- snprintf(buf, sizeof(buf), _filenamePattern.pattern, room);
+ result = Common::String::format(_filenamePattern.pattern, room);
break;
case kGenUnchanged:
- strncpy(buf, _filenamePattern.pattern, sizeof(buf));
+ result = _filenamePattern.pattern;
break;
default:
@@ -96,11 +96,11 @@ Common::String ScummEngine::generateFilename(const int room) const {
}
}
- return buf;
+ return result;
}
Common::String ScummEngine_v60he::generateFilename(const int room) const {
- char buf[128];
+ Common::String result;
char id = 0;
switch (_filenamePattern.genMethod) {
@@ -115,16 +115,16 @@ Common::String ScummEngine_v60he::generateFilename(const int room) const {
}
if (_filenamePattern.genMethod == kGenHEPC) {
- snprintf(buf, sizeof(buf), "%s.he%c", _filenamePattern.pattern, id);
+ result = Common::String::format("%s.he%c", _filenamePattern.pattern, id);
} else {
if (id == '3') { // special case for cursors
// For mac they're stored in game binary
- strncpy(buf, _filenamePattern.pattern, sizeof(buf));
+ result = _filenamePattern.pattern;
} else {
if (_filenamePattern.genMethod == kGenHEMac)
- snprintf(buf, sizeof(buf), "%s (%c)", _filenamePattern.pattern, id);
+ result = Common::String::format("%s (%c)", _filenamePattern.pattern, id);
else
- snprintf(buf, sizeof(buf), "%s %c", _filenamePattern.pattern, id);
+ result = Common::String::format("%s %c", _filenamePattern.pattern, id);
}
}
@@ -135,11 +135,11 @@ Common::String ScummEngine_v60he::generateFilename(const int room) const {
return ScummEngine::generateFilename(room);
}
- return buf;
+ return result;
}
Common::String ScummEngine_v70he::generateFilename(const int room) const {
- char buf[128];
+ Common::String result;
char id = 0;
switch (_filenamePattern.genMethod) {
@@ -156,19 +156,19 @@ Common::String ScummEngine_v70he::generateFilename(const int room) const {
id = 'b';
// Special cases for Blue's games, which share common (b) files
if (_game.id == GID_BIRTHDAY && !(_game.features & GF_DEMO))
- strcpy(buf, "Blue'sBirthday.(b)");
+ result = "Blue'sBirthday.(b)";
else if (_game.id == GID_TREASUREHUNT)
- strcpy(buf, "Blue'sTreasureHunt.(b)");
+ result = "Blue'sTreasureHunt.(b)";
else
- snprintf(buf, sizeof(buf), "%s.(b)", _filenamePattern.pattern);
+ result = Common::String::format("%s.(b)", _filenamePattern.pattern);
break;
case 1:
id = 'a';
- snprintf(buf, sizeof(buf), "%s.(a)", _filenamePattern.pattern);
+ result = Common::String::format("%s.(a)", _filenamePattern.pattern);
break;
default:
id = '0';
- snprintf(buf, sizeof(buf), "%s.he0", _filenamePattern.pattern);
+ result = Common::String::format("%s.he0", _filenamePattern.pattern);
}
} else if (room < 0) {
id = '0' - room;
@@ -179,16 +179,16 @@ Common::String ScummEngine_v70he::generateFilename(const int room) const {
if (_filenamePattern.genMethod == kGenHEPC) {
// For HE >= 98, we already called snprintf above.
if (_game.heversion < 98 || room < 0)
- snprintf(buf, sizeof(buf), "%s.he%c", _filenamePattern.pattern, id);
+ result = Common::String::format("%s.he%c", _filenamePattern.pattern, id);
} else {
if (id == '3') { // special case for cursors
// For mac they're stored in game binary
- strncpy(buf, _filenamePattern.pattern, sizeof(buf));
+ result = _filenamePattern.pattern;
} else {
if (_filenamePattern.genMethod == kGenHEMac)
- snprintf(buf, sizeof(buf), "%s (%c)", _filenamePattern.pattern, id);
+ result = Common::String::format("%s (%c)", _filenamePattern.pattern, id);
else
- snprintf(buf, sizeof(buf), "%s %c", _filenamePattern.pattern, id);
+ result = Common::String::format("%s %c", _filenamePattern.pattern, id);
}
}
@@ -199,40 +199,39 @@ Common::String ScummEngine_v70he::generateFilename(const int room) const {
return ScummEngine_v60he::generateFilename(room);
}
- return buf;
+ return result;
}
static Common::String generateFilenameForDetection(const char *pattern, FilenameGenMethod genMethod) {
- char buf[128];
+ Common::String result;
switch (genMethod) {
case kGenDiskNum:
case kGenRoomNum:
- snprintf(buf, sizeof(buf), pattern, 0);
+ result = Common::String::format(pattern, 0);
break;
case kGenHEPC:
- snprintf(buf, sizeof(buf), "%s.he0", pattern);
+ result = Common::String::format("%s.he0", pattern);
break;
case kGenHEMac:
- snprintf(buf, sizeof(buf), "%s (0)", pattern);
+ result = Common::String::format("%s (0)", pattern);
break;
case kGenHEMacNoParens:
- snprintf(buf, sizeof(buf), "%s 0", pattern);
+ result = Common::String::format("%s 0", pattern);
break;
case kGenUnchanged:
- strncpy(buf, pattern, sizeof(buf));
+ result = pattern;
break;
default:
error("generateFilenameForDetection: Unsupported genMethod");
}
- buf[sizeof(buf) - 1] = 0;
- return buf;
+ return result;
}
struct DetectorDesc {
@@ -432,7 +431,7 @@ static void computeGameSettingsFromMD5(const Common::FSList &fslist, const GameF
}
}
-static void composeFileHashMap(const Common::FSList &fslist, DescMap &fileMD5Map, int depth, const char **globs) {
+static void composeFileHashMap(DescMap &fileMD5Map, const Common::FSList &fslist, int depth, const char **globs) {
if (depth <= 0)
return;
@@ -460,9 +459,8 @@ static void composeFileHashMap(const Common::FSList &fslist, DescMap &fileMD5Map
continue;
Common::FSList files;
-
if (file->getChildren(files, Common::FSNode::kListAll)) {
- composeFileHashMap(files, fileMD5Map, depth - 1, globs);
+ composeFileHashMap(fileMD5Map, files, depth - 1, globs);
}
}
}
@@ -473,7 +471,7 @@ static void detectGames(const Common::FSList &fslist, Common::List<DetectorResul
DetectorResult dr;
// Dive one level down since mac indy3/loom has its files split into directories. See Bug #1438631
- composeFileHashMap(fslist, fileMD5Map, 2, directoryGlobs);
+ composeFileHashMap(fileMD5Map, fslist, 2, directoryGlobs);
// Iterate over all filename patterns.
for (const GameFilenamePattern *gfp = gameFilenamesTable; gfp->gameid; ++gfp) {
@@ -883,7 +881,7 @@ GameList ScummMetaEngine::getSupportedGames() const {
}
GameDescriptor ScummMetaEngine::findGame(const char *gameid) const {
- return AdvancedDetector::findGameID(gameid, gameDescriptions, obsoleteGameIDsTable);
+ return Engines::findGameID(gameid, gameDescriptions, obsoleteGameIDsTable);
}
static Common::String generatePreferredTarget(const DetectorResult &x) {
@@ -976,20 +974,7 @@ Common::Error ScummMetaEngine::createInstance(OSystem *syst, Engine **engine) co
// We start by checking whether the specified game ID is obsolete.
// If that is the case, we automatically upgrade the target to use
// the correct new game ID (and platform, if specified).
- for (const ADObsoleteGameID *o = obsoleteGameIDsTable; o->from; ++o) {
- if (!scumm_stricmp(gameid, o->from)) {
- // Match found, perform upgrade
- gameid = o->to;
- ConfMan.set("gameid", o->to);
-
- if (o->platform != Common::kPlatformUnknown)
- ConfMan.set("platform", Common::getPlatformCode(o->platform));
-
- warning("Target upgraded from game ID %s to %s", o->from, o->to);
- ConfMan.flushToDisk();
- break;
- }
- }
+ Engines::upgradeTargetIfNecessary(obsoleteGameIDsTable);
// Fetch the list of files in the current directory
Common::FSList fslist;