summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/being.cpp36
-rw-r--r--src/being.h12
2 files changed, 22 insertions, 26 deletions
diff --git a/src/being.cpp b/src/being.cpp
index b8fb4df7..de334291 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -93,7 +93,6 @@ Being::Being(int id, int job, Map *map):
#else
mWalkSpeed(150),
#endif
- mPx(0), mPy(0),
mX(0), mY(0),
mTakedDamage(0),
mUsedTargetCursor(NULL)
@@ -125,15 +124,11 @@ void Being::setPosition(const Vector &pos)
{
mPos = pos;
- // Update pixel coordinates (convert once, for performance reasons)
- mPx = (int) pos.x;
- mPy = (int) pos.y;
-
updateCoords();
if (mText)
- mText->adviseXY(mPx,
- mPy - getHeight() - mText->getHeight() - 6);
+ mText->adviseXY(pos.x,
+ pos.y - getHeight() - mText->getHeight() - 6);
}
#ifdef EATHENA_SUPPORT
@@ -142,9 +137,7 @@ void Being::setDestination(int destX, int destY)
if (mMap)
setPath(mMap->findPath(mX, mY, destX, destY, getWalkMask()));
}
-#endif
-
-#ifdef MANASERV_SUPPORT
+#else
void Being::setDestination(int dstX, int dstY)
{
mDest.x = dstX;
@@ -266,7 +259,7 @@ void Being::setSpeech(const std::string &text, int time)
delete mText;
mText = new Text(mSpeech,
- mPx, mPy - getHeight(),
+ getPixelX(), getPixelY() - getHeight(),
gcn::Graphics::CENTER,
&guiPalette->getColor(Palette::PARTICLE),
true);
@@ -311,7 +304,7 @@ void Being::takeDamage(Being *attacker, int amount, AttackType type)
// Show damage number
particleEngine->addTextSplashEffect(damage,
- mPx, mPy - 16,
+ getPixelX(), getPixelY() - 16,
color, font, true);
if (amount > 0)
@@ -346,7 +339,8 @@ void Being::handleAttack(Being *victim, int damage, AttackType type)
p->moveBy(Vector(0.0f, 0.0f, 32.0f));
victim->controlParticle(p);
- Particle *p2 = particleEngine->addEffect("graphics/particles/arrow.particle.xml", mPx, mPy);
+ Particle *p2 = particleEngine->addEffect("graphics/particles/arrow.particle.xml",
+ getPixelX(), getPixelY());
if (p2)
{
p2->setLifetime(900);
@@ -646,11 +640,11 @@ void Being::draw(Graphics *graphics, int offsetX, int offsetY) const
// TODO: Eventually, we probably should fix all sprite offsets so that
// these translations aren't necessary anymore. The sprites know
// best where their base point should be.
- const int px = mPx + offsetX - 16;
+ const int px = getPixelX() + offsetX - 16;
#ifdef MANASERV_SUPPORT
- const int py = mPy + offsetY - 15; // Temporary fix to the Y offset.
+ const int py = getPixelY() + offsetY - 15; // Temporary fix to the Y offset.
#else
- const int py = mPy + offsetY - 32;
+ const int py = getPixelY() + offsetY - 32;
#endif
if (mUsedTargetCursor)
@@ -684,8 +678,8 @@ void Being::drawEmotion(Graphics *graphics, int offsetX, int offsetY)
if (!mEmotion)
return;
- const int px = mPx - offsetX - 16;
- const int py = mPy - offsetY - 64 - 32;
+ const int px = getPixelX() - offsetX - 16;
+ const int py = getPixelY() - offsetY - 64 - 32;
const int emotionIndex = mEmotion - 1;
if (emotionIndex >= 0 && emotionIndex <= EmoteDB::getLast())
@@ -694,8 +688,8 @@ void Being::drawEmotion(Graphics *graphics, int offsetX, int offsetY)
void Being::drawSpeech(int offsetX, int offsetY)
{
- const int px = mPx - offsetX;
- const int py = mPy - offsetY;
+ const int px = getPixelX() - offsetX;
+ const int py = getPixelY() - offsetY;
const int speech = (int) config.getValue("speech", TEXT_OVERHEAD);
// Draw speech above this being
@@ -729,7 +723,7 @@ void Being::drawSpeech(int offsetX, int offsetY)
if (! mText)
{
mText = new Text(mSpeech,
- mPx, mPy - getHeight(),
+ getPixelX(), getPixelY() - getHeight(),
gcn::Graphics::CENTER,
&guiPalette->getColor(Palette::PARTICLE),
true);
diff --git a/src/being.h b/src/being.h
index fe4ab475..9f50b2cc 100644
--- a/src/being.h
+++ b/src/being.h
@@ -161,16 +161,19 @@ class Being : public Sprite, public ConfigListener
#endif
/**
- * Returns the tile x or y coord
+ * Returns the tile x coord
*/
int getTileX() const
{ return mX; }
+ /**
+ * Returns the tile y coord
+ */
int getTileY() const
{ return mY; }
/**
- * Sets the tile x or y coord
+ * Sets the tile x and y coord
*/
void setTileCoords(int x, int y)
{ mX = x; mY = y; }
@@ -348,7 +351,7 @@ class Being : public Sprite, public ConfigListener
* Returns the X coordinate in pixels.
*/
int getPixelX() const
- { return mPx; }
+ { return mPos.x; }
/**
* Returns the Y coordinate in pixels.
@@ -356,7 +359,7 @@ class Being : public Sprite, public ConfigListener
* @see Sprite::getPixelY()
*/
int getPixelY() const
- { return mPy; }
+ { return mPos.y; }
#ifdef EATHENA_SUPPORT
/**
@@ -596,7 +599,6 @@ class Being : public Sprite, public ConfigListener
Vector mPos;
Vector mDest;
- int mPx, mPy; /**< Position in pixels */
int mX, mY; /**< Position on tile */
int mTakedDamage;