Skip to content

Commit

Permalink
Fixes for sound replacement strings
Browse files Browse the repository at this point in the history
  • Loading branch information
FreeSlave committed May 1, 2024
1 parent a56d407 commit 50a3f1f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 5 additions & 3 deletions dlls/soundreplacement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -138,5 +140,5 @@ const std::string& SoundReplacementSystem::FindReplacement(const char *fileName,
return soundReplacementFile.ReplacementFor(originalSoundName);
}
}
return std::string();
return SoundReplacementSystem::emptyString;
}
4 changes: 3 additions & 1 deletion dlls/soundreplacement.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class SoundReplacementList
{
public:
typedef std::map<const std::string, const std::string> ReplacementMap;
typedef std::map<std::string, std::string> ReplacementMap;
SoundReplacementList();
SoundReplacementList(ReplacementMap&& replacementMap);
bool IsValid() const;
Expand All @@ -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<std::string, SoundReplacementList> _fileMap;
};
Expand Down

0 comments on commit 50a3f1f

Please sign in to comment.