Skip to content

Commit 514b78b

Browse files
Merge pull request #23 from usermicrodevices/develop
fix ConfigManager
2 parents ee156ce + c173b2d commit 514b78b

12 files changed

Lines changed: 510 additions & 468 deletions

File tree

build.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,15 @@ else
4747
fi
4848

4949
#rm -rf build
50-
#rm -f CMakeCache.txt Makefile cmake_install.cmake
51-
#rm -rf CMakeFiles
50+
rm -f CMakeCache.txt Makefile cmake_install.cmake
51+
rm -rf CMakeFiles
5252

5353
# Build
54-
#mkdir -p build
54+
mkdir -p build
55+
cp -fr config build/config
5556
cd build
56-
cmake .. -B . -DUSE_CITUS=${USE_CITUS:-OFF} -DCMAKE_BUILD_TYPE=Release
57+
#cmake .. -B . -DUSE_CITUS=${USE_CITUS:-OFF} -DCMAKE_BUILD_TYPE=Release
58+
cmake .. -B . -DUSE_CITUS=${USE_CITUS:-OFF} -DCMAKE_BUILD_TYPE=Debug
5759
make -j$(nproc)
5860

5961
if [ -f "gameserver" ]; then
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"receive_timeout_ms": 1000
55
},
66
"server": {
7+
"host": "127.0.0.1",
78
"port": 8080,
89
"maxConnections": 1000,
910
"processCount": 4,
@@ -107,5 +108,9 @@
107108
"enabled": true,
108109
"scriptDirectory": "scripts",
109110
"hotReload": true
111+
},
112+
113+
"game": {
114+
"max_players_per_session": 1
110115
}
111-
}
116+
}

include/config/ConfigManager.hpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
#pragma once
22

3-
#include <nlohmann/json.hpp>
4-
#include <string>
5-
#include <memory>
6-
#include <vector>
3+
#include <algorithm>
74
#include <cstdint>
5+
#include <filesystem>
6+
#include <fstream>
7+
#include <map>
8+
#include <memory>
89
#include <mutex>
10+
#include <sstream>
11+
#include <string>
12+
#include <stdexcept>
13+
#include <vector>
14+
15+
#include <nlohmann/json.hpp>
16+
17+
#include "logging/Logger.hpp"
918

1019
class ConfigManager {
1120
public:

include/logging/Logger.hpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,14 @@
1010
#include <spdlog/sinks/rotating_file_sink.h>
1111
#include <spdlog/sinks/stdout_color_sinks.h>
1212

13+
#include "config/ConfigManager.hpp"
14+
1315
class Logger {
1416
public:
15-
static void Initialize(const std::string& configPath = "");
17+
static void Initialize();
18+
static void InitializeDefaults();
1619
static void InitializeWithWorkerId(int workerId);
20+
1721
static std::shared_ptr<spdlog::logger> GetLogger(const std::string& name = "GameServer");
1822

1923
template<typename... Args>
@@ -48,7 +52,6 @@ class Logger {
4852

4953
private:
5054
static std::shared_ptr<spdlog::logger> logger_;
51-
static std::string configPath_;
52-
55+
5356
static void SetupLogger(const std::string& loggerName = "GameServer");
5457
};

include/network/NetworkQualityMonitor.hpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
#pragma once
22

3-
#include <deque>
3+
#include <algorithm>
4+
#include <atomic>
45
#include <chrono>
6+
#include <cmath>
7+
#include <deque>
8+
#include <iomanip>
59
#include <mutex>
6-
#include <atomic>
710
#include <vector>
8-
#include <algorithm>
11+
#include <sstream>
12+
13+
#include "logging/Logger.hpp"
914

1015
struct NetworkMetrics {
1116
uint64_t average_latency_ms{0};
@@ -127,4 +132,4 @@ class NetworkQualityMonitor {
127132
static constexpr float PACKET_LOSS_GOOD = 0.03f; // 3%
128133
static constexpr float PACKET_LOSS_FAIR = 0.05f; // 5%
129134
static constexpr float PACKET_LOSS_POOR = 0.10f; // 10%
130-
};
135+
};

0 commit comments

Comments
 (0)