Files
DarkflameServer/dCommon/dConfig.h
David Markowitz 4a5dd68e87 fix: hardcore mode fixes (#1882)
fixes hardcore modes uscore drops
adds config option for excluded item drops
2025-09-21 18:36:32 -07:00

46 lines
976 B
C++

#pragma once
#include <fstream>
#include <functional>
#include <map>
#include <string>
class dConfig {
public:
dConfig(const std::string& filepath);
/**
* Checks whether the specified filepath exists
*/
static const bool Exists(const std::string& filepath);
/**
* Gets the specified key from the config. Returns an empty string if the value is not found.
*
* @param key Key to find
* @return The keys value in the config
*/
const std::string& GetValue(std::string key);
/**
* Loads the config from a file
*/
void LoadConfig();
/**
* Reloads the config file to reset values
*/
void ReloadConfig();
// Adds a function to be called when the config is (re)loaded
void AddConfigHandler(std::function<void()> handler);
void LogSettings() const;
private:
void ProcessLine(const std::string& line);
std::map<std::string, std::string> m_ConfigValues;
std::vector<std::function<void()>> m_ConfigHandlers;
std::string m_ConfigFilePath;
};