Fix issues with audio localization bank switching (#2945)

* Fix issues with locating and loading loc banks

The code that initially checked the g_languageAudio cvar wasn't properly
detecting when the cvar wasn't set.  Fixed an issue discovering
localized banks wasn't properly recursing into subdirectories.
Simplified handling of audio language switching for Wwise.

Signed-off-by: amzn-phist <52085794+amzn-phist@users.noreply.github.com>

* Address feedback on PR

Change .size() == 0 to .empty()

Signed-off-by: amzn-phist <52085794+amzn-phist@users.noreply.github.com>
monroegm-disable-blank-issue-2
amzn-phist 5 years ago committed by GitHub
parent 0999a7f6e4
commit f03df3e546
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -896,16 +896,14 @@ void CSystem::InitLocalization()
if (auto console = AZ::Interface<AZ::IConsole>::Get(); console != nullptr)
{
AZ::CVarFixedString languageAudio;
if (auto result = console->GetCvarValue("g_languageAudio", languageAudio); result == AZ::GetValueResult::Success)
console->GetCvarValue("g_languageAudio", languageAudio);
if (languageAudio.empty())
{
if (languageAudio.size() == 0)
{
console->PerformCommand(AZStd::string::format("g_languageAudio %s", language.c_str()).c_str());
}
else
{
language.assign(languageAudio.data(), languageAudio.size());
}
console->PerformCommand(AZStd::string::format("g_languageAudio %s", language.c_str()).c_str());
}
else
{
language.assign(languageAudio.data(), languageAudio.size());
}
}
OpenLanguageAudioPak(language);

@ -54,7 +54,9 @@ namespace AudioControls
//-------------------------------------------------------------------------------------------//
void CAudioWwiseLoader::LoadSoundBanks(const AZStd::string_view rootFolder, const AZStd::string_view subPath, bool isLocalized)
{
auto foundFiles = Audio::FindFilesInPath(rootFolder, "*");
AZ::IO::FixedMaxPath searchPath(rootFolder);
searchPath /= subPath;
auto foundFiles = Audio::FindFilesInPath(searchPath.Native(), "*");
bool isLocalizedLoaded = isLocalized;
for (const auto& filePath : foundFiles)
@ -71,7 +73,7 @@ namespace AudioControls
// same content (in the future we want to have a
// consistency report to highlight if this is not the case)
m_localizationFolder.assign(fileName.Native().data(), fileName.Native().size());
LoadSoundBanks(rootFolder, m_localizationFolder, true);
LoadSoundBanks(searchPath.Native(), m_localizationFolder, true);
isLocalizedLoaded = true;
}
}

@ -2173,16 +2173,7 @@ namespace Audio
{
if (language)
{
AZStd::string languageSubfolder;
if (azstricmp(language, "english") == 0)
{
languageSubfolder = "english(us)";
}
else
{
languageSubfolder = language;
}
AZStd::string languageSubfolder(language);
languageSubfolder += "/";

Loading…
Cancel
Save