From 0d379b3783e368160476c78d31b05a9e9914e782 Mon Sep 17 00:00:00 2001 From: D G Turner Date: Thu, 2 Jun 2011 03:44:31 +0100 Subject: CINE: Replace snprintf() usage with Common::String::format() Safer and less portability issues. --- engines/cine/detection.cpp | 16 +++++----------- engines/cine/saveload.cpp | 5 +---- engines/cine/various.cpp | 7 +++---- 3 files changed, 9 insertions(+), 19 deletions(-) (limited to 'engines/cine') diff --git a/engines/cine/detection.cpp b/engines/cine/detection.cpp index 0ef2c87288..64eee4574f 100644 --- a/engines/cine/detection.cpp +++ b/engines/cine/detection.cpp @@ -185,10 +185,7 @@ void CineMetaEngine::removeSaveState(const char *target, int slot) const { memset(saveNames, 0, sizeof(saveNames)); Common::InSaveFile *in; - char tmp[80]; - - snprintf(tmp, 80, "%s.dir", target); - in = g_system->getSavefileManager()->openForLoading(tmp); + in = g_system->getSavefileManager()->openForLoading(Common::String::format("%s.dir", target)); if (!in) return; @@ -202,12 +199,10 @@ void CineMetaEngine::removeSaveState(const char *target, int slot) const { strncpy(saveNames[slot], slotName, 20); // Update savegame descriptions - char indexFile[80]; - snprintf(indexFile, 80, "%s.dir", target); - + Common::String indexFile = Common::String::format("%s.dir", target); Common::OutSaveFile *out = g_system->getSavefileManager()->openForSaving(indexFile); if (!out) { - warning("Unable to open file %s for saving", indexFile); + warning("Unable to open file %s for saving", indexFile.c_str()); return; } @@ -246,12 +241,11 @@ Common::Error CineEngine::saveGameState(int slot, const char *desc) { currentSaveName[slot][sizeof(CommandeType) - 1] = 0; // Update savegame descriptions - char indexFile[80]; - snprintf(indexFile, 80, "%s.dir", _targetName.c_str()); + Common::String indexFile = Common::String::format("%s.dir", _targetName.c_str()); Common::OutSaveFile *fHandle = _saveFileMan->openForSaving(indexFile); if (!fHandle) { - warning("Unable to open file %s for saving", indexFile); + warning("Unable to open file %s for saving", indexFile.c_str()); return Common::kUnknownError; } diff --git a/engines/cine/saveload.cpp b/engines/cine/saveload.cpp index 700875e302..e51d07b1a5 100644 --- a/engines/cine/saveload.cpp +++ b/engines/cine/saveload.cpp @@ -460,10 +460,7 @@ void saveSeqList(Common::OutSaveFile &out) { bool CineEngine::loadSaveDirectory() { Common::InSaveFile *fHandle; - char tmp[80]; - - snprintf(tmp, 80, "%s.dir", _targetName.c_str()); - fHandle = _saveFileMan->openForLoading(tmp); + fHandle = _saveFileMan->openForLoading(Common::String::format("%s.dir", _targetName.c_str())); if (!fHandle) { return false; diff --git a/engines/cine/various.cpp b/engines/cine/various.cpp index 1892a78cca..81e72d6905 100644 --- a/engines/cine/various.cpp +++ b/engines/cine/various.cpp @@ -440,13 +440,12 @@ void CineEngine::makeSystemMenu() { getMouseData(mouseUpdateStatus, (uint16 *)&mouseButton, (uint16 *)&mouseX, (uint16 *)&mouseY); if (!makeMenuChoice(confirmMenu, 2, mouseX, mouseY + 8, 100)) { - char saveString[256], tmp[80]; - - snprintf(tmp, 80, "%s.dir", _targetName.c_str()); + char saveString[256]; + Common::String tmp = Common::String::format("%s.dir", _targetName.c_str()); Common::OutSaveFile *fHandle = _saveFileMan->openForSaving(tmp); if (!fHandle) { - warning("Unable to open file %s for saving", tmp); + warning("Unable to open file %s for saving", tmp.c_str()); break; } -- cgit v1.2.3