mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-09-05 14:58:27 +00:00
Implement a shared config between servers (#795)
* Implement a shared config between servers * Auto move config file on CMake run
This commit is contained in:
@@ -12,6 +12,15 @@ dConfig::dConfig(const std::string& filepath) {
|
||||
if (line[0] != '#') ProcessLine(line);
|
||||
}
|
||||
}
|
||||
|
||||
std::ifstream sharedConfig("sharedconfig.ini", std::ios::in);
|
||||
if (!sharedConfig.good()) return;
|
||||
|
||||
while (std::getline(sharedConfig, line)) {
|
||||
if (line.length() > 0) {
|
||||
if (line[0] != '#') ProcessLine(line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dConfig::~dConfig(void) {
|
||||
@@ -40,6 +49,12 @@ void dConfig::ProcessLine(const std::string& line) {
|
||||
if (!seglist[1].empty() && seglist[1][seglist[1].size() - 1] == '\r')
|
||||
seglist[1].erase(seglist[1].size() - 1);
|
||||
|
||||
for (const auto& key : m_Keys) {
|
||||
if (seglist[0] == key) {
|
||||
return; // first loaded key is preferred due to loading shared config secondarily
|
||||
}
|
||||
}
|
||||
|
||||
m_Keys.push_back(seglist[0]);
|
||||
m_Values.push_back(seglist[1]);
|
||||
}
|
||||
|
Reference in New Issue
Block a user