summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-03-05 01:35:02 +0300
committerAndrei Karas <akaras@inbox.ru>2016-03-05 01:35:02 +0300
commit097ef639a433f5d87d675ee7551a1640788031bd (patch)
tree6d38ea5a0b134e402d8824e15ee215351b594360 /src
parent21b14e4b8708be1d9b804f61330ef7cd5521397d (diff)
downloadmv-097ef639a433f5d87d675ee7551a1640788031bd.tar.gz
mv-097ef639a433f5d87d675ee7551a1640788031bd.tar.bz2
mv-097ef639a433f5d87d675ee7551a1640788031bd.tar.xz
mv-097ef639a433f5d87d675ee7551a1640788031bd.zip
Rename actor functions getPosition and setPosition.
Diffstat (limited to 'src')
-rw-r--r--src/actormanager.cpp2
-rw-r--r--src/being/actor.h4
-rw-r--r--src/being/being.cpp6
-rw-r--r--src/being/being.h10
-rw-r--r--src/being/localplayer.cpp23
-rw-r--r--src/gui/viewport.cpp10
-rw-r--r--src/gui/windows/minimap.cpp6
7 files changed, 31 insertions, 30 deletions
diff --git a/src/actormanager.cpp b/src/actormanager.cpp
index d022e6127..3769eceee 100644
--- a/src/actormanager.cpp
+++ b/src/actormanager.cpp
@@ -86,7 +86,7 @@ class FindBeingFunctor final
const unsigned other_y = y
+ ((b->getType() == ActorType::Npc) ? 1 : 0);
- const Vector &pos = b->getPosition();
+ const Vector &pos = b->getPixelPositionF();
return (CAST_U32(pos.x) / mapTileSize == x &&
(CAST_U32(pos.y) / mapTileSize == y
|| CAST_U32(pos.y) / mapTileSize == other_y) &&
diff --git a/src/being/actor.h b/src/being/actor.h
index 875d162bb..0b83e46be 100644
--- a/src/being/actor.h
+++ b/src/being/actor.h
@@ -70,13 +70,13 @@ class Actor notfinal
/**
* Returns the pixel position of this actor.
*/
- const Vector &getPosition() const A_WARN_UNUSED
+ const Vector &getPixelPositionF() const A_WARN_UNUSED
{ return mPos; }
/**
* Sets the pixel position of this actor.
*/
- virtual void setPosition(const Vector &restrict pos) restrict2
+ virtual void setPixelPositionF(const Vector &restrict pos) restrict2
{ mPos = pos; }
/**
diff --git a/src/being/being.cpp b/src/being/being.cpp
index bd09a36c2..c45616ee8 100644
--- a/src/being/being.cpp
+++ b/src/being/being.cpp
@@ -510,9 +510,9 @@ TargetCursorSizeT Being::getTargetCursorSize() const restrict2
return mInfo->getTargetCursorSize();
}
-void Being::setPosition(const Vector &restrict pos) restrict2
+void Being::setPixelPositionF(const Vector &restrict pos) restrict2
{
- Actor::setPosition(pos);
+ Actor::setPixelPositionF(pos);
updateCoords();
@@ -1843,7 +1843,7 @@ void Being::logic() restrict2
- (mOldHeight + mOffsetY) * halfTile + offset2;
// Update pixel coordinates
- setPosition(static_cast<float>(mX * mapTileSize
+ setPixelPositionF(static_cast<float>(mX * mapTileSize
+ mapTileSize / 2 + xOffset), yOffset3);
}
diff --git a/src/being/being.h b/src/being/being.h
index 2f03bd877..dd0c64af0 100644
--- a/src/being/being.h
+++ b/src/being/being.h
@@ -481,17 +481,17 @@ class Being notfinal : public ActorSprite,
A_WARN_UNUSED
{ return mSpriteDirection; }
- void setPosition(const Vector &restrict pos) restrict2 override;
+ void setPixelPositionF(const Vector &restrict pos) restrict2 override;
/**
* Overloaded method provided for convenience.
*
* @see setPosition(const Vector &pos)
*/
- inline void setPosition(const float x,
- const float y,
- const float z = 0.0F) restrict2 A_INLINE
- { setPosition(Vector(x, y, z)); }
+ inline void setPixelPositionF(const float x,
+ const float y,
+ const float z = 0.0F) restrict2 A_INLINE
+ { setPixelPositionF(Vector(x, y, z)); }
/**
* Returns the horizontal size of the current base sprite of the being.
diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp
index fed3a4d2c..87b2d8213 100644
--- a/src/being/localplayer.cpp
+++ b/src/being/localplayer.cpp
@@ -497,7 +497,7 @@ bool LocalPlayer::pickUp(FloorItem *const item)
}
else if (pickUpType >= 4 && pickUpType <= 6)
{
- const Vector &playerPos = getPosition();
+ const Vector &playerPos = getPixelPositionF();
const Path debugPath = mMap->findPath(
CAST_S32(playerPos.x - mapTileSize / 2) / mapTileSize,
CAST_S32(playerPos.y - mapTileSize) / mapTileSize,
@@ -685,13 +685,14 @@ void LocalPlayer::stopWalking(const bool sendToServer)
mWalkingDir = 0;
mPickUpTarget = nullptr;
- setDestination(CAST_S32(getPosition().x),
- CAST_S32(getPosition().y));
+ const Vector &pos = getPixelPositionF();
+ setDestination(CAST_S32(pos.x),
+ CAST_S32(pos.y));
if (sendToServer)
{
playerHandler->setDestination(
- CAST_S32(getPosition().x),
- CAST_S32(getPosition().y), -1);
+ CAST_S32(pos.x),
+ CAST_S32(pos.y), -1);
}
setAction(BeingAction::STAND);
}
@@ -1202,7 +1203,7 @@ void LocalPlayer::moveToTarget(int dist)
bool gotPos(false);
Path debugPath;
- const Vector &playerPos = getPosition();
+ const Vector &playerPos = getPixelPositionF();
unsigned int limit(0);
if (dist == -1)
@@ -1421,7 +1422,7 @@ bool LocalPlayer::isReachable(Being *const being,
return true;
}
- const Vector &playerPos = getPosition();
+ const Vector &playerPos = getPixelPositionF();
const Path debugPath = mMap->findPath(
CAST_S32(playerPos.x - mapTileSize / 2) / mapTileSize,
@@ -1966,7 +1967,7 @@ bool LocalPlayer::navigateTo(const int x, const int y)
if (!tmpLayer)
return false;
- const Vector &playerPos = getPosition();
+ const Vector &playerPos = getPixelPositionF();
mShowNavigePath = true;
mOldX = CAST_S32(playerPos.x);
mOldY = CAST_S32(playerPos.y);
@@ -2030,7 +2031,7 @@ void LocalPlayer::updateCoords()
{
Being::updateCoords();
- const Vector &playerPos = getPosition();
+ const Vector &playerPos = getPixelPositionF();
// probably map not loaded.
if (!playerPos.x || !playerPos.y)
return;
@@ -2128,7 +2129,7 @@ int LocalPlayer::getPathLength(const Being *const being) const
if (!mMap || !being)
return 0;
- const Vector &playerPos = getPosition();
+ const Vector &playerPos = getPixelPositionF();
if (being->mX == mX && being->mY == mY)
return 0;
@@ -2525,7 +2526,7 @@ void LocalPlayer::fixAttackTarget()
return;
}
- const Vector &playerPos = getPosition();
+ const Vector &playerPos = getPixelPositionF();
const Path debugPath = mMap->findPath(
CAST_S32(playerPos.x - mapTileSize / 2) / mapTileSize,
CAST_S32(playerPos.y - mapTileSize) / mapTileSize,
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index 157815811..23afa9bfd 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -141,7 +141,7 @@ void Viewport::draw(Graphics *const graphics)
// Calculate viewpoint
- const Vector &playerPos = localPlayer->getPosition();
+ const Vector &playerPos = localPlayer->getPixelPositionF();
const int player_x = CAST_S32(playerPos.x) - mMidTileX;
const int player_y = CAST_S32(playerPos.y) - mMidTileY;
@@ -314,7 +314,7 @@ void Viewport::drawDebugPath(Graphics *const graphics)
if (mouseDestination.x != lastMouseDestination.x
|| mouseDestination.y != lastMouseDestination.y)
{
- const Vector &playerPos = localPlayer->getPosition();
+ const Vector &playerPos = localPlayer->getPixelPositionF();
debugPath = mMap->findPath(
CAST_S32(playerPos.x - mapTileSize / 2) / mapTileSize,
@@ -983,8 +983,8 @@ void Viewport::moveCameraToActor(const BeingId actorId,
const Actor *const actor = actorManager->findBeing(actorId);
if (!actor)
return;
- const Vector &actorPos = actor->getPosition();
- const Vector &playerPos = localPlayer->getPosition();
+ const Vector &actorPos = actor->getPixelPositionF();
+ const Vector &playerPos = localPlayer->getPixelPositionF();
settings.cameraMode = 1;
mCameraRelativeX = CAST_S32(actorPos.x - playerPos.x) + x;
mCameraRelativeY = CAST_S32(actorPos.y - playerPos.y) + y;
@@ -996,7 +996,7 @@ void Viewport::moveCameraToPosition(const int x, const int y)
if (!localPlayer)
return;
- const Vector &playerPos = localPlayer->getPosition();
+ const Vector &playerPos = localPlayer->getPixelPositionF();
settings.cameraMode = 1;
mCameraRelativeX = x - CAST_S32(playerPos.x);
diff --git a/src/gui/windows/minimap.cpp b/src/gui/windows/minimap.cpp
index 371d98414..3f0f4c14e 100644
--- a/src/gui/windows/minimap.cpp
+++ b/src/gui/windows/minimap.cpp
@@ -281,7 +281,7 @@ void Minimap::draw2(Graphics *const graphics)
const int h = rect.h;
if (w > a.width || h > a.height)
{
- const Vector &p = localPlayer->getPosition();
+ const Vector &p = localPlayer->getPixelPositionF();
mMapOriginX = (a.width / 2) - (p.x + static_cast<float>(
viewport->getCameraRelativeX()) * mWidthProportion) / 32;
@@ -382,7 +382,7 @@ void Minimap::draw2(Graphics *const graphics)
dotSize - 1) * mHeightProportion);
const int offsetWidth = CAST_S32(static_cast<float>(
dotSize - 1) * mWidthProportion);
- const Vector &pos = being->getPosition();
+ const Vector &pos = being->getPixelPositionF();
graphics->fillRectangle(Rect(
static_cast<float>(pos.x * mWidthProportion) / 32
@@ -435,7 +435,7 @@ void Minimap::draw2(Graphics *const graphics)
}
}
- const Vector &pos = localPlayer->getPosition();
+ const Vector &pos = localPlayer->getPixelPositionF();
const int gw = graphics->getWidth();
const int gh = graphics->getHeight();