From 104f3fdd5000e95626adb09c1e8146eeb8d176f7 Mon Sep 17 00:00:00 2001 From: Nicolay Korslund Date: Fri, 20 Aug 2010 09:36:34 +0200 Subject: [PATCH] Added path conversion for say() sounds --- apps/openmw/mwsound/soundmanager.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwsound/soundmanager.cpp b/apps/openmw/mwsound/soundmanager.cpp index dfd8510565..2c6ab6339a 100644 --- a/apps/openmw/mwsound/soundmanager.cpp +++ b/apps/openmw/mwsound/soundmanager.cpp @@ -100,6 +100,19 @@ namespace MWSound dir = soundDir + "/"; } + // Convert a Morrowind sound path (eg. Fx\funny.wav) to full path + // with proper slash conversion (eg. datadir/Sound/Fx/funny.wav) + std::string convertPath(const std::string &str) + { + std::string file = dir + str; +#ifndef WIN32 + // Actually / path separators should work in Windows too, they + // just aren't necessary. + std::replace(file.begin(), file.end(), '\\', '/'); +#endif + return file; + } + // Convert a soundId to file name, and modify the volume // according to the sounds local volume setting, minRange and // maxRange. @@ -113,9 +126,7 @@ namespace MWSound // These factors are not very fine tuned. min = snd->data.minRange * 7; max = snd->data.maxRange * 2000; - std::string file = dir + snd->sound; - std::replace(file.begin(), file.end(), '\\', '/'); - return file; + return convertPath(snd->sound); } // Add a sound to the list and play it @@ -266,7 +277,7 @@ namespace MWSound { // The range values are not tested if(!mData) return; - mData->add(filename, ptr, "_say_sound", 1, 1, 100, 10000, false); + mData->add(mData->convertPath(filename), ptr, "_say_sound", 1, 1, 100, 10000, false); } bool SoundManager::sayDone (MWWorld::Ptr ptr) const