WINTERMUTE: Correctly find .ogg version of .wav files

As it was, it didn't reliably work across platforms because it turned
some\\windows\\path.wav
into
some/system/pathogg

Note no "." before "ogg"; also since we use the new filename
to search for the file inside DCPs, which use Windows naming,
we don't want system-specific path format.

Fixes #7088
This commit is contained in:
Tobia Tesan 2016-03-30 17:16:41 +02:00
parent 2c81602454
commit 0cfd058943

View File

@ -100,15 +100,14 @@ BaseSoundBuffer *BaseSoundMgr::addSound(const Common::String &filename, Audio::M
BaseSoundBuffer *sound;
Common::String useFilename = filename;
useFilename.toLowercase();
// try to switch WAV to OGG file (if available)
AnsiString ext = PathUtil::getExtension(filename);
if (StringUtil::compareNoCase(ext, "wav")) {
AnsiString path = PathUtil::getDirectoryName(filename);
AnsiString name = PathUtil::getFileNameWithoutExtension(filename);
AnsiString newFile = PathUtil::combine(path, name + "ogg");
if (BaseFileManager::getEngineInstance()->hasFile(newFile)) {
useFilename = newFile;
if (useFilename.hasSuffix(".wav")) {
Common::String oggFilename = useFilename;
oggFilename.erase(oggFilename.size() - 4);
oggFilename = oggFilename + ".ogg";
if (BaseFileManager::getEngineInstance()->hasFile(oggFilename)) {
useFilename = oggFilename;
}
}