diff options
author | D G Turner | 2011-06-02 02:53:48 +0100 |
---|---|---|
committer | D G Turner | 2011-06-02 02:53:48 +0100 |
commit | 889f5d119a419b5f7f98341a8ae8d0159f9cf820 (patch) | |
tree | 531dba3b2afb287cf5ed13bde606325ac903c538 /engines | |
parent | 8356656575b4c07229dc0e9bd97fa2f67573de73 (diff) | |
download | scummvm-rg350-889f5d119a419b5f7f98341a8ae8d0159f9cf820.tar.gz scummvm-rg350-889f5d119a419b5f7f98341a8ae8d0159f9cf820.tar.bz2 scummvm-rg350-889f5d119a419b5f7f98341a8ae8d0159f9cf820.zip |
DRASCULA: Replace snprintf() usage with Common::String::format()
Safer and less portability issues.
Diffstat (limited to 'engines')
-rw-r--r-- | engines/drascula/drascula.cpp | 6 | ||||
-rw-r--r-- | engines/drascula/drascula.h | 2 | ||||
-rw-r--r-- | engines/drascula/saveload.cpp | 31 |
3 files changed, 19 insertions, 20 deletions
diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp index cac7f93f12..b4f009eb44 100644 --- a/engines/drascula/drascula.cpp +++ b/engines/drascula/drascula.cpp @@ -893,9 +893,9 @@ bool DrasculaEngine::loadDrasculaDat() { ver = in.readByte(); if (ver != DRASCULA_DAT_VER) { - snprintf(buf, 256, "File 'drascula.dat' is wrong version. Expected %d but got %d. Get it from the ScummVM website", DRASCULA_DAT_VER, ver); - GUIErrorMessage(buf); - warning("%s", buf); + Common::String errorMessage = Common::String::format("File 'drascula.dat' is wrong version. Expected %d but got %d. Get it from the ScummVM website", DRASCULA_DAT_VER, ver); + GUIErrorMessage(errorMessage); + warning("%s", errorMessage.c_str()); return false; } diff --git a/engines/drascula/drascula.h b/engines/drascula/drascula.h index f9dcbe2810..2b6aa0f291 100644 --- a/engines/drascula/drascula.h +++ b/engines/drascula/drascula.h @@ -588,7 +588,7 @@ public: void quadrant_2(); void quadrant_3(); void quadrant_4(); - void saveGame(char[]); + void saveGame(const char *gameName); void increaseFrameNum(); int whichObject(); bool checkMenuFlags(); diff --git a/engines/drascula/saveload.cpp b/engines/drascula/saveload.cpp index 15f5855bdc..664a082eb4 100644 --- a/engines/drascula/saveload.cpp +++ b/engines/drascula/saveload.cpp @@ -28,24 +28,23 @@ namespace Drascula { bool DrasculaEngine::saveLoadScreen() { char names[10][23]; - char file[50]; - char fileEpa[50]; + Common::String file; int n, n2, num_sav = 0, y = 27; Common::InSaveFile *sav; clearRoom(); - snprintf(fileEpa, 50, "%s.epa", _targetName.c_str()); + Common::String fileEpa = Common::String::format("%s.epa", _targetName.c_str()); if (!(sav = _saveFileMan->openForLoading(fileEpa))) { Common::OutSaveFile *epa; if (!(epa = _saveFileMan->openForSaving(fileEpa))) - error("Can't open %s file", fileEpa); + error("Can't open %s file", fileEpa.c_str()); for (n = 0; n < NUM_SAVES; n++) epa->writeString("*\n"); epa->finalize(); delete epa; if (!(sav = _saveFileMan->openForLoading(fileEpa))) { - error("Can't open %s file", fileEpa); + error("Can't open %s file", fileEpa.c_str()); } } for (n = 0; n < NUM_SAVES; n++) { @@ -88,11 +87,11 @@ bool DrasculaEngine::saveLoadScreen() { enterName(); strcpy(names[n], select); if (selectionMade == 1) { - snprintf(file, 50, "%s%02d", _targetName.c_str(), n + 1); - saveGame(file); + file = Common::String::format("%s%02d", _targetName.c_str(), n + 1); + saveGame(file.c_str()); Common::OutSaveFile *tsav; if (!(tsav = _saveFileMan->openForSaving(fileEpa))) { - error("Can't open %s file", fileEpa); + error("Can't open %s file", fileEpa.c_str()); } for (n = 0; n < NUM_SAVES; n++) { tsav->writeString(names[n]); @@ -110,7 +109,7 @@ bool DrasculaEngine::saveLoadScreen() { y = y + 9; } if (selectionMade == 1) { - snprintf(file, 50, "%s%02d", _targetName.c_str(), n + 1); + file = Common::String::format("%s%02d", _targetName.c_str(), n + 1); } num_sav = n; } @@ -127,11 +126,11 @@ bool DrasculaEngine::saveLoadScreen() { } if (selectionMade == 1) { - snprintf(file, 50, "%s%02d", _targetName.c_str(), n + 1); - saveGame(file); + file = Common::String::format("%s%02d", _targetName.c_str(), n + 1); + saveGame(file.c_str()); Common::OutSaveFile *tsav; if (!(tsav = _saveFileMan->openForSaving(fileEpa))) { - error("Can't open %s file", fileEpa); + error("Can't open %s file", fileEpa.c_str()); } for (n = 0; n < NUM_SAVES; n++) { tsav->writeString(names[n]); @@ -143,16 +142,16 @@ bool DrasculaEngine::saveLoadScreen() { } if (mouseX > 125 && mouseY > 123 && mouseX < 199 && mouseY < 149 && selectionMade == 1) { - if (!loadGame(file)) { + if (!loadGame(file.c_str())) { _system->setFeatureState(OSystem::kFeatureVirtualKeyboard, false); return false; } break; } else if (mouseX > 208 && mouseY > 123 && mouseX < 282 && mouseY < 149 && selectionMade == 1) { - saveGame(file); + saveGame(file.c_str()); Common::OutSaveFile *tsav; if (!(tsav = _saveFileMan->openForSaving(fileEpa))) { - error("Can't open %s file", fileEpa); + error("Can't open %s file", fileEpa.c_str()); } for (n = 0; n < NUM_SAVES; n++) { tsav->writeString(names[n]); @@ -229,7 +228,7 @@ bool DrasculaEngine::loadGame(const char *gameName) { return true; } -void DrasculaEngine::saveGame(char gameName[]) { +void DrasculaEngine::saveGame(const char *gameName) { Common::OutSaveFile *out; int l; |