diff options
author | Pino Toscano | 2014-12-22 22:39:05 +0100 |
---|---|---|
committer | Pino Toscano | 2014-12-22 23:10:31 +0100 |
commit | cfd00ad6afc09ca6990ce905b1a8db4ea1ad1602 (patch) | |
tree | 47928eaf92455bfe65d79ce2665ae6120056a587 | |
parent | eb4645cda855b0ac919124fefc79c580883903d3 (diff) | |
download | scummvm-rg350-cfd00ad6afc09ca6990ce905b1a8db4ea1ad1602.tar.gz scummvm-rg350-cfd00ad6afc09ca6990ce905b1a8db4ea1ad1602.tar.bz2 scummvm-rg350-cfd00ad6afc09ca6990ce905b1a8db4ea1ad1602.zip |
AGI: use Common::String::format when possible
Use Common::String::format instead of a MAXPATHLEN-sized char[] buffer.
-rw-r--r-- | engines/agi/detection.cpp | 6 | ||||
-rw-r--r-- | engines/agi/loader_v2.cpp | 8 | ||||
-rw-r--r-- | engines/agi/loader_v3.cpp | 3 |
3 files changed, 7 insertions, 10 deletions
diff --git a/engines/agi/detection.cpp b/engines/agi/detection.cpp index e7285d8112..3230b4e5d3 100644 --- a/engines/agi/detection.cpp +++ b/engines/agi/detection.cpp @@ -276,15 +276,13 @@ SaveStateList AgiMetaEngine::listSaves(const char *target) const { int AgiMetaEngine::getMaximumSaveSlot() const { return 999; } void AgiMetaEngine::removeSaveState(const char *target, int slot) const { - char fileName[MAXPATHLEN]; - sprintf(fileName, "%s.%03d", target, slot); + Common::String fileName = Common::String::format("%s.%03d", target, slot); g_system->getSavefileManager()->removeSavefile(fileName); } SaveStateDescriptor AgiMetaEngine::querySaveMetaInfos(const char *target, int slot) const { const uint32 AGIflag = MKTAG('A','G','I',':'); - char fileName[MAXPATHLEN]; - sprintf(fileName, "%s.%03d", target, slot); + Common::String fileName = Common::String::format("%s.%03d", target, slot); Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(fileName); diff --git a/engines/agi/loader_v2.cpp b/engines/agi/loader_v2.cpp index 787eeaa0c7..3f164b7fc0 100644 --- a/engines/agi/loader_v2.cpp +++ b/engines/agi/loader_v2.cpp @@ -135,13 +135,13 @@ int AgiLoader_v2::unloadResource(int t, int n) { */ uint8 *AgiLoader_v2::loadVolRes(struct AgiDir *agid) { uint8 *data = NULL; - char x[MAXPATHLEN], *path; + char x[MAXPATHLEN]; Common::File fp; unsigned int sig; + Common::String path; - sprintf(x, "vol.%i", agid->volume); - path = x; - debugC(3, kDebugLevelResources, "Vol res: path = %s", path); + path = Common::String::format("vol.%i", agid->volume); + debugC(3, kDebugLevelResources, "Vol res: path = %s", path.c_str()); if (agid->offset != _EMPTY && fp.open(path)) { debugC(3, kDebugLevelResources, "loading resource at offset %d", agid->offset); diff --git a/engines/agi/loader_v3.cpp b/engines/agi/loader_v3.cpp index fa135e5476..b90c17a1f3 100644 --- a/engines/agi/loader_v3.cpp +++ b/engines/agi/loader_v3.cpp @@ -204,8 +204,7 @@ uint8 *AgiLoader_v3::loadVolRes(AgiDir *agid) { Common::String path; debugC(3, kDebugLevelResources, "(%p)", (void *)agid); - sprintf(x, "vol.%i", agid->volume); - path = Common::String(_vm->_game.name) + x; + path = Common::String::format("%svol.%i", _vm->_game.name, agid->volume); if (agid->offset != _EMPTY && fp.open(path)) { fp.seek(agid->offset, SEEK_SET); |