summaryrefslogtreecommitdiff
path: root/src/playerrelations.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-04-25 02:26:34 +0300
committerAndrei Karas <akaras@inbox.ru>2012-04-25 02:26:34 +0300
commitc9f43996f3147100627ee2c6f9da993ceb160113 (patch)
tree7577f02f4658b19e05d586f66b67a9a4f5fedb7e /src/playerrelations.cpp
parent8e19f9b9d792cf4d3d3b022fd26a258c3d3d97bf (diff)
downloadManaVerse-c9f43996f3147100627ee2c6f9da993ceb160113.tar.gz
ManaVerse-c9f43996f3147100627ee2c6f9da993ceb160113.tar.bz2
ManaVerse-c9f43996f3147100627ee2c6f9da993ceb160113.tar.xz
ManaVerse-c9f43996f3147100627ee2c6f9da993ceb160113.zip
Improve iterators part 2.
Diffstat (limited to 'src/playerrelations.cpp')
-rw-r--r--src/playerrelations.cpp33
1 files changed, 19 insertions, 14 deletions
diff --git a/src/playerrelations.cpp b/src/playerrelations.cpp
index d79a621d5..d4a72ceab 100644
--- a/src/playerrelations.cpp
+++ b/src/playerrelations.cpp
@@ -44,6 +44,11 @@
#define IGNORE_EMOTE_TIME 100
+typedef std::map<std::string, PlayerRelation *> PlayerRelations;
+typedef PlayerRelations::const_iterator PlayerRelationsCIter;
+typedef std::list<PlayerRelationsListener *> PlayerRelationListeners;
+typedef PlayerRelationListeners::const_iterator PlayerRelationListenersCIter;
+
class SortPlayersFunctor
{
public:
@@ -130,9 +135,8 @@ PlayerRelationsManager::~PlayerRelationsManager()
{
delete_all(mIgnoreStrategies);
- for (std::map<std::string,
- PlayerRelation *>::const_iterator it = mRelations.begin();
- it != mRelations.end(); ++it)
+ for (PlayerRelationsCIter it = mRelations.begin(),
+ it_end = mRelations.end(); it != it_end; ++ it)
{
delete it->second;
}
@@ -141,8 +145,11 @@ PlayerRelationsManager::~PlayerRelationsManager()
void PlayerRelationsManager::clear()
{
StringVect *names = getPlayers();
- for (StringVectCIter it = names->begin(); it != names->end(); ++ it)
+ for (StringVectCIter it = names->begin(), it_end = names->end();
+ it != it_end; ++ it)
+ {
removePlayer(*it);
+ }
delete names;
names = nullptr;
}
@@ -209,8 +216,8 @@ void PlayerRelationsManager::init()
// until the next update.
}
- for (std::list<PlayerRelationsListener *>::const_iterator
- it = mListeners.begin(); it != mListeners.end(); ++it)
+ for (PlayerRelationListenersCIter it = mListeners.begin(),
+ it_end = mListeners.end(); it != it_end; ++it)
{
(*it)->updateAll();
}
@@ -237,8 +244,8 @@ void PlayerRelationsManager::store()
void PlayerRelationsManager::signalUpdate(const std::string &name)
{
- for (std::list<PlayerRelationsListener *>::const_iterator
- it = mListeners.begin(); it != mListeners.end(); ++it)
+ for (PlayerRelationListenersCIter it = mListeners.begin(),
+ it_end = mListeners.end(); it != it_end; ++ it)
{
(*it)->updatedPlayer(name);
}
@@ -346,9 +353,8 @@ StringVect * PlayerRelationsManager::getPlayers()
{
StringVect *retval = new StringVect();
- for (std::map<std::string,
- PlayerRelation *>::const_iterator it = mRelations.begin();
- it != mRelations.end(); ++it)
+ for (PlayerRelationsCIter it = mRelations.begin(),
+ it_end = mRelations.end(); it != it_end; ++ it)
{
if (it->second)
retval->push_back(it->first);
@@ -364,9 +370,8 @@ StringVect *PlayerRelationsManager::getPlayersByRelation(
{
StringVect *retval = new StringVect();
- for (std::map<std::string,
- PlayerRelation *>::const_iterator it = mRelations.begin();
- it != mRelations.end(); ++it)
+ for (PlayerRelationsCIter it = mRelations.begin(),
+ it_end = mRelations.end(); it != it_end; ++ it)
{
if (it->second && it->second->mRelation == rel)
retval->push_back(it->first);