diff --git a/src/audio/AudioWorld.cpp b/src/audio/AudioWorld.cpp index 1bc2659d..c16bebd7 100644 --- a/src/audio/AudioWorld.cpp +++ b/src/audio/AudioWorld.cpp @@ -136,8 +136,7 @@ namespace World Handle::SfxHandle AudioWorld::loadAudioVDF(const VDFS::FileIndex& idx, const std::string& name) { - std::string ucname = name; - std::transform(ucname.begin(), ucname.end(), ucname.begin(), ::toupper); + std::string ucname = Utils::uppered(name); // m_SoundMap contains all the sounds with C_SFX script definitions Sound* snd = nullptr; @@ -408,16 +407,13 @@ namespace World { return false; } - else + + if (m_playingSegment != loweredName) { - if (m_playingSegment != loweredName) - { - m_musicContext->playSegment(m_Segments.at(loweredName), timing); - m_playingSegment = loweredName; - } - return true; + m_musicContext->playSegment(m_Segments.at(loweredName), timing); + m_playingSegment = loweredName; } - return false; + return true; } bool AudioWorld::playMusicTheme(const std::string& name) diff --git a/src/components/Vob.cpp b/src/components/Vob.cpp index 73324709..3e36dbe2 100644 --- a/src/components/Vob.cpp +++ b/src/components/Vob.cpp @@ -92,8 +92,7 @@ void ::Vob::broadcastTransformChange(VobInformation& vob) void ::Vob::setVisual(VobInformation& vob, const std::string& _visual) { - std::string visual = _visual; - std::transform(visual.begin(), visual.end(), visual.begin(), ::toupper); + std::string visual = Utils::uppered(_visual); // Don't set twice if (vob.visual && vob.visual->getName() == visual) diff --git a/src/content/AnimationAllocator.h b/src/content/AnimationAllocator.h index fd7a6d8a..2458a0fb 100644 --- a/src/content/AnimationAllocator.h +++ b/src/content/AnimationAllocator.h @@ -54,8 +54,7 @@ namespace Animations inline Handle::AnimationHandle AnimationAllocator::allocate(const std::string& name) { - std::string uname = name; - std::transform(uname.begin(), uname.end(), uname.begin(), ::toupper); + std::string uname = Utils::uppered(name); auto h = m_Allocator.createObject(); m_AnimationsByName[uname] = h; diff --git a/src/content/AnimationLibrary.cpp b/src/content/AnimationLibrary.cpp index d616bff5..eac692f2 100644 --- a/src/content/AnimationLibrary.cpp +++ b/src/content/AnimationLibrary.cpp @@ -94,8 +94,7 @@ namespace Animations Handle::AnimationDataHandle AnimationLibrary::loadMAN(const std::string& name) { - std::string file_name = name + ".MAN"; - std::transform(file_name.begin(), file_name.end(), file_name.begin(), ::toupper); + std::string file_name = Utils::uppered(name + ".MAN"); Handle::AnimationDataHandle h = m_World.getAnimationDataAllocator().getAnimationData(name); if (h.isValid()) @@ -347,10 +346,9 @@ namespace Animations std::string AnimationLibrary::makeQualifiedName(const std::string& mesh_lib, const std::string& overlay, const std::string& name) { - std::string umesh_lib = mesh_lib, uoverlay = overlay, uname = name; - std::transform(umesh_lib.begin(), umesh_lib.end(), umesh_lib.begin(), ::toupper); - std::transform(uoverlay.begin(), uoverlay.end(), uoverlay.begin(), ::toupper); - std::transform(uname.begin(), uname.end(), uname.begin(), ::toupper); + std::string umesh_lib = Utils::uppered(mesh_lib), + uoverlay = Utils::uppered(overlay), + uname = Utils::uppered(name); std::string qname; if (uoverlay.find(umesh_lib) != 0) diff --git a/src/utils/Utils.cpp b/src/utils/Utils.cpp index 35b3dd10..088078e1 100644 --- a/src/utils/Utils.cpp +++ b/src/utils/Utils.cpp @@ -76,8 +76,7 @@ std::list Utils::getFilesInDirectory(const std::string& directory, std::list l; forEachFile(directory, [&](const std::string& path, const std::string& name, const std::string& fext) { - std::string extlower = fext; - std::transform(extlower.begin(), extlower.end(), extlower.begin(), ::tolower); + std::string extlower = Utils::lowered(fext); if (ext == "*" || extlower == ext) l.push_back(path); @@ -117,8 +116,7 @@ size_t Utils::getFileSize(const std::string& file) std::string Utils::getCaseSensitivePath(const std::string& caseInsensitivePath, const std::string& prePath) { // Transform input path to lower - std::string pathLower = caseInsensitivePath; - std::transform(pathLower.begin(), pathLower.end(), pathLower.begin(), ::tolower); + std::string pathLower = Utils::lowered(caseInsensitivePath); // Split the input-path at / std::vector parts = Utils::split(pathLower, "/\\");