From d0adcf0e3c8a1db5e06bbbb8ae950ea5ebeeb8eb Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 4 Jan 2015 15:50:56 +0300 Subject: Add stringmap typedefs. --- src/actormanager.cpp | 47 +++++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 24 deletions(-) (limited to 'src/actormanager.cpp') diff --git a/src/actormanager.cpp b/src/actormanager.cpp index 506d1e79e..499471b02 100644 --- a/src/actormanager.cpp +++ b/src/actormanager.cpp @@ -74,15 +74,16 @@ class FindBeingFunctor final public: bool operator() (const ActorSprite *const actor) const { - if (!actor || actor->getType() == ActorType::FloorItem + if (!actor + || actor->getType() == ActorType::FloorItem || actor->getType() == ActorType::Portal) { return false; } const Being *const b = static_cast(actor); - const unsigned other_y = y + ((b->getType() - == ActorType::Npc) ? 1 : 0); + const unsigned other_y = y + + ((b->getType() == ActorType::Npc) ? 1 : 0); const Vector &pos = b->getPosition(); return (static_cast(pos.x) / mapTileSize == x && (static_cast(pos.y) / mapTileSize == y @@ -121,10 +122,10 @@ class SortBeingFunctor final { int w1 = defaultPriorityIndex; int w2 = defaultPriorityIndex; - const std::map::const_iterator it1 - = priorityBeings->find(being1->getName()); - const std::map::const_iterator it2 - = priorityBeings->find(being2->getName()); + const StringIntMapCIter it1 = priorityBeings->find( + being1->getName()); + const StringIntMapCIter it2 = priorityBeings->find( + being2->getName()); if (it1 != priorityBeings->end()) w1 = (*it1).second; if (it2 != priorityBeings->end()) @@ -161,10 +162,10 @@ class SortBeingFunctor final { int w1 = defaultAttackIndex; int w2 = defaultAttackIndex; - const std::map::const_iterator it1 - = attackBeings->find(being1->getName()); - const std::map::const_iterator it2 - = attackBeings->find(being2->getName()); + const StringIntMapCIter it1 = attackBeings->find( + being1->getName()); + const StringIntMapCIter it2 = attackBeings->find( + being2->getName()); if (it1 != attackBeings->end()) w1 = (*it1).second; if (it2 != attackBeings->end()) @@ -176,8 +177,8 @@ class SortBeingFunctor final return (being1->getName() < being2->getName()); } - std::map *attackBeings; - std::map *priorityBeings; + StringIntMap *attackBeings; + StringIntMap *priorityBeings; int x; int y; int defaultAttackIndex; @@ -919,8 +920,8 @@ Being *ActorManager::findNearestLivingBeing(const Being *const aroundBeing, std::set attackMobs; std::set priorityMobs; std::set ignoreAttackMobs; - std::map attackMobsMap; - std::map priorityMobsMap; + StringIntMap attackMobsMap; + StringIntMap priorityMobsMap; int defaultAttackIndex = 10000; int defaultPriorityIndex = 10000; const int attackRange = localPlayer->getAttackRange(); @@ -959,8 +960,7 @@ Being *ActorManager::findNearestLivingBeing(const Being *const aroundBeing, beingActorSorter.attackRange = attackRange; if (ignoreAttackMobs.find("") != ignoreAttackMobs.end()) ignoreDefault = true; - std::map::const_iterator - itr = attackMobsMap.find(""); + StringIntMapCIter itr = attackMobsMap.find(""); if (itr != attackMobsMap.end()) defaultAttackIndex = (*itr).second; itr = priorityMobsMap.find(""); @@ -1136,8 +1136,8 @@ Being *ActorManager::findNearestLivingBeing(const Being *const aroundBeing, int w2 = defaultPriorityIndex; if (closestBeing) { - const std::map::const_iterator it2 - = priorityMobsMap.find(being->getName()); + const StringIntMapCIter it2 = priorityMobsMap.find( + being->getName()); if (it2 != priorityMobsMap.end()) w2 = (*it2).second; @@ -1161,8 +1161,8 @@ Being *ActorManager::findNearestLivingBeing(const Being *const aroundBeing, { dist = d; closestBeing = being; - const std::map::const_iterator it1 - = priorityMobsMap.find(being->getName()); + const StringIntMapCIter it1 = priorityMobsMap.find( + being->getName()); if (it1 != priorityMobsMap.end()) index = (*it1).second; else @@ -1628,10 +1628,9 @@ void ActorManager::rebuildPickupItems() } int ActorManager::getIndexByName(const std::string &name, - const std::map &map) + const StringIntMap &map) { - const std::map::const_iterator - i = map.find(name); + const StringIntMapCIter i = map.find(name); if (i == map.end()) return -1; -- cgit v1.2.3-60-g2f50