summaryrefslogtreecommitdiff
path: root/src/playerrelations.h
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-10-07 12:19:10 +0200
committerThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-10-29 17:16:37 +0100
commit63fffadacc51fb7c4915361f0286682e08a55cb1 (patch)
tree94b49c6afadaf91541076d2a57553a6c5097422e /src/playerrelations.h
parentf0f2496a25cedc0cf9076491ccaccab0647e16f5 (diff)
downloadmana-63fffadacc51fb7c4915361f0286682e08a55cb1.tar.gz
mana-63fffadacc51fb7c4915361f0286682e08a55cb1.tar.bz2
mana-63fffadacc51fb7c4915361f0286682e08a55cb1.tar.xz
mana-63fffadacc51fb7c4915361f0286682e08a55cb1.zip
Avoid some needless pointer indirection
* Don't use `PlayerRelation*` in `mRelations`, but just store the value. * Pass `std::vector<PlayerIgnoreStrategy *>` by reference instead of pointer. * Return player list in `PlayerRelationsManager::getPlayers` by value instead of pointer. Overall these changes simplify the code, making it less prone to errors.
Diffstat (limited to 'src/playerrelations.h')
-rw-r--r--src/playerrelations.h11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/playerrelations.h b/src/playerrelations.h
index a836a976..2a0426a1 100644
--- a/src/playerrelations.h
+++ b/src/playerrelations.h
@@ -56,7 +56,7 @@ struct PlayerRelation
IGNORED = 3
};
- PlayerRelation(Relation relation);
+ explicit PlayerRelation(Relation relation = NEUTRAL);
Relation mRelation; // bitmask for all of the above
};
@@ -158,11 +158,8 @@ public:
/**
* Retrieves all known player ignore strategies.
- *
- * The player ignore strategies are allocated statically and must not be
- * deleted.
*/
- std::vector<PlayerIgnoreStrategy *> *getPlayerIgnoreStrategies();
+ std::vector<PlayerIgnoreStrategy *> &getPlayerIgnoreStrategies();
/**
* Return the current player ignore strategy.
@@ -195,7 +192,7 @@ public:
* Retrieves a sorted vector of all players for which we have any relations
* recorded.
*/
- std::vector<std::string> *getPlayers() const;
+ std::vector<std::string> getPlayers() const;
/**
* Removes all recorded player info.
@@ -231,7 +228,7 @@ private:
unsigned int mDefaultPermissions;
PlayerIgnoreStrategy *mIgnoreStrategy;
- std::map<std::string, PlayerRelation *> mRelations;
+ std::map<std::string, PlayerRelation> mRelations;
std::list<PlayerRelationsListener *> mListeners;
std::vector<PlayerIgnoreStrategy *> mIgnoreStrategies;
};