diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-10-08 14:22:49 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-10-08 14:22:49 +0300 |
commit | 0c2def29e3bf56a686305ba7385de45214ec86a4 (patch) | |
tree | 6e310b27035d5dd5dc9d1ada3adf1f724236b3c1 /src/configuration.cpp | |
parent | b8dbda756100d2ad6c01ddac0247296a74c28742 (diff) | |
download | manaverse-0c2def29e3bf56a686305ba7385de45214ec86a4.tar.gz manaverse-0c2def29e3bf56a686305ba7385de45214ec86a4.tar.bz2 manaverse-0c2def29e3bf56a686305ba7385de45214ec86a4.tar.xz manaverse-0c2def29e3bf56a686305ba7385de45214ec86a4.zip |
Allow reinit configuration files.
Diffstat (limited to 'src/configuration.cpp')
-rw-r--r-- | src/configuration.cpp | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/src/configuration.cpp b/src/configuration.cpp index 3b8aa6a92..a9c4037e9 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -317,9 +317,10 @@ ConfigurationObject::~ConfigurationObject() Configuration::Configuration() : ConfigurationObject(), - mConfigPath(""), + mConfigPath(), mDefaultsData(nullptr), - mDirectory("") + mDirectory(), + mUseResManager(false) { #ifdef DEBUG_CONFIG mLogKeys = false; @@ -690,6 +691,8 @@ void Configuration::init(const std::string &filename, const bool useResManager) { mDefaultsData = nullptr; XML::Document doc(filename, useResManager); + mFilename = filename; + mUseResManager = useResManager; if (useResManager) { @@ -721,6 +724,26 @@ void Configuration::init(const std::string &filename, const bool useResManager) initFromXML(rootNode); } +void Configuration::reInit() +{ + XML::Document doc(mFilename, mUseResManager); + if (!doc.rootNode()) + { + logger->log("Couldn't open configuration file: %s", mFilename.c_str()); + return; + } + + const XmlNodePtr rootNode = doc.rootNode(); + + if (!rootNode || !xmlNameEqual(rootNode, "configuration")) + { + logger->log("Warning: No configuration file (%s)", mFilename.c_str()); + return; + } + + initFromXML(rootNode); +} + void ConfigurationObject::writeToXML(const XmlTextWriterPtr writer) { for (Options::const_iterator i = mOptions.begin(), i_end = mOptions.end(); |