Skip to content

Commit

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

// If ASE is enabled
m_pASE = new ASE(m_pMainConfig, m_pPlayerManager, static_cast<int>(usServerPort), strServerIPList);
if (m_pMainConfig->GetSerialVerificationEnabled())
m_pASE->SetRuleValue("SerialVerification", "yes");
if (m_pASE) {
if (m_pMainConfig->GetSerialVerificationEnabled())
m_pASE->SetRuleValue("SerialVerification", "yes");

// 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);
}

ApplyAseSetting();
m_pMasterServerAnnouncer = new CMasterServerAnnouncer();
m_pMasterServerAnnouncer->Pulse();
Expand Down
29 changes: 27 additions & 2 deletions Server/mods/deathmatch/logic/CMainConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,31 @@ bool CMainConfig::Load()
return false;
}

// Grab rules
CXMLNode* pNode = nullptr;
unsigned int uiCurrentIndex = 0;
do
{
// 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() : "";

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

// Ignore if name or value are empty
if (strName != "" && strValue != "") {
// Store the key value pair
m_RulesForASEMap[strName] = strValue;
}
}
} while (pNode);

// Grab the forced server ip(s)
GetString(m_pRootNode, "serverip", m_strServerIP);
m_strServerIP = SString(m_strServerIP).Replace(" ", "");
Expand Down Expand Up @@ -232,8 +257,8 @@ bool CMainConfig::Load()
GetInteger(m_pRootNode, "verifyclientsettings", m_iEnableClientChecks);

// Handle the <client_file> nodes
CXMLNode* pNode = NULL;
unsigned int uiCurrentIndex = 0;
pNode = nullptr;
uiCurrentIndex = 0;
do
{
// Grab the current script node
Expand Down
2 changes: 2 additions & 0 deletions Server/mods/deathmatch/logic/CMainConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class CMainConfig : public CXMLConfig
unsigned int GetScriptDebugLogLevel() { return m_uiScriptDebugLogLevel; };
const std::string& GetAccessControlListFile() { return m_strAccessControlListFile; };
bool GetSerialVerificationEnabled() { return m_bVerifySerials; };
std::map<SString, SString> GetRulesForASE() { return m_RulesForASEMap; };
bool IsDisableAC(const char* szTagAC) { return MapContains(m_DisableComboACMap, szTagAC); };
bool IsEnableDiagnostic(const char* szTag) { return MapContains(m_EnableDiagnosticMap, szTag); };
CMtaVersion GetMinClientVersion() { return m_strMinClientVersion; }
Expand Down Expand Up @@ -190,6 +191,7 @@ class CMainConfig : public CXMLConfig
unsigned short m_usFPSLimit;
int m_bDontBroadcastLan;
std::set<SString> m_DisableComboACMap;
std::map<SString, SString> m_RulesForASEMap;
std::set<SString> m_EnableDiagnosticMap;
std::vector<SString> m_AuthSerialGroupList;
bool m_bAuthSerialHttpEnabled;
Expand Down

0 comments on commit c29110a

Please sign in to comment.