Skip to content

Commit 58e7cdf

Browse files
committed
update(configs/core): Added FollowCS2ServerGuidelines
1 parent 2006432 commit 58e7cdf

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

plugin_files/configs/core.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,8 @@
77
"commandSilentPrefixes": ["/"],
88
"console_filtering": true,
99
"language": "en",
10-
"patches_to_perform": []
10+
"patches_to_perform": [],
11+
12+
"CS2ServerGuidelines": "https://blog.counter-strike.net/index.php/server_guidelines/",
13+
"FollowCS2ServerGuidelines": true
1114
}

src/configuration/Configuration.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
#include <rapidjson/document.h>
77
#include <rapidjson/error/en.h>
8+
#include <rapidjson/prettywriter.h>
9+
#include <rapidjson/stringbuffer.h>
810

911
#define HAS_MEMBER(FILE, DOCUMENT, MEMBER_NAME, MEMBER_PATH) \
1012
if (!DOCUMENT.HasMember(MEMBER_NAME)) \
@@ -77,6 +79,27 @@ bool Configuration::LoadConfiguration()
7779
this->SetValue("core.patchesToPerform", implode(patchesToPerform, " "));
7880
}
7981

82+
if (!coreConfigFile.HasMember("FollowCS2ServerGuidelines"))
83+
{
84+
coreConfigFile.AddMember(rapidjson::Value().SetString("CS2ServerGuidelines", coreConfigFile.GetAllocator()), rapidjson::Value().SetString("https://blog.counter-strike.net/index.php/server_guidelines/", coreConfigFile.GetAllocator()), coreConfigFile.GetAllocator());
85+
coreConfigFile.AddMember(rapidjson::Value().SetString("FollowCS2ServerGuidelines", coreConfigFile.GetAllocator()), rapidjson::Value().SetBool(true), coreConfigFile.GetAllocator());
86+
87+
rapidjson::StringBuffer buffer;
88+
rapidjson::PrettyWriter<rapidjson::StringBuffer> writer(buffer);
89+
90+
coreConfigFile.Accept(writer);
91+
std::string content = buffer.GetString();
92+
93+
Files::Write("addons/swiftly/configs/core.json", content, false);
94+
95+
this->SetValue("core.FollowCS2ServerGuidelines", true);
96+
}
97+
else
98+
{
99+
IS_BOOL("core.json", coreConfigFile, "FollowCS2ServerGuidelines", "FollowCS2ServerGuidelines");
100+
this->SetValue("core.FollowCS2ServerGuidelines", coreConfigFile["FollowCS2ServerGuidelines"].GetBool());
101+
}
102+
80103
HAS_MEMBER("core.json", coreConfigFile, "console_filtering", "console_filtering");
81104
IS_BOOL("core.json", coreConfigFile, "console_filtering", "console_filtering");
82105

0 commit comments

Comments
 (0)