diff options
author | D G Turner | 2011-06-02 04:21:48 +0100 |
---|---|---|
committer | D G Turner | 2011-06-02 04:21:48 +0100 |
commit | 24ac81ead8b5bcee8ee7ded4f7b1ed7f2f263e65 (patch) | |
tree | 062d101b419ff9d5d3a12be57fa74a5b433c0560 | |
parent | c9156d369f386645a28e2d845bb6b6969e91f1bc (diff) | |
download | scummvm-rg350-24ac81ead8b5bcee8ee7ded4f7b1ed7f2f263e65.tar.gz scummvm-rg350-24ac81ead8b5bcee8ee7ded4f7b1ed7f2f263e65.tar.bz2 scummvm-rg350-24ac81ead8b5bcee8ee7ded4f7b1ed7f2f263e65.zip |
SWORD1: Replace snprintf() usage with Common::String::format()
Safer and less portability issues.
-rw-r--r-- | engines/sword1/animation.cpp | 22 | ||||
-rw-r--r-- | engines/sword1/detection.cpp | 8 |
2 files changed, 13 insertions, 17 deletions
diff --git a/engines/sword1/animation.cpp b/engines/sword1/animation.cpp index b66cc6b5a7..7e9d1142be 100644 --- a/engines/sword1/animation.cpp +++ b/engines/sword1/animation.cpp @@ -85,7 +85,7 @@ MoviePlayer::~MoviePlayer() { */ bool MoviePlayer::load(uint32 id) { Common::File f; - char filename[20]; + Common::String filename; if (_decoderType == kVideoDecoderDXA) _bgSoundStream = Audio::SeekableAudioStream::openStreamFile(sequenceList[id]); @@ -93,7 +93,7 @@ bool MoviePlayer::load(uint32 id) { _bgSoundStream = NULL; if (SwordEngine::_systemVars.showText) { - sprintf(filename, "%s.txt", sequenceList[id]); + filename = Common::String::format("%s.txt", sequenceList[id]); if (f.open(filename)) { Common::String line; int lineNo = 0; @@ -117,12 +117,12 @@ bool MoviePlayer::load(uint32 id) { ptr++; if (startFrame > endFrame) { - warning("%s:%d: startFrame (%d) > endFrame (%d)", filename, lineNo, startFrame, endFrame); + warning("%s:%d: startFrame (%d) > endFrame (%d)", filename.c_str(), lineNo, startFrame, endFrame); continue; } if (startFrame <= lastEnd) { - warning("%s:%d startFrame (%d) <= lastEnd (%d)", filename, lineNo, startFrame, lastEnd); + warning("%s:%d startFrame (%d) <= lastEnd (%d)", filename.c_str(), lineNo, startFrame, lastEnd); continue; } @@ -135,14 +135,14 @@ bool MoviePlayer::load(uint32 id) { switch (_decoderType) { case kVideoDecoderDXA: - snprintf(filename, sizeof(filename), "%s.dxa", sequenceList[id]); + filename = Common::String::format("%s.dxa", sequenceList[id]); break; case kVideoDecoderSMK: - snprintf(filename, sizeof(filename), "%s.smk", sequenceList[id]); + filename = Common::String::format("%s.smk", sequenceList[id]); break; } - return _decoder->loadFile(filename); + return _decoder->loadFile(filename.c_str()); } void MoviePlayer::play() { @@ -323,18 +323,18 @@ uint32 DXADecoderWithSound::getElapsedTime() const { /////////////////////////////////////////////////////////////////////////////// MoviePlayer *makeMoviePlayer(uint32 id, SwordEngine *vm, Text *textMan, Audio::Mixer *snd, OSystem *system) { - char filename[20]; + Common::String filename; char buf[60]; Audio::SoundHandle *bgSoundHandle = new Audio::SoundHandle; - snprintf(filename, sizeof(filename), "%s.smk", sequenceList[id]); + filename = Common::String::format("%s.smk", sequenceList[id]); if (Common::File::exists(filename)) { Video::SmackerDecoder *smkDecoder = new Video::SmackerDecoder(snd); return new MoviePlayer(vm, textMan, snd, system, bgSoundHandle, smkDecoder, kVideoDecoderSMK); } - snprintf(filename, sizeof(filename), "%s.dxa", sequenceList[id]); + filename = Common::String::format("%s.dxa", sequenceList[id]); if (Common::File::exists(filename)) { #ifdef USE_ZLIB @@ -348,7 +348,7 @@ MoviePlayer *makeMoviePlayer(uint32 id, SwordEngine *vm, Text *textMan, Audio::M } // Old MPEG2 cutscenes - snprintf(filename, sizeof(filename), "%s.mp2", sequenceList[id]); + filename = Common::String::format("%s.mp2", sequenceList[id]); if (Common::File::exists(filename)) { GUI::MessageDialog dialog("MPEG2 cutscenes are no longer supported", "OK"); diff --git a/engines/sword1/detection.cpp b/engines/sword1/detection.cpp index 8ffd96d308..b02cadc6db 100644 --- a/engines/sword1/detection.cpp +++ b/engines/sword1/detection.cpp @@ -249,15 +249,11 @@ SaveStateList SwordMetaEngine::listSaves(const char *target) const { int SwordMetaEngine::getMaximumSaveSlot() const { return 999; } void SwordMetaEngine::removeSaveState(const char *target, int slot) const { - char fileName[12]; - snprintf(fileName, 12, "sword1.%03d", slot); - - g_system->getSavefileManager()->removeSavefile(fileName); + g_system->getSavefileManager()->removeSavefile(Common::String::format("sword1.%03d", slot)); } SaveStateDescriptor SwordMetaEngine::querySaveMetaInfos(const char *target, int slot) const { - char fileName[12]; - snprintf(fileName, 12, "sword1.%03d", slot); + Common::String fileName = Common::String::format("sword1.%03d", slot); char name[40]; uint32 playTime = 0; byte versionSave; |