mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-22 12:12:16 +00:00
SWORD1: Replace snprintf() usage with Common::String::format()
Safer and less portability issues.
This commit is contained in:
parent
c9156d369f
commit
24ac81ead8
@ -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");
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user