SHERLOCK: Simplify animation loading filename handling

This commit is contained in:
Paul Gilbert 2015-05-09 08:41:13 -04:00
parent f622d7471e
commit 13c06c100e

View file

@ -78,13 +78,8 @@ bool Animation::play(const Common::String &filename, int minDelay, int fade,
// Check for any any sound frames for the given animation // Check for any any sound frames for the given animation
const int *soundFrames = checkForSoundFrames(filename); const int *soundFrames = checkForSoundFrames(filename);
// Strip any extension off of the passed filename and add .vdx suffix // Add on the VDX extension
Common::String baseName = filename; Common::String vdxName = filename + ".vdx";
const char *p = strchr(baseName.c_str(), '.');
if (p)
baseName = Common::String(filename.c_str(), MIN(p - 1, baseName.c_str() + 7));
Common::String vdxName = baseName + ".vdx";
// Load the animation // Load the animation
Common::SeekableReadStream *stream; Common::SeekableReadStream *stream;
@ -96,7 +91,7 @@ bool Animation::play(const Common::String &filename, int minDelay, int fade,
stream = _vm->_res->load(vdxName, "epilogue.lib"); stream = _vm->_res->load(vdxName, "epilogue.lib");
// Load initial image // Load initial image
Common::String vdaName = baseName + ".vda"; Common::String vdaName = filename + ".vda";
ImageFile images(vdaName, true, true); ImageFile images(vdaName, true, true);
events.wait(minDelay); events.wait(minDelay);
@ -144,8 +139,8 @@ bool Animation::play(const Common::String &filename, int minDelay, int fade,
++soundNumber; ++soundNumber;
++soundFrames; ++soundFrames;
Common::String fname = _vm->_soundOverride.empty() ? Common::String fname = _vm->_soundOverride.empty() ?
Common::String::format("%s%01d", baseName.c_str(), soundNumber) : Common::String::format("%s%01d", filename.c_str(), soundNumber) :
Common::String::format("%s%02d", baseName.c_str(), soundNumber); Common::String::format("%s%02d", filename.c_str(), soundNumber);
if (sound._voices) if (sound._voices)
sound.playSound(fname); sound.playSound(fname);