From 50a3f1f2034e10d6bc8f6e8e5135eb324f8bb569 Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Wed, 1 May 2024 20:25:49 +0300 Subject: [PATCH] Fixes for sound replacement strings --- dlls/soundreplacement.cpp | 8 +++++--- dlls/soundreplacement.h | 4 +++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/dlls/soundreplacement.cpp b/dlls/soundreplacement.cpp index 2b7edfc983..91e39c0569 100644 --- a/dlls/soundreplacement.cpp +++ b/dlls/soundreplacement.cpp @@ -20,9 +20,11 @@ const std::string& SoundReplacementList::ReplacementFor(const std::string &sound if (it != _replacementMap.end()) { return it->second; } - return std::string(); + return SoundReplacementSystem::emptyString; } +const std::string SoundReplacementSystem::emptyString; + static void LogExpectedQuoteError(const char* fileName, int line, int pos) { ALERT(at_console, "Parsing %s. Expected \" at line %d, position %d\n", fileName, line, pos); @@ -90,7 +92,7 @@ bool SoundReplacementSystem::EnsureReplacementFile(const char *fileName) const std::string originalName(buffer + origNameStart, buffer + origNameEnd); const std::string replacementName(buffer + replNameStart, buffer + replNameEnd); replacementMap[originalName] = replacementName; - ALERT(at_console, "File '%s' is replaced with '%s'\n", originalName.c_str(), replacementName.c_str()); + ALERT(at_console, "Sound replacement '%s': '%s' is replaced with '%s'\n", fileName, originalName.c_str(), replacementName.c_str()); } else { @@ -138,5 +140,5 @@ const std::string& SoundReplacementSystem::FindReplacement(const char *fileName, return soundReplacementFile.ReplacementFor(originalSoundName); } } - return std::string(); + return SoundReplacementSystem::emptyString; } diff --git a/dlls/soundreplacement.h b/dlls/soundreplacement.h index 9974a52a26..d5b97e93f0 100644 --- a/dlls/soundreplacement.h +++ b/dlls/soundreplacement.h @@ -8,7 +8,7 @@ class SoundReplacementList { public: - typedef std::map ReplacementMap; + typedef std::map ReplacementMap; SoundReplacementList(); SoundReplacementList(ReplacementMap&& replacementMap); bool IsValid() const; @@ -23,6 +23,8 @@ class SoundReplacementSystem public: bool EnsureReplacementFile(const char* fileName); const std::string& FindReplacement(const char* fileName, const char* originalSoundName); + + static const std::string emptyString; private: std::map _fileMap; };