summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIra Rice <irarice@gmail.com>2009-01-26 01:56:55 -0700
committerIra Rice <irarice@gmail.com>2009-01-26 01:56:55 -0700
commit803e0dae01f09afbe529799cf89a8f57fe518ddb (patch)
tree6721b01603dcf77934cdb55afa659580a215b56d
parent062f4065f5a2117fc5fd5f408e1f3163e2f63afc (diff)
downloadmana-client-803e0dae01f09afbe529799cf89a8f57fe518ddb.tar.gz
mana-client-803e0dae01f09afbe529799cf89a8f57fe518ddb.tar.bz2
mana-client-803e0dae01f09afbe529799cf89a8f57fe518ddb.tar.xz
mana-client-803e0dae01f09afbe529799cf89a8f57fe518ddb.zip
Bit of code cleanup for the last commit (moved default width and height
out of being.h, so that they aren't included in any classes that don't need them and cut the number of divisions in half in the being manager) Signed-off-by: Ira Rice <irarice@gmail.com>
-rw-r--r--src/being.cpp15
-rw-r--r--src/being.h3
-rw-r--r--src/beingmanager.cpp6
3 files changed, 12 insertions, 12 deletions
diff --git a/src/being.cpp b/src/being.cpp
index ad5f4204..985be69c 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -56,6 +56,9 @@ std::vector<AnimatedSprite*> Being::emotionSet;
static const int X_SPEECH_OFFSET = 18;
static const int Y_SPEECH_OFFSET = 60;
+static const int DEFAULT_WIDTH = 32;
+static const int DEFAULT_HEIGHT = 32;
+
Being::Being(int id, int job, Map *map):
mJob(job),
mX(0), mY(0),
@@ -571,14 +574,14 @@ int Being::getWidth() const
{
if (mSprites[BASE_SPRITE])
{
- const int width = mSprites[BASE_SPRITE]->getWidth() > Being::DEFAULT_WIDTH ?
+ const int width = mSprites[BASE_SPRITE]->getWidth() > DEFAULT_WIDTH ?
mSprites[BASE_SPRITE]->getWidth() :
- Being::DEFAULT_WIDTH;
+ DEFAULT_WIDTH;
return width;
}
else
{
- return Being::DEFAULT_WIDTH;
+ return DEFAULT_WIDTH;
}
}
@@ -587,14 +590,14 @@ int Being::getHeight() const
{
if (mSprites[BASE_SPRITE])
{
- const int height = mSprites[BASE_SPRITE]->getHeight() > Being::DEFAULT_HEIGHT ?
+ const int height = mSprites[BASE_SPRITE]->getHeight() > DEFAULT_HEIGHT ?
mSprites[BASE_SPRITE]->getHeight() :
- Being::DEFAULT_HEIGHT;
+ DEFAULT_HEIGHT;
return height;
}
else
{
- return Being::DEFAULT_HEIGHT;
+ return DEFAULT_HEIGHT;
}
}
diff --git a/src/being.h b/src/being.h
index a43297ad..80295db8 100644
--- a/src/being.h
+++ b/src/being.h
@@ -432,9 +432,6 @@ class Being : public Sprite
*/
int getOffset(char pos, char neg) const;
- static const int DEFAULT_WIDTH = 32;
- static const int DEFAULT_HEIGHT = 32;
-
// Speech Bubble components
SpeechBubble *mSpeechBubble;
diff --git a/src/beingmanager.cpp b/src/beingmanager.cpp
index 6b71b3bf..9e620ca0 100644
--- a/src/beingmanager.cpp
+++ b/src/beingmanager.cpp
@@ -131,14 +131,14 @@ Being* BeingManager::findBeingByPixel(Uint16 x, Uint16 y)
Being *being = (*itr);
int xtol = being->getWidth();
- int uptol = being->getHeight();
+ int uptol = being->getHeight() / 2;
if ((being->mAction != Being::DEAD) &&
(being != player_node) &&
(being->getPixelX() <= x) &&
(being->getPixelX() + xtol >= x) &&
- (being->getPixelY() - (uptol / 2) <= y) &&
- (being->getPixelY() + (uptol / 2) >= y))
+ (being->getPixelY() - uptol <= y) &&
+ (being->getPixelY() + uptol >= y))
{
return being;
}