Server config now uses json

This commit is contained in:
Anonymous-275
2021-04-22 02:28:02 +03:00
parent f1e1b6cc28
commit 1bee72a175
6 changed files with 221 additions and 32 deletions

View File

@@ -17,18 +17,26 @@ class Application final {
public:
// types
struct TSettings {
TSettings() noexcept
: DebugModeEnabled(true) { }
TSettings() noexcept :
ServerName("BeamMP Server"),
ServerDesc("BeamMP Default Description"),
Resource("Resources"),
MapName("/levels/gridmap/info.json"),
MaxPlayers(10),
Private(true),
MaxCars(1),
DebugModeEnabled(false),
Port(30814){}
std::string ServerName;
std::string ServerDesc;
std::string Resource;
std::string MapName;
std::string Key;
int MaxPlayers {};
bool Private {};
int MaxCars {};
int MaxPlayers;
bool Private;
int MaxCars;
bool DebugModeEnabled;
int Port {};
int Port;
std::string CustomIP;
[[nodiscard]] bool HasCustomIP() const { return !CustomIP.empty(); }
};

9
include/Json.h Normal file
View File

@@ -0,0 +1,9 @@
//
// Created by anon on 4/21/21.
//
#pragma once
#include "rapidjson/stringbuffer.h"
#include "rapidjson/prettywriter.h"
#include "rapidjson/document.h"
#include "rapidjson/writer.h"

View File

@@ -7,6 +7,9 @@ public:
explicit TConfig(const std::string& ConfigFile);
private:
static void ReadJson();
static void PrintDebug();
static void ManageJson();
static std::string RemoveComments(const std::string& Line);
static void SetValues(const std::string& Line, int Index);
};