From a80f8f578a78752b5b43f3aeb8759b0db4c51714 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 18 Mar 2016 15:47:51 +0300 Subject: Improve a bit findBeingsByPixel. --- src/actormanager.cpp | 76 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 51 insertions(+), 25 deletions(-) (limited to 'src/actormanager.cpp') 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 &beings, for_actors { - if (!*it) - continue; - - if ((*it)->getType() == ActorType::Portal) - continue; - - const Being *const being = dynamic_cast(*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(*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; } } } -- cgit v1.2.3-60-g2f50