From 668ae0363e8f0c823a43a83b4b9682140ffb8eff Mon Sep 17 00:00:00 2001 From: Max Horn Date: Thu, 2 Jun 2011 10:46:29 +0200 Subject: DRACI: Remove all instances of s(n)printf --- engines/draci/draci.cpp | 6 ++---- engines/draci/draci.h | 2 +- engines/draci/game.cpp | 9 ++++----- engines/draci/saveload.cpp | 2 +- engines/draci/sound.cpp | 5 ++--- 5 files changed, 10 insertions(+), 14 deletions(-) (limited to 'engines/draci') diff --git a/engines/draci/draci.cpp b/engines/draci/draci.cpp index cdc91e8d9f..a5236b5835 100644 --- a/engines/draci/draci.cpp +++ b/engines/draci/draci.cpp @@ -439,10 +439,8 @@ void DraciEngine::syncSoundSettings() { _music->syncVolume(); } -const char *DraciEngine::getSavegameFile(int saveGameIdx) { - static char buffer[20]; - sprintf(buffer, "draci.s%02d", saveGameIdx); - return buffer; +Common::String DraciEngine::getSavegameFile(int saveGameIdx) { + return Common::String::format("draci.s%02d", saveGameIdx); } Common::Error DraciEngine::loadGameState(int slot) { diff --git a/engines/draci/draci.h b/engines/draci/draci.h index 83e69ca332..f99bdd5b8e 100644 --- a/engines/draci/draci.h +++ b/engines/draci/draci.h @@ -67,7 +67,7 @@ public: void handleEvents(); - static const char *getSavegameFile(int saveGameIdx); + static Common::String getSavegameFile(int saveGameIdx); virtual Common::Error loadGameState(int slot); virtual bool canLoadGameStateCurrently(); virtual Common::Error saveGameState(int slot, const char *desc); diff --git a/engines/draci/game.cpp b/engines/draci/game.cpp index 657e381986..893e321b79 100644 --- a/engines/draci/game.cpp +++ b/engines/draci/game.cpp @@ -934,13 +934,12 @@ void Game::inventorySwitch(int keycode) { void Game::dialogueMenu(int dialogueID) { int oldLines, hit; - char tmp[5]; - sprintf(tmp, "%d", dialogueID+1); - Common::String ext(tmp); - _dialogueArchive = new BArchive(dialoguePath + ext + ".dfw"); + Common::String name; + name = dialoguePath + Common::String::format("%d.dfw", dialogueID + 1); + _dialogueArchive = new BArchive(name); debugC(4, kDraciLogicDebugLevel, "Starting dialogue (ID: %d, Archive: %s)", - dialogueID, (dialoguePath + ext + ".dfw").c_str()); + dialogueID, name.c_str()); _currentDialogue = dialogueID; oldLines = 255; diff --git a/engines/draci/saveload.cpp b/engines/draci/saveload.cpp index ffb1ed7ff4..1479dd3c77 100644 --- a/engines/draci/saveload.cpp +++ b/engines/draci/saveload.cpp @@ -86,7 +86,7 @@ void writeSavegameHeader(Common::OutSaveFile *out, const DraciSavegameHeader &he } Common::Error saveSavegameData(int saveGameIdx, const Common::String &saveName, DraciEngine &vm) { - const char *filename = vm.getSavegameFile(saveGameIdx); + Common::String filename = vm.getSavegameFile(saveGameIdx); Common::SaveFileManager *saveMan = g_system->getSavefileManager(); Common::OutSaveFile *f = saveMan->openForSaving(filename); if (f == NULL) diff --git a/engines/draci/sound.cpp b/engines/draci/sound.cpp index bbba9d9cc0..106167ef8a 100644 --- a/engines/draci/sound.cpp +++ b/engines/draci/sound.cpp @@ -240,9 +240,8 @@ SoundSample *ZipSoundArchive::getSample(int i, uint freq) { sample._frequency = freq ? freq : _defaultFreq; sample._format = _format; // Read in the file (without the file header) - char file_name[20]; - sprintf(file_name, "%d.%s", i+1, _extension); - sample._stream = _archive->createReadStreamForMember(file_name); + Common::String filename = Common::String::format("%d.%s", i+1, _extension); + sample._stream = _archive->createReadStreamForMember(filename); if (!sample._stream) { debugC(2, kDraciArchiverDebugLevel, "Doesn't exist"); return NULL; -- cgit v1.2.3