diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-03-02 19:31:34 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-03-02 19:31:34 +0300 |
commit | 63d82eada2fccdecf3c90452e93860a37656e7c4 (patch) | |
tree | 1b0fdd869d9066524057339212b7255e59c8485b /src/configuration.cpp | |
parent | edc8de3400acbbae60930a9c1d4f946df5b2e68f (diff) | |
download | manaverse-63d82eada2fccdecf3c90452e93860a37656e7c4.tar.gz manaverse-63d82eada2fccdecf3c90452e93860a37656e7c4.tar.bz2 manaverse-63d82eada2fccdecf3c90452e93860a37656e7c4.tar.xz manaverse-63d82eada2fccdecf3c90452e93860a37656e7c4.zip |
auto save config if it was changed in game each 10 seconds.
Diffstat (limited to 'src/configuration.cpp')
-rw-r--r-- | src/configuration.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/configuration.cpp b/src/configuration.cpp index ed2adfc61..36a1a724f 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -223,6 +223,7 @@ void ConfigurationObject::deleteKey(const std::string &key) void Configuration::setValue(const std::string &key, const std::string &value) { ConfigurationObject::setValue(key, value); + mUpdated = true; // Notify listeners const ListenerMapIterator list = mListenerMap.find(key); @@ -347,7 +348,8 @@ Configuration::Configuration() : mDefaultsData(nullptr), mDirectory(), mFilename(), - mUseResManager(false) + mUseResManager(false), + mUpdated(false) { #ifdef DEBUG_CONFIG mLogKeys = false; @@ -803,11 +805,18 @@ void ConfigurationObject::writeToXML(const XmlTextWriterPtr writer) } } +void Configuration::writeUpdated() +{ + if (mUpdated) + write(); +} + void Configuration::write() { if (mConfigPath.empty()) return; + mUpdated = false; // Do not attempt to write to file that cannot be opened for writing FILE *const testFile = fopen(mConfigPath.c_str(), "w"); if (!testFile) |