|
5 | 5 |
|
6 | 6 | #include <rapidjson/document.h> |
7 | 7 | #include <rapidjson/error/en.h> |
| 8 | +#include <rapidjson/prettywriter.h> |
| 9 | +#include <rapidjson/stringbuffer.h> |
8 | 10 |
|
9 | 11 | #define HAS_MEMBER(FILE, DOCUMENT, MEMBER_NAME, MEMBER_PATH) \ |
10 | 12 | if (!DOCUMENT.HasMember(MEMBER_NAME)) \ |
@@ -77,6 +79,27 @@ bool Configuration::LoadConfiguration() |
77 | 79 | this->SetValue("core.patchesToPerform", implode(patchesToPerform, " ")); |
78 | 80 | } |
79 | 81 |
|
| 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 | + |
80 | 103 | HAS_MEMBER("core.json", coreConfigFile, "console_filtering", "console_filtering"); |
81 | 104 | IS_BOOL("core.json", coreConfigFile, "console_filtering", "console_filtering"); |
82 | 105 |
|
|
0 commit comments