diff options
author | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-10-29 17:58:38 +0100 |
---|---|---|
committer | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-10-29 17:58:38 +0100 |
commit | 5649f2ecae088793fb87445a26b82f4d7451bc89 (patch) | |
tree | d11ebcc3f7aaa971a716abeb9f40f4a5fff91382 /src | |
parent | 6cd8881f1b11c99f8e72735017e743c50094e922 (diff) | |
download | mana-5649f2ecae088793fb87445a26b82f4d7451bc89.tar.gz mana-5649f2ecae088793fb87445a26b82f4d7451bc89.tar.bz2 mana-5649f2ecae088793fb87445a26b82f4d7451bc89.tar.xz mana-5649f2ecae088793fb87445a26b82f4d7451bc89.zip |
There were two issues here. First, the loading of the relations was
triggering a storing of the settings before they were loaded. In effect,
all the related settings were reset on every startup. And since storing
of the relations wasn't enabled by default, they were always cleared.
Second problem was in `PlayerConfSerialiser::readConfigItem`, which was
never setting any relation because of an inverted condition introduced
in 9a702e64449ba54fab28706c5b9c5ff9f2a41f8a.
Diffstat (limited to 'src')
-rw-r--r-- | src/playerrelations.cpp | 36 | ||||
-rw-r--r-- | src/playerrelations.h | 5 |
2 files changed, 14 insertions, 27 deletions
diff --git a/src/playerrelations.cpp b/src/playerrelations.cpp index f78852e8..22396009 100644 --- a/src/playerrelations.cpp +++ b/src/playerrelations.cpp @@ -56,13 +56,8 @@ class PlayerConfSerialiser : public ConfigurationListManager<std::pair<std::stri if (name.empty()) return container; - auto it = (*container).find(name); - if (it != (*container).end()) - { - int v = cobj->getValue(RELATION, static_cast<int>(PlayerRelation::NEUTRAL)); - (*container)[name] = static_cast<PlayerRelation>(v); - } - // otherwise ignore the duplicate entry + int v = cobj->getValue(RELATION, static_cast<int>(PlayerRelation::NEUTRAL)); + (*container)[name] = static_cast<PlayerRelation>(v); return container; } @@ -95,30 +90,27 @@ int PlayerRelationsManager::getPlayerIgnoreStrategyIndex(const std::string &name return -1; } -void PlayerRelationsManager::load() +void PlayerRelationsManager::init() { - clear(); - mPersistIgnores = config.getValue(PERSIST_IGNORE_LIST, 1); - mDefaultPermissions = (int) config.getValue(DEFAULT_PERMISSIONS, mDefaultPermissions); + mDefaultPermissions = config.getValue(DEFAULT_PERMISSIONS, mDefaultPermissions); std::string ignore_strategy_name = config.getValue(PLAYER_IGNORE_STRATEGY, DEFAULT_IGNORE_STRATEGY); int ignore_strategy_index = getPlayerIgnoreStrategyIndex(ignore_strategy_name); if (ignore_strategy_index >= 0) setPlayerIgnoreStrategy(getPlayerIgnoreStrategies()[ignore_strategy_index]); - PlayerConfSerialiser player_conf_serialiser; - config.getList<std::pair<std::string, PlayerRelation>, - std::map<std::string, PlayerRelation> *> - ("player", &mRelations, player_conf_serialiser); -} - + mRelations.clear(); -void PlayerRelationsManager::init() -{ - load(); + // Ignores are always saved to the config file, but might not be loaded + if (mPersistIgnores) + { + PlayerConfSerialiser player_conf_serialiser; + config.getList<std::pair<std::string, PlayerRelation>, + std::map<std::string, PlayerRelation> *> + ("player", &mRelations, player_conf_serialiser); + } - if (!mPersistIgnores) - clear(); // Yes, we still keep them around in the config file until the next update. + signalUpdate(); } void PlayerRelationsManager::store() diff --git a/src/playerrelations.h b/src/playerrelations.h index 45102fd9..2a43675e 100644 --- a/src/playerrelations.h +++ b/src/playerrelations.h @@ -95,11 +95,6 @@ public: void init(); /** - * Load configuration from our config file, or substitute defaults. - */ - void load(); - - /** * Save configuration to our config file. */ void store(); |