diff options
author | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-03-02 12:55:32 +0000 |
---|---|---|
committer | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-03-02 12:55:32 +0000 |
commit | 5efaa5125fe92a5438b3cc2949f4d720bced5a7a (patch) | |
tree | 87f4da1382fb6179610182ca3e502e5365e66276 /src/playerrelations.cpp | |
parent | 2e60491ceb0548b0bea93207c13b974d6a6cf5cc (diff) | |
download | mana-5efaa5125fe92a5438b3cc2949f4d720bced5a7a.tar.gz mana-5efaa5125fe92a5438b3cc2949f4d720bced5a7a.tar.bz2 mana-5efaa5125fe92a5438b3cc2949f4d720bced5a7a.tar.xz mana-5efaa5125fe92a5438b3cc2949f4d720bced5a7a.zip |
General code cleanups
* Don't needlessly store or return raw pointers in BeingInfo
* Less copying, more moving
* Less else after return
* Make AddDEF a template instead of a macro
* Removed some unused includes
* Use range-based for loops
Diffstat (limited to 'src/playerrelations.cpp')
-rw-r--r-- | src/playerrelations.cpp | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/src/playerrelations.cpp b/src/playerrelations.cpp index 69e857a7..d0e4a195 100644 --- a/src/playerrelations.cpp +++ b/src/playerrelations.cpp @@ -24,7 +24,6 @@ #include "actorspritemanager.h" #include "being.h" #include "configuration.h" -#include "graphics.h" #include "playerrelations.h" #include "utils/dtor.h" @@ -97,12 +96,8 @@ PlayerRelationsManager::~PlayerRelationsManager() { delete_all(mIgnoreStrategies); - for (std::map<std::string, - PlayerRelation *>::const_iterator it = mRelations.begin(); - it != mRelations.end(); it++) - { - delete it->second; - } + for (auto &[_, relation] : mRelations) + delete relation; } void PlayerRelationsManager::clear() @@ -175,11 +170,8 @@ void PlayerRelationsManager::signalUpdate(const std::string &name) { store(); - for (std::list<PlayerRelationsListener *>::const_iterator it = mListeners.begin(); - it != mListeners.end(); it++) - { - (*it)->updatedPlayer(name); - } + for (auto listener : mListeners) + listener->updatedPlayer(name); } unsigned int PlayerRelationsManager::checkPermissionSilently( @@ -188,8 +180,7 @@ unsigned int PlayerRelationsManager::checkPermissionSilently( { PlayerRelation *r = nullptr; - std::map<std::string, PlayerRelation *>::const_iterator it = - mRelations.find(playerName); + auto it = mRelations.find(playerName); if (it != mRelations.end()) r = it->second; if (!r) @@ -341,9 +332,9 @@ public: } void ignore(Being *being, unsigned int flags) override - { - being->setSpeech("...", 500); - } + { + being->setSpeech("...", 500); + } }; @@ -365,7 +356,7 @@ public: std::vector<PlayerIgnoreStrategy *> * PlayerRelationsManager::getPlayerIgnoreStrategies() { - if (mIgnoreStrategies.size() == 0) + if (mIgnoreStrategies.empty()) { mIgnoreStrategies.push_back(new PIS_nothing()); mIgnoreStrategies.push_back(new PIS_dotdotdot()); |