Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new mtaserver.conf rules for server browser/list #3761

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
b97c3ab
add new serverlist rule values mtaserver.conf
Fernando-A-Rocha Oct 1, 2024
bf12328
Fix empty lines etc
Fernando-A-Rocha Oct 3, 2024
ed0d19a
Fix newline at end of line
Fernando-A-Rocha Oct 3, 2024
c29110a
Load rules from mtaserver.conf
Fernando-A-Rocha Oct 3, 2024
6a74163
Merge branch 'master' into serverlist-new-conf
Fernando-A-Rocha Oct 3, 2024
5cbe04d
Improve code thnx to review by tederis
Fernando-A-Rocha Oct 3, 2024
c622dd3
Merge branch 'serverlist-new-conf' of github.com:Fernando-A-Rocha/mta…
Fernando-A-Rocha Oct 3, 2024
e4b797f
add const noexcept GetRulesForASE
Fernando-A-Rocha Oct 3, 2024
32c56a2
Refactor
Fernando-A-Rocha Oct 3, 2024
f8b08f5
Refactor hungarian notation
Fernando-A-Rocha Oct 3, 2024
13ff349
Merge branch 'master' into serverlist-new-conf
Fernando-A-Rocha Oct 3, 2024
4cb8995
Fix redundant check ASE
Fernando-A-Rocha Oct 3, 2024
a938d62
Refactor grab client_file part
Fernando-A-Rocha Oct 4, 2024
be21fa1
Refactor CMainConfig::AddMissingSettings() and edit .conf comments
Fernando-A-Rocha Oct 5, 2024
a7facd3
Merge branch 'master' into serverlist-new-conf
Fernando-A-Rocha Oct 5, 2024
d191085
early continue
Fernando-A-Rocha Oct 5, 2024
2e39c06
fix
Fernando-A-Rocha Oct 8, 2024
75d3ccb
refactor
Fernando-A-Rocha Oct 8, 2024
2741a3c
Merge branch 'master' into serverlist-new-conf
Fernando-A-Rocha Nov 4, 2024
031a840
Merge branch 'master' into serverlist-new-conf
Fernando-A-Rocha Nov 20, 2024
5ec4e66
Merge branch 'master' into serverlist-new-conf
Fernando-A-Rocha Nov 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions Server/mods/deathmatch/editor.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,30 @@
<!-- This parameter specifies the name the server will be visible as in the ingame server browser
and on Game-Monitor. It is a required parameter. -->
<servername>Map Editor Server</servername>

<!-- These rules are optional parameters for the server browser/list (they can be left empty).
Each rule has their own requirements. Read carefully. -->

<!-- A brief description of the server. -->
<rule name="description" value="" />

<!-- A comma separated list of languages that the server supports (e.g. en). -->
<rule name="languages" value="" />

<!-- A comma separated list of tags that describe the server (e.g. freeroam,roleplay). -->
<rule name="tags" value="" />

<!-- The URL of the server's website. -->
<rule name="website_url" value="" />

<!-- A social media URL #1 (e.g. Discord). -->
<rule name="social1_url" value="" />

<!-- A social media URL #2 (e.g. YouTube). -->
<rule name="social2_url" value="" />

<!-- A social media URL #3 (e.g. Facebook). -->
<rule name="social3_url" value="" />

<!-- This parameter specifies the contact email addresses for the owner(s) of this server.
The email addresses will not be publicly available, and only used by MTA administrators
Expand Down
24 changes: 24 additions & 0 deletions Server/mods/deathmatch/local.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,30 @@
<!-- This parameter specifies the name the server will be visible as in the ingame server browser
and on Game-Monitor. It is a required parameter. -->
<servername>Default MTA Server</servername>

<!-- These rules are optional parameters for the server browser/list (they can be left empty).
Each rule has their own requirements. Read carefully. -->

<!-- A brief description of the server. -->
<rule name="description" value="" />

<!-- A comma separated list of languages that the server supports (e.g. en). -->
<rule name="languages" value="" />

<!-- A comma separated list of tags that describe the server (e.g. freeroam,roleplay). -->
<rule name="tags" value="" />

<!-- The URL of the server's website. -->
<rule name="website_url" value="" />

<!-- A social media URL #1 (e.g. Discord). -->
<rule name="social1_url" value="" />

<!-- A social media URL #2 (e.g. YouTube). -->
<rule name="social2_url" value="" />

<!-- A social media URL #3 (e.g. Facebook). -->
<rule name="social3_url" value="" />

<!-- This parameter specifies the contact email addresses for the owner(s) of this server.
The email addresses will not be publicly available, and only used by MTA administrators
Expand Down
8 changes: 7 additions & 1 deletion Server/mods/deathmatch/logic/CGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -960,10 +960,16 @@ bool CGame::Start(int iArgumentCount, char* szArguments[])
}
}

// If ASE is enabled
// Init ASE
m_pASE = new ASE(m_pMainConfig, m_pPlayerManager, static_cast<int>(usServerPort), strServerIPList);
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& [key, value] : rulesMap)
m_pASE->SetRuleValue(key, value);

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

// Grab rules
CXMLNode* currentNode = nullptr;
std::size_t currentIndex = 0;
while (currentNode = m_pRootNode->FindSubNode("rule", currentIndex++))
{
CXMLAttribute* attribute = currentNode->GetAttributes().Find("name");
SString ruleName = attribute ? attribute->GetValue() : SString{};

attribute = currentNode->GetAttributes().Find("value");
SString ruleValue = attribute ? attribute->GetValue() : SString{};

if (!ruleName.empty() && !ruleValue.empty())
m_RulesForASEMap[std::move(ruleName)] = std::move(ruleValue);
}

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

// Handle the <client_file> nodes
CXMLNode* pNode = NULL;
unsigned int uiCurrentIndex = 0;
do
{
// Grab the current script node
pNode = m_pRootNode->FindSubNode("client_file", uiCurrentIndex++);
if (pNode)
currentNode = nullptr;
currentIndex = 0;
while (currentNode = m_pRootNode->FindSubNode("client_file", currentIndex++))
{
// Grab its "name" attribute
CXMLAttribute* attribute = currentNode->GetAttributes().Find("name");
SString name = attribute ? attribute->GetValue() : SString{};
name = name.Replace("\\", "/").ToLower();

// Grab its "verify" attribute
attribute = currentNode->GetAttributes().Find("verify");
SString verify = attribute ? attribute->GetValue() : SString{};
bool shouldVerify = verify == "true" || verify == "yes" || verify == "1";

// Find bitnumber
bool found = false;
for (uint i = 0; i < NUMELMS(gtaDataFiles); i++)
Fernando-A-Rocha marked this conversation as resolved.
Show resolved Hide resolved
{
// Grab its "name" attribute
CXMLAttribute* pAttribute = pNode->GetAttributes().Find("name");
SString strName = pAttribute ? pAttribute->GetValue() : "";
strName = strName.Replace("\\", "/").ToLower();

// Grab its "verify" attribute
pAttribute = pNode->GetAttributes().Find("verify");
SString strVerify = pAttribute ? pAttribute->GetValue() : "";
bool bVerify = strVerify == "true" || strVerify == "yes" || strVerify == "1";

// Find bitnumber
bool bFound = false;
for (uint i = 0; i < NUMELMS(gtaDataFiles); i++)
if (name == gtaDataFiles[i].szRealFilename)
{
if (strName == gtaDataFiles[i].szRealFilename)
{
if (bVerify)
m_iEnableClientChecks |= 1 << gtaDataFiles[i].iBitNumber;
else
m_iEnableClientChecks &= ~(1 << gtaDataFiles[i].iBitNumber);
bFound = true;
break;
}
if (shouldVerify)
m_iEnableClientChecks |= 1 << gtaDataFiles[i].iBitNumber;
else
m_iEnableClientChecks &= ~(1 << gtaDataFiles[i].iBitNumber);
found = true;
break;
}

if (!bFound)
CLogger::ErrorPrintf("Unknown client_file '%s'\n", *strName);
}
} while (pNode);
if (!found)
CLogger::ErrorPrintf("Unknown client_file '%s'\n", *name);
}

// allow_gta3_img_mods
SString strImgMods;
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; };
const std::map<SString, SString>& GetRulesForASE() const noexcept { 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
26 changes: 25 additions & 1 deletion Server/mods/deathmatch/mtaserver.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,31 @@
<!-- This parameter specifies the name the server will be visible as in the ingame server browser
and on Game-Monitor. It is a required parameter. -->
<servername>Default MTA Server</servername>


<!-- These rules are optional parameters for the server browser/list (they can be left empty).
Each rule has their own requirements. Read carefully. -->

<!-- A brief description of the server. -->
<rule name="description" value="" />

<!-- A comma separated list of languages that the server supports (e.g. en). -->
<rule name="languages" value="" />

<!-- A comma separated list of tags that describe the server (e.g. freeroam,roleplay). -->
<rule name="tags" value="" />

<!-- The URL of the server's website. -->
<rule name="website_url" value="" />

<!-- A social media URL #1 (e.g. Discord). -->
<rule name="social1_url" value="" />

<!-- A social media URL #2 (e.g. YouTube). -->
<rule name="social2_url" value="" />

<!-- A social media URL #3 (e.g. Facebook). -->
<rule name="social3_url" value="" />

<!-- This parameter specifies the contact email addresses for the owner(s) of this server.
The email addresses will not be publicly available, and only used by MTA administrators
to contact the server owner.
Expand Down
24 changes: 24 additions & 0 deletions Server/mods/deathmatch/mtaserver.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,30 @@
<!-- This parameter specifies the name the server will be visible as in the ingame server browser
and on Game-Monitor. It is a required parameter. -->
<servername>Default MTA Server</servername>

<!-- These rules are optional parameters for the server browser/list (they can be left empty).
Each rule has their own requirements. Read carefully. -->

<!-- A brief description of the server. -->
<rule name="description" value="" />

<!-- A comma separated list of languages that the server supports (e.g. en). -->
<rule name="languages" value="" />

<!-- A comma separated list of tags that describe the server (e.g. freeroam,roleplay). -->
<rule name="tags" value="" />

<!-- The URL of the server's website. -->
<rule name="website_url" value="" />

<!-- A social media URL #1 (e.g. Discord). -->
<rule name="social1_url" value="" />

<!-- A social media URL #2 (e.g. YouTube). -->
<rule name="social2_url" value="" />

<!-- A social media URL #3 (e.g. Facebook). -->
<rule name="social3_url" value="" />

<!-- This parameter specifies the contact email addresses for the owner(s) of this server.
The email addresses will not be publicly available, and only used by MTA administrators
Expand Down
Loading