mirror of
https://github.com/BeamMP/BeamMP-Launcher.git
synced 2026-08-27 12:41:32 +00:00
reformat
This commit is contained in:
+24
-23
@@ -2,57 +2,58 @@
|
||||
/// Created by Anonymous275 on 2/23/2021
|
||||
///
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
#include "Network/network.hpp"
|
||||
#include <filesystem>
|
||||
#include "Logger.h"
|
||||
#include <fstream>
|
||||
#include "Network/network.hpp"
|
||||
#include <cstdint>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <nlohmann/json.hpp>
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
std::string Branch;
|
||||
void ParseConfig(const nlohmann::json& d){
|
||||
if(d["Port"].is_number()){
|
||||
void ParseConfig(const nlohmann::json& d) {
|
||||
if (d["Port"].is_number()) {
|
||||
DEFAULT_PORT = d["Port"].get<int>();
|
||||
}
|
||||
//Default -1
|
||||
//Release 1
|
||||
//EA 2
|
||||
//Dev 3
|
||||
//Custom 3
|
||||
// Default -1
|
||||
// Release 1
|
||||
// EA 2
|
||||
// Dev 3
|
||||
// Custom 3
|
||||
|
||||
if(d["Build"].is_string()){
|
||||
if (d["Build"].is_string()) {
|
||||
Branch = d["Build"].get<std::string>();
|
||||
for(char& c : Branch)c = char(tolower(c));
|
||||
for (char& c : Branch)
|
||||
c = char(tolower(c));
|
||||
}
|
||||
}
|
||||
|
||||
void ConfigInit(){
|
||||
if(fs::exists("Launcher.cfg")){
|
||||
void ConfigInit() {
|
||||
if (fs::exists("Launcher.cfg")) {
|
||||
std::ifstream cfg("Launcher.cfg");
|
||||
if(cfg.is_open()){
|
||||
if (cfg.is_open()) {
|
||||
auto Size = fs::file_size("Launcher.cfg");
|
||||
std::string Buffer(Size, 0);
|
||||
cfg.read(&Buffer[0], Size);
|
||||
cfg.close();
|
||||
nlohmann::json d = nlohmann::json::parse(Buffer, nullptr, false);
|
||||
if(d.is_discarded()){
|
||||
if (d.is_discarded()) {
|
||||
fatal("Config failed to parse make sure it's valid JSON!");
|
||||
}
|
||||
ParseConfig(d);
|
||||
}else fatal("Failed to open Launcher.cfg!");
|
||||
}else{
|
||||
} else
|
||||
fatal("Failed to open Launcher.cfg!");
|
||||
} else {
|
||||
std::ofstream cfg("Launcher.cfg");
|
||||
if(cfg.is_open()){
|
||||
if (cfg.is_open()) {
|
||||
cfg <<
|
||||
R"({
|
||||
R"({
|
||||
"Port": 4444,
|
||||
"Build": "Default"
|
||||
})";
|
||||
cfg.close();
|
||||
}else{
|
||||
} else {
|
||||
fatal("Failed to write config on disk!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user