diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-08-31 01:34:38 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-08-31 01:34:38 +0300 |
commit | e826d4c63365dde4c988453846437dcb65370945 (patch) | |
tree | 1bd23d4694c06d97e7e8c885253c0100fe6142b9 /src | |
parent | 75ca03c95c90064e67fa9eaddb4c609196dd3a27 (diff) | |
download | mv-e826d4c63365dde4c988453846437dcb65370945.tar.gz mv-e826d4c63365dde4c988453846437dcb65370945.tar.bz2 mv-e826d4c63365dde4c988453846437dcb65370945.tar.xz mv-e826d4c63365dde4c988453846437dcb65370945.zip |
Improve setting default values for configuration objects.
Diffstat (limited to 'src')
-rw-r--r-- | src/client.cpp | 10 | ||||
-rw-r--r-- | src/configmanager.cpp | 4 | ||||
-rw-r--r-- | src/configuration.cpp | 368 | ||||
-rw-r--r-- | src/configuration.h | 13 | ||||
-rw-r--r-- | src/defaults.cpp | 33 | ||||
-rw-r--r-- | src/defaults.h | 11 | ||||
-rw-r--r-- | src/dirs.cpp | 2 | ||||
-rw-r--r-- | src/dyetool/client.cpp | 8 | ||||
-rw-r--r-- | src/test/testmain.cpp | 2 | ||||
-rw-r--r-- | src/unittests/gui/widgets/browserbox.cc | 4 | ||||
-rw-r--r-- | src/unittests/gui/windowmanager.cc | 12 | ||||
-rw-r--r-- | src/unittests/resources/dye/dyepalette.cc | 6 | ||||
-rw-r--r-- | src/unittests/resources/resourcemanager/resourcemanager.cc | 2 | ||||
-rw-r--r-- | src/unittests/resources/sprite/animatedsprite.cc | 4 | ||||
-rw-r--r-- | src/unittests/utils/chatutils.cc | 4 | ||||
-rw-r--r-- | src/unittests/utils/stringutils.cc | 2 | ||||
-rw-r--r-- | src/unittests/utils/translation/poparser.cc | 4 | ||||
-rw-r--r-- | src/unittests/utils/xml.cc | 4 |
18 files changed, 229 insertions, 264 deletions
diff --git a/src/client.cpp b/src/client.cpp index b59033213..c9c1ad976 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -279,7 +279,7 @@ void Client::gameInit() // Load branding information if (!settings.options.brandingPath.empty()) branding.init(settings.options.brandingPath); - branding.setDefaultValues(getBrandingDefaults()); + setBrandingDefaults(branding); Dirs::initRootDir(); Dirs::initHomeDir(); @@ -308,7 +308,7 @@ void Client::gameInit() ConfigManager::initConfiguration(); settings.init(); Net::loadIgnorePackets(); - paths.setDefaultValues(getPathsDefaults()); + setPathsDefaults(paths); initFeatures(); initPaths(); logger->log("init 4"); @@ -595,7 +595,7 @@ void Client::initGraphics() graphicsManager.initGraphics(); imageHelper->postInit(); - getConfigDefaults2(config.getDefaultValues()); + setConfigDefaults2(config); WindowManager::applyGrabMode(); WindowManager::applyGamma(); @@ -1720,7 +1720,7 @@ void Client::initFeatures() features.init(paths.getStringValue("featuresFile"), UseVirtFs_true, SkipError_true); - features.setDefaultValues(getFeaturesDefaults()); + setFeaturesDefaults(features); settings.fixDeadAnimation = features.getBoolValue("fixDeadAnimation"); } @@ -1896,7 +1896,7 @@ void Client::loadData() logger->log("Init paths"); paths.init("paths.xml", UseVirtFs_true); - paths.setDefaultValues(getPathsDefaults()); + setPathsDefaults(paths); initPaths(); if (SpriteReference::Empty == nullptr) { diff --git a/src/configmanager.cpp b/src/configmanager.cpp index 1039c5a01..b34688b76 100644 --- a/src/configmanager.cpp +++ b/src/configmanager.cpp @@ -79,7 +79,7 @@ void ConfigManager::initServerConfig(const std::string &serverName) { fclose(configFile); serverConfig.init(configPath); - serverConfig.setDefaultValues(getConfigDefaults()); + setConfigDefaults(serverConfig); logger->log("serverConfigPath: " + configPath); } else @@ -165,7 +165,7 @@ void ConfigManager::initConfiguration() fclose(configFile); config.init(configPath); logger->log1("init 3"); - config.setDefaultValues(getConfigDefaults()); + setConfigDefaults(config); logger->log("configuration file: " + configPath); } } diff --git a/src/configuration.cpp b/src/configuration.cpp index 6e42304f6..bce7d79b4 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -363,7 +363,7 @@ Configuration::Configuration() : ConfigurationObject(), mListenerMap(), mConfigPath(), - mDefaultsData(nullptr), + mDefaultsData(), mDirectory(), mFilename(), mUseResManager(UseVirtFs_false), @@ -377,17 +377,13 @@ Configuration::Configuration() : void Configuration::cleanDefaults() { - if (mDefaultsData != nullptr) + for (DefaultsData::const_iterator iter = mDefaultsData.begin(); + iter != mDefaultsData.end(); + ++iter) { - for (DefaultsData::const_iterator iter = mDefaultsData->begin(); - iter != mDefaultsData->end(); - ++iter) - { - delete (iter->second); - } - mDefaultsData->clear(); - delete2(mDefaultsData); + delete iter->second; } + mDefaultsData.clear(); } Configuration::~Configuration() @@ -405,12 +401,6 @@ void Configuration::unload() ConfigurationObject::clear(); } -void Configuration::setDefaultValues(DefaultsData *const defaultsData) -{ - cleanDefaults(); - mDefaultsData = defaultsData; -} - int Configuration::getIntValue(const std::string &key) const { GETLOG(); @@ -418,47 +408,44 @@ int Configuration::getIntValue(const std::string &key) const const Options::const_iterator iter = mOptions.find(key); if (iter == mOptions.end()) { - if (mDefaultsData != nullptr) - { - const DefaultsData::const_iterator itdef - = mDefaultsData->find(key); + const DefaultsData::const_iterator itdef + = mDefaultsData.find(key); - if (itdef != mDefaultsData->end() && (itdef->second != nullptr)) + if (itdef != mDefaultsData.end() && (itdef->second != nullptr)) + { + const VariableData *const data = itdef->second; + const VariableData::DataType type = static_cast< + VariableData::DataType>(data->getType()); + if (type == VariableData::DATA_INT) { - const VariableData *const data = itdef->second; - const VariableData::DataType type = static_cast< - VariableData::DataType>(data->getType()); - if (type == VariableData::DATA_INT) - { - defaultValue = (static_cast<const IntData*>( - data))->getData(); - } - else if (type == VariableData::DATA_STRING) - { - defaultValue = atoi((static_cast<const StringData*>( - data))->getData().c_str()); - } - else if (type == VariableData::DATA_BOOL) - { - if ((static_cast<const BoolData*>(data))->getData()) - defaultValue = 1; - else - defaultValue = 0; - } - else if (type == VariableData::DATA_FLOAT) - { - defaultValue = CAST_S32( - (static_cast<const FloatData*>(data))->getData()); - } + defaultValue = (static_cast<const IntData*>( + data))->getData(); + } + else if (type == VariableData::DATA_STRING) + { + defaultValue = atoi((static_cast<const StringData*>( + data))->getData().c_str()); + } + else if (type == VariableData::DATA_BOOL) + { + if ((static_cast<const BoolData*>(data))->getData()) + defaultValue = 1; + else + defaultValue = 0; } - else + else if (type == VariableData::DATA_FLOAT) { - logger->assertLog( - "%s: No integer value in registry for key %s", - mConfigPath.c_str(), - key.c_str()); + defaultValue = CAST_S32( + (static_cast<const FloatData*>(data))->getData()); } } + else + { + logger->assertLog( + "%s: No integer value in registry for key %s", + mConfigPath.c_str(), + key.c_str()); + } } else { @@ -471,22 +458,19 @@ int Configuration::resetIntValue(const std::string &key) { GETLOG(); int defaultValue = 0; - if (mDefaultsData != nullptr) + const DefaultsData::const_iterator itdef = mDefaultsData.find(key); + const VariableData *const data = itdef->second; + if (itdef != mDefaultsData.end() && data != nullptr + && data->getType() == VariableData::DATA_INT) { - const DefaultsData::const_iterator itdef = mDefaultsData->find(key); - const VariableData *const data = itdef->second; - if (itdef != mDefaultsData->end() && (data != nullptr) - && data->getType() == VariableData::DATA_INT) - { - defaultValue = (static_cast<const IntData*>( - data))->getData(); - } - else - { - logger->assertLog("%s: No integer value in registry for key %s", - mConfigPath.c_str(), - key.c_str()); - } + defaultValue = (static_cast<const IntData*>( + data))->getData(); + } + else + { + logger->assertLog("%s: No integer value in registry for key %s", + mConfigPath.c_str(), + key.c_str()); } setValue(key, defaultValue); return defaultValue; @@ -499,46 +483,43 @@ std::string Configuration::getStringValue(const std::string &key) const const Options::const_iterator iter = mOptions.find(key); if (iter == mOptions.end()) { - if (mDefaultsData != nullptr) - { - const DefaultsData::const_iterator - itdef = mDefaultsData->find(key); + const DefaultsData::const_iterator + itdef = mDefaultsData.find(key); - if (itdef != mDefaultsData->end() && - (itdef->second != nullptr)) + if (itdef != mDefaultsData.end() && + (itdef->second != nullptr)) + { + const VariableData *const data = itdef->second; + const VariableData::DataType type = static_cast< + VariableData::DataType>(data->getType()); + if (type == VariableData::DATA_STRING) { - const VariableData *const data = itdef->second; - const VariableData::DataType type = static_cast< - VariableData::DataType>(data->getType()); - if (type == VariableData::DATA_STRING) - { - defaultValue = (static_cast<const StringData*>( - data))->getData(); - } - else if (type == VariableData::DATA_BOOL) - { - if ((static_cast<const BoolData*>(data))->getData()) - defaultValue = "1"; - else - defaultValue = "0"; - } - else if (type == VariableData::DATA_INT) - { - defaultValue = toString((static_cast<const IntData*>( - data))->getData()); - } - else if (type == VariableData::DATA_FLOAT) - { - defaultValue = toString((static_cast<const FloatData*>( - data))->getData()); - } + defaultValue = (static_cast<const StringData*>( + data))->getData(); + } + else if (type == VariableData::DATA_BOOL) + { + if ((static_cast<const BoolData*>(data))->getData()) + defaultValue = "1"; + else + defaultValue = "0"; } - else + else if (type == VariableData::DATA_INT) { - logger->assertLog("%s: No string value in registry for key %s", - mConfigPath.c_str(), - key.c_str()); + defaultValue = toString((static_cast<const IntData*>( + data))->getData()); } + else if (type == VariableData::DATA_FLOAT) + { + defaultValue = toString((static_cast<const FloatData*>( + data))->getData()); + } + } + else + { + logger->assertLog("%s: No string value in registry for key %s", + mConfigPath.c_str(), + key.c_str()); } } else @@ -556,48 +537,45 @@ float Configuration::getFloatValue(const std::string &key) const const Options::const_iterator iter = mOptions.find(key); if (iter == mOptions.end()) { - if (mDefaultsData != nullptr) - { - const DefaultsData::const_iterator itdef - = mDefaultsData->find(key); + const DefaultsData::const_iterator itdef + = mDefaultsData.find(key); - if (itdef != mDefaultsData->end() && - (itdef->second != nullptr)) + if (itdef != mDefaultsData.end() && + (itdef->second != nullptr)) + { + const VariableData *const data = itdef->second; + const VariableData::DataType type = static_cast< + VariableData::DataType>(data->getType()); + if (type == VariableData::DATA_FLOAT) { - const VariableData *const data = itdef->second; - const VariableData::DataType type = static_cast< - VariableData::DataType>(data->getType()); - if (type == VariableData::DATA_FLOAT) - { - defaultValue = static_cast<float>( - (static_cast<const FloatData*>(data))->getData()); - } - else if (type == VariableData::DATA_STRING) - { - defaultValue = static_cast<float>(atof(( - static_cast<const StringData*>( - data))->getData().c_str())); - } - else if (type == VariableData::DATA_BOOL) - { - if ((static_cast<const BoolData*>(data))->getData()) - defaultValue = 1; - else - defaultValue = 0; - } - else if (type == VariableData::DATA_INT) - { - defaultValue = static_cast<float>(( - static_cast<const IntData*>( - data))->getData()); - } + defaultValue = static_cast<float>( + (static_cast<const FloatData*>(data))->getData()); + } + else if (type == VariableData::DATA_STRING) + { + defaultValue = static_cast<float>(atof(( + static_cast<const StringData*>( + data))->getData().c_str())); } - else + else if (type == VariableData::DATA_BOOL) { - logger->assertLog("%s: No float value in registry for key %s", - mConfigPath.c_str(), - key.c_str()); + if ((static_cast<const BoolData*>(data))->getData()) + defaultValue = 1; + else + defaultValue = 0; } + else if (type == VariableData::DATA_INT) + { + defaultValue = static_cast<float>(( + static_cast<const IntData*>( + data))->getData()); + } + } + else + { + logger->assertLog("%s: No float value in registry for key %s", + mConfigPath.c_str(), + key.c_str()); } } else @@ -614,61 +592,58 @@ bool Configuration::getBoolValue(const std::string &key) const const Options::const_iterator iter = mOptions.find(key); if (iter == mOptions.end()) { - if (mDefaultsData != nullptr) - { - const DefaultsData::const_iterator itdef - = mDefaultsData->find(key); + const DefaultsData::const_iterator itdef + = mDefaultsData.find(key); - if (itdef != mDefaultsData->end() && - (itdef->second != nullptr)) + if (itdef != mDefaultsData.end() && + (itdef->second != nullptr)) + { + const VariableData *const data = itdef->second; + const VariableData::DataType type = static_cast< + VariableData::DataType>(data->getType()); + if (type == VariableData::DATA_BOOL) { - const VariableData *const data = itdef->second; - const VariableData::DataType type = static_cast< - VariableData::DataType>(data->getType()); - if (type == VariableData::DATA_BOOL) + defaultValue = (static_cast<const BoolData*>( + data))->getData(); + } + else if (type == VariableData::DATA_INT) + { + if ((static_cast<const IntData*>(data))->getData() != 0) + defaultValue = true; + else + defaultValue = false; + } + else if (type == VariableData::DATA_STRING) + { + if ((static_cast<const StringData*>( + data))->getData() != "0") { - defaultValue = (static_cast<const BoolData*>( - data))->getData(); + defaultValue = true; } - else if (type == VariableData::DATA_INT) + else { - if ((static_cast<const IntData*>(data))->getData() != 0) - defaultValue = true; - else - defaultValue = false; + defaultValue = false; } - else if (type == VariableData::DATA_STRING) + } + if (type == VariableData::DATA_FLOAT) + { + if (CAST_S32((static_cast<const FloatData*>( + data))->getData()) != 0) { - if ((static_cast<const StringData*>( - data))->getData() != "0") - { - defaultValue = true; - } - else - { - defaultValue = false; - } + defaultValue = true; } - if (type == VariableData::DATA_FLOAT) + else { - if (CAST_S32((static_cast<const FloatData*>( - data))->getData()) != 0) - { - defaultValue = true; - } - else - { - defaultValue = false; - } + defaultValue = false; } } - else - { - logger->assertLog( - "%s: No boolean value in registry for key %s", - mConfigPath.c_str(), - key.c_str()); - } + } + else + { + logger->assertLog( + "%s: No boolean value in registry for key %s", + mConfigPath.c_str(), + key.c_str()); } } else @@ -683,23 +658,20 @@ bool Configuration::resetBoolValue(const std::string &key) { GETLOG(); bool defaultValue = false; - if (mDefaultsData != nullptr) - { - const DefaultsData::const_iterator itdef = mDefaultsData->find(key); - const VariableData *const data = itdef->second; + const DefaultsData::const_iterator itdef = mDefaultsData.find(key); + const VariableData *const data = itdef->second; - if (itdef != mDefaultsData->end() && - (data != nullptr) && - data->getType() == VariableData::DATA_BOOL) - { - defaultValue = (static_cast<const BoolData*>(data))->getData(); - } - else - { - logger->assertLog("%s: No boolean value in registry for key %s", - mConfigPath.c_str(), - key.c_str()); - } + if (itdef != mDefaultsData.end() && + (data != nullptr) && + data->getType() == VariableData::DATA_BOOL) + { + defaultValue = (static_cast<const BoolData*>(data))->getData(); + } + else + { + logger->assertLog("%s: No boolean value in registry for key %s", + mConfigPath.c_str(), + key.c_str()); } setValue(key, defaultValue); diff --git a/src/configuration.h b/src/configuration.h index 2556ac283..fa3e0ec19 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -255,14 +255,7 @@ class Configuration final : public ConfigurationObject void unload(); - /** - * Set the default values for each keys. - * - * @param defaultsData data used as defaults. - */ - void setDefaultValues(DefaultsData *const defaultsData); - - DefaultsData *getDefaultValues() + DefaultsData &getDefaultValues() { return mDefaultsData; } /** @@ -365,12 +358,12 @@ class Configuration final : public ConfigurationObject void writeUpdated(); - private: /** * Clean up the default values member. */ void cleanDefaults(); + private: typedef std::list<ConfigListener*> Listeners; typedef Listeners::iterator ListenerIterator; typedef std::map<std::string, Listeners> ListenerMap; @@ -380,7 +373,7 @@ class Configuration final : public ConfigurationObject // Location of config file std::string mConfigPath; /// Defaults of value for a given key - DefaultsData *mDefaultsData; + DefaultsData mDefaultsData; std::string mDirectory; std::string mFilename; UseVirtFs mUseResManager; diff --git a/src/defaults.cpp b/src/defaults.cpp index 5a26ba8f8..b77bf1875 100644 --- a/src/defaults.cpp +++ b/src/defaults.cpp @@ -21,6 +21,7 @@ #include "defaults.h" +#include "configuration.h" #include "graphicsmanager.h" #include "variabledata.h" @@ -82,12 +83,13 @@ VariableData* createData(const bool defData) } #define AddDEF(key, value) \ - configData->insert(std::pair<std::string, VariableData*> \ + configData.insert(std::pair<std::string, VariableData*> \ (key, createData(value))); -DefaultsData* getConfigDefaults() +void setConfigDefaults(Configuration &cfg) { - DefaultsData *const configData = new DefaultsData; + cfg.cleanDefaults(); + DefaultsData &configData = cfg.getDefaultValues(); AddDEF("OverlayDetail", 2); AddDEF("speechBubbleAlpha", 1.0F); AddDEF("MostUsedServerName0", "server.themanaworld.org"); @@ -410,13 +412,11 @@ DefaultsData* getConfigDefaults() AddDEF("openglContext", false); AddDEF("allowMoveByMouse", true); AddDEF("enableDSA", true); - return configData; } -void getConfigDefaults2(DefaultsData *const configData) +void setConfigDefaults2(Configuration &cfg) { - if (configData == nullptr) - return; + DefaultsData &configData = cfg.getDefaultValues(); const int density = graphicsManager.getDensity(); int size = 12; int buttonSize = 1; @@ -459,9 +459,10 @@ void getConfigDefaults2(DefaultsData *const configData) } } -DefaultsData* getBrandingDefaults() +void setBrandingDefaults(Configuration &cfg) { - DefaultsData *const configData = new DefaultsData; + cfg.cleanDefaults(); + DefaultsData &configData = cfg.getDefaultValues(); AddDEF("wallpapersPath", ""); AddDEF("wallpapersFile", ""); AddDEF("appName", "ManaPlus"); @@ -514,12 +515,12 @@ DefaultsData* getBrandingDefaults() AddDEF("updateMirror5", ""); AddDEF("updateMirror6", ""); AddDEF("updateMirror7", ""); - return configData; } -DefaultsData* getPathsDefaults() +void setPathsDefaults(Configuration &cfg) { - DefaultsData *const configData = new DefaultsData; + cfg.cleanDefaults(); + DefaultsData &configData = cfg.getDefaultValues(); AddDEF("itemIcons", "graphics/items/"); AddDEF("unknownItemFile", "unknown-item.png"); AddDEF("sprites", "graphics/sprites/"); @@ -710,19 +711,17 @@ DefaultsData* getPathsDefaults() #endif // TMWA_SUPPORT AddDEF("enableNewMailSystem", true); - - return configData; } -DefaultsData* getFeaturesDefaults() +void setFeaturesDefaults(Configuration &cfg) { - DefaultsData *const configData = new DefaultsData; + cfg.cleanDefaults(); + DefaultsData &configData = cfg.getDefaultValues(); AddDEF("languageTab", false); AddDEF("allowFollow", true); AddDEF("fixDeadAnimation", true); AddDEF("forceAccountGender", -1); AddDEF("forceCharGender", -1); - return configData; } #undef AddDEF diff --git a/src/defaults.h b/src/defaults.h index 944b91fe4..f38c13ee1 100644 --- a/src/defaults.h +++ b/src/defaults.h @@ -27,6 +27,7 @@ #include "localconsts.h" +class Configuration; class VariableData; typedef std::map<std::string, VariableData*> DefaultsData; @@ -37,10 +38,10 @@ VariableData* createData(const float defData) A_WARN_UNUSED; VariableData* createData(const std::string &defData) A_WARN_UNUSED; VariableData* createData(const char *const defData) A_WARN_UNUSED; VariableData* createData(const bool defData) A_WARN_UNUSED; -DefaultsData* getConfigDefaults() A_WARN_UNUSED; -void getConfigDefaults2(DefaultsData *const configData); -DefaultsData* getBrandingDefaults() A_WARN_UNUSED; -DefaultsData* getPathsDefaults() A_WARN_UNUSED; -DefaultsData* getFeaturesDefaults() A_WARN_UNUSED; +void setConfigDefaults(Configuration &cfg); +void setConfigDefaults2(Configuration &cfg); +void setBrandingDefaults(Configuration &cfg); +void setPathsDefaults(Configuration &cfg); +void setFeaturesDefaults(Configuration &cfg); #endif // DEFAULTS_H diff --git a/src/dirs.cpp b/src/dirs.cpp index c48e910d1..004e1fdb4 100644 --- a/src/dirs.cpp +++ b/src/dirs.cpp @@ -278,7 +278,7 @@ void Dirs::initRootDir() if (settings.options.brandingPath.empty()) { branding.init(portableName); - branding.setDefaultValues(getBrandingDefaults()); + setBrandingDefaults(branding); } logger->log("Portable file: %s", portableName.c_str()); diff --git a/src/dyetool/client.cpp b/src/dyetool/client.cpp index 18fb9943c..42b570a6b 100644 --- a/src/dyetool/client.cpp +++ b/src/dyetool/client.cpp @@ -163,7 +163,7 @@ void Client::gameInit() // Load branding information if (!settings.options.brandingPath.empty()) branding.init(settings.options.brandingPath); - branding.setDefaultValues(getBrandingDefaults()); + setBrandingDefaults(branding); Dirs::initRootDir(); Dirs::initHomeDir(); @@ -187,7 +187,7 @@ void Client::gameInit() if (settings.options.test.empty()) ConfigManager::backupConfig("config.xml"); ConfigManager::initConfiguration(); - paths.setDefaultValues(getPathsDefaults()); + setPathsDefaults(paths); initPaths(); logger->log("init 4"); logger->setDebugLog(config.getBoolValue("debugLog")); @@ -400,7 +400,7 @@ void Client::initGraphics() graphicsManager.initGraphics(); imageHelper->postInit(); - getConfigDefaults2(config.getDefaultValues()); + setConfigDefaults2(config); WindowManager::applyGrabMode(); WindowManager::applyGamma(); @@ -676,7 +676,7 @@ int Client::gameExec() logger->log("Init paths"); paths.init("paths.xml", UseVirtFs_true); - paths.setDefaultValues(getPathsDefaults()); + setPathsDefaults(paths); initPaths(); TranslationManager::loadCurrentLang(); TranslationManager::loadDictionaryLang(); diff --git a/src/test/testmain.cpp b/src/test/testmain.cpp index ce62b537c..0d75cae7b 100644 --- a/src/test/testmain.cpp +++ b/src/test/testmain.cpp @@ -53,7 +53,7 @@ void TestMain::initConfig() { mConfig.init(settings.configDir + "/test.xml"); mConfig.clear(); -// mConfig.setDefaultValues(getConfigDefaults()); +// setConfigDefaults(mConfig); mConfig.setValue("hwaccel", false); mConfig.setValue("screen", false); diff --git a/src/unittests/gui/widgets/browserbox.cc b/src/unittests/gui/widgets/browserbox.cc index 128c7a52c..8f97a6984 100644 --- a/src/unittests/gui/widgets/browserbox.cc +++ b/src/unittests/gui/widgets/browserbox.cc @@ -83,8 +83,8 @@ TEST_CASE("BrowserBox tests", "browserbox") Dirs::initHomeDir(); ConfigManager::initConfiguration(); - getConfigDefaults2(config.getDefaultValues()); - branding.setDefaultValues(getBrandingDefaults()); + setConfigDefaults2(config); + setBrandingDefaults(branding); ActorSprite::load(); gui = new Gui(); diff --git a/src/unittests/gui/windowmanager.cc b/src/unittests/gui/windowmanager.cc index 6a215d081..0bf21a97d 100644 --- a/src/unittests/gui/windowmanager.cc +++ b/src/unittests/gui/windowmanager.cc @@ -162,7 +162,7 @@ TEST_CASE("Windows tests", "windowmanager") VirtFs::mountDirSilent("../data", Append_false); VirtFs::mountDirSilent("data/test", Append_false); VirtFs::mountDirSilent("../data/test", Append_false); - paths.setDefaultValues(getPathsDefaults()); + setPathsDefaults(paths); branding.setValue("onlineServerFile", "test/serverlistplus.xml"); mainGraphics = new SDLGraphics; imageHelper = new SDLImageHelper; @@ -188,8 +188,8 @@ TEST_CASE("Windows tests", "windowmanager") ::remove(cfgName.c_str()); ConfigManager::initConfiguration(); - getConfigDefaults2(config.getDefaultValues()); - branding.setDefaultValues(getBrandingDefaults()); + setConfigDefaults2(config); + setBrandingDefaults(branding); ConfigManager::initServerConfig("nonexistserver"); localPlayer = new LocalPlayer(static_cast<BeingId>(1), @@ -845,7 +845,7 @@ TEST_CASE("WindowManager", "create windows") VirtFs::mountDirSilent("../data", Append_false); VirtFs::mountDirSilent("data/test", Append_false); VirtFs::mountDirSilent("../data/test", Append_false); - paths.setDefaultValues(getPathsDefaults()); + setPathsDefaults(paths); branding.setValue("onlineServerFile", "test/serverlistplus.xml"); mainGraphics = new SDLGraphics; imageHelper = new SDLImageHelper; @@ -870,8 +870,8 @@ TEST_CASE("WindowManager", "create windows") ::remove(cfgName.c_str()); ConfigManager::initConfiguration(); - getConfigDefaults2(config.getDefaultValues()); - branding.setDefaultValues(getBrandingDefaults()); + setConfigDefaults2(config); + setBrandingDefaults(branding); ConfigManager::initServerConfig("nonexistserver"); localPlayer = new LocalPlayer(static_cast<BeingId>(1), diff --git a/src/unittests/resources/dye/dyepalette.cc b/src/unittests/resources/dye/dyepalette.cc index 0e99e9871..9a64be1f5 100644 --- a/src/unittests/resources/dye/dyepalette.cc +++ b/src/unittests/resources/dye/dyepalette.cc @@ -95,13 +95,13 @@ TEST_CASE("DyePalette tests", "") Dirs::initHomeDir(); ConfigManager::initConfiguration(); - getConfigDefaults2(config.getDefaultValues()); - branding.setDefaultValues(getBrandingDefaults()); + setConfigDefaults2(config); + setBrandingDefaults(branding); ActorSprite::load(); gui = new Gui(); gui->postInit(mainGraphics); - paths.setDefaultValues(getPathsDefaults()); + setPathsDefaults(paths); PaletteDB::load(); SECTION("simple test 1") diff --git a/src/unittests/resources/resourcemanager/resourcemanager.cc b/src/unittests/resources/resourcemanager/resourcemanager.cc index cd67b10d8..3e3a188f2 100644 --- a/src/unittests/resources/resourcemanager/resourcemanager.cc +++ b/src/unittests/resources/resourcemanager/resourcemanager.cc @@ -130,7 +130,7 @@ TEST_CASE("resourcemanager", "resourcemanager") ActorSprite::load(); // ConfigManager::initConfiguration(); -// getConfigDefaults2(config.getDefaultValues()); +// setConfigDefaults2(config); while (ResourceManager::cleanOrphans(true)) continue; diff --git a/src/unittests/resources/sprite/animatedsprite.cc b/src/unittests/resources/sprite/animatedsprite.cc index 3e4a1826c..f05fd76dd 100644 --- a/src/unittests/resources/sprite/animatedsprite.cc +++ b/src/unittests/resources/sprite/animatedsprite.cc @@ -96,8 +96,8 @@ TEST_CASE("AnimatedSprite tests", "animatedsprite") Dirs::initHomeDir(); ConfigManager::initConfiguration(); - getConfigDefaults2(config.getDefaultValues()); - branding.setDefaultValues(getBrandingDefaults()); + setConfigDefaults2(config); + setBrandingDefaults(branding); ActorSprite::load(); gui = new Gui(); diff --git a/src/unittests/utils/chatutils.cc b/src/unittests/utils/chatutils.cc index 681d91d3e..69e79db27 100644 --- a/src/unittests/utils/chatutils.cc +++ b/src/unittests/utils/chatutils.cc @@ -92,8 +92,8 @@ TEST_CASE("chatutils replaceVars", "") Dirs::initHomeDir(); ConfigManager::initConfiguration(); - getConfigDefaults2(config.getDefaultValues()); - branding.setDefaultValues(getBrandingDefaults()); + setConfigDefaults2(config); + setBrandingDefaults(branding); gui = new Gui(); gui->postInit(mainGraphics); diff --git a/src/unittests/utils/stringutils.cc b/src/unittests/utils/stringutils.cc index ee0a00cb0..44bc4d13f 100644 --- a/src/unittests/utils/stringutils.cc +++ b/src/unittests/utils/stringutils.cc @@ -1498,7 +1498,7 @@ TEST_CASE("stringuntils replaceItemLinks", "") ItemDB::NamedItemInfos &namedInfos = ItemDB::getNamedItemInfosTest(); ItemDB::ItemInfos &infos = ItemDB::getItemInfosTest(); - paths.setDefaultValues(getPathsDefaults()); + setPathsDefaults(paths); ItemInfo *info = new ItemInfo; info->setId(123456); info->setName("test name 1"); diff --git a/src/unittests/utils/translation/poparser.cc b/src/unittests/utils/translation/poparser.cc index f724e66fb..a299617e9 100644 --- a/src/unittests/utils/translation/poparser.cc +++ b/src/unittests/utils/translation/poparser.cc @@ -83,8 +83,8 @@ TEST_CASE("PoParser tests", "PoParser") Dirs::initHomeDir(); ConfigManager::initConfiguration(); - getConfigDefaults2(config.getDefaultValues()); - branding.setDefaultValues(getBrandingDefaults()); + setConfigDefaults2(config); + setBrandingDefaults(branding); ActorSprite::load(); gui = new Gui(); diff --git a/src/unittests/utils/xml.cc b/src/unittests/utils/xml.cc index f9f7990f8..f27b65597 100644 --- a/src/unittests/utils/xml.cc +++ b/src/unittests/utils/xml.cc @@ -81,8 +81,8 @@ TEST_CASE("xml doc", "") Dirs::initHomeDir(); ConfigManager::initConfiguration(); - getConfigDefaults2(config.getDefaultValues()); - branding.setDefaultValues(getBrandingDefaults()); + setConfigDefaults2(config); + setBrandingDefaults(branding); theme = new Theme; Theme::selectSkin(); |