diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-08-21 22:44:29 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-08-21 22:45:15 +0300 |
commit | 42f47e483da19079a937c4801ca94bd62d8dc970 (patch) | |
tree | 56dc96737e01e04d54357ce7118de3a1f000c516 /src/actormanager.cpp | |
parent | 2d8b9246c8003f1d32ba396bc19cc11bc5a595b2 (diff) | |
download | manaverse-42f47e483da19079a937c4801ca94bd62d8dc970.tar.gz manaverse-42f47e483da19079a937c4801ca94bd62d8dc970.tar.bz2 manaverse-42f47e483da19079a937c4801ca94bd62d8dc970.tar.xz manaverse-42f47e483da19079a937c4801ca94bd62d8dc970.zip |
Remove useless else.
Diffstat (limited to 'src/actormanager.cpp')
-rw-r--r-- | src/actormanager.cpp | 218 |
1 files changed, 105 insertions, 113 deletions
diff --git a/src/actormanager.cpp b/src/actormanager.cpp index c864b8c08..2649cb230 100644 --- a/src/actormanager.cpp +++ b/src/actormanager.cpp @@ -541,40 +541,37 @@ Being *ActorManager::findBeingByPixel(const int x, const int y, return nullptr; return tempBeing; } - else + for_actorsm { - for_actorsm - { // disabled for performance // if (reportTrue(*it == nullptr)) // continue; - if ((*it)->getType() == ActorType::Portal || - (*it)->getType() == ActorType::FloorItem) - { - continue; - } + if ((*it)->getType() == ActorType::Portal || + (*it)->getType() == ActorType::FloorItem) + { + continue; + } - Being *const being = static_cast<Being*>(*it); + Being *const being = static_cast<Being*>(*it); - if (being->getInfo() != nullptr && - !(being->getInfo()->isTargetSelection() || modActive)) - { - continue; - } + if (being->getInfo() != nullptr && + !(being->getInfo()->isTargetSelection() || modActive)) + { + continue; + } - const int px = being->getPixelX(); - const int py = being->getPixelY(); - if ((px - mapTileSize / 2 <= x) && - (px + mapTileSize / 2 > x) && - (py - mapTileSize <= y) && - (py > y)) - { - return being; - } + const int px = being->getPixelX(); + const int py = being->getPixelY(); + if ((px - mapTileSize / 2 <= x) && + (px + mapTileSize / 2 > x) && + (py - mapTileSize <= y) && + (py > y)) + { + return being; } - return nullptr; } + return nullptr; } void ActorManager::findBeingsByPixel(STD_VECTOR<ActorSprite*> &beings, @@ -922,17 +919,14 @@ Being *ActorManager::findNearestByName(const std::string &name, { return being; } - else - { - const int d = (being->getTileX() - x) * (being->getTileX() - x) - + (being->getTileY() - y) * (being->getTileY() - y); + const int d = (being->getTileX() - x) * (being->getTileX() - x) + + (being->getTileY() - y) * (being->getTileY() - y); - if (validateBeing(nullptr, being, type, nullptr, 50) - && (d < dist || closestBeing == nullptr)) - { - dist = d; - closestBeing = being; - } + if (validateBeing(nullptr, being, type, nullptr, 50) + && (d < dist || closestBeing == nullptr)) + { + dist = d; + closestBeing = being; } } } @@ -1277,115 +1271,113 @@ Being *ActorManager::findNearestLivingBeing(const Being *const aroundBeing, // we find next being after target return *i; } - else - { - int dist = 0; - int index = defaultPriorityIndex; - Being *closestBeing = nullptr; - FOR_EACH (ActorSprites::iterator, i, mActors) - { + int dist = 0; + int index = defaultPriorityIndex; + Being *closestBeing = nullptr; + + FOR_EACH (ActorSprites::iterator, i, mActors) + { // disabled for performance // if (reportTrue(*i == nullptr)) // continue; - if ((*i)->getType() == ActorType::FloorItem || - (*i)->getType() == ActorType::Portal) - { - continue; - } - Being *const being = static_cast<Being*>(*i); + if ((*i)->getType() == ActorType::FloorItem || + (*i)->getType() == ActorType::Portal) + { + continue; + } + Being *const being = static_cast<Being*>(*i); - if (filtered) + if (filtered) + { + if (ignoreAttackMobs.find(being->getName()) + != ignoreAttackMobs.end()) { - if (ignoreAttackMobs.find(being->getName()) - != ignoreAttackMobs.end()) - { - continue; - } - if (ignoreDefault && attackMobs.find(being->getName()) - == attackMobs.end() && priorityMobs.find(being->getName()) - == priorityMobs.end()) - { - continue; - } + continue; } - - if ((being->getInfo() != nullptr) - && !(being->getInfo()->isTargetSelection() || modActive)) + if (ignoreDefault && attackMobs.find(being->getName()) + == attackMobs.end() && priorityMobs.find(being->getName()) + == priorityMobs.end()) { continue; } + } + + if ((being->getInfo() != nullptr) + && !(being->getInfo()->isTargetSelection() || modActive)) + { + continue; + } - const bool valid = validateBeing(aroundBeing, being, + const bool valid = validateBeing(aroundBeing, being, type, excluded, 50); - int d = being->getDistance(); - if (being->getType() != ActorType::Monster - || !mTargetOnlyReachable) - { // if distance not calculated, use old distance - d = (being->getTileX() - x) * (being->getTileX() - x) - + (being->getTileY() - y) * (being->getTileY() - y); - } + int d = being->getDistance(); + if (being->getType() != ActorType::Monster + || !mTargetOnlyReachable) + { // if distance not calculated, use old distance + d = (being->getTileX() - x) * (being->getTileX() - x) + + (being->getTileY() - y) * (being->getTileY() - y); + } - if (!valid) - continue; + if (!valid) + continue; - if (specialDistance && being->getDistance() <= 2 - && being->getType() == type) - { - continue; - } + if (specialDistance && being->getDistance() <= 2 + && being->getType() == type) + { + continue; + } // logger->log("being name:" + being->getName()); // logger->log("index:" + toString(index)); // logger->log("d:" + toString(d)); - if (!filtered && (d <= dist || (closestBeing == nullptr))) - { - dist = d; - closestBeing = being; - } - else if (filtered) + if (!filtered && (d <= dist || (closestBeing == nullptr))) + { + dist = d; + closestBeing = being; + } + else if (filtered) + { + int w2 = defaultPriorityIndex; + if (closestBeing != nullptr) { - int w2 = defaultPriorityIndex; - if (closestBeing != nullptr) - { - const StringIntMapCIter it2 = priorityMobsMap.find( - being->getName()); - if (it2 != priorityMobsMap.end()) - w2 = (*it2).second; + const StringIntMapCIter it2 = priorityMobsMap.find( + being->getName()); + if (it2 != priorityMobsMap.end()) + w2 = (*it2).second; - if (w2 < index) - { - dist = d; - closestBeing = being; - index = w2; - continue; - } - if (w2 == index && d <= dist) - { - dist = d; - closestBeing = being; - index = w2; - continue; - } + if (w2 < index) + { + dist = d; + closestBeing = being; + index = w2; + continue; } - - if (closestBeing == nullptr) + if (w2 == index && d <= dist) { dist = d; closestBeing = being; - const StringIntMapCIter it1 = priorityMobsMap.find( - being->getName()); - if (it1 != priorityMobsMap.end()) - index = (*it1).second; - else - index = defaultPriorityIndex; + index = w2; + continue; } } + + if (closestBeing == nullptr) + { + dist = d; + closestBeing = being; + const StringIntMapCIter it1 = priorityMobsMap.find( + being->getName()); + if (it1 != priorityMobsMap.end()) + index = (*it1).second; + else + index = defaultPriorityIndex; + } } - return (maxDist >= dist) ? closestBeing : nullptr; } + return (maxDist >= dist) ? closestBeing : nullptr; } bool ActorManager::validateBeing(const Being *const aroundBeing, |