Add configuration option for ghost reset distance. Improve documentation.

This commit is contained in:
2025-12-20 17:12:58 -05:00
parent faf3f239d8
commit 7a3705d342
25 changed files with 132 additions and 28 deletions

View File

@@ -6,6 +6,7 @@
std::map<std::string, std::string> Config::values;
bool Config::loadFromFile(const std::string& filename) {
// Extremely small JSON subset reader: expects `"key": value` pairs per line.
std::ifstream file(filename);
if (!file.is_open()) {
std::cout << "Warning: Could not open config file: " << filename << std::endl;
@@ -26,6 +27,7 @@ bool Config::loadFromFile(const std::string& filename) {
}
float Config::getFloat(const std::string& key, float defaultValue) {
// Values are stored as strings; convert on demand and fall back if invalid.
auto it = values.find(key);
if (it != values.end()) {
try {
@@ -38,6 +40,7 @@ float Config::getFloat(const std::string& key, float defaultValue) {
}
int Config::getInt(const std::string& key, int defaultValue) {
// Values are stored as strings; convert on demand and fall back if invalid.
auto it = values.find(key);
if (it != values.end()) {
try {
@@ -50,6 +53,7 @@ int Config::getInt(const std::string& key, int defaultValue) {
}
std::string Config::getString(const std::string& key, const std::string& defaultValue) {
// Direct passthrough for callers that want raw string values.
auto it = values.find(key);
if (it != values.end()) {
return it->second;
@@ -58,6 +62,7 @@ std::string Config::getString(const std::string& key, const std::string& default
}
std::string Config::trim(const std::string& str) {
// Helper for stripping whitespace around keys/values.
size_t start = str.find_first_not_of(" \t\r\n");
if (start == std::string::npos) return "";
size_t end = str.find_last_not_of(" \t\r\n");
@@ -100,4 +105,4 @@ bool Config::parseJsonValue(const std::string& line, std::string& key, std::stri
}
return !key.empty();
}
}