summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/viewport.cpp26
-rw-r--r--src/gui/windows/minimap.cpp25
2 files changed, 20 insertions, 31 deletions
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index 23afa9bfd..7dddb4414 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -141,9 +141,8 @@ void Viewport::draw(Graphics *const graphics)
// Calculate viewpoint
- const Vector &playerPos = localPlayer->getPixelPositionF();
- const int player_x = CAST_S32(playerPos.x) - mMidTileX;
- const int player_y = CAST_S32(playerPos.y) - mMidTileY;
+ const int player_x = localPlayer->mPixelX - mMidTileX;
+ const int player_y = localPlayer->mPixelY - mMidTileY;
if (mScrollLaziness < 1)
mScrollLaziness = 1; // Avoids division by zero
@@ -314,12 +313,11 @@ void Viewport::drawDebugPath(Graphics *const graphics)
if (mouseDestination.x != lastMouseDestination.x
|| mouseDestination.y != lastMouseDestination.y)
{
- const Vector &playerPos = localPlayer->getPixelPositionF();
-
debugPath = mMap->findPath(
- CAST_S32(playerPos.x - mapTileSize / 2) / mapTileSize,
- CAST_S32(playerPos.y - mapTileSize) / mapTileSize,
- mousePosX / mapTileSize, mousePosY / mapTileSize,
+ CAST_S32(localPlayer->mPixelX - mapTileSize / 2) / mapTileSize,
+ CAST_S32(localPlayer->mPixelY - mapTileSize) / mapTileSize,
+ mousePosX / mapTileSize,
+ mousePosY / mapTileSize,
localPlayer->getBlockWalkMask(),
500);
lastMouseDestination = mouseDestination;
@@ -983,11 +981,9 @@ void Viewport::moveCameraToActor(const BeingId actorId,
const Actor *const actor = actorManager->findBeing(actorId);
if (!actor)
return;
- 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;
+ mCameraRelativeX = actor->mPixelX - localPlayer->mPixelX + x;
+ mCameraRelativeY = actor->mPixelY - localPlayer->mPixelY + y;
updateMidVars();
}
@@ -996,11 +992,9 @@ void Viewport::moveCameraToPosition(const int x, const int y)
if (!localPlayer)
return;
- const Vector &playerPos = localPlayer->getPixelPositionF();
settings.cameraMode = 1;
-
- mCameraRelativeX = x - CAST_S32(playerPos.x);
- mCameraRelativeY = y - CAST_S32(playerPos.y);
+ mCameraRelativeX = x - localPlayer->mPixelX;
+ mCameraRelativeY = y - localPlayer->mPixelY;
updateMidVars();
}
diff --git a/src/gui/windows/minimap.cpp b/src/gui/windows/minimap.cpp
index 3f0f4c14e..291cb7a7a 100644
--- a/src/gui/windows/minimap.cpp
+++ b/src/gui/windows/minimap.cpp
@@ -281,12 +281,11 @@ void Minimap::draw2(Graphics *const graphics)
const int h = rect.h;
if (w > a.width || h > a.height)
{
- const Vector &p = localPlayer->getPixelPositionF();
- mMapOriginX = (a.width / 2) - (p.x + static_cast<float>(
- viewport->getCameraRelativeX()) * mWidthProportion) / 32;
+ mMapOriginX = (a.width / 2) - (localPlayer->mPixelX +
+ viewport->getCameraRelativeX() * mWidthProportion) / 32;
- mMapOriginY = (a.height / 2) - (p.y + static_cast<float>(
- viewport->getCameraRelativeY()) * mHeightProportion) / 32;
+ mMapOriginY = (a.height / 2) - (localPlayer->mPixelY +
+ viewport->getCameraRelativeY() * mHeightProportion) / 32;
const int minOriginX = a.width - w;
const int minOriginY = a.height - h;
@@ -382,12 +381,10 @@ void Minimap::draw2(Graphics *const graphics)
dotSize - 1) * mHeightProportion);
const int offsetWidth = CAST_S32(static_cast<float>(
dotSize - 1) * mWidthProportion);
- const Vector &pos = being->getPixelPositionF();
-
graphics->fillRectangle(Rect(
- static_cast<float>(pos.x * mWidthProportion) / 32
+ (being->mPixelX * mWidthProportion) / 32
+ mMapOriginX - offsetWidth,
- static_cast<float>(pos.y * mHeightProportion) / 32
+ (being->mPixelY * mHeightProportion) / 32
+ mMapOriginY - offsetHeight, dotSize, dotSize));
}
@@ -435,16 +432,14 @@ void Minimap::draw2(Graphics *const graphics)
}
}
- const Vector &pos = localPlayer->getPixelPositionF();
-
const int gw = graphics->getWidth();
const int gh = graphics->getHeight();
- int x = static_cast<float>((pos.x - (gw / 2)
+ int x = (localPlayer->mPixelX - (gw / 2)
+ viewport->getCameraRelativeX())
- * mWidthProportion) / 32 + mMapOriginX;
- int y = static_cast<float>((pos.y - (gh / 2)
+ * mWidthProportion / 32 + mMapOriginX;
+ int y = (localPlayer->mPixelY - (gh / 2)
+ viewport->getCameraRelativeY())
- * mHeightProportion) / 32 + mMapOriginY;
+ * mHeightProportion / 32 + mMapOriginY;
const int w = CAST_S32(static_cast<float>(
gw) * mWidthProportion / 32);