summaryrefslogtreecommitdiff
path: root/src/playerrelations.cpp
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-10-29 17:58:38 +0100
committerThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-10-29 17:58:38 +0100
commit5649f2ecae088793fb87445a26b82f4d7451bc89 (patch)
treed11ebcc3f7aaa971a716abeb9f40f4a5fff91382 /src/playerrelations.cpp
parent6cd8881f1b11c99f8e72735017e743c50094e922 (diff)
downloadmana-master.tar.gz
mana-master.tar.bz2
mana-master.tar.xz
mana-master.zip
Fixed storing of player relationsHEADmaster
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/playerrelations.cpp')
-rw-r--r--src/playerrelations.cpp36
1 files changed, 14 insertions, 22 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()