diff options
author | Philipp Sehmisch <crush@themanaworld.org> | 2009-01-25 19:45:18 +0100 |
---|---|---|
committer | Philipp Sehmisch <crush@themanaworld.org> | 2009-01-25 19:45:18 +0100 |
commit | 3ca85b152531b9dd9cffa18d9b64d7c7ae615adf (patch) | |
tree | 91bbf1fdb71c52e1074160652abacfc1911a5bac | |
parent | 2a7c63f6070606e6623a9730aa1ca9d52c942055 (diff) | |
download | mana-client-3ca85b152531b9dd9cffa18d9b64d7c7ae615adf.tar.gz mana-client-3ca85b152531b9dd9cffa18d9b64d7c7ae615adf.tar.bz2 mana-client-3ca85b152531b9dd9cffa18d9b64d7c7ae615adf.tar.xz mana-client-3ca85b152531b9dd9cffa18d9b64d7c7ae615adf.zip |
Fixed offset of right-click hitboxes and made NPCs without sprites clickable.
-rw-r--r-- | src/being.cpp | 4 | ||||
-rw-r--r-- | src/being.h | 4 | ||||
-rw-r--r-- | src/beingmanager.cpp | 19 |
3 files changed, 16 insertions, 11 deletions
diff --git a/src/being.cpp b/src/being.cpp index d32ffa59..442c08ef 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -603,7 +603,7 @@ int Being::getWidth() const return mSprites[BASE_SPRITE]->getWidth(); } else { - return 0; + return Being::DEFAULT_WIDTH; } } @@ -614,7 +614,7 @@ int Being::getHeight() const return mSprites[BASE_SPRITE]->getHeight(); } else { - return 0; + return Being::DEFAULT_HEIGHT; } } diff --git a/src/being.h b/src/being.h index aeb03564..0591777e 100644 --- a/src/being.h +++ b/src/being.h @@ -411,6 +411,10 @@ class Being : public Sprite std::list<Particle *> mChildParticleEffects; private: + + static const int Being::DEFAULT_WIDTH = 32; + static const int Being::DEFAULT_HEIGHT = 32; + // Speech Bubble components SpeechBubble *mSpeechBubble; diff --git a/src/beingmanager.cpp b/src/beingmanager.cpp index 6d9267d2..7f3d8845 100644 --- a/src/beingmanager.cpp +++ b/src/beingmanager.cpp @@ -123,12 +123,13 @@ Being* BeingManager::findBeingByPixel(Uint16 x, Uint16 y) for (; itr != itr_end; ++itr) { Being *being = (*itr); - if ((being->mAction != Being::DEAD) && - (being != player_node) && - (being->getPixelX() <= x) && - (being->getPixelX() + being->getWidth() >= x) && - (being->getPixelY() <= y) && - (being->getPixelY() + being->getHeight() >= y)) + int xtol = being->getWidth() / 2; + int uptol = being->getHeight(); + if ((being != player_node) && + (being->getPixelX() - xtol <= x) && + (being->getPixelX() + xtol >= x) && + (being->getPixelY() - uptol <= y) && + (being->getPixelY() >= y)) { return being; } @@ -190,7 +191,7 @@ Being* BeingManager::findNearestLivingBeing(Uint16 x, Uint16 y, int maxdist, //in map coords, while down below its in pixels // //I believe there is a deeper problem under this, but - //for a temp solution we'll convert to coords to pixels + //for a temp solution we'll convert to coords to pixels x = x * 32; y = y * 32; maxdist = maxdist * 32; @@ -210,8 +211,8 @@ Being* BeingManager::findNearestLivingBeing(Uint16 x, Uint16 y, int maxdist, closestBeing = being; } } - - return (maxdist >= dist) ? closestBeing : NULL; + + return (maxdist >= dist) ? closestBeing : NULL; } Being* BeingManager::findNearestLivingBeing(Being *aroundBeing, int maxdist, |