Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Fernando-A-Rocha committed Oct 3, 2024
1 parent e4b797f commit 32c56a2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
4 changes: 2 additions & 2 deletions Server/mods/deathmatch/logic/CGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -968,8 +968,8 @@ bool CGame::Start(int iArgumentCount, char* szArguments[])

// Set the Rules loaded from config
std::map<SString, SString> rulesMap = m_pMainConfig->GetRulesForASE();
for (const auto& rule : rulesMap)
m_pASE->SetRuleValue(rule.first, rule.second);
for (const auto& [key, value] : rulesMap)
m_pASE->SetRuleValue(key, value);
}

ApplyAseSetting();
Expand Down
24 changes: 8 additions & 16 deletions Server/mods/deathmatch/logic/CMainConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,25 +136,17 @@ bool CMainConfig::Load()
// Grab rules
CXMLNode* pNode = nullptr;
std::size_t uiCurrentIndex = 0;
do
while (pNode = m_pRootNode->FindSubNode("rule", uiCurrentIndex++))
{
// Grab the current script node
pNode = m_pRootNode->FindSubNode("rule", uiCurrentIndex++);
if (pNode)
{
// Grab its "name" attribute
CXMLAttribute* pAttribute = pNode->GetAttributes().Find("name");
SString strName = pAttribute ? pAttribute->GetValue() : SString{};
CXMLAttribute* pAttribute = pNode->GetAttributes().Find("name");
SString strName = pAttribute ? pAttribute->GetValue() : SString{};

// Grab its "value" attribute
pAttribute = pNode->GetAttributes().Find("value");
SString strValue = pAttribute ? pAttribute->GetValue() : SString{};
pAttribute = pNode->GetAttributes().Find("value");
SString strValue = pAttribute ? pAttribute->GetValue() : SString{};

// Ignore if name or value are empty
if (!strName.empty() && !strValue.empty())
m_RulesForASEMap[std::move(strName)] = std::move(strValue);
}
} while (pNode);
if (!strName.empty() && !strValue.empty())
m_RulesForASEMap[std::move(strName)] = std::move(strValue);
}

// Grab the forced server ip(s)
GetString(m_pRootNode, "serverip", m_strServerIP);
Expand Down

0 comments on commit 32c56a2

Please sign in to comment.