summaryrefslogtreecommitdiff
path: root/src/being
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-10-01 22:30:44 +0300
committerAndrei Karas <akaras@inbox.ru>2013-10-01 22:30:44 +0300
commitd13de51121a332cf8613a38d7ed5468f971c999f (patch)
tree253c2911e291303fd90eb5d61c23076630782a11 /src/being
parent6915c38ca9c35bfb9a5ea05fe957463d644a75de (diff)
downloadmanaplus-d13de51121a332cf8613a38d7ed5468f971c999f.tar.gz
manaplus-d13de51121a332cf8613a38d7ed5468f971c999f.tar.bz2
manaplus-d13de51121a332cf8613a38d7ed5468f971c999f.tar.xz
manaplus-d13de51121a332cf8613a38d7ed5468f971c999f.zip
replace tile size from 32 to mapTitleSize.
Diffstat (limited to 'src/being')
-rw-r--r--src/being/actorsprite.cpp9
-rw-r--r--src/being/being.cpp50
-rw-r--r--src/being/compoundsprite.cpp4
-rw-r--r--src/being/localplayer.cpp135
4 files changed, 102 insertions, 96 deletions
diff --git a/src/being/actorsprite.cpp b/src/being/actorsprite.cpp
index 6d783e6f1..17d58539b 100644
--- a/src/being/actorsprite.cpp
+++ b/src/being/actorsprite.cpp
@@ -78,13 +78,13 @@ bool ActorSprite::draw(Graphics *const graphics,
const int offsetX, const int offsetY) const
{
FUNC_BLOCK("ActorSprite::draw", 1)
- const int px = getPixelX() + offsetX - 16;
+ const int px = getPixelX() + offsetX - mapTileSize / 2;
// Temporary fix to the Y offset.
#ifdef MANASERV_SUPPORT
const int py = getPixelY() + offsetY -
- ((Net::getNetworkType() == ServerInfo::MANASERV) ? 15 : 32);
+ ((Net::getNetworkType() == ServerInfo::MANASERV) ? 15 : mapTileSize);
#else
- const int py = getPixelY() + offsetY - 32;
+ const int py = getPixelY() + offsetY - mapTileSize;
#endif
if (mUsedTargetCursor)
@@ -149,7 +149,8 @@ void ActorSprite::controlParticle(Particle *const particle)
void ActorSprite::setTargetType(const TargetCursorType type)
{
static const int targetWidths[ActorSprite::NUM_TC] = {0, 0, 0};
- static const int targetHeights[ActorSprite::NUM_TC] = {-16, -16, -32};
+ static const int targetHeights[ActorSprite::NUM_TC]
+ = {-mapTileSize / 2, -mapTileSize / 2, -mapTileSize};
if (type == TCT_NONE)
{
diff --git a/src/being/being.cpp b/src/being/being.cpp
index 683661420..01ab7b267 100644
--- a/src/being/being.cpp
+++ b/src/being/being.cpp
@@ -349,7 +349,7 @@ void Being::setDestination(const int dstX, const int dstY)
return;
// If the destination is unwalkable, don't bother trying to get there
- if (!mMap->getWalk(dstX / 32, dstY / 32))
+ if (!mMap->getWalk(dstX / mapTileSize, dstY / mapTileSize))
return;
Position dest = mMap->checkNodeOffsets(getCollisionRadius(), getWalkMask(),
@@ -363,8 +363,8 @@ void Being::setDestination(const int dstX, const int dstY)
{
// If there is no path but the destination is on the same walkable tile,
// we accept it.
- if (static_cast<int>(mPos.x) / 32 == dest.x / 32
- && static_cast<int>(mPos.y) / 32 == dest.y / 32)
+ if (static_cast<int>(mPos.x) / mapTileSize == dest.x / mapTileSize
+ && static_cast<int>(mPos.y) / mapTileSize == dest.y / mapTileSize)
{
mDest.x = static_cast<float>(dest.x);
mDest.y = static_cast<float>(dest.y);
@@ -1534,18 +1534,20 @@ void Being::logic()
if (!offset)
offset = yOffset;
- mSortOffsetY = (mOldHeight * 16) + (mOffsetY * 16)
- * (32 - abs(offset)) / 32;
+ mSortOffsetY = (mOldHeight * mapTileSize / 2)
+ + (mOffsetY * mapTileSize / 2)
+ * (mapTileSize - abs(offset)) / mapTileSize;
const int yOffset2 = yOffset - mSortOffsetY;
// Update pixel coordinates
- setPosition(static_cast<float>(mX * 32 + 16 + xOffset),
- static_cast<float>(mY * 32 + 32 + yOffset2));
+ setPosition(static_cast<float>(mX * mapTileSize
+ + mapTileSize / 2 + xOffset), static_cast<float>(
+ mY * mapTileSize + mapTileSize + yOffset2));
}
else
{
- setPosition(static_cast<float>(mX * 32 + 16),
- static_cast<float>(mY * 32 + 32));
+ setPosition(static_cast<float>(mX * mapTileSize + mapTileSize / 2),
+ static_cast<float>(mY * mapTileSize + mapTileSize));
}
}
@@ -1591,8 +1593,8 @@ void Being::logic()
void Being::drawEmotion(Graphics *const graphics, const int offsetX,
const int offsetY) const
{
- const int px = getPixelX() - offsetX - 16;
- const int py = getPixelY() - offsetY - 64 - 32;
+ const int px = getPixelX() - offsetX - mapTileSize / 2;
+ const int py = getPixelY() - offsetY - mapTileSize * 2 - mapTileSize;
if (mEmotionSprite)
mEmotionSprite->draw(graphics, px, py);
if (mAnimationEffect)
@@ -1668,7 +1670,7 @@ int Being::getOffset(const signed char pos, const signed char neg) const
}
// We calculate the offset _from_ the _target_ location
- offset -= 32;
+ offset -= mapTileSize;
if (offset > 0)
offset = 0;
@@ -1676,10 +1678,10 @@ int Being::getOffset(const signed char pos, const signed char neg) const
if (mDirection & pos)
offset = -offset;
- if (offset > 32)
- offset = 32;
- if (offset < -32)
- offset = -32;
+ if (offset > mapTileSize)
+ offset = mapTileSize;
+ if (offset < -mapTileSize)
+ offset = -mapTileSize;
return offset;
}
@@ -2270,7 +2272,7 @@ bool Being::drawSpriteAt(Graphics *const graphics,
graphics->setColor(userPalette->
getColorWithAlpha(UserPalette::PORTAL_HIGHLIGHT));
- graphics->fillRectangle(gcn::Rectangle(x, y, 32, 32));
+ graphics->fillRectangle(gcn::Rectangle(x, y, mapTileSize, mapTileSize));
if (mDrawHotKeys && !mName.empty())
{
@@ -2288,16 +2290,16 @@ bool Being::drawSpriteAt(Graphics *const graphics,
{
int attackRange;
if (mAttackRange)
- attackRange = 32 * mAttackRange;
+ attackRange = mapTileSize * mAttackRange;
else
- attackRange = 32;
+ attackRange = mapTileSize;
graphics->setColor(userPalette->getColorWithAlpha(
UserPalette::MONSTER_ATTACK_RANGE));
graphics->fillRectangle(gcn::Rectangle(
x - attackRange, y - attackRange,
- 2 * attackRange + 32, 2 * attackRange + 32));
+ 2 * attackRange + mapTileSize, 2 * attackRange + mapTileSize));
}
if (mShowMobHP && mInfo && player_node && player_node->getTarget() == this
@@ -2310,8 +2312,8 @@ bool Being::drawSpriteAt(Graphics *const graphics,
drawHpBar(graphics, maxHP, mHP, mDamageTaken,
UserPalette::MONSTER_HP, UserPalette::MONSTER_HP2,
- x - 50 + 16 + mInfo->getHpBarOffsetX(),
- y + 32 - 6 + mInfo->getHpBarOffsetY(),
+ x - 50 + mapTileSize / 2 + mInfo->getHpBarOffsetX(),
+ y + mapTileSize - 6 + mInfo->getHpBarOffsetY(),
2 * 50, 4);
}
if (mShowOwnHP && mInfo && player_node == this && mAction != DEAD)
@@ -2319,8 +2321,8 @@ bool Being::drawSpriteAt(Graphics *const graphics,
drawHpBar(graphics, PlayerInfo::getAttribute(PlayerInfo::MAX_HP),
PlayerInfo::getAttribute(PlayerInfo::HP), 0,
UserPalette::PLAYER_HP, UserPalette::PLAYER_HP2,
- x - 50 + 16 + mInfo->getHpBarOffsetX(),
- y + 32 - 6 + mInfo->getHpBarOffsetY(),
+ x - 50 + mapTileSize / 2 + mInfo->getHpBarOffsetX(),
+ y + mapTileSize - 6 + mInfo->getHpBarOffsetY(),
2 * 50, 4);
}
return res;
diff --git a/src/being/compoundsprite.cpp b/src/being/compoundsprite.cpp
index 261532be8..64231ee05 100644
--- a/src/being/compoundsprite.cpp
+++ b/src/being/compoundsprite.cpp
@@ -338,8 +338,8 @@ void CompoundSprite::redraw() const
graphics->setTarget(surface);
graphics->_beginDraw();
- int tileX = 32 / 2;
- int tileY = 32;
+ int tileX = mapTileSize / 2;
+ int tileY = mapTileSize;
const Game *const game = Game::instance();
if (game)
diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp
index 2f5e18888..3da2f7ed9 100644
--- a/src/being/localplayer.cpp
+++ b/src/being/localplayer.cpp
@@ -486,8 +486,8 @@ Position LocalPlayer::getNextWalkPosition(const unsigned char dir) const
}
else if (!wTop && !wRight)
{
- return Position(tileX * 32 + 32 - radius,
- tileY * 32 + getCollisionRadius());
+ return Position(tileX * mapTileSize + mapTileSize - radius,
+ tileY * mapTileSize + getCollisionRadius());
}
else // Both straight direction are walkable
{
@@ -507,7 +507,7 @@ Position LocalPlayer::getNextWalkPosition(const unsigned char dir) const
else // The diagonal is walkable
{
return mMap->checkNodeOffsets(radius,
- walkMask, Position(posX + 32, posY - 32));
+ walkMask, Position(posX + mapTileSize, posY - mapTileSize));
}
}
@@ -527,8 +527,8 @@ Position LocalPlayer::getNextWalkPosition(const unsigned char dir) const
}
else if (!wTop && !wLeft)
{
- return Position(tileX * 32 + radius,
- tileY * 32 + radius);
+ return Position(tileX * mapTileSize + radius,
+ tileY * mapTileSize + radius);
}
else // Both straight direction are walkable
{
@@ -546,8 +546,8 @@ Position LocalPlayer::getNextWalkPosition(const unsigned char dir) const
}
else // The diagonal is walkable
{
- return mMap->checkNodeOffsets(radius,
- walkMask, Position(posX - 32, posY - 32));
+ return mMap->checkNodeOffsets(radius, walkMask,
+ Position(posX - mapTileSize, posY - mapTileSize));
}
}
@@ -567,8 +567,8 @@ Position LocalPlayer::getNextWalkPosition(const unsigned char dir) const
}
else if (!wBottom && !wLeft)
{
- return Position(tileX * 32 + radius,
- tileY * 32 + 32 - radius);
+ return Position(tileX * mapTileSize + radius,
+ tileY * mapTileSize + mapTileSize - radius);
}
else // Both straight direction are walkable
{
@@ -587,8 +587,8 @@ Position LocalPlayer::getNextWalkPosition(const unsigned char dir) const
}
else // The diagonal is walkable
{
- return mMap->checkNodeOffsets(radius,
- walkMask, Position(posX - 32, posY + 32));
+ return mMap->checkNodeOffsets(radius, walkMask,
+ Position(posX - mapTileSize, posY + mapTileSize));
}
}
@@ -608,8 +608,8 @@ Position LocalPlayer::getNextWalkPosition(const unsigned char dir) const
}
else if (!wBottom && !wRight)
{
- return Position(tileX * 32 + 32 - radius,
- tileY * 32 + 32 - radius);
+ return Position(tileX * mapTileSize + mapTileSize - radius,
+ tileY * mapTileSize + mapTileSize - radius);
}
else // Both straight direction are walkable
{
@@ -627,8 +627,8 @@ Position LocalPlayer::getNextWalkPosition(const unsigned char dir) const
}
else // The diagonal is walkable
{
- return mMap->checkNodeOffsets(radius,
- walkMask, Position(posX + 32, posY + 32));
+ return mMap->checkNodeOffsets(radius, walkMask,
+ Position(posX + mapTileSize, posY + mapTileSize));
}
}
} // End of diagonal cases
@@ -641,7 +641,7 @@ Position LocalPlayer::getNextWalkPosition(const unsigned char dir) const
// Make the player go the closest possible.
if (!wRight)
{
- return Position(tileX * 32 + 32 - radius, posY);
+ return Position(tileX * mapTileSize + mapTileSize - radius, posY);
}
else
{
@@ -652,25 +652,25 @@ Position LocalPlayer::getNextWalkPosition(const unsigned char dir) const
{
// We make the player corrects its offset
// before going further
- return Position(tileX * 32 + 32 - radius,
- tileY * 32 + radius);
+ return Position(tileX * mapTileSize + mapTileSize - radius,
+ tileY * mapTileSize + radius);
}
}
if (!wBottomRight)
{
// If we're going to collide with the bottom-right corner
- if (offsetY + radius > 32)
+ if (offsetY + radius > mapTileSize)
{
// We make the player corrects its offset
// before going further
- return Position(tileX * 32 + 32 - radius,
- tileY * 32 + 32 - radius);
+ return Position(tileX * mapTileSize + mapTileSize - radius,
+ tileY * mapTileSize + mapTileSize - radius);
}
}
// If the way is clear, step up one checked tile ahead.
- return mMap->checkNodeOffsets(radius,
- walkMask, Position(posX + 32, posY));
+ return mMap->checkNodeOffsets(radius, walkMask,
+ Position(posX + mapTileSize, posY));
}
}
@@ -681,7 +681,7 @@ Position LocalPlayer::getNextWalkPosition(const unsigned char dir) const
// Make the player go the closest possible.
if (!wLeft)
{
- return Position(tileX * 32 + radius, posY);
+ return Position(tileX * mapTileSize + radius, posY);
}
else
{
@@ -692,25 +692,25 @@ Position LocalPlayer::getNextWalkPosition(const unsigned char dir) const
{
// We make the player corrects its offset
// before going further
- return Position(tileX * 32 + radius,
- tileY * 32 + radius);
+ return Position(tileX * mapTileSize + radius,
+ tileY * mapTileSize + radius);
}
}
if (!wBottomLeft)
{
// If we're going to collide with the bottom-left corner
- if (offsetY + radius > 32)
+ if (offsetY + radius > mapTileSize)
{
// We make the player corrects its offset
// before going further
- return Position(tileX * 32 + radius,
- tileY * 32 + 32 - radius);
+ return Position(tileX * mapTileSize + radius,
+ tileY * mapTileSize + mapTileSize - radius);
}
}
// If the way is clear, step up one checked tile ahead.
- return mMap->checkNodeOffsets(radius,
- walkMask, Position(posX - 32, posY));
+ return mMap->checkNodeOffsets(radius, walkMask,
+ Position(posX - mapTileSize, posY));
}
}
@@ -721,7 +721,7 @@ Position LocalPlayer::getNextWalkPosition(const unsigned char dir) const
// Make the player go the closest possible.
if (!wTop)
{
- return Position(posX, tileY * 32 + radius);
+ return Position(posX, tileY * mapTileSize + radius);
}
else
{
@@ -732,25 +732,25 @@ Position LocalPlayer::getNextWalkPosition(const unsigned char dir) const
{
// We make the player corrects its offset
// before going further
- return Position(tileX * 32 + radius,
- tileY * 32 + radius);
+ return Position(tileX * mapTileSize + radius,
+ tileY * mapTileSize + radius);
}
}
if (!wTopRight)
{
// If we're going to collide with the top-right corner
- if (offsetX + radius > 32)
+ if (offsetX + radius > mapTileSize)
{
// We make the player corrects its offset
// before going further
- return Position(tileX * 32 + 32 - radius,
- tileY * 32 + radius);
+ return Position(tileX * mapTileSize + mapTileSize - radius,
+ tileY * mapTileSize + radius);
}
}
// If the way is clear, step up one checked tile ahead.
return mMap->checkNodeOffsets(radius,
- walkMask, Position(posX, posY - 32));
+ walkMask, Position(posX, posY - mapTileSize));
}
}
@@ -761,7 +761,7 @@ Position LocalPlayer::getNextWalkPosition(const unsigned char dir) const
// Make the player go the closest possible.
if (!wBottom)
{
- return Position(posX, tileY * 32 + 32 - radius);
+ return Position(posX, tileY * mapTileSize + mapTileSize - radius);
}
else
{
@@ -772,25 +772,25 @@ Position LocalPlayer::getNextWalkPosition(const unsigned char dir) const
{
// We make the player corrects its offset
// before going further
- return Position(tileX * 32 + radius,
- tileY * 32 + 32 - radius);
+ return Position(tileX * mapTileSize + radius,
+ tileY * mapTileSize + mapTileSize - radius);
}
}
if (!wBottomRight)
{
// If we're going to collide with the bottom-right corner
- if (offsetX + radius > 32)
+ if (offsetX + radius > mapTileSize)
{
// We make the player corrects its offset
// before going further
- return Position(tileX * 32 + 32 - radius,
- tileY * 32 + 32 - radius);
+ return Position(tileX * mapTileSize + mapTileSize - radius,
+ tileY * mapTileSize + mapTileSize - radius);
}
}
// If the way is clear, step up one checked tile ahead.
return mMap->checkNodeOffsets(radius,
- walkMask, Position(posX, posY + 32));
+ walkMask, Position(posX, posY + mapTileSize));
}
}
@@ -916,9 +916,9 @@ bool LocalPlayer::pickUp(FloorItem *const item)
{
const Vector &playerPos = getPosition();
const Path debugPath = mMap->findPath(
- static_cast<int>(playerPos.x - 16) / 32,
- static_cast<int>(playerPos.y - 32) / 32,
- item->getTileX(), item->getTileY(), getWalkMask(), 0);
+ static_cast<int>(playerPos.x - mapTileSize / 2) / mapTileSize,
+ static_cast<int>(playerPos.y - mapTileSize) / mapTileSize,
+ item->getTileX(), item->getTileY(), getWalkMask(), 0);
if (!debugPath.empty())
navigateTo(item->getTileX(), item->getTileY());
else
@@ -1747,8 +1747,9 @@ void LocalPlayer::moveToTarget(int dist)
{
if (mMap)
{
- debugPath = mMap->findPath(static_cast<int>(playerPos.x - 16) / 32,
- static_cast<int>(playerPos.y - 32) / 32,
+ debugPath = mMap->findPath(static_cast<int>(
+ playerPos.x - mapTileSize / 2) / mapTileSize,
+ static_cast<int>(playerPos.y - mapTileSize) / mapTileSize,
mTarget->getTileX(), mTarget->getTileY(), getWalkMask(), 0);
}
@@ -3029,8 +3030,8 @@ bool LocalPlayer::isReachable(Being *const being,
const Vector &playerPos = getPosition();
const Path debugPath = mMap->findPath(
- static_cast<int>(playerPos.x - 16) / 32,
- static_cast<int>(playerPos.y - 32) / 32,
+ static_cast<int>(playerPos.x - mapTileSize / 2) / mapTileSize,
+ static_cast<int>(playerPos.y - mapTileSize) / mapTileSize,
being->getTileX(), being->getTileY(), getWalkMask(), maxCost);
being->setDistance(static_cast<int>(debugPath.size()));
@@ -3161,13 +3162,13 @@ void LocalPlayer::moveByDirection(const unsigned char dir)
int dx = 0, dy = 0;
#ifdef MANASERV_SUPPORT
if (dir & UP)
- dy -= 32;
+ dy -= mapTileSize;
if (dir & DOWN)
- dy += 32;
+ dy += mapTileSize;
if (dir & LEFT)
- dx -= 32;
+ dx -= mapTileSize;
if (dir & RIGHT)
- dx += 32;
+ dx += mapTileSize;
#else
if (dir & UP)
dy--;
@@ -3571,8 +3572,8 @@ bool LocalPlayer::navigateTo(const int x, const int y)
mNavigateId = 0;
mNavigatePath = mMap->findPath(
- static_cast<int>(playerPos.x - 16) / 32,
- static_cast<int>(playerPos.y - 32) / 32,
+ static_cast<int>(playerPos.x - mapTileSize / 2) / mapTileSize,
+ static_cast<int>(playerPos.y - mapTileSize) / mapTileSize,
x, y, getWalkMask(), 0);
if (mDrawPath)
@@ -3599,8 +3600,8 @@ void LocalPlayer::navigateTo(const Being *const being)
mNavigateY = being->getTileY();
mNavigatePath = mMap->findPath(
- static_cast<int>(playerPos.x - 16) / 32,
- static_cast<int>(playerPos.y - 32) / 32,
+ static_cast<int>(playerPos.x - mapTileSize / 2) / mapTileSize,
+ static_cast<int>(playerPos.y - mapTileSize) / mapTileSize,
being->getTileX(), being->getTileY(),
getWalkMask(), 0);
@@ -3670,8 +3671,10 @@ void LocalPlayer::updateCoords()
if (!tmpLayer)
return;
- const int x = static_cast<int>(playerPos.x - 16) / 32;
- const int y = static_cast<int>(playerPos.y - 32) / 32;
+ const int x = static_cast<int>(playerPos.x - mapTileSize / 2)
+ / mapTileSize;
+ const int y = static_cast<int>(playerPos.y - mapTileSize)
+ / mapTileSize;
if (mNavigateId)
{
if (!actorSpriteManager)
@@ -3758,8 +3761,8 @@ int LocalPlayer::getPathLength(const Being *const being) const
if (mTargetOnlyReachable)
{
const Path debugPath = mMap->findPath(
- static_cast<int>(playerPos.x - 16) / 32,
- static_cast<int>(playerPos.y - 32) / 32,
+ static_cast<int>(playerPos.x - mapTileSize / 2) / mapTileSize,
+ static_cast<int>(playerPos.y - mapTileSize) / mapTileSize,
being->getTileX(), being->getTileY(),
getWalkMask(), 0);
return static_cast<int>(debugPath.size());
@@ -4130,8 +4133,8 @@ void LocalPlayer::fixAttackTarget()
const Vector &playerPos = getPosition();
const Path debugPath = mMap->findPath(
- static_cast<int>(playerPos.x - 16) / 32,
- static_cast<int>(playerPos.y - 32) / 32,
+ static_cast<int>(playerPos.x - mapTileSize / 2) / mapTileSize,
+ static_cast<int>(playerPos.y - mapTileSize) / mapTileSize,
mTarget->getTileX(), mTarget->getTileY(),
getWalkMask(), 0);