Skip to content

Commit 7f99425

Browse files
fix PythonAPI
1 parent 72a95f1 commit 7f99425

3 files changed

Lines changed: 110 additions & 91 deletions

File tree

include/config/ConfigManager.hpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ class ConfigManager {
1414
bool LoadConfig(const std::string& configPath);
1515
bool ReloadConfig();
1616

17+
// Setters
18+
void SetBool(const std::string& key, bool value);
19+
void SetInt(const std::string& key, int value);
20+
void SetFloat(const std::string& key, float value);
21+
void SetString(const std::string& key, const std::string& value);
22+
void SetJson(const std::string& key, const nlohmann::json& value);
23+
1724
// Server configuration
1825
std::string GetServerHost() const;
1926
uint16_t GetServerPort() const;
@@ -38,7 +45,7 @@ class ConfigManager {
3845
int GetHeartbeatInterval() const;
3946
int GetSessionTimeout() const;
4047

41-
// 3D World configuration
48+
// World configuration
4249
int GetWorldSeed() const;
4350
int GetViewDistance() const;
4451
int GetChunkSize() const;

src/config/ConfigManager.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,46 @@ bool ConfigManager::ValidateConfig() const {
129129
}
130130
}
131131

132+
void ConfigManager::SetBool(const std::string& key, bool value) {
133+
std::lock_guard<std::mutex> lock(configMutex_);
134+
std::string keyPath = key;
135+
std::replace(keyPath.begin(), keyPath.end(), '.', '/');
136+
nlohmann::json::json_pointer ptr("/" + keyPath);
137+
config_[ptr] = value;
138+
}
139+
140+
void ConfigManager::SetInt(const std::string& key, int value) {
141+
std::lock_guard<std::mutex> lock(configMutex_);
142+
std::string keyPath = key;
143+
std::replace(keyPath.begin(), keyPath.end(), '.', '/');
144+
nlohmann::json::json_pointer ptr("/" + keyPath);
145+
config_[ptr] = value;
146+
}
147+
148+
void ConfigManager::SetFloat(const std::string& key, float value) {
149+
std::lock_guard<std::mutex> lock(configMutex_);
150+
std::string keyPath = key;
151+
std::replace(keyPath.begin(), keyPath.end(), '.', '/');
152+
nlohmann::json::json_pointer ptr("/" + keyPath);
153+
config_[ptr] = value;
154+
}
155+
156+
void ConfigManager::SetString(const std::string& key, const std::string& value) {
157+
std::lock_guard<std::mutex> lock(configMutex_);
158+
std::string keyPath = key;
159+
std::replace(keyPath.begin(), keyPath.end(), '.', '/');
160+
nlohmann::json::json_pointer ptr("/" + keyPath);
161+
config_[ptr] = value;
162+
}
163+
164+
void ConfigManager::SetJson(const std::string& key, const nlohmann::json& value) {
165+
std::lock_guard<std::mutex> lock(configMutex_);
166+
std::string keyPath = key;
167+
std::replace(keyPath.begin(), keyPath.end(), '.', '/');
168+
nlohmann::json::json_pointer ptr("/" + keyPath);
169+
config_[ptr] = value;
170+
}
171+
132172
// Server configuration getters
133173
std::string ConfigManager::GetServerHost() const {
134174
std::lock_guard<std::mutex> lock(configMutex_);

0 commit comments

Comments
 (0)