diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-03-18 15:47:51 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-03-18 15:47:51 +0300 |
commit | a80f8f578a78752b5b43f3aeb8759b0db4c51714 (patch) | |
tree | f4edfcf9f994f1ac919d88de7ad8921eb8a475c9 /src | |
parent | b8fd168c06687338268226ac4e8292549c31bbfc (diff) | |
download | mv-a80f8f578a78752b5b43f3aeb8759b0db4c51714.tar.gz mv-a80f8f578a78752b5b43f3aeb8759b0db4c51714.tar.bz2 mv-a80f8f578a78752b5b43f3aeb8759b0db4c51714.tar.xz mv-a80f8f578a78752b5b43f3aeb8759b0db4c51714.zip |
Improve a bit findBeingsByPixel.
Diffstat (limited to 'src')
-rw-r--r-- | src/actormanager.cpp | 76 |
1 files changed, 51 insertions, 25 deletions
diff --git a/src/actormanager.cpp b/src/actormanager.cpp index cf7884a9f..fe4e55687 100644 --- a/src/actormanager.cpp +++ b/src/actormanager.cpp @@ -542,36 +542,62 @@ void ActorManager::findBeingsByPixel(std::vector<ActorSprite*> &beings, for_actors { - if (!*it) - continue; - - if ((*it)->getType() == ActorType::Portal) - continue; - - const Being *const being = dynamic_cast<const Being*>(*it); + ActorSprite *const actor = *it; - if (being && being->getInfo() - && !(being->getInfo()->isTargetSelection() || modActive)) - { + if (!actor) continue; - } - - ActorSprite *const actor = *it; - if ((being && - (being->isAlive() || - (mTargetDeadPlayers && - being->getType() == ActorType::Player)) && - (allPlayers == AllPlayers_true || - being != localPlayer)) || - actor->getType() == ActorType::FloorItem) + const ActorTypeT actorType = actor->getType(); + switch (actorType) { - if ((actor->getPixelX() - xtol <= x) && - (actor->getPixelX() + xtol > x) && - (actor->getPixelY() - uptol <= y) && - (actor->getPixelY() > y)) + default: + case ActorType::Unknown: + case ActorType::Avatar: + case ActorType::Portal: + break; + case ActorType::FloorItem: + if ((actor->getPixelX() - xtol <= x) && + (actor->getPixelX() + xtol > x) && + (actor->getPixelY() - uptol <= y) && + (actor->getPixelY() > y)) + { + beings.push_back(actor); + } + break; + case ActorType::Player: + case ActorType::Npc: + case ActorType::Monster: + case ActorType::LocalPet: +#ifdef EATHENA_SUPPORT + case ActorType::Pet: + case ActorType::Mercenary: + case ActorType::Homunculus: + case ActorType::SkillUnit: +#endif { - beings.push_back(actor); + const Being *const being = static_cast<const Being*>(*it); + if (!being) + continue; + if (being->getInfo() && + !(being->getInfo()->isTargetSelection() || modActive)) + { + continue; + } + if ((being->isAlive() || + (mTargetDeadPlayers && + actorType == ActorType::Player)) && + (allPlayers == AllPlayers_true || + being != localPlayer)) + { + if ((actor->getPixelX() - xtol <= x) && + (actor->getPixelX() + xtol > x) && + (actor->getPixelY() - uptol <= y) && + (actor->getPixelY() > y)) + { + beings.push_back(actor); + } + } + break; } } } |