summaryrefslogtreecommitdiff
path: root/src/being
diff options
context:
space:
mode:
Diffstat (limited to 'src/being')
-rw-r--r--src/being/being.cpp40
-rw-r--r--src/being/flooritem.cpp12
-rw-r--r--src/being/localplayer.cpp99
3 files changed, 79 insertions, 72 deletions
diff --git a/src/being/being.cpp b/src/being/being.cpp
index c45616ee8..319bf34eb 100644
--- a/src/being/being.cpp
+++ b/src/being/being.cpp
@@ -630,8 +630,8 @@ void Being::setSpeech(const std::string &restrict text,
{
delete mText;
mText = new Text(mSpeech,
- CAST_S32(mPos.x),
- CAST_S32(mPos.y) - getHeight(),
+ mPixelX,
+ mPixelY - getHeight(),
Graphics::CENTER,
&userPalette->getColor(UserColorId::PARTICLE),
Speech_true);
@@ -755,8 +755,8 @@ void Being::takeDamage(Being *restrict const attacker,
{
// Show damage number
particleEngine->addTextSplashEffect(damage,
- CAST_S32(mPos.x),
- CAST_S32(mPos.y) - 16,
+ mPixelX,
+ mPixelY - 16,
color,
font,
true);
@@ -1296,8 +1296,8 @@ void Being::fireMissile(Being *restrict const victim,
Particle *restrict const missile = target->addEffect(
particle,
- CAST_S32(mPos.x),
- CAST_S32(mPos.y));
+ mPixelX,
+ mPixelY);
if (missile)
{
@@ -2071,8 +2071,8 @@ void Being::drawEmotion(Graphics *restrict const graphics,
const int offsetX,
const int offsetY) const restrict2
{
- const int px = CAST_S32(mPos.x) - offsetX - mapTileSize / 2;
- const int py = CAST_S32(mPos.y) - offsetY - mapTileSize * 2 - mapTileSize;
+ const int px = mPixelX - offsetX - mapTileSize / 2;
+ const int py = mPixelY - offsetY - mapTileSize * 2 - mapTileSize;
if (mAnimationEffect)
mAnimationEffect->draw(graphics, px, py);
if (mShowBadges && mBadgesCount)
@@ -2115,8 +2115,8 @@ void Being::drawSpeech(const int offsetX,
if (mSpeech.empty())
return;
- const int px = CAST_S32(mPos.x) - offsetX;
- const int py = CAST_S32(mPos.y) - offsetY;
+ const int px = mPixelX - offsetX;
+ const int py = mPixelY - offsetY;
const int speech = mSpeechType;
// Draw speech above this being
@@ -2147,8 +2147,8 @@ void Being::drawSpeech(const int offsetX,
if (!mText && userPalette)
{
mText = new Text(mSpeech,
- CAST_S32(mPos.x),
- CAST_S32(mPos.y) - getHeight(),
+ mPixelX,
+ mPixelY - getHeight(),
Graphics::CENTER,
&theme->getColor(ThemeColorId::BUBBLE_TEXT, 255),
Speech_true);
@@ -2204,8 +2204,8 @@ void Being::updateCoords() restrict2
if (!mDispName)
return;
- int offsetX = CAST_S32(mPos.x);
- int offsetY = CAST_S32(mPos.y);
+ int offsetX = mPixelX;
+ int offsetY = mPixelY;
if (mInfo)
{
offsetX += mInfo->getNameOffsetX();
@@ -2309,8 +2309,8 @@ void Being::showName() restrict2
if (mInfo)
{
mDispName = new FlashText(displayName,
- CAST_S32(mPos.x) + mInfo->getNameOffsetX(),
- CAST_S32(mPos.y) + mInfo->getNameOffsetY(),
+ mPixelX + mInfo->getNameOffsetX(),
+ mPixelY + mInfo->getNameOffsetY(),
Graphics::CENTER,
mNameColor,
font);
@@ -2318,8 +2318,8 @@ void Being::showName() restrict2
else
{
mDispName = new FlashText(displayName,
- CAST_S32(mPos.x),
- CAST_S32(mPos.y),
+ mPixelX,
+ mPixelY,
Graphics::CENTER,
mNameColor,
font);
@@ -2867,9 +2867,9 @@ void Being::draw(Graphics *restrict const graphics,
if (!mErased)
{
// getActorX() + offsetX;
- const int px = CAST_S32(mPos.x) - mapTileSize / 2 + offsetX;
+ const int px = mPixelX - mapTileSize / 2 + offsetX;
// getActorY() + offsetY;
- const int py = CAST_S32(mPos.y) - mapTileSize + offsetY;
+ const int py = mPixelY - mapTileSize + offsetY;
#ifdef EATHENA_SUPPORT
if (mHorseInfo)
{
diff --git a/src/being/flooritem.cpp b/src/being/flooritem.cpp
index a33a5b09b..05352c40f 100644
--- a/src/being/flooritem.cpp
+++ b/src/being/flooritem.cpp
@@ -99,14 +99,18 @@ void FloorItem::postInit(Map *const map, int subX, int subY)
}
mHeightPosDiff = map->getHeightOffset(mX, mY) * 16;
- mPos.x = static_cast<float>(mX * map->getTileWidth()
- + subX + mapTileSize / 2);
- mPos.y = static_cast<float>(mY * map->getTileHeight()
- + subY + mapTileSize - mHeightPosDiff);
+ mPixelX = mX * map->getTileWidth()
+ + subX + mapTileSize / 2;
+ mPixelY = mY * map->getTileHeight()
+ + subY + mapTileSize - mHeightPosDiff;
+ mPos.x = static_cast<float>(mPixelX);
+ mPos.y = static_cast<float>(mPixelY);
mYDiff = 31 - mHeightPosDiff;
}
else
{
+ mPixelX = 0;
+ mPixelY = 0;
mPos.x = 0;
mPos.y = 0;
mYDiff = 31;
diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp
index 87b2d8213..ecc3b20e4 100644
--- a/src/being/localplayer.cpp
+++ b/src/being/localplayer.cpp
@@ -278,8 +278,8 @@ void LocalPlayer::logic()
{
particleEngine->addTextRiseFadeOutEffect(
info.first,
- CAST_S32(mPos.x),
- CAST_S32(mPos.y) - 48,
+ mPixelX,
+ mPixelY - 48,
&userPalette->getColor(info.second),
gui->getInfoParticleFont(),
true);
@@ -497,11 +497,13 @@ bool LocalPlayer::pickUp(FloorItem *const item)
}
else if (pickUpType >= 4 && pickUpType <= 6)
{
- const Vector &playerPos = getPixelPositionF();
const Path debugPath = mMap->findPath(
- CAST_S32(playerPos.x - mapTileSize / 2) / mapTileSize,
- CAST_S32(playerPos.y - mapTileSize) / mapTileSize,
- item->getTileX(), item->getTileY(), getBlockWalkMask(), 0);
+ (mPixelX - mapTileSize / 2) / mapTileSize,
+ (mPixelY - mapTileSize) / mapTileSize,
+ item->getTileX(),
+ item->getTileY(),
+ getBlockWalkMask(),
+ 0);
if (!debugPath.empty())
navigateTo(item->getTileX(), item->getTileY());
else
@@ -684,15 +686,14 @@ void LocalPlayer::stopWalking(const bool sendToServer)
{
mWalkingDir = 0;
mPickUpTarget = nullptr;
-
- const Vector &pos = getPixelPositionF();
- setDestination(CAST_S32(pos.x),
- CAST_S32(pos.y));
+ setDestination(mPixelX,
+ mPixelY);
if (sendToServer)
{
playerHandler->setDestination(
- CAST_S32(pos.x),
- CAST_S32(pos.y), -1);
+ mPixelX,
+ mPixelY,
+ -1);
}
setAction(BeingAction::STAND);
}
@@ -1203,7 +1204,6 @@ void LocalPlayer::moveToTarget(int dist)
bool gotPos(false);
Path debugPath;
- const Vector &playerPos = getPixelPositionF();
unsigned int limit(0);
if (dist == -1)
@@ -1237,9 +1237,9 @@ void LocalPlayer::moveToTarget(int dist)
{
if (mMap)
{
- debugPath = mMap->findPath(CAST_S32(
- playerPos.x - mapTileSize / 2) / mapTileSize,
- CAST_S32(playerPos.y - mapTileSize) / mapTileSize,
+ debugPath = mMap->findPath(
+ (mPixelX - mapTileSize / 2) / mapTileSize,
+ (mPixelY - mapTileSize) / mapTileSize,
mTarget->getTileX(),
mTarget->getTileY(),
getBlockWalkMask(),
@@ -1422,12 +1422,13 @@ bool LocalPlayer::isReachable(Being *const being,
return true;
}
- const Vector &playerPos = getPixelPositionF();
-
const Path debugPath = mMap->findPath(
- CAST_S32(playerPos.x - mapTileSize / 2) / mapTileSize,
- CAST_S32(playerPos.y - mapTileSize) / mapTileSize,
- being->getTileX(), being->getTileY(), getBlockWalkMask(), maxCost);
+ (mPixelX - mapTileSize / 2) / mapTileSize,
+ (mPixelY - mapTileSize) / mapTileSize,
+ being->getTileX(),
+ being->getTileY(),
+ getBlockWalkMask(),
+ maxCost);
being->setDistance(CAST_S32(debugPath.size()));
if (!debugPath.empty())
@@ -1967,10 +1968,9 @@ bool LocalPlayer::navigateTo(const int x, const int y)
if (!tmpLayer)
return false;
- const Vector &playerPos = getPixelPositionF();
mShowNavigePath = true;
- mOldX = CAST_S32(playerPos.x);
- mOldY = CAST_S32(playerPos.y);
+ mOldX = mPixelX;
+ mOldY = mPixelY;
mOldTileX = mX;
mOldTileY = mY;
mNavigateX = x;
@@ -1978,9 +1978,12 @@ bool LocalPlayer::navigateTo(const int x, const int y)
mNavigateId = BeingId_zero;
mNavigatePath = mMap->findPath(
- CAST_S32(playerPos.x - mapTileSize / 2) / mapTileSize,
- CAST_S32(playerPos.y - mapTileSize) / mapTileSize,
- x, y, getBlockWalkMask(), 0);
+ (mPixelX - mapTileSize / 2) / mapTileSize,
+ (mPixelY - mapTileSize) / mapTileSize,
+ x,
+ y,
+ getBlockWalkMask(),
+ 0);
if (mDrawPath)
tmpLayer->addRoad(mNavigatePath);
@@ -2031,9 +2034,8 @@ void LocalPlayer::updateCoords()
{
Being::updateCoords();
- const Vector &playerPos = getPixelPositionF();
// probably map not loaded.
- if (!playerPos.x || !playerPos.y)
+ if (!mPixelX || !mPixelY)
return;
if (mX != mOldTileX || mY != mOldTileY)
@@ -2051,10 +2053,8 @@ void LocalPlayer::updateCoords()
if (!tmpLayer)
return;
- const int x = CAST_S32(playerPos.x - mapTileSize / 2)
- / mapTileSize;
- const int y = CAST_S32(playerPos.y - mapTileSize)
- / mapTileSize;
+ const int x = (mPixelX - mapTileSize / 2) / mapTileSize;
+ const int y = (mPixelY - mapTileSize) / mapTileSize;
if (mNavigateId != BeingId_zero)
{
if (!actorManager)
@@ -2101,8 +2101,8 @@ void LocalPlayer::updateCoords()
}
}
}
- mOldX = CAST_S32(playerPos.x);
- mOldY = CAST_S32(playerPos.y);
+ mOldX = mPixelX;
+ mOldY = mPixelY;
mOldTileX = mX;
mOldTileY = mY;
}
@@ -2129,13 +2129,13 @@ int LocalPlayer::getPathLength(const Being *const being) const
if (!mMap || !being)
return 0;
- const Vector &playerPos = getPixelPositionF();
-
if (being->mX == mX && being->mY == mY)
return 0;
- if (being->mX - 1 <= mX && being->mX + 1 >= mX
- && being->mY - 1 <= mY && being->mY + 1 >= mY)
+ if (being->mX - 1 <= mX &&
+ being->mX + 1 >= mX &&
+ being->mY - 1 <= mY &&
+ being->mY + 1 >= mY)
{
return 1;
}
@@ -2143,10 +2143,12 @@ int LocalPlayer::getPathLength(const Being *const being) const
if (mTargetOnlyReachable)
{
const Path debugPath = mMap->findPath(
- CAST_S32(playerPos.x - mapTileSize / 2) / mapTileSize,
- CAST_S32(playerPos.y - mapTileSize) / mapTileSize,
- being->getTileX(), being->getTileY(),
- getBlockWalkMask(), 0);
+ (mPixelX - mapTileSize / 2) / mapTileSize,
+ (mPixelY - mapTileSize) / mapTileSize,
+ being->getTileX(),
+ being->getTileY(),
+ getBlockWalkMask(),
+ 0);
return CAST_S32(debugPath.size());
}
else
@@ -2526,12 +2528,13 @@ void LocalPlayer::fixAttackTarget()
return;
}
- const Vector &playerPos = getPixelPositionF();
const Path debugPath = mMap->findPath(
- CAST_S32(playerPos.x - mapTileSize / 2) / mapTileSize,
- CAST_S32(playerPos.y - mapTileSize) / mapTileSize,
- mTarget->getTileX(), mTarget->getTileY(),
- getBlockWalkMask(), 0);
+ (mPixelX - mapTileSize / 2) / mapTileSize,
+ (mPixelY - mapTileSize) / mapTileSize,
+ mTarget->getTileX(),
+ mTarget->getTileY(),
+ getBlockWalkMask(),
+ 0);
if (!debugPath.empty())
{