diff --git a/lib/base/configobject.cpp b/lib/base/configobject.cpp index 7f4887b70..148ff0ea4 100644 --- a/lib/base/configobject.cpp +++ b/lib/base/configobject.cpp @@ -159,11 +159,9 @@ void ConfigObject::ModifyAttribute(const String& attr, const Value& value, bool const String& key = tokens[i]; prefix += "." + key; - if (!dict->Contains(key)) { + if (!dict->Get(key, ¤t)) { current = new Dictionary(); dict->Set(key, current); - } else { - current = dict->Get(key); } } diff --git a/lib/base/scriptglobal.cpp b/lib/base/scriptglobal.cpp index d1dd26871..48a1d6654 100644 --- a/lib/base/scriptglobal.cpp +++ b/lib/base/scriptglobal.cpp @@ -36,14 +36,16 @@ Dictionary::Ptr ScriptGlobal::m_Globals = new Dictionary(); Value ScriptGlobal::Get(const String& name, const Value *defaultValue) { - if (!m_Globals->Contains(name)) { + Value result; + + if (!m_Globals->Get(name, &result)) { if (defaultValue) return *defaultValue; BOOST_THROW_EXCEPTION(std::invalid_argument("Tried to access undefined script variable '" + name + "'")); } - return m_Globals->Get(name); + return result; } void ScriptGlobal::Set(const String& name, const Value& value) @@ -63,12 +65,14 @@ void ScriptGlobal::Set(const String& name, const Value& value) const String& token = tokens[i]; if (i + 1 != tokens.size()) { - if (!parent->Contains(token)) { + Value vparent; + + if (!parent->Get(token, &vparent)) { Dictionary::Ptr dict = new Dictionary(); parent->Set(token, dict); parent = dict; } else { - parent = parent->Get(token); + parent = vparent; } } }