Skip to content

Commit bd5db2c

Browse files
Update CMainConfig.cpp
1 parent d9fa84b commit bd5db2c

File tree

1 file changed

+39
-2
lines changed

1 file changed

+39
-2
lines changed

Server/mods/deathmatch/logic/CMainConfig.cpp

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -894,8 +894,45 @@ bool CMainConfig::AddMissingSettings()
894894
// Skip certain optional nodes
895895
if (templateNodeName == "resource" || templateNodeName == "module")
896896
continue;
897-
898-
CXMLNode* foundNode = m_pRootNode->FindSubNode(templateNodeName.c_str());
897+
898+
// Find node with exact same attributes
899+
CXMLAttributes& templateAttributes = templateNode->GetAttributes();
900+
CXMLNode* foundNode = nullptr;
901+
for (auto it2 = m_pRootNode->ChildrenBegin(); it2 != m_pRootNode->ChildrenEnd(); ++it2)
902+
{
903+
CXMLNode* tempNode = *it2;
904+
if (tempNode->GetTagName() != templateNodeName)
905+
continue;
906+
907+
CXMLAttributes& attributes = tempNode->GetAttributes();
908+
bool attributesMatch = true;
909+
910+
for (auto it3 = templateAttributes.ListBegin(); it3 != templateAttributes.ListEnd(); ++it3)
911+
{
912+
CXMLAttribute* templateAttribute = *it3;
913+
const SString& attrName = templateAttribute->GetName();
914+
915+
// Don't check value attribute which is intended to be different
916+
if (attrName == "value")
917+
continue;
918+
919+
const SString& attrValue = templateAttribute->GetValue();
920+
921+
CXMLAttribute* foundAttribute = attributes.Find(attrName);
922+
if (!foundAttribute || foundAttribute->GetValue() != attrValue)
923+
{
924+
attributesMatch = false;
925+
break;
926+
}
927+
}
928+
929+
if (attributesMatch)
930+
{
931+
foundNode = tempNode;
932+
break;
933+
}
934+
}
935+
899936
if (!foundNode)
900937
{
901938
const std::string templateNodeValue = templateNode->GetTagContent();

0 commit comments

Comments
 (0)