diff --git a/source/simulation2/system/ParamNode.cpp b/source/simulation2/system/ParamNode.cpp index 3af2f14fec..12fceec6e2 100644 --- a/source/simulation2/system/ParamNode.cpp +++ b/source/simulation2/system/ParamNode.cpp @@ -86,13 +86,18 @@ void CParamNode::ApplyLayer(const XMBFile& xmb, const XMBElement& element) { CParamNode& node = m_Childs[name]; std::wstring newValue(value.begin(), value.end()); + + // Split into tokens std::vector oldTokens; std::vector newTokens; - if (!node.m_Value.empty()) - boost::algorithm::split(oldTokens, node.m_Value, boost::algorithm::is_space()); - if (!newValue.empty()) - boost::algorithm::split(newTokens, newValue, boost::algorithm::is_space()); + boost::algorithm::split(oldTokens, node.m_Value, boost::algorithm::is_space()); + boost::algorithm::split(newTokens, newValue, boost::algorithm::is_space()); + // Delete empty tokens + oldTokens.erase(std::remove_if(oldTokens.begin(), oldTokens.end(), std::mem_fun_ref(&std::wstring::empty)), oldTokens.end()); + newTokens.erase(std::remove_if(newTokens.begin(), newTokens.end(), std::mem_fun_ref(&std::wstring::empty)), newTokens.end()); + + // Merge the two lists std::vector tokens = oldTokens; for (size_t i = 0; i < newTokens.size(); ++i) { diff --git a/source/simulation2/tests/test_ParamNode.h b/source/simulation2/tests/test_ParamNode.h index bdc5628ee6..223da2b24d 100644 --- a/source/simulation2/tests/test_ParamNode.h +++ b/source/simulation2/tests/test_ParamNode.h @@ -112,9 +112,9 @@ public: void test_overlay_tokens() { CParamNode node; - TS_ASSERT_EQUALS(CParamNode::LoadXMLString(node, " x y"), PSRETURN_OK); + TS_ASSERT_EQUALS(CParamNode::LoadXMLString(node, " x ya b\nc\td"), PSRETURN_OK); TS_ASSERT_EQUALS(CParamNode::LoadXMLString(node, " -y z w"), PSRETURN_OK); - TS_ASSERT_WSTR_EQUALS(node.ToXML(), L"x z w"); + TS_ASSERT_WSTR_EQUALS(node.ToXML(), L"x z wa b c d"); } void test_types()