Skip to content

Commit

Permalink
WINTERMUTE: Correctly find .ogg version of .wav files
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tobiatesan committed Mar 30, 2016
1 parent 2c81602 commit 0cfd058
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions engines/wintermute/base/sound/base_sound_manager.cpp
Expand Up @@ -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;
}
}

Expand Down

0 comments on commit 0cfd058

Please sign in to comment.