aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorMax Horn2003-11-10 23:17:11 +0000
committerMax Horn2003-11-10 23:17:11 +0000
commit5c2a3da7f2f8f45e20b732defbaed7aa47af00c8 (patch)
tree8b973869cb90d51e08d8770f4c56ecca1ca2aa9e /common
parentdeef1ef32b2f4dbfe87bd5a3b9268dc77beca7db (diff)
downloadscummvm-rg350-5c2a3da7f2f8f45e20b732defbaed7aa47af00c8.tar.gz
scummvm-rg350-5c2a3da7f2f8f45e20b732defbaed7aa47af00c8.tar.bz2
scummvm-rg350-5c2a3da7f2f8f45e20b732defbaed7aa47af00c8.zip
fix for bug #833537 (Config manager saves "save_slot")
svn-id: r11254
Diffstat (limited to 'common')
-rw-r--r--common/config-manager.cpp56
-rw-r--r--common/config-manager.h5
2 files changed, 38 insertions, 23 deletions
diff --git a/common/config-manager.cpp b/common/config-manager.cpp
index ad51b14407..90297779d5 100644
--- a/common/config-manager.cpp
+++ b/common/config-manager.cpp
@@ -56,6 +56,7 @@ static char *rtrim(char *t) {
namespace Common {
const String ConfigManager::kApplicationDomain("scummvm");
+const String ConfigManager::kTransientDomain("__TRANSIENT");
const String trueStr("true");
const String falseStr("false");
@@ -206,13 +207,13 @@ void ConfigManager::writeDomain(FILE *file, const String &name, const Domain &do
bool ConfigManager::hasKey(const String &key) const {
// Search the domains in the following order:
- // 1) Run time domain
+ // 1) Transient domain
// 2) Active game domain (if any)
// 3) All global domains
// The defaults domain is explicitly *not* checked.
-// if (_transientDomain.contain(key))
-// return true;
+ if (_transientDomain.contains(key))
+ return true;
if (!_activeDomain.isEmpty() && _gameDomains[_activeDomain].contains(key))
return true;
@@ -229,6 +230,8 @@ bool ConfigManager::hasKey(const String &key) const {
bool ConfigManager::hasKey(const String &key, const String &dom) const {
assert(!dom.isEmpty());
+ if (dom == kTransientDomain)
+ return _transientDomain.contains(key);
if (_gameDomains.contains(dom))
return _gameDomains[dom].contains(key);
if (_globalDomains.contains(dom))
@@ -240,7 +243,9 @@ bool ConfigManager::hasKey(const String &key, const String &dom) const {
void ConfigManager::removeKey(const String &key, const String &dom) {
assert(!dom.isEmpty());
- if (_gameDomains.contains(dom))
+ if (dom == kTransientDomain)
+ _transientDomain.remove(key);
+ else if (_gameDomains.contains(dom))
_gameDomains[dom].remove(key);
else if (_globalDomains.contains(dom))
_globalDomains[dom].remove(key);
@@ -252,21 +257,21 @@ void ConfigManager::removeKey(const String &key, const String &dom) {
#pragma mark -
-const String & ConfigManager::get(const String &key, const String &dom) const {
+const String & ConfigManager::get(const String &key, const String &domain) const {
// Search the domains in the following order:
- // 1) Run time domain
+ // 1) Transient domain
// 2) Active game domain (if any)
// 3) All global domains
// 4) The defaults
-// if (_transientDomain.contain(key))
-// return true;
- if (!dom.isEmpty()) {
- if (_gameDomains.contains(dom) && _gameDomains[dom].contains(key))
- return _gameDomains[dom][key];
- } else if (!_activeDomain.isEmpty() && _gameDomains[_activeDomain].contains(key))
- return _gameDomains[_activeDomain][key];
+ if ((domain.isEmpty() || domain == kTransientDomain) && _transientDomain.contains(key))
+ return _transientDomain[key];
+
+ const String &dom = domain.isEmpty() ? _activeDomain : domain;
+
+ if (!dom.isEmpty() && _gameDomains.contains(dom) && _gameDomains[dom].contains(key))
+ return _gameDomains[dom][key];
DomainMap::ConstIterator iter;
for (iter = _globalDomains.begin(); iter != _globalDomains.end(); ++iter) {
@@ -296,15 +301,13 @@ bool ConfigManager::getBool(const String &key, const String &dom) const {
void ConfigManager::set(const String &key, const String &value) {
-#if 0
- // TODO ?!?
-// _transientDomain[key] = value;
-#else
+ // Remove the transient domain value
+ _transientDomain.remove(key);
+
if (_activeDomain.isEmpty())
_globalDomains[kApplicationDomain][key] = value;
else
_gameDomains[_activeDomain][key] = value;
-#endif
}
void ConfigManager::set(const String &key, const String &value, const String &dom) {
@@ -313,10 +316,19 @@ void ConfigManager::set(const String &key, const String &value, const String &do
return;
}
- if (_globalDomains.contains(dom))
- _globalDomains[dom][key] = value;
- else
- _gameDomains[dom][key] = value;
+ if (dom == kTransientDomain)
+ _transientDomain[key] = value;
+ else {
+ if (_globalDomains.contains(dom)) {
+ _globalDomains[dom][key] = value;
+ if (_activeDomain.isEmpty() || !_gameDomains[_activeDomain].contains(key))
+ _transientDomain.remove(key);
+ } else {
+ _gameDomains[dom][key] = value;
+ if (dom == _activeDomain)
+ _transientDomain.remove(key);
+ }
+ }
}
void ConfigManager::set(const String &key, const char *value, const String &dom) {
diff --git a/common/config-manager.h b/common/config-manager.h
index 335c7d9dd5..62e824623b 100644
--- a/common/config-manager.h
+++ b/common/config-manager.h
@@ -58,6 +58,9 @@ public:
/** The name of the application domain (normally 'scummvm'). */
static const String kApplicationDomain;
+ /** The transient (pseudo) domain. */
+ static const String kTransientDomain;
+
bool hasKey(const String &key) const;
bool hasKey(const String &key, const String &dom) const;
@@ -104,7 +107,7 @@ private:
void loadFile(const String &filename);
void writeDomain(FILE *file, const String &name, const Domain &domain);
-// Domain _transientDomain;
+ Domain _transientDomain;
DomainMap _gameDomains;
DomainMap _globalDomains;
Domain _defaultsDomain;