Skip to content

Commit

Permalink
#5269: When writing a D3 entity, preserve line breaks in spawnarg val…
Browse files Browse the repository at this point in the history
…ues by converting them to "\n".
  • Loading branch information
codereader committed Sep 18, 2020
1 parent b375759 commit 28c763f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion radiantcore/map/format/Doom3MapWriter.cpp
Expand Up @@ -11,6 +11,17 @@
namespace map
{

namespace
{

// Escape the line break characters in the given input string to \n
inline std::string escapeLineBreaks(const std::string& input)
{
return string::replace_all_copy(input, "\n", "\\n");
}

}

Doom3MapWriter::Doom3MapWriter() :
_entityCount(0),
_primitiveCount(0)
Expand Down Expand Up @@ -44,7 +55,7 @@ void Doom3MapWriter::writeEntityKeyValues(const IEntityNodePtr& entity, std::ost
// Export the entity key values
entity->getEntity().forEachKeyValue([&](const std::string& key, const std::string& value)
{
stream << "\"" << key << "\" \"" << value << "\"" << std::endl;
stream << "\"" << key << "\" \"" << escapeLineBreaks(value) << "\"" << std::endl;
});
}

Expand Down

0 comments on commit 28c763f

Please sign in to comment.