summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/actorspritemanager.cpp40
-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
-rw-r--r--src/commands.cpp5
-rw-r--r--src/flooritem.cpp10
-rw-r--r--src/gui/popups/popupmenu.cpp2
-rw-r--r--src/gui/viewport.cpp14
-rw-r--r--src/gui/widgets/playerbox.cpp12
-rw-r--r--src/gui/widgets/tabs/setup_other.cpp3
-rw-r--r--src/gui/windows/debugwindow.cpp5
-rw-r--r--src/map.cpp74
-rw-r--r--src/map.h2
-rw-r--r--src/maplayer.cpp95
-rw-r--r--src/particle/particleemitter.cpp9
-rw-r--r--src/resources/db/itemdb.cpp2
-rw-r--r--src/resources/iteminfo.cpp2
-rw-r--r--src/resources/mapreader.cpp2
-rw-r--r--src/resources/spritedef.cpp10
-rw-r--r--src/simpleanimation.cpp5
21 files changed, 265 insertions, 225 deletions
diff --git a/src/actorspritemanager.cpp b/src/actorspritemanager.cpp
index 3d5e5ed32..7a8dd13e4 100644
--- a/src/actorspritemanager.cpp
+++ b/src/actorspritemanager.cpp
@@ -67,9 +67,9 @@ class FindBeingFunctor final
const unsigned other_y = y + ((b->getType()
== ActorSprite::NPC) ? 1 : 0);
const Vector &pos = b->getPosition();
- return (static_cast<unsigned>(pos.x) / 32 == x &&
- (static_cast<unsigned>(pos.y) / 32 == y
- || static_cast<unsigned>(pos.y) / 32 == other_y) &&
+ return (static_cast<unsigned>(pos.x) / mapTileSize == x &&
+ (static_cast<unsigned>(pos.y) / mapTileSize == y
+ || static_cast<unsigned>(pos.y) / mapTileSize == other_y) &&
b->isAlive() && (type == ActorSprite::UNKNOWN
|| b->getType() == type));
}
@@ -343,10 +343,10 @@ Being *ActorSpriteManager::findBeingByPixel(const int x, const int y,
{
const FloorItem *const floor
= static_cast<FloorItem*>(*it);
- if ((floor->getPixelX() - 32 <= x) &&
- (floor->getPixelX() + 32 > x) &&
- (floor->getPixelY() - 64 <= y) &&
- (floor->getPixelY() + 16 > y))
+ if ((floor->getPixelX() - mapTileSize <= x) &&
+ (floor->getPixelX() + mapTileSize > x) &&
+ (floor->getPixelY() - mapTileSize * 2 <= y) &&
+ (floor->getPixelY() + mapTileSize / 2 > y))
{
noBeing = true;
}
@@ -363,17 +363,17 @@ Being *ActorSpriteManager::findBeingByPixel(const int x, const int y,
|| (targetDead && being->getType() == Being::PLAYER))
&& (allPlayers || being != player_node))
{
- if ((being->getPixelX() - 16 <= x) &&
- (being->getPixelX() + 16 > x) &&
- (being->getPixelY() - 32 <= y) &&
+ if ((being->getPixelX() - mapTileSize / 2 <= x) &&
+ (being->getPixelX() + mapTileSize / 2 > x) &&
+ (being->getPixelY() - mapTileSize <= y) &&
(being->getPixelY() > y))
{
return being;
}
- else if (!noBeing && (being->getPixelX() - 32 <= x) &&
- (being->getPixelX() + 32 > x) &&
- (being->getPixelY() - 64 <= y) &&
- (being->getPixelY() + 16 > y))
+ else if (!noBeing && (being->getPixelX() - mapTileSize <= x) &&
+ (being->getPixelX() + mapTileSize > x) &&
+ (being->getPixelY() - mapTileSize * 2 <= y) &&
+ (being->getPixelY() + mapTileSize / 2 > y))
{
if (tempBeing)
noBeing = true;
@@ -405,9 +405,9 @@ Being *ActorSpriteManager::findBeingByPixel(const int x, const int y,
if (being->getInfo() && !being->getInfo()->isTargetSelection())
continue;
- if ((being->getPixelX() - 16 <= x) &&
- (being->getPixelX() + 16 > x) &&
- (being->getPixelY() - 32 <= y) &&
+ if ((being->getPixelX() - mapTileSize / 2 <= x) &&
+ (being->getPixelX() + mapTileSize / 2 > x) &&
+ (being->getPixelY() - mapTileSize <= y) &&
(being->getPixelY() > y))
{
return being;
@@ -424,8 +424,8 @@ void ActorSpriteManager::findBeingsByPixel(std::vector<ActorSprite*> &beings,
if (!mMap)
return;
- const int xtol = 16;
- const int uptol = 32;
+ const int xtol = mapTileSize / 2;
+ const int uptol = mapTileSize;
for_actors
{
@@ -826,7 +826,7 @@ Being *ActorSpriteManager::findNearestLivingBeing(const int x, const int y,
const Being *const
excluded) const
{
- const int maxDist = maxTileDist * 32;
+ const int maxDist = maxTileDist * mapTileSize;
return findNearestLivingBeing(nullptr, maxDist, type, x, y, excluded);
}
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);
diff --git a/src/commands.cpp b/src/commands.cpp
index 727bb036c..67bf9cf73 100644
--- a/src/commands.cpp
+++ b/src/commands.cpp
@@ -287,9 +287,8 @@ impHandler2(where)
{
std::ostringstream where;
where << Game::instance()->getCurrentMapName() << ", coordinates: "
- << ((player_node->getPixelX() - 16) / 32) << ", "
- << ((player_node->getPixelY() - 32) / 32);
-
+ << ((player_node->getPixelX() - mapTileSize / 2) / mapTileSize)
+ << ", " << ((player_node->getPixelY() - mapTileSize) / mapTileSize);
tab->chatLog(where.str(), BY_SERVER);
}
diff --git a/src/flooritem.cpp b/src/flooritem.cpp
index c5a07a74d..81ffa67cc 100644
--- a/src/flooritem.cpp
+++ b/src/flooritem.cpp
@@ -66,8 +66,10 @@ FloorItem::FloorItem(const int id, const int itemId, const int x, const int y,
subY = max;
else if (subY < -max)
subY = -max;
- mPos.x = static_cast<float>(x * map->getTileWidth() + subX + 16 - 8);
- mPos.y = static_cast<float>(y * map->getTileHeight() + subY + 32 - 8);
+ mPos.x = static_cast<float>(x * map->getTileWidth()
+ + subX + mapTileSize / 2 - 8);
+ mPos.y = static_cast<float>(y * map->getTileHeight()
+ + subY + mapTileSize - 8);
}
else
{
@@ -112,8 +114,8 @@ bool FloorItem::draw(Graphics *const graphics,
font = gui->getFont();
if (mDropTime < curTime)
{
- const int dx = 32;
- const int dy = 32;
+ const int dx = mapTileSize;
+ const int dy = mapTileSize;
if (curTime > mDropTime + 28 && curTime < mDropTime + 50)
{
diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp
index 0d81e4314..015067a6f 100644
--- a/src/gui/popups/popupmenu.cpp
+++ b/src/gui/popups/popupmenu.cpp
@@ -1119,7 +1119,7 @@ void PopupMenu::handleLink(const std::string &link,
else if (link == "movecamera" && (mX || mY))
{
if (viewport)
- viewport->moveCameraToPosition(mX * 32, mY * 32);
+ viewport->moveCameraToPosition(mX * mapTileSize, mY * mapTileSize);
}
else if (link == "split" && mItem)
{
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index 5e855bea5..958fd3587 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -147,7 +147,7 @@ void Viewport::draw(gcn::Graphics *gcnGraphics)
int cnt = 0;
// Apply lazy scrolling
- while (lastTick < tick_time && cnt < 32)
+ while (lastTick < tick_time && cnt < mapTileSize)
{
if (player_x > mPixelViewX + mScrollRadius)
{
@@ -309,9 +309,9 @@ void Viewport::_drawDebugPath(Graphics *const graphics)
const Vector &playerPos = player_node->getPosition();
debugPath = mMap->findPath(
- static_cast<int>(playerPos.x - 16) / 32,
- static_cast<int>(playerPos.y - 32) / 32,
- mousePosX / 32, mousePosY / 32,
+ static_cast<int>(playerPos.x - mapTileSize / 2) / mapTileSize,
+ static_cast<int>(playerPos.y - mapTileSize) / mapTileSize,
+ mousePosX / mapTileSize, mousePosY / mapTileSize,
player_node->getWalkMask(),
500);
lastMouseDestination = mouseDestination;
@@ -345,8 +345,8 @@ void Viewport::_drawPath(Graphics *const graphics, const Path &path,
int cnt = 1;
FOR_EACH (Path::const_iterator, i, path)
{
- const int squareX = i->x * 32 - mPixelViewX + 12;
- const int squareY = i->y * 32 - mPixelViewY + 12;
+ const int squareX = i->x * mapTileSize - mPixelViewX + 12;
+ const int squareY = i->y * mapTileSize - mPixelViewY + 12;
graphics->fillRectangle(gcn::Rectangle(squareX, squareY, 8, 8));
if (mMap)
@@ -371,7 +371,7 @@ void Viewport::_drawPath(Graphics *const graphics, const Path &path,
if (mMap)
{
const std::string str = toString(mMap->getMetaTile(
- i->x / 32, i->y / 32)->Gcost);
+ i->x / mapTileSize, i->y / mapTileSize)->Gcost);
font->drawString(graphics, str,
squareX + 4 - font->getWidth(text) / 2, squareY + 12);
}
diff --git a/src/gui/widgets/playerbox.cpp b/src/gui/widgets/playerbox.cpp
index ff865bdbe..21617c57b 100644
--- a/src/gui/widgets/playerbox.cpp
+++ b/src/gui/widgets/playerbox.cpp
@@ -40,8 +40,8 @@ PlayerBox::PlayerBox(Being *const being, const std::string &skin,
mSelectedBackground(),
mSkin(nullptr),
mSelectedSkin(nullptr),
- mOffsetX(-16),
- mOffsetY(-32),
+ mOffsetX(-mapTileSize / 2),
+ mOffsetY(-mapTileSize),
mDrawBackground(false),
mSelected(false)
{
@@ -57,8 +57,8 @@ PlayerBox::PlayerBox(const std::string &skin,
mSelectedBackground(),
mSkin(nullptr),
mSelectedSkin(nullptr),
- mOffsetX(-16),
- mOffsetY(-32),
+ mOffsetX(-mapTileSize / 2),
+ mOffsetY(-mapTileSize),
mDrawBackground(false),
mSelected(false)
{
@@ -94,8 +94,8 @@ void PlayerBox::init(std::string name, std::string selectedName)
if (mSkin)
{
mDrawBackground = (mSkin->getOption("drawbackground") != 0);
- mOffsetX = mSkin->getOption("offsetX", -16);
- mOffsetY = mSkin->getOption("offsetY", -32);
+ mOffsetX = mSkin->getOption("offsetX", -mapTileSize / 2);
+ mOffsetY = mSkin->getOption("offsetY", -mapTileSize);
mFrameSize = mSkin->getOption("frameSize", 2);
}
if (selectedName.empty())
diff --git a/src/gui/widgets/tabs/setup_other.cpp b/src/gui/widgets/tabs/setup_other.cpp
index ec4e2fe06..b59edfd4a 100644
--- a/src/gui/widgets/tabs/setup_other.cpp
+++ b/src/gui/widgets/tabs/setup_other.cpp
@@ -28,6 +28,7 @@
#include "gui/widgets/scrollarea.h"
#include "configuration.h"
+#include "map.h"
#include "utils/gettext.h"
@@ -161,7 +162,7 @@ Setup_Other::Setup_Other(const Widget2 *const widget) :
// TRANSLATORS: settings option
new SetupItemIntTextField(_("Scroll radius"), "", "ScrollRadius",
- this, "ScrollRadiusEvent", 0, 32);
+ this, "ScrollRadiusEvent", 0, mapTileSize);
// TRANSLATORS: settings option
new SetupItemCheckBox(_("Auto resize minimaps"), "", "autoresizeminimaps",
diff --git a/src/gui/windows/debugwindow.cpp b/src/gui/windows/debugwindow.cpp
index 0104af792..3c3a856b8 100644
--- a/src/gui/windows/debugwindow.cpp
+++ b/src/gui/windows/debugwindow.cpp
@@ -133,8 +133,9 @@ void DebugWindow::draw(gcn::Graphics *g)
if (target)
{
Graphics *const g2 = static_cast<Graphics*>(g);
- target->draw(g2, -target->getPixelX() + 16 + mDimension.width / 2,
- -target->getPixelY() + 32 + mDimension.height / 2);
+ target->draw(g2, -target->getPixelX() + mapTileSize / 2
+ + mDimension.width / 2, -target->getPixelY() + mapTileSize
+ + mDimension.height / 2);
}
}
BLOCK_END("DebugWindow::draw")
diff --git a/src/map.cpp b/src/map.cpp
index 69a59b0b1..3ff62e88d 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -513,12 +513,12 @@ void Map::draw(Graphics *const graphics, int scrollX, int scrollY)
#define fillCollision(collision, color) \
if (x < endX && mMetaTiles[tilePtr].blockmask & collision)\
{\
- width = 32;\
+ width = mapTileSize;\
for (int x2 = tilePtr + 1; x < endX; x2 ++)\
{\
if (!(mMetaTiles[x2].blockmask & collision))\
break;\
- width += 32;\
+ width += mapTileSize;\
x ++;\
tilePtr ++;\
}\
@@ -529,7 +529,7 @@ void Map::draw(Graphics *const graphics, int scrollX, int scrollY)
graphics->fillRectangle(gcn::Rectangle(\
x0 * mTileWidth - scrollX, \
y * mTileHeight - scrollY, \
- width, 32));\
+ width, mapTileSize));\
}\
}\
@@ -560,7 +560,7 @@ void Map::drawCollision(Graphics *const graphics,
startY * mTileHeight - scrollY,
endX * mTileWidth - scrollX,
endY * mTileHeight - scrollY,
- 32, 32);
+ mapTileSize, mapTileSize);
}
for (int y = startY; y < endY; y++)
@@ -770,22 +770,22 @@ Position Map::checkNodeOffsets(int radius, const unsigned char walkMask,
const Position &position) const
{
// Pre-computing character's position in tiles
- const int tx = position.x / 32;
- const int ty = position.y / 32;
+ const int tx = position.x / mapTileSize;
+ const int ty = position.y / mapTileSize;
// Pre-computing character's position offsets.
- int fx = position.x % 32;
- int fy = position.y % 32;
+ int fx = position.x % mapTileSize;
+ int fy = position.y % mapTileSize;
// Compute the being radius:
// FIXME: Hande beings with more than 1/2 tile radius by not letting them
// go or spawn in too narrow places. The server will have to be aware
// of being's radius value (in tiles) to handle this gracefully.
- if (radius > 32 / 2)
- radius = 32 / 2;
+ if (radius > mapTileSize / 2)
+ radius = mapTileSize / 2;
// set a default value if no value returned.
if (radius < 1)
- radius = 32 / 3;
+ radius = mapTileSize / 3;
// We check diagonal first as they are more restrictive.
// Top-left border check
@@ -797,37 +797,37 @@ Position Map::checkNodeOffsets(int radius, const unsigned char walkMask,
}
// Top-right border check
if (!getWalk(tx + 1, ty - 1, walkMask)
- && (fy < radius) && fx > (32 - radius))
+ && (fy < radius) && fx > (mapTileSize - radius))
{
- fx = 32 - radius;
+ fx = mapTileSize - radius;
fy = radius;
}
// Bottom-left border check
if (!getWalk(tx - 1, ty + 1, walkMask)
- && fy > (32 - radius) && fx < radius)
+ && fy > (mapTileSize - radius) && fx < radius)
{
fx = radius;
- fy = 32 - radius;
+ fy = mapTileSize - radius;
}
// Bottom-right border check
if (!getWalk(tx + 1, ty + 1, walkMask)
- && fy > (32 - radius) && fx > (32 - radius))
+ && fy > (mapTileSize - radius) && fx > (mapTileSize - radius))
{
- fx = 32 - radius;
+ fx = mapTileSize - radius;
fy = fx;
}
// Fix coordinates so that the player does not seem to dig into walls.
- if (fx > (32 - radius) && !getWalk(tx + 1, ty, walkMask))
- fx = 32 - radius;
+ if (fx > (mapTileSize - radius) && !getWalk(tx + 1, ty, walkMask))
+ fx = mapTileSize - radius;
else if (fx < radius && !getWalk(tx - 1, ty, walkMask))
fx = radius;
- else if (fy > (32 - radius) && !getWalk(tx, ty + 1, walkMask))
- fy = 32 - radius;
+ else if (fy > (mapTileSize - radius) && !getWalk(tx, ty + 1, walkMask))
+ fy = mapTileSize - radius;
else if (fy < radius && !getWalk(tx, ty - 1, walkMask))
fy = radius;
- return Position(tx * 32 + fx, ty * 32 + fy);
+ return Position(tx * mapTileSize + fx, ty * mapTileSize + fy);
}
Path Map::findPixelPath(const int startPixelX, const int startPixelY,
@@ -835,20 +835,23 @@ Path Map::findPixelPath(const int startPixelX, const int startPixelY,
const int radius, const unsigned char walkMask,
const int maxCost)
{
- Path myPath = findPath(startPixelX / 32, startPixelY / 32,
- endPixelX / 32, endPixelY / 32, walkMask, maxCost);
+ Path myPath = findPath(startPixelX / mapTileSize,
+ startPixelY / mapTileSize,
+ endPixelX / mapTileSize,
+ endPixelY / mapTileSize,
+ walkMask, maxCost);
// Don't compute empty coordinates.
if (myPath.empty())
return myPath;
// Find the starting offset
- const float startOffsetX = static_cast<float>(startPixelX % 32);
- const float startOffsetY = static_cast<float>(startPixelY % 32);
+ const float startOffsetX = static_cast<float>(startPixelX % mapTileSize);
+ const float startOffsetY = static_cast<float>(startPixelY % mapTileSize);
// Find the ending offset
- const float endOffsetX = static_cast<float>(endPixelX % 32);
- const float endOffsetY = static_cast<float>(endPixelY % 32);
+ const float endOffsetX = static_cast<float>(endPixelX % mapTileSize);
+ const float endOffsetY = static_cast<float>(endPixelY % mapTileSize);
const int sz = static_cast<int>(myPath.size());
// Find the distance, and divide it by the number of steps
@@ -867,8 +870,10 @@ Path Map::findPixelPath(const int startPixelX, const int startPixelY,
// A position that is valid on the start and end tile is not
// necessarily valid on all the tiles in between, so check the offsets.
*it = checkNodeOffsets(radius, walkMask,
- it->x * 32 + startOffsetX + static_cast<float>(changeX * i),
- it->y * 32 + startOffsetY + static_cast<float>(changeY * i));
+ it->x * mapTileSize + startOffsetX
+ + static_cast<float>(changeX * i),
+ it->y * mapTileSize + startOffsetY
+ + static_cast<float>(changeY * i));
i++;
++it;
}
@@ -1268,13 +1273,15 @@ void Map::addRange(const std::string &name, const int type,
if (!mObjects)
return;
- mObjects->addObject(name, type, x / 32, y / 32, dx / 32, dy / 32);
+ mObjects->addObject(name, type, x / mapTileSize, y / mapTileSize,
+ dx / mapTileSize, dy / mapTileSize);
}
void Map::addPortal(const std::string &name, const int type,
const int x, const int y, const int dx, const int dy)
{
- addPortalTile(name, type, (x / 32) + (dx / 64), (y / 32) + (dy / 64));
+ addPortalTile(name, type, (x / mapTileSize) + (dx / mapTileSize / 2),
+ (y / mapTileSize) + (dy / mapTileSize / 2));
}
void Map::addPortalTile(const std::string &name, const int type,
@@ -1479,7 +1486,8 @@ void Map::reduce()
img->setAlphaVisible(false);
}
}
- else if (img->mBounds.w > 32 || img->mBounds.h > 32)
+ else if (img->mBounds.w > mapTileSize
+ || img->mBounds.h > mapTileSize)
{
correct = false;
img->setAlphaVisible(true);
diff --git a/src/map.h b/src/map.h
index 11ef04fa1..a4393b832 100644
--- a/src/map.h
+++ b/src/map.h
@@ -58,6 +58,8 @@ typedef TilePairVector::const_iterator TilePairVectorCIter;
typedef std::vector<AmbientLayer*> AmbientLayerVector;
typedef AmbientLayerVector::const_iterator AmbientLayerVectorCIter;
+static const int mapTileSize = 32;
+
/**
* A meta tile stores additional information about a location on a tile map.
* This is information that doesn't need to be repeated for each tile in each
diff --git a/src/maplayer.cpp b/src/maplayer.cpp
index a6f726c90..686ab7a35 100644
--- a/src/maplayer.cpp
+++ b/src/maplayer.cpp
@@ -105,14 +105,14 @@ void MapLayer::draw(Graphics *const graphics,
if (endY > mHeight)
endY = mHeight;
- const int dx = (mX * 32) - scrollX;
- const int dy = (mY * 32) - scrollY + 32;
+ const int dx = (mX * mapTileSize) - scrollX;
+ const int dy = (mY * mapTileSize) - scrollY + mapTileSize;
const bool flag = (debugFlags != Map::MAP_SPECIAL
&& debugFlags != Map::MAP_SPECIAL2);
for (int y = startY; y < endY; y++)
{
- const int y32 = y * 32;
+ const int y32 = y * mapTileSize;
const int yWidth = y * mWidth;
const int py0 = y32 + dy;
@@ -121,7 +121,7 @@ void MapLayer::draw(Graphics *const graphics,
for (int x = startX; x < endX; x++, tilePtr++)
{
- const int x32 = x * 32;
+ const int x32 = x * mapTileSize;
int c = 0;
const Image *const img = *tilePtr;
@@ -129,7 +129,7 @@ void MapLayer::draw(Graphics *const graphics,
{
const int px = x32 + dx;
const int py = py0 - img->mBounds.h;
- if (flag || img->mBounds.h <= 32)
+ if (flag || img->mBounds.h <= mapTileSize)
{
int width = 0;
// here need not draw over player position
@@ -197,8 +197,8 @@ void MapLayer::updateSDL(Graphics *const graphics, int startX, int startY,
if (endY > mHeight)
endY = mHeight;
- const int dx = (mX * 32) - scrollX;
- const int dy = (mY * 32) - scrollY + 32;
+ const int dx = (mX * mapTileSize) - scrollX;
+ const int dy = (mY * mapTileSize) - scrollY + mapTileSize;
const bool flag = (debugFlags != Map::MAP_SPECIAL
&& debugFlags != Map::MAP_SPECIAL2);
@@ -211,7 +211,7 @@ void MapLayer::updateSDL(Graphics *const graphics, int startX, int startY,
ImageVertexes *imgVert = nullptr;
const int yWidth = y * mWidth;
- const int py0 = y * 32 + dy;
+ const int py0 = y * mapTileSize + dy;
Image **tilePtr = mTiles + startX + yWidth;
for (int x = startX; x < endX; x++, tilePtr++)
@@ -219,9 +219,9 @@ void MapLayer::updateSDL(Graphics *const graphics, int startX, int startY,
Image *const img = *tilePtr;
if (img)
{
- const int px = x * 32 + dx;
+ const int px = x * mapTileSize + dx;
const int py = py0 - img->mBounds.h;
- if (flag || img->mBounds.h <= 32)
+ if (flag || img->mBounds.h <= mapTileSize)
{
if (lastImage != img)
{
@@ -261,8 +261,8 @@ void MapLayer::updateOGL(Graphics *const graphics, int startX, int startY,
if (endY > mHeight)
endY = mHeight;
- const int dx = (mX * 32) - scrollX;
- const int dy = (mY * 32) - scrollY + 32;
+ const int dx = (mX * mapTileSize) - scrollX;
+ const int dy = (mY * mapTileSize) - scrollY + mapTileSize;
const bool flag = (debugFlags != Map::MAP_SPECIAL
&& debugFlags != Map::MAP_SPECIAL2);
@@ -275,21 +275,21 @@ void MapLayer::updateOGL(Graphics *const graphics, int startX, int startY,
for (int y = startY; y < endY; y++)
{
const int yWidth = y * mWidth;
- const int py0 = y * 32 + dy;
+ const int py0 = y * mapTileSize + dy;
Image **tilePtr = mTiles + startX + yWidth;
for (int x = startX; x < endX; x++, tilePtr++)
{
Image *const img = *tilePtr;
if (img)
{
- const int px = x * 32 + dx;
+ const int px = x * mapTileSize + dx;
const int py = py0 - img->mBounds.h;
const GLuint imgGlImage = img->mGLImage;
- if (flag || img->mBounds.h <= 32)
+ if (flag || img->mBounds.h <= mapTileSize)
{
if (!lastImage || lastImage->mGLImage != imgGlImage)
{
- if (img->mBounds.w > 32)
+ if (img->mBounds.w > mapTileSize)
imgSet.clear();
if (imgSet.find(imgGlImage) != imgSet.end())
@@ -371,16 +371,16 @@ void MapLayer::drawFringe(Graphics *const graphics, int startX, int startY,
ActorsCIter ai = actors->begin();
const ActorsCIter ai_end = actors->end();
- const int dx = (mX * 32) - scrollX;
- const int dy = (mY * 32) - scrollY + 32;
+ const int dx = (mX * mapTileSize) - scrollX;
+ const int dy = (mY * mapTileSize) - scrollY + mapTileSize;
const int specialWidth = mSpecialLayer->mWidth;
const int specialHeight = mSpecialLayer->mHeight;
for (int y = startY; y < endY; y++)
{
- const int y32 = y * 32;
- const int y32s = (y + yFix) * 32;
+ const int y32 = y * mapTileSize;
+ const int y32s = (y + yFix) * mapTileSize;
const int yWidth = y * mWidth;
BLOCK_START("MapLayer::drawFringe drawmobs")
@@ -408,15 +408,21 @@ void MapLayer::drawFringe(Graphics *const graphics, int startX, int startY,
for (int x = startX; x < endX1; x++)
{
- const int px1 = x * 32 - scrollX;
+ const int px1 = x * mapTileSize - scrollX;
const MapItem *item = mSpecialLayer->mTiles[ptr + x];
if (item)
- item->draw(graphics, px1, py1, 32, 32);
+ {
+ item->draw(graphics, px1, py1,
+ mapTileSize, mapTileSize);
+ }
item = mTempLayer->mTiles[ptr + x];
if (item)
- item->draw(graphics, px1, py1, 32, 32);
+ {
+ item->draw(graphics, px1, py1,
+ mapTileSize, mapTileSize);
+ }
}
}
}
@@ -428,7 +434,7 @@ void MapLayer::drawFringe(Graphics *const graphics, int startX, int startY,
Image **tilePtr = mTiles + startX + yWidth;
for (int x = startX; x < endX; x++, tilePtr++)
{
- const int x32 = x * 32;
+ const int x32 = x * mapTileSize;
const int px1 = x32 - scrollX;
int c = 0;
@@ -439,7 +445,7 @@ void MapLayer::drawFringe(Graphics *const graphics, int startX, int startY,
const int py = py0 - img->mBounds.h;
if ((debugFlags != Map::MAP_SPECIAL
&& debugFlags != Map::MAP_SPECIAL2)
- || img->mBounds.h <= 32)
+ || img->mBounds.h <= mapTileSize)
{
int width = 0;
// here need not draw over player position
@@ -475,12 +481,18 @@ void MapLayer::drawFringe(Graphics *const graphics, int startX, int startY,
= mTempLayer->mTiles[ptr + x1];
if (item1 || item2)
{
- const int px2 = px1 + (x1 * 32);
+ const int px2 = px1 + (x1 * mapTileSize);
if (item1 && item1->mType != MapItem::EMPTY)
- item1->draw(graphics, px2, py1, 32, 32);
+ {
+ item1->draw(graphics, px2, py1,
+ mapTileSize, mapTileSize);
+ }
if (item2 && item2->mType != MapItem::EMPTY)
- item2->draw(graphics, px2, py1, 32, 32);
+ {
+ item2->draw(graphics, px2, py1,
+ mapTileSize, mapTileSize);
+ }
}
}
}
@@ -501,20 +513,22 @@ void MapLayer::drawFringe(Graphics *const graphics, int startX, int startY,
BLOCK_END("MapLayer::drawFringe drawmobs")
if (mHighlightAttackRange && player_node)
{
- const int px = player_node->getPixelX() - scrollX - 16;
- const int py = player_node->getPixelY() - scrollY - 32;
- const int attackRange = player_node->getAttackRange() * 32;
+ const int px = player_node->getPixelX()
+ - scrollX - mapTileSize / 2;
+ const int py = player_node->getPixelY() - scrollY - mapTileSize;
+ const int attackRange = player_node->getAttackRange()
+ * mapTileSize;
int x = px - attackRange;
int y = py - attackRange;
- int w = 2 * attackRange + 32;
+ int w = 2 * attackRange + mapTileSize;
int h = w;
- if (attackRange <= 32)
+ if (attackRange <= mapTileSize)
{
- x -= 16;
- y -= 16;
- w += 32;
- h += 32;
+ x -= mapTileSize / 2;
+ y -= mapTileSize / 2;
+ w += mapTileSize;
+ h += mapTileSize;
}
if (userPalette)
@@ -666,13 +680,16 @@ void SpecialLayer::draw(Graphics *const graphics, int startX, int startY,
for (int y = startY; y < endY; y ++)
{
- const int py = y * 32 - scrollY;
+ const int py = y * mapTileSize - scrollY;
const int y2 = y * mWidth;
for (int x = startX; x < endX; x ++)
{
const MapItem *const item = mTiles[x + y2];
if (item)
- item->draw(graphics, x * 32 - scrollX, py, 32, 32);
+ {
+ item->draw(graphics, x * mapTileSize - scrollX, py,
+ mapTileSize, mapTileSize);
+ }
}
}
BLOCK_END("SpecialLayer::draw")
diff --git a/src/particle/particleemitter.cpp b/src/particle/particleemitter.cpp
index 74aec293a..089fa31de 100644
--- a/src/particle/particleemitter.cpp
+++ b/src/particle/particleemitter.cpp
@@ -23,6 +23,7 @@
#include "particle/particleemitter.h"
#include "logger.h"
+#include "map.h"
#include "particle/animationparticle.h"
#include "particle/rotationalparticle.h"
@@ -253,9 +254,9 @@ ParticleEmitter::ParticleEmitter(const XmlNodePtr emitterNode,
const int delay = XML::getIntProperty(
frameNode, "delay", 0, 0, 100000);
const int offsetX = XML::getProperty(frameNode, "offsetX", 0)
- - imageset->getWidth() / 2 + 16;
+ - imageset->getWidth() / 2 + mapTileSize / 2;
const int offsetY = XML::getProperty(frameNode, "offsetY", 0)
- - imageset->getHeight() + 32;
+ - imageset->getHeight() + mapTileSize;
const int rand = XML::getIntProperty(
frameNode, "rand", 100, 0, 100);
@@ -327,9 +328,9 @@ ParticleEmitter::ParticleEmitter(const XmlNodePtr emitterNode,
const int delay = XML::getIntProperty(
frameNode, "delay", 0, 0, 100000);
const int offsetX = XML::getProperty(frameNode, "offsetX", 0)
- - imageset->getWidth() / 2 + 16;
+ - imageset->getWidth() / 2 + mapTileSize / 2;
const int offsetY = XML::getProperty(frameNode, "offsetY", 0)
- - imageset->getHeight() + 32;
+ - imageset->getHeight() + mapTileSize;
const int rand = XML::getIntProperty(
frameNode, "rand", 100, 0, 100);
diff --git a/src/resources/db/itemdb.cpp b/src/resources/db/itemdb.cpp
index eeae4cfec..19b618208 100644
--- a/src/resources/db/itemdb.cpp
+++ b/src/resources/db/itemdb.cpp
@@ -244,7 +244,7 @@ void ItemDB::loadXmlFile(const std::string &fileName, int &tagNum)
std::string drawAfter = XML::getProperty(node, "drawAfter", "");
const int pet = XML::getProperty(node, "pet", 0);
const int maxFloorOffset = XML::getIntProperty(
- node, "maxFloorOffset", 32, 0, 32);
+ node, "maxFloorOffset", mapTileSize, 0, mapTileSize);
std::string colors;
if (serverVersion >= 1)
{
diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp
index eb8014f3e..fa8ca2b61 100644
--- a/src/resources/iteminfo.cpp
+++ b/src/resources/iteminfo.cpp
@@ -60,7 +60,7 @@ ItemInfo::ItemInfo() :
mHitEffectId(-1),
mCriticalHitEffectId(-1),
mMissEffectId(-1),
- maxFloorOffset(32),
+ maxFloorOffset(mapTileSize),
mPickupCursor(Cursor::CURSOR_POINTER),
mPet(0),
mProtected(false)
diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp
index 4097acb89..1382e66af 100644
--- a/src/resources/mapreader.cpp
+++ b/src/resources/mapreader.cpp
@@ -934,7 +934,7 @@ Map *MapReader::createEmptyMap(const std::string &filename,
const std::string &realFilename)
{
logger->log1("Creating empty map");
- Map *const map = new Map(300, 300, 32, 32);
+ Map *const map = new Map(300, 300, mapTileSize, mapTileSize);
map->setProperty("_filename", realFilename);
map->setProperty("_realfilename", filename);
updateMusic(map);
diff --git a/src/resources/spritedef.cpp b/src/resources/spritedef.cpp
index af0ada0dc..1c593fc71 100644
--- a/src/resources/spritedef.cpp
+++ b/src/resources/spritedef.cpp
@@ -23,6 +23,7 @@
#include "resources/spritedef.h"
#include "logger.h"
+#include "map.h"
#include "resources/action.h"
#include "resources/animation.h"
@@ -293,10 +294,11 @@ void SpriteDef::loadAnimation(const XmlNodePtr animationNode,
{
const int delay = XML::getIntProperty(
frameNode, "delay", 0, 0, 100000);
- const int offsetX = XML::getProperty(frameNode, "offsetX", 0) +
- imageSet->getOffsetX() - imageSet->getWidth() / 2 + 16;
- const int offsetY = XML::getProperty(frameNode, "offsetY", 0) +
- imageSet->getOffsetY() - imageSet->getHeight() + 32;
+ const int offsetX = XML::getProperty(frameNode, "offsetX", 0)
+ + imageSet->getOffsetX() - imageSet->getWidth() / 2
+ + mapTileSize / 2;
+ const int offsetY = XML::getProperty(frameNode, "offsetY", 0)
+ + imageSet->getOffsetY() - imageSet->getHeight() + mapTileSize;
const int rand = XML::getIntProperty(frameNode, "rand", 100, 0, 100);
if (xmlNameEqual(frameNode, "frame"))
diff --git a/src/simpleanimation.cpp b/src/simpleanimation.cpp
index e0623c937..bb120dee7 100644
--- a/src/simpleanimation.cpp
+++ b/src/simpleanimation.cpp
@@ -23,6 +23,7 @@
#include "simpleanimation.h"
#include "logger.h"
+#include "map.h"
#include "render/graphics.h"
@@ -163,8 +164,8 @@ void SimpleAnimation::initializeAnimation(const XmlNodePtr animationNode,
if (!imageset)
return;
- const int x1 = imageset->getWidth() / 2 - 16;
- const int y1 = imageset->getHeight() - 32;
+ const int x1 = imageset->getWidth() / 2 - mapTileSize / 2;
+ const int y1 = imageset->getHeight() - mapTileSize;
// Get animation frames
for (XmlNodePtr frameNode = animationNode->xmlChildrenNode;