summaryrefslogtreecommitdiff
path: root/src/being
diff options
context:
space:
mode:
Diffstat (limited to 'src/being')
-rw-r--r--src/being/actorsprite.h9
-rw-r--r--src/being/being.cpp249
-rw-r--r--src/being/being.h11
-rw-r--r--src/being/localplayer.cpp765
-rw-r--r--src/being/playerinfo.cpp19
5 files changed, 138 insertions, 915 deletions
diff --git a/src/being/actorsprite.h b/src/being/actorsprite.h
index f9876fa79..444232ddd 100644
--- a/src/being/actorsprite.h
+++ b/src/being/actorsprite.h
@@ -183,14 +183,7 @@ public:
{ return getPixelX() - mapTileSize / 2; }
int getActorY() const
- {
-#ifdef MANASERV_SUPPORT
- return getPixelY() + ((Net::getNetworkType() == ServerInfo::MANASERV)
- ? 15 : mapTileSize);
-#else
- return getPixelY() - mapTileSize;
-#endif
- }
+ { return getPixelY() - mapTileSize; }
protected:
/**
diff --git a/src/being/being.cpp b/src/being/being.cpp
index 428e6e7f8..705d97439 100644
--- a/src/being/being.cpp
+++ b/src/being/being.cpp
@@ -371,50 +371,7 @@ void Being::setDestination(const int dstX, const int dstY)
if (!mMap)
return;
-#ifdef MANASERV_SUPPORT
- if (Net::getNetworkType() != ServerInfo::MANASERV)
-#endif
- {
- setPath(mMap->findPath(mX, mY, dstX, dstY, getWalkMask()));
- return;
- }
-
-#ifdef MANASERV_SUPPORT
- // Don't handle flawed destinations from server...
- if (dstX == 0 || dstY == 0)
- return;
-
- // If the destination is unwalkable, don't bother trying to get there
- if (!mMap->getWalk(dstX / mapTileSize, dstY / mapTileSize))
- return;
-
- Position dest = mMap->checkNodeOffsets(getCollisionRadius(), getWalkMask(),
- dstX, dstY);
- Path thisPath = mMap->findPixelPath(static_cast<int>(mPos.x),
- static_cast<int>(mPos.y), dest.x, dest.y,
- static_cast<int>(getCollisionRadius()),
- static_cast<unsigned char>(getWalkMask()));
-
- if (thisPath.empty())
- {
- // If there is no path but the destination is on the same walkable tile,
- // we accept it.
- 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);
- }
- setPath(Path());
- return;
- }
-
- // The destination is valid, so we set it.
- mDest.x = static_cast<float>(dest.x);
- mDest.y = static_cast<float>(dest.y);
-
- setPath(thisPath);
-#endif
+ setPath(mMap->findPath(mX, mY, dstX, dstY, getWalkMask()));
}
void Being::clearPath()
@@ -428,12 +385,7 @@ void Being::setPath(const Path &path)
if (mPath.empty())
return;
-#ifdef MANASERV_SUPPORT
- if ((Net::getNetworkType() != ServerInfo::MANASERV) &&
- mAction != MOVE && mAction != DEAD)
-#else
if (mAction != MOVE && mAction != DEAD)
-#endif
{
nextTile();
mActionTime = tick_time;
@@ -771,13 +723,8 @@ void Being::handleAttack(Being *const victim, const int damage,
else if (mInfo->getAttack(attackId))
fireMissile(victim, mInfo->getAttack(attackId)->mMissileParticle);
-#ifdef MANASERV_SUPPORT
- if (Net::getNetworkType() != ServerInfo::MANASERV)
-#endif
- {
- reset();
- mActionTime = tick_time;
- }
+ reset();
+ mActionTime = tick_time;
if (this != player_node)
{
@@ -824,13 +771,8 @@ void Being::handleSkill(Being *const victim, const int damage,
if (data)
fireMissile(victim, data->particle);
-#ifdef MANASERV_SUPPORT
- if (Net::getNetworkType() != ServerInfo::MANASERV)
-#endif
- {
- reset();
- mActionTime = tick_time;
- }
+ reset();
+ mActionTime = tick_time;
if (this != player_node)
{
@@ -1443,157 +1385,68 @@ void Being::logic()
}
int frameCount = static_cast<int>(getFrameCount());
-#ifdef MANASERV_SUPPORT
- if ((Net::getNetworkType() == ServerInfo::MANASERV) && (mAction != DEAD))
- {
- const Vector dest = (mPath.empty()) ?
- mDest : Vector(static_cast<float>(mPath.front().x),
- static_cast<float>(mPath.front().y));
- // This is a hack that stops NPCs from running off the map...
- if (mDest.x <= 0 && mDest.y <= 0)
- {
- BLOCK_END("Being::logic")
- return;
- }
-
- // The Vector representing the difference between current position
- // and the next destination path node.
- Vector dir = dest - mPos;
-
- const float nominalLength = dir.length();
+ switch (mAction)
+ {
+ case STAND:
+ case SIT:
+ case DEAD:
+ case HURT:
+ case SPAWN:
+ default:
+ break;
- // When we've not reached our destination, move to it.
- if (nominalLength > 0.0F && !mWalkSpeed.isNull())
+ case MOVE:
{
- // The deplacement of a point along a vector is calculated
- // using the Unit Vector (â) multiplied by the point speed.
- // â = a / ||a|| (||a|| is the a length.)
- // Then, diff = (dir/||dir||) * speed.
- const Vector normalizedDir = dir.normalized();
- Vector diff(normalizedDir.x * mWalkSpeed.x,
- normalizedDir.y * mWalkSpeed.y);
-
- // Test if we don't miss the destination by a move too far:
- if (diff.length() > nominalLength)
- {
- setPosition(mPos + dir);
-
- // Also, if the destination is reached, try to get the next
- // path point, if existing.
- if (!mPath.empty())
- mPath.pop_front();
- }
- // Otherwise, go to it using the nominal speed.
- else
+ if (static_cast<float>(get_elapsed_time(
+ mActionTime)) >= mSpeed)
{
- setPosition(mPos + diff);
+ nextTile();
}
-
- if (mAction != MOVE)
- setAction(MOVE, 0);
-
- // Update the player sprite direction.
- // N.B.: We only change this if the distance is more than one pixel.
- if (nominalLength > 1.0F)
- {
- int direction = 0;
- const float dx = std::abs(dir.x);
- float dy = std::abs(dir.y);
-
- // When not using mouse for the player, we slightly prefer
- // UP and DOWN position, especially when walking diagonally.
- if (player_node && this == player_node &&
- !player_node->isPathSetByMouse())
- {
- dy = dy + 2;
- }
-
- if (dx > dy)
- direction |= (dir.x > 0) ? RIGHT : LEFT;
- else
- direction |= (dir.y > 0) ? DOWN : UP;
-
- setDirection(static_cast<uint8_t>(direction));
- }
- }
- else if (!mPath.empty())
- {
- // If the current path node has been reached,
- // remove it and go to the next one.
- mPath.pop_front();
- }
- else if (mAction == MOVE)
- {
- setAction(STAND, 0);
+ break;
}
- }
- else
- if (Net::getNetworkType() != ServerInfo::MANASERV)
-#endif
- {
- switch (mAction)
- {
- case STAND:
- case SIT:
- case DEAD:
- case HURT:
- case SPAWN:
- default:
- break;
- case MOVE:
- {
- if (static_cast<float>(get_elapsed_time(
- mActionTime)) >= mSpeed)
- {
- nextTile();
- }
+ case ATTACK:
+ {
+ if (!mActionTime)
break;
- }
- case ATTACK:
+ int curFrame = 0;
+ if (mAttackSpeed)
{
- if (!mActionTime)
- break;
-
- int curFrame = 0;
- if (mAttackSpeed)
- {
- curFrame = (get_elapsed_time(mActionTime) * frameCount)
- / mAttackSpeed;
- }
+ curFrame = (get_elapsed_time(mActionTime) * frameCount)
+ / mAttackSpeed;
+ }
- if (this == player_node && curFrame >= frameCount)
- nextTile();
+ if (this == player_node && curFrame >= frameCount)
+ nextTile();
- break;
- }
+ break;
}
+ }
- if (mAction == MOVE)
- {
- const int xOffset = getXOffset();
- const int yOffset = getYOffset();
- int offset = xOffset;
- if (!offset)
- offset = yOffset;
+ if (mAction == MOVE)
+ {
+ const int xOffset = getXOffset();
+ const int yOffset = getYOffset();
+ int offset = xOffset;
+ if (!offset)
+ offset = yOffset;
- mSortOffsetY = (mOldHeight * mapTileSize / 2)
- + (mOffsetY * mapTileSize / 2)
- * (mapTileSize - abs(offset)) / mapTileSize;
- const int yOffset2 = yOffset - mSortOffsetY;
+ mSortOffsetY = (mOldHeight * mapTileSize / 2)
+ + (mOffsetY * mapTileSize / 2)
+ * (mapTileSize - abs(offset)) / mapTileSize;
+ const int yOffset2 = yOffset - mSortOffsetY;
- // Update pixel coordinates
- setPosition(static_cast<float>(mX * mapTileSize
- + mapTileSize / 2 + xOffset), static_cast<float>(
- mY * mapTileSize + mapTileSize + yOffset2));
- }
- else
- {
- setPosition(static_cast<float>(mX * mapTileSize + mapTileSize / 2),
- static_cast<float>(mY * mapTileSize + mapTileSize));
- }
+ // Update pixel coordinates
+ setPosition(static_cast<float>(mX * mapTileSize
+ + mapTileSize / 2 + xOffset), static_cast<float>(
+ mY * mapTileSize + mapTileSize + yOffset2));
+ }
+ else
+ {
+ setPosition(static_cast<float>(mX * mapTileSize + mapTileSize / 2),
+ static_cast<float>(mY * mapTileSize + mapTileSize));
}
if (mEmotionSprite)
diff --git a/src/being/being.h b/src/being/being.h
index e427612f0..2521eb0c3 100644
--- a/src/being/being.h
+++ b/src/being/being.h
@@ -472,17 +472,13 @@ class Being : public ActorSprite, public ConfigListener
}
/**
- * Sets the walk speed.
- * in pixels per second for eAthena,
- * in tiles per second for Manaserv.
+ * Sets the walk speed in pixels per second.
*/
void setWalkSpeed(Vector speed)
{ mWalkSpeed = speed; mSpeed = speed.x; }
/**
- * Gets the walk speed.
- * in pixels per second for eAthena,
- * in tiles per second for Manaserv (0.1 precision).
+ * Gets the walk speed in pixels per second.
*/
Vector getWalkSpeed() const A_WARN_UNUSED
{ return mWalkSpeed; }
@@ -1037,8 +1033,7 @@ class Being : public ActorSprite, public ConfigListener
/**
* Walk speed for x and y movement values.
- * In pixels per second for eAthena,
- * In pixels per ticks for Manaserv.
+ * In pixels per second.
* @see MILLISECONDS_IN_A_TICK
*/
Vector mWalkSpeed;
diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp
index 0e7f8a9b0..5d4ce123e 100644
--- a/src/being/localplayer.cpp
+++ b/src/being/localplayer.cpp
@@ -286,10 +286,6 @@ void LocalPlayer::logic()
mMessageTime--;
}
-#ifdef MANASERV_SUPPORT
- PlayerInfo::logic();
-#endif
-
if (mTarget)
{
if (mTarget->getType() == ActorSprite::NPC)
@@ -300,23 +296,10 @@ void LocalPlayer::logic()
else
{
// Find whether target is in range
-#ifdef MANASERV_SUPPORT
- const int rangeX =
- (Net::getNetworkType() == ServerInfo::MANASERV) ?
- static_cast<int>(abs(static_cast<int>(mTarget->getPosition().x
- - getPosition().x))) :
- static_cast<int>(abs(mTarget->getTileX() - getTileX()));
- const int rangeY =
- (Net::getNetworkType() == ServerInfo::MANASERV) ?
- static_cast<int>(abs(static_cast<int>(mTarget->getPosition().y
- - getPosition().y))) :
- static_cast<int>(abs(mTarget->getTileY() - getTileY()));
-#else
const int rangeX = static_cast<int>(
abs(mTarget->getTileX() - getTileX()));
const int rangeY = static_cast<int>(
abs(mTarget->getTileY() - getTileY()));
-#endif
const int attackRange = getAttackRange();
const TargetCursorType targetType = rangeX > attackRange ||
rangeY > attackRange ?
@@ -420,475 +403,58 @@ void LocalPlayer::setGMLevel(const int level)
}
}
-#ifdef MANASERV_SUPPORT
-Position LocalPlayer::getNextWalkPosition(const unsigned char dir) const
+void LocalPlayer::nextTile(unsigned char dir A_UNUSED = 0)
{
- // Compute where the next tile will be set.
- int dx = 0, dy = 0;
- if (dir & Being::UP)
- dy--;
- if (dir & Being::DOWN)
- dy++;
- if (dir & Being::LEFT)
- dx--;
- if (dir & Being::RIGHT)
- dx++;
-
- const Vector &pos = getPosition();
-
- // If no map or no direction is given, give back the current player position
- if (!mMap || (!dx && !dy))
- return Position(static_cast<int>(pos.x), static_cast<int>(pos.y));
-
- const int posX = static_cast<int>(pos.x);
- const int posY = static_cast<int>(pos.y);
- // Get the current tile pos and its offset
- const int tileX = posX / mMap->getTileWidth();
- const int tileY = posY / mMap->getTileHeight();
- const int offsetX = posX % mMap->getTileWidth();
- const int offsetY = posY % mMap->getTileHeight();
- const unsigned char walkMask = getWalkMask();
- const int radius = getCollisionRadius();
-
- // Get the walkability of every surrounding tiles.
- bool wTopLeft = mMap->getWalk(tileX - 1, tileY - 1, walkMask);
- const bool wTop = mMap->getWalk(tileX, tileY - 1, walkMask);
- bool wTopRight = mMap->getWalk(tileX + 1, tileY - 1, walkMask);
- const bool wLeft = mMap->getWalk(tileX - 1, tileY, walkMask);
- const bool wRight = mMap->getWalk(tileX + 1, tileY, walkMask);
- bool wBottomLeft = mMap->getWalk(tileX - 1, tileY + 1, walkMask);
- const bool wBottom = mMap->getWalk(tileX, tileY + 1, walkMask);
- bool wBottomRight = mMap->getWalk(tileX + 1, tileY + 1, walkMask);
-
- // Make diagonals unwalkable when both straight directions are blocking
- if (!wTop)
- {
- if (!wRight)
- wTopRight = false;
- if (!wLeft)
- wTopLeft = false;
- }
- if (!wBottom)
- {
- if (!wRight)
- wBottomRight = false;
- if (!wLeft)
- wBottomLeft = false;
- }
-
- // We'll make tests for each desired direction
-
- // Handle diagonal cases by setting the way back to a straight direction
- // when necessary.
- if (dx && dy)
+ const Party *const party = Party::getParty(1);
+ if (party)
{
- // Going top-right
- if (dx > 0 && dy < 0)
- {
- if (!wTopRight)
- {
- // Choose a straight direction when diagonal target is blocked
- if (!wTop && wRight)
- {
- dy = 0;
- }
- else if (wTop && !wRight)
- {
- dx = 0;
- }
- else if (!wTop && !wRight)
- {
- return Position(tileX * mapTileSize + mapTileSize - radius,
- tileY * mapTileSize + getCollisionRadius());
- }
- else // Both straight direction are walkable
- {
- // Go right when below the corner
- if (offsetY >= (offsetX / mMap->getTileHeight()
- - (offsetX / mMap->getTileWidth()
- * mMap->getTileHeight()) ))
- {
- dy = 0;
- }
- else // Go up otherwise
- {
- dx = 0;
- }
- }
- }
- else // The diagonal is walkable
- {
- return mMap->checkNodeOffsets(radius, walkMask,
- Position(posX + mapTileSize, posY - mapTileSize));
- }
- }
-
- // Going top-left
- if (dx < 0 && dy < 0)
- {
- if (!wTopLeft)
- {
- // Choose a straight direction when diagonal target is blocked
- if (!wTop && wLeft)
- {
- dy = 0;
- }
- else if (wTop && !wLeft)
- {
- dx = 0;
- }
- else if (!wTop && !wLeft)
- {
- return Position(tileX * mapTileSize + radius,
- tileY * mapTileSize + radius);
- }
- else // Both straight direction are walkable
- {
- // Go left when below the corner
- if (offsetY >= (offsetX / mMap->getTileWidth()
- * mMap->getTileHeight()))
- {
- dy = 0;
- }
- else // Go up otherwise
- {
- dx = 0;
- }
- }
- }
- else // The diagonal is walkable
- {
- return mMap->checkNodeOffsets(radius, walkMask,
- Position(posX - mapTileSize, posY - mapTileSize));
- }
- }
-
- // Going bottom-left
- if (dx < 0 && dy > 0)
- {
- if (!wBottomLeft)
- {
- // Choose a straight direction when diagonal target is blocked
- if (!wBottom && wLeft)
- {
- dy = 0;
- }
- else if (wBottom && !wLeft)
- {
- dx = 0;
- }
- else if (!wBottom && !wLeft)
- {
- return Position(tileX * mapTileSize + radius,
- tileY * mapTileSize + mapTileSize - radius);
- }
- else // Both straight direction are walkable
- {
- // Go down when below the corner
- if (offsetY >= (offsetX / mMap->getTileHeight()
- - (offsetX / mMap->getTileWidth()
- * mMap->getTileHeight())))
- {
- dx = 0;
- }
- else // Go left otherwise
- {
- dy = 0;
- }
- }
- }
- else // The diagonal is walkable
- {
- return mMap->checkNodeOffsets(radius, walkMask,
- Position(posX - mapTileSize, posY + mapTileSize));
- }
- }
-
- // Going bottom-right
- if (dx > 0 && dy > 0)
+ PartyMember *const pm = party->getMember(getName());
+ if (pm)
{
- if (!wBottomRight)
- {
- // Choose a straight direction when diagonal target is blocked
- if (!wBottom && wRight)
- {
- dy = 0;
- }
- else if (wBottom && !wRight)
- {
- dx = 0;
- }
- else if (!wBottom && !wRight)
- {
- return Position(tileX * mapTileSize + mapTileSize - radius,
- tileY * mapTileSize + mapTileSize - radius);
- }
- else // Both straight direction are walkable
- {
- // Go down when below the corner
- if (offsetY >= (offsetX / mMap->getTileWidth()
- * mMap->getTileHeight()))
- {
- dx = 0;
- }
- else // Go right otherwise
- {
- dy = 0;
- }
- }
- }
- else // The diagonal is walkable
- {
- return mMap->checkNodeOffsets(radius, walkMask,
- Position(posX + mapTileSize, posY + mapTileSize));
- }
+ pm->setX(mX);
+ pm->setY(mY);
}
- } // End of diagonal cases
+ }
- // Straight directions
- // Right direction
- if (dx > 0 && !dy)
+ if (mPath.empty())
{
- // If the straight destination is blocked,
- // Make the player go the closest possible.
- if (!wRight)
- {
- return Position(tileX * mapTileSize + mapTileSize - radius, posY);
- }
- else
- {
- if (!wTopRight)
- {
- // If we're going to collide with the top-right corner
- if (offsetY - radius < 0)
- {
- // We make the player corrects its offset
- // before going further
- return Position(tileX * mapTileSize + mapTileSize - radius,
- tileY * mapTileSize + radius);
- }
- }
+ if (mPickUpTarget)
+ pickUp(mPickUpTarget);
- if (!wBottomRight)
- {
- // If we're going to collide with the bottom-right corner
- if (offsetY + radius > mapTileSize)
- {
- // We make the player corrects its offset
- // before going further
- 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 + mapTileSize, posY));
- }
+ if (mWalkingDir)
+ startWalking(mWalkingDir);
}
-
- // Left direction
- if (dx < 0 && !dy)
+ else if (mPath.size() == 1)
{
- // If the straight destination is blocked,
- // Make the player go the closest possible.
- if (!wLeft)
- {
- return Position(tileX * mapTileSize + radius, posY);
- }
- else
- {
- if (!wTopLeft)
- {
- // If we're going to collide with the top-left corner
- if (offsetY - radius < 0)
- {
- // We make the player corrects its offset
- // before going further
- return Position(tileX * mapTileSize + radius,
- tileY * mapTileSize + radius);
- }
- }
-
- if (!wBottomLeft)
- {
- // If we're going to collide with the bottom-left corner
- if (offsetY + radius > mapTileSize)
- {
- // We make the player corrects its offset
- // before going further
- 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 - mapTileSize, posY));
- }
+ if (mPickUpTarget)
+ pickUp(mPickUpTarget);
}
- // Up direction
- if (!dx && dy < 0)
+ if (mGoingToTarget && mTarget && withinAttackRange(mTarget))
{
- // If the straight destination is blocked,
- // Make the player go the closest possible.
- if (!wTop)
- {
- return Position(posX, tileY * mapTileSize + radius);
- }
- else
- {
- if (!wTopLeft)
- {
- // If we're going to collide with the top-left corner
- if (offsetX - radius < 0)
- {
- // We make the player corrects its offset
- // before going further
- return Position(tileX * mapTileSize + radius,
- tileY * mapTileSize + radius);
- }
- }
-
- if (!wTopRight)
- {
- // If we're going to collide with the top-right corner
- if (offsetX + radius > mapTileSize)
- {
- // We make the player corrects its offset
- // before going further
- 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 - mapTileSize));
- }
+ mAction = Being::STAND;
+ attack(mTarget, true);
+ mGoingToTarget = false;
+ mPath.clear();
+ return;
}
-
- // Down direction
- if (!dx && dy > 0)
+ else if (mGoingToTarget && !mTarget)
{
- // If the straight destination is blocked,
- // Make the player go the closest possible.
- if (!wBottom)
- {
- return Position(posX, tileY * mapTileSize + mapTileSize - radius);
- }
- else
- {
- if (!wBottomLeft)
- {
- // If we're going to collide with the bottom-left corner
- if (offsetX - radius < 0)
- {
- // We make the player corrects its offset
- // before going further
- 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 > mapTileSize)
- {
- // We make the player corrects its offset
- // before going further
- 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 + mapTileSize));
- }
+ mGoingToTarget = false;
+ mPath.clear();
}
- // Return the current position if everything else has failed.
- return Position(posX, posY);
-}
-#endif
-
-void LocalPlayer::nextTile(unsigned char dir A_UNUSED = 0)
-{
-#ifdef MANASERV_SUPPORT
- if (Net::getNetworkType() != ServerInfo::MANASERV)
-#endif
+ if (mPath.empty())
{
- const Party *const party = Party::getParty(1);
- if (party)
- {
- PartyMember *const pm = party->getMember(getName());
- if (pm)
- {
- pm->setX(mX);
- pm->setY(mY);
- }
- }
-
- if (mPath.empty())
- {
- if (mPickUpTarget)
- pickUp(mPickUpTarget);
-
- if (mWalkingDir)
- startWalking(mWalkingDir);
- }
- else if (mPath.size() == 1)
- {
- if (mPickUpTarget)
- pickUp(mPickUpTarget);
- }
-
- if (mGoingToTarget && mTarget && withinAttackRange(mTarget))
- {
- mAction = Being::STAND;
- attack(mTarget, true);
- mGoingToTarget = false;
- mPath.clear();
- return;
- }
- else if (mGoingToTarget && !mTarget)
- {
- mGoingToTarget = false;
- mPath.clear();
- }
-
- if (mPath.empty())
- {
- if (mNavigatePath.empty() || mAction != MOVE)
- setAction(STAND);
- else
- mNextStep = true;
- }
+ if (mNavigatePath.empty() || mAction != MOVE)
+ setAction(STAND);
else
- {
- Being::nextTile();
- }
+ mNextStep = true;
}
-#ifdef MANASERV_SUPPORT
else
{
- if (!mMap || !dir)
- return;
-
- const Vector &pos = getPosition();
- const Position destination = getNextWalkPosition(dir);
-
- if (static_cast<int>(pos.x) != destination.x
- || static_cast<int>(pos.y) != destination.y)
- {
- setDestination(destination.x, destination.y);
- }
- else if (dir != mDirection)
- {
- Net::getPlayerHandler()->setDirection(dir);
- setDirection(dir);
- }
+ Being::nextTile();
}
-#endif
}
bool LocalPlayer::pickUp(FloorItem *const item)
@@ -916,29 +482,18 @@ bool LocalPlayer::pickUp(FloorItem *const item)
}
else if (mPickUpType >= 4 && mPickUpType <= 6)
{
-#ifdef MANASERV_SUPPORT
- if (Net::getNetworkType() == ServerInfo::MANASERV)
- {
- setDestination(item->getPixelX() + 16, item->getPixelY() + 16);
- mPickUpTarget = item;
- mPickUpTarget->addActorSpriteListener(this);
- }
+ const Vector &playerPos = getPosition();
+ const Path debugPath = mMap->findPath(
+ 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
-#endif
- {
- const Vector &playerPos = getPosition();
- const Path debugPath = mMap->findPath(
- 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
- setDestination(item->getTileX(), item->getTileY());
+ setDestination(item->getTileX(), item->getTileY());
- mPickUpTarget = item;
- mPickUpTarget->addActorSpriteListener(this);
- }
+ mPickUpTarget = item;
+ mPickUpTarget->addActorSpriteListener(this);
}
return true;
}
@@ -1024,17 +579,7 @@ void LocalPlayer::setDestination(const int x, const int y)
}
Being::setDestination(x, y);
-
-#ifdef MANASERV_SUPPORT
- // Manaserv:
- // If the destination given to being class is accepted,
- // we inform the Server.
- if ((x == mDest.x && y == mDest.y)
- || Net::getNetworkType() != ServerInfo::MANASERV)
-#endif
- {
- Net::getPlayerHandler()->setDestination(x, y, mDirection);
- }
+ Net::getPlayerHandler()->setDestination(x, y, mDirection);
}
}
}
@@ -1042,51 +587,11 @@ void LocalPlayer::setDestination(const int x, const int y)
void LocalPlayer::setWalkingDir(const unsigned char dir)
{
// This function is called by Game::handleInput()
-
-#ifdef MANASERV_SUPPORT
- if (Net::getNetworkType() == ServerInfo::MANASERV)
- {
- // First if player is pressing key for the direction he is already
- // going, do nothing more...
-
- // Else if he is pressing a key, and its different from what he has
- // been pressing, stop (do not send this stop to the server) and
- // start in the new direction
- if (dir && (dir != getWalkingDir()))
- stopWalking(false);
-
- // Else, he is not pressing a key,
- // and the current path hasn't been sent by mouse,
- // then, stop (sending to server).
- else if (!dir)
- {
- if (!mPathSetByMouse)
- stopWalking(true);
- return;
- }
-
- // If the delay to send another walk message to the server hasn't
- // expired, don't do anything or we could get disconnected for
- // spamming the server
- if (get_elapsed_time(mLocalWalkTime) < walkingKeyboardDelay)
- return;
- }
-#endif
-
mWalkingDir = dir;
// If we're not already walking, start walking.
if (mAction != MOVE && dir)
- {
startWalking(dir);
- }
-#ifdef MANASERV_SUPPORT
- else if (mAction == MOVE && (Net::getNetworkType()
- == ServerInfo::MANASERV))
- {
- nextTile(dir);
- }
-#endif
}
void LocalPlayer::startWalking(const unsigned char dir)
@@ -1100,18 +605,7 @@ void LocalPlayer::startWalking(const unsigned char dir)
if (mAction == MOVE && !mPath.empty())
{
// Just finish the current action, otherwise we get out of sync
-#ifdef MANASERV_SUPPORT
- if (Net::getNetworkType() == ServerInfo::MANASERV)
- {
- const Vector &pos = getPosition();
- Being::setDestination(static_cast<int>(pos.x),
- static_cast<int>(pos.y));
- }
- else
-#endif
- {
- Being::setDestination(mX, mY);
- }
+ Being::setDestination(mX, mY);
return;
}
@@ -1125,43 +619,32 @@ void LocalPlayer::startWalking(const unsigned char dir)
if (dir & RIGHT)
dx++;
-#ifdef MANASERV_SUPPORT
- if (Net::getNetworkType() != ServerInfo::MANASERV)
-#endif
- {
- const unsigned char walkMask = getWalkMask();
- // Prevent skipping corners over colliding tiles
- if (dx && !mMap->getWalk(mX + dx, mY, walkMask))
- dx = 0;
- if (dy && !mMap->getWalk(mX, mY + dy, walkMask))
- dy = 0;
+ const unsigned char walkMask = getWalkMask();
+ // Prevent skipping corners over colliding tiles
+ if (dx && !mMap->getWalk(mX + dx, mY, walkMask))
+ dx = 0;
+ if (dy && !mMap->getWalk(mX, mY + dy, walkMask))
+ dy = 0;
- // Choose a straight direction when diagonal target is blocked
- if (dx && dy && !mMap->getWalk(mX + dx, mY + dy, walkMask))
- dx = 0;
+ // Choose a straight direction when diagonal target is blocked
+ if (dx && dy && !mMap->getWalk(mX + dx, mY + dy, walkMask))
+ dx = 0;
- // Walk to where the player can actually go
- if ((dx || dy) && mMap->getWalk(mX + dx, mY + dy, walkMask))
- {
- setDestination(mX + dx, mY + dy);
- }
- else if (dir != mDirection)
- {
- // If the being can't move, just change direction
+ // Walk to where the player can actually go
+ if ((dx || dy) && mMap->getWalk(mX + dx, mY + dy, walkMask))
+ {
+ setDestination(mX + dx, mY + dy);
+ }
+ else if (dir != mDirection)
+ {
+ // If the being can't move, just change direction
// if (client->limitPackets(PACKET_DIRECTION))
- {
- Net::getPlayerHandler()->setDirection(dir);
- setDirection(dir);
- }
+ {
+ Net::getPlayerHandler()->setDirection(dir);
+ setDirection(dir);
}
}
-#ifdef MANASERV_SUPPORT
- else
- {
- nextTile(dir);
- }
-#endif
}
void LocalPlayer::stopWalking(const bool sendToServer)
@@ -1238,18 +721,6 @@ bool LocalPlayer::emote(const uint8_t emotion)
void LocalPlayer::attack(Being *const target, const bool keep,
const bool dontChangeEquipment)
{
-#ifdef MANASERV_SUPPORT
- if (Net::getNetworkType() == ServerInfo::MANASERV)
- {
- if (mLastAction != -1)
- return;
-
- // Can only attack when standing still
- if (mAction != STAND && mAction != ATTACK)
- return;
- }
-#endif
-
mKeepAttacking = keep;
if (!target || target->getType() == ActorSprite::NPC)
@@ -1258,59 +729,30 @@ void LocalPlayer::attack(Being *const target, const bool keep,
if (mTarget != target)
setTarget(target);
-#ifdef MANASERV_SUPPORT
- if (Net::getNetworkType() == ServerInfo::MANASERV)
- {
- const Vector &plaPos = this->getPosition();
- const Vector &tarPos = mTarget->getPosition();
- const int dist_x = static_cast<int>(plaPos.x - tarPos.x);
- const int dist_y = static_cast<int>(plaPos.y - tarPos.y);
+ const int dist_x = target->getTileX() - mX;
+ const int dist_y = target->getTileY() - mY;
- if (abs(dist_y) >= abs(dist_x))
- {
- if (dist_y < 0)
- setDirection(DOWN);
- else
- setDirection(UP);
- }
- else
- {
- if (dist_x < 0)
- setDirection(RIGHT);
- else
- setDirection(LEFT);
- }
+ // Must be standing or sitting to attack
+ if (mAction != STAND && mAction != SIT)
+ return;
- mLastAction = tick_time;
+ if (abs(dist_y) >= abs(dist_x))
+ {
+ if (dist_y > 0)
+ setDirection(DOWN);
+ else
+ setDirection(UP);
}
else
-#endif
{
- const int dist_x = target->getTileX() - mX;
- const int dist_y = target->getTileY() - mY;
-
- // Must be standing or sitting to attack
- if (mAction != STAND && mAction != SIT)
- return;
-
- if (abs(dist_y) >= abs(dist_x))
- {
- if (dist_y > 0)
- setDirection(DOWN);
- else
- setDirection(UP);
- }
+ if (dist_x > 0)
+ setDirection(RIGHT);
else
- {
- if (dist_x > 0)
- setDirection(RIGHT);
- else
- setDirection(LEFT);
- }
-
- mActionTime = tick_time;
+ setDirection(LEFT);
}
+ mActionTime = tick_time;
+
if (target->getType() != Being::PLAYER || checAttackPermissions(target))
{
setAction(ATTACK);
@@ -1324,11 +766,7 @@ void LocalPlayer::attack(Being *const target, const bool keep,
Net::getPlayerHandler()->attack(target->getId(), mServerAttack);
}
-#ifdef MANASERV_SUPPORT
- if ((Net::getNetworkType() != ServerInfo::MANASERV) && !keep)
-#else
if (!keep)
-#endif
stopAttack();
}
@@ -1476,20 +914,8 @@ bool LocalPlayer::withinAttackRange(const Being *const target,
if (fixDistance && range == 1)
range = 2;
-#ifdef MANASERV_SUPPORT
- if (Net::getNetworkType() == ServerInfo::MANASERV)
- {
- const Vector &targetPos = target->getPosition();
- const Vector &pos = getPosition();
- dx = static_cast<int>(abs(static_cast<int>(targetPos.x - pos.x)));
- dy = static_cast<int>(abs(static_cast<int>(targetPos.y - pos.y)));
- }
- else
-#endif
- {
- dx = static_cast<int>(abs(target->getTileX() - mX));
- dy = static_cast<int>(abs(target->getTileY() - mY));
- }
+ dx = static_cast<int>(abs(target->getTileX() - mX));
+ dy = static_cast<int>(abs(target->getTileY() - mY));
return !(dx > range || dy > range);
}
@@ -1499,22 +925,9 @@ void LocalPlayer::setGotoTarget(Being *const target)
return;
mPickUpTarget = nullptr;
-#ifdef MANASERV_SUPPORT
- if (Net::getNetworkType() == ServerInfo::MANASERV)
- {
- mTarget = target;
- mGoingToTarget = true;
- const Vector &targetPos = target->getPosition();
- setDestination(static_cast<int>(targetPos.x),
- static_cast<int>(targetPos.y));
- }
- else
-#endif
- {
- setTarget(target);
- mGoingToTarget = true;
- setDestination(target->getTileX(), target->getTileY());
- }
+ setTarget(target);
+ mGoingToTarget = true;
+ setDestination(target->getTileX(), target->getTileY());
}
void LocalPlayer::handleStatusEffect(StatusEffect *const effect,
@@ -3192,16 +2605,6 @@ bool LocalPlayer::pickUpItems(int pickUpType)
void LocalPlayer::moveByDirection(const unsigned char dir)
{
int dx = 0, dy = 0;
-#ifdef MANASERV_SUPPORT
- if (dir & UP)
- dy -= mapTileSize;
- if (dir & DOWN)
- dy += mapTileSize;
- if (dir & LEFT)
- dx -= mapTileSize;
- if (dir & RIGHT)
- dx += mapTileSize;
-#else
if (dir & UP)
dy--;
if (dir & DOWN)
@@ -3210,8 +2613,6 @@ void LocalPlayer::moveByDirection(const unsigned char dir)
dx--;
if (dir & RIGHT)
dx++;
-#endif
-
move(dx, dy);
}
diff --git a/src/being/playerinfo.cpp b/src/being/playerinfo.cpp
index c9b10b4a6..728fe786f 100644
--- a/src/being/playerinfo.cpp
+++ b/src/being/playerinfo.cpp
@@ -48,11 +48,6 @@ int mCharId = 0;
Inventory *mInventory = nullptr;
Equipment *mEquipment = nullptr;
-#ifdef MANASERV_SUPPORT
-std::map<int, Special> mSpecials;
-signed char mSpecialRechargeUpdateNeeded = 0;
-#endif
-
bool mTrading = false;
int mLevelProgress = 0;
std::set<int> mProtectedItems;
@@ -365,20 +360,6 @@ int getCharId()
void logic()
{
-#ifdef MANASERV_SUPPORT
- if ((mSpecialRechargeUpdateNeeded % 11) == 0)
- {
- mSpecialRechargeUpdateNeeded = 0;
- FOR_EACH (SpecialsMap::iterator, it, mSpecials)
- {
- Special &special = it->second;
- special.currentMana += special.recharge;
- if (special.currentMana > special.neededMana)
- special.currentMana = special.neededMana;
- }
- }
- mSpecialRechargeUpdateNeeded++;
-#endif
}
bool isTrading()