aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorMax Horn2011-05-25 10:46:58 +0200
committerMax Horn2011-05-25 13:01:05 +0200
commit0aa6aca4201df105276455d550d00495fdaa067b (patch)
treea43d0abd98a9d7609b76918a12f9b928c4b91cd4 /engines
parent91e304e35fe641f46aaf5dce874354627256c1a7 (diff)
downloadscummvm-rg350-0aa6aca4201df105276455d550d00495fdaa067b.tar.gz
scummvm-rg350-0aa6aca4201df105276455d550d00495fdaa067b.tar.bz2
scummvm-rg350-0aa6aca4201df105276455d550d00495fdaa067b.zip
SCUMM: Switch some code to use String::format
Diffstat (limited to 'engines')
-rw-r--r--engines/scumm/detection.cpp63
1 files changed, 31 insertions, 32 deletions
diff --git a/engines/scumm/detection.cpp b/engines/scumm/detection.cpp
index bba26961c7..aecd13db5a 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 {