diff options
Diffstat (limited to 'engines/sword2')
-rw-r--r-- | engines/sword2/animation.cpp | 16 | ||||
-rw-r--r-- | engines/sword2/saveload.cpp | 15 | ||||
-rw-r--r-- | engines/sword2/sword2.cpp | 5 | ||||
-rw-r--r-- | engines/sword2/sword2.h | 2 |
4 files changed, 16 insertions, 22 deletions
diff --git a/engines/sword2/animation.cpp b/engines/sword2/animation.cpp index 5c5ff6c7ee..11ee4a98fd 100644 --- a/engines/sword2/animation.cpp +++ b/engines/sword2/animation.cpp @@ -72,17 +72,17 @@ bool MoviePlayer::load(const char *name) { _textSurface = NULL; - char filename[20]; + Common::String filename; switch (_decoderType) { case kVideoDecoderDXA: - snprintf(filename, sizeof(filename), "%s.dxa", name); + filename = Common::String::format("%s.dxa", name); break; case kVideoDecoderSMK: - snprintf(filename, sizeof(filename), "%s.smk", name); + filename = Common::String::format("%s.smk", name); break; } - return _decoder->loadFile(filename); + return _decoder->loadFile(filename.c_str()); } void MoviePlayer::play(MovieText *movieTexts, uint32 numMovieTexts, uint32 leadIn, uint32 leadOut) { @@ -358,18 +358,18 @@ uint32 DXADecoderWithSound::getElapsedTime() const { /////////////////////////////////////////////////////////////////////////////// MoviePlayer *makeMoviePlayer(const char *name, Sword2Engine *vm, 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", name); + filename = Common::String::format("%s.smk", name); if (Common::File::exists(filename)) { Video::SmackerDecoder *smkDecoder = new Video::SmackerDecoder(snd); return new MoviePlayer(vm, snd, system, bgSoundHandle, smkDecoder, kVideoDecoderSMK); } - snprintf(filename, sizeof(filename), "%s.dxa", name); + filename = Common::String::format("%s.dxa", name); if (Common::File::exists(filename)) { #ifdef USE_ZLIB @@ -383,7 +383,7 @@ MoviePlayer *makeMoviePlayer(const char *name, Sword2Engine *vm, Audio::Mixer *s } // Old MPEG2 cutscenes - snprintf(filename, sizeof(filename), "%s.mp2", name); + filename = Common::String::format("%s.mp2", name); if (Common::File::exists(filename)) { GUI::MessageDialog dialog("MPEG2 cutscenes are no longer supported", "OK"); diff --git a/engines/sword2/saveload.cpp b/engines/sword2/saveload.cpp index 870170e378..34f99923f7 100644 --- a/engines/sword2/saveload.cpp +++ b/engines/sword2/saveload.cpp @@ -49,11 +49,8 @@ namespace Sword2 { -char *Sword2Engine::getSaveFileName(uint16 slotNo) { - static char buf[128]; - - snprintf(buf, sizeof(buf), "%s.%.3d", _targetName.c_str(), slotNo); - return buf; +Common::String Sword2Engine::getSaveFileName(uint16 slotNo) { + return Common::String::format("%s.%.3d", _targetName.c_str(), slotNo); } /** @@ -128,7 +125,7 @@ uint32 Sword2Engine::saveGame(uint16 slotNo, const byte *desc) { } uint32 Sword2Engine::saveData(uint16 slotNo, byte *buffer, uint32 bufferSize) { - char *saveFileName = getSaveFileName(slotNo); + Common::String saveFileName = getSaveFileName(slotNo); Common::OutSaveFile *out; @@ -206,7 +203,7 @@ uint32 Sword2Engine::restoreGame(uint16 slotNo) { } uint32 Sword2Engine::restoreData(uint16 slotNo, byte *buffer, uint32 bufferSize) { - char *saveFileName = getSaveFileName(slotNo); + Common::String saveFileName = getSaveFileName(slotNo); Common::InSaveFile *in; @@ -371,7 +368,7 @@ uint32 Sword2Engine::restoreFromBuffer(byte *buffer, uint32 size) { */ uint32 Sword2Engine::getSaveDescription(uint16 slotNo, byte *description) { - char *saveFileName = getSaveFileName(slotNo); + Common::String saveFileName = getSaveFileName(slotNo); Common::InSaveFile *in; @@ -394,7 +391,7 @@ bool Sword2Engine::saveExists() { } bool Sword2Engine::saveExists(uint16 slotNo) { - char *saveFileName = getSaveFileName(slotNo); + Common::String saveFileName = getSaveFileName(slotNo); Common::InSaveFile *in; if (!(in = _saveFileMan->openForLoading(saveFileName))) { diff --git a/engines/sword2/sword2.cpp b/engines/sword2/sword2.cpp index 62a391923d..99ffd5586e 100644 --- a/engines/sword2/sword2.cpp +++ b/engines/sword2/sword2.cpp @@ -210,11 +210,8 @@ SaveStateList Sword2MetaEngine::listSaves(const char *target) const { int Sword2MetaEngine::getMaximumSaveSlot() const { return 999; } void Sword2MetaEngine::removeSaveState(const char *target, int slot) const { - char extension[6]; - snprintf(extension, sizeof(extension), ".%03d", slot); - Common::String filename = target; - filename += extension; + filename += Common::String::format(".%03d", slot); g_system->getSavefileManager()->removeSavefile(filename); } diff --git a/engines/sword2/sword2.h b/engines/sword2/sword2.h index e4c9dcca3c..ee9ea9f27b 100644 --- a/engines/sword2/sword2.h +++ b/engines/sword2/sword2.h @@ -224,7 +224,7 @@ public: bool saveExists(); bool saveExists(uint16 slotNo); uint32 restoreFromBuffer(byte *buffer, uint32 size); - char *getSaveFileName(uint16 slotNo); + Common::String getSaveFileName(uint16 slotNo); uint32 findBufferSize(); void startGame(); |