summaryrefslogtreecommitdiff
path: root/src/gui/viewport.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-02-27 13:25:41 +0300
committerAndrei Karas <akaras@inbox.ru>2014-02-27 13:25:41 +0300
commitc61f1b6abe8e68995f00ae3a939afe5049e5cdb3 (patch)
treec50613a2c7722fba4aba9d5a67949b118a279b33 /src/gui/viewport.cpp
parentb481cd74dfd1629ca7b045cde57562e752c49638 (diff)
downloadmv-c61f1b6abe8e68995f00ae3a939afe5049e5cdb3.tar.gz
mv-c61f1b6abe8e68995f00ae3a939afe5049e5cdb3.tar.bz2
mv-c61f1b6abe8e68995f00ae3a939afe5049e5cdb3.tar.xz
mv-c61f1b6abe8e68995f00ae3a939afe5049e5cdb3.zip
Remove manaserv ifdefs code.
ManaServ was already depricated long ago.
Diffstat (limited to 'src/gui/viewport.cpp')
-rw-r--r--src/gui/viewport.cpp242
1 files changed, 100 insertions, 142 deletions
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index 500378628..96760f8c7 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -343,46 +343,21 @@ void Viewport::_drawPath(Graphics *const graphics, const Path &path,
graphics->setColor(color);
Font *const font = getFont();
-#ifdef MANASERV_SUPPORT
- if (Net::getNetworkType() != ServerInfo::MANASERV)
-#endif
+ int cnt = 1;
+ FOR_EACH (Path::const_iterator, i, path)
{
- int cnt = 1;
- FOR_EACH (Path::const_iterator, i, path)
- {
- const int squareX = i->x * mapTileSize - mPixelViewX + 12;
- const int squareY = i->y * mapTileSize - mPixelViewY + 12;
+ const int squareX = i->x * mapTileSize - mPixelViewX + 12;
+ const int squareY = i->y * mapTileSize - mPixelViewY + 12;
- graphics->fillRectangle(Rect(squareX, squareY, 8, 8));
- if (mMap)
- {
- const std::string str = toString(cnt);
- font->drawString(graphics, str, squareX + 4
- - font->getWidth(str) / 2, squareY + 12);
- }
- cnt ++;
- }
- }
-#ifdef MANASERV_SUPPORT
- else if (Net::getNetworkType() == ServerInfo::MANASERV)
- {
- FOR_EACH (Path::const_iterator, i, path)
+ graphics->fillRectangle(Rect(squareX, squareY, 8, 8));
+ if (mMap)
{
- const int squareX = i->x - mPixelViewX;
- const int squareY = i->y - mPixelViewY;
-
- graphics->fillRectangle(Rect(
- squareX - 4, squareY - 4, 8, 8));
- if (mMap)
- {
- const std::string str = toString(mMap->getMetaTile(
- i->x / mapTileSize, i->y / mapTileSize)->Gcost);
- font->drawString(graphics, str,
- squareX + 4 - font->getWidth(text) / 2, squareY + 12);
- }
+ const std::string str = toString(cnt);
+ font->drawString(graphics, str, squareX + 4
+ - font->getWidth(str) / 2, squareY + 12);
}
+ cnt ++;
}
-#endif
}
void Viewport::mousePressed(MouseEvent &event)
@@ -557,127 +532,111 @@ void Viewport::mouseDragged(MouseEvent &event)
Input::KEY_STOP_ATTACK) && !inputManager.isActionActive(
Input::KEY_UNTARGET))
{
-#ifdef MANASERV_SUPPORT
- if (Net::getNetworkType() == ServerInfo::MANASERV)
- {
- if (get_elapsed_time(mLocalWalkTime) >= walkingMouseDelay)
- {
- mLocalWalkTime = tick_time;
- player_node->unSetPickUpTarget();
- player_node->setDestination(event.getX() + mPixelViewX,
- event.getY() + mPixelViewY);
- player_node->pathSetByMouse();
- }
- }
- else
-#endif
+ if (mLocalWalkTime != player_node->getActionTime())
{
- if (mLocalWalkTime != player_node->getActionTime())
+ mLocalWalkTime = cur_time;
+ player_node->unSetPickUpTarget();
+ int playerX = player_node->getTileX();
+ int playerY = player_node->getTileY();
+ if (mMouseDirectionMove)
{
- mLocalWalkTime = cur_time;
- player_node->unSetPickUpTarget();
- int playerX = player_node->getTileX();
- int playerY = player_node->getTileY();
- if (mMouseDirectionMove)
+ const int width = mainGraphics->mWidth / 2;
+ const int height = mainGraphics->mHeight / 2;
+ const float wh = static_cast<float>(width)
+ / static_cast<float>(height);
+ int x = event.getX() - width;
+ int y = event.getY() - height;
+ if (!x && !y)
+ return;
+ const int x2 = abs(x);
+ const int y2 = abs(y);
+ const float diff = 2;
+ int dx = 0;
+ int dy = 0;
+ if (x2 > y2)
{
- const int width = mainGraphics->mWidth / 2;
- const int height = mainGraphics->mHeight / 2;
- const float wh = static_cast<float>(width)
- / static_cast<float>(height);
- int x = event.getX() - width;
- int y = event.getY() - height;
- if (!x && !y)
- return;
- const int x2 = abs(x);
- const int y2 = abs(y);
- const float diff = 2;
- int dx = 0;
- int dy = 0;
- if (x2 > y2)
- {
- if (y2 && x2 / y2 / wh > diff)
- y = 0;
- }
- else
- {
- if (x2 && y2 * wh / x2 > diff)
- x = 0;
- }
- if (x > 0)
- dx = 1;
- else if (x < 0)
- dx = -1;
- if (y > 0)
- dy = 1;
- else if (y < 0)
- dy = -1;
-
- if (mMap->getWalk(playerX + dx, playerY + dy))
+ if (y2 && x2 / y2 / wh > diff)
+ y = 0;
+ }
+ else
+ {
+ if (x2 && y2 * wh / x2 > diff)
+ x = 0;
+ }
+ if (x > 0)
+ dx = 1;
+ else if (x < 0)
+ dx = -1;
+ if (y > 0)
+ dy = 1;
+ else if (y < 0)
+ dy = -1;
+
+ if (mMap->getWalk(playerX + dx, playerY + dy))
+ {
+ player_node->navigateTo(playerX + dx, playerY + dy);
+ }
+ else
+ {
+ if (dx && dy)
{
- player_node->navigateTo(playerX + dx, playerY + dy);
+ // try avoid diagonal collision
+ if (x2 > y2)
+ {
+ if (mMap->getWalk(playerX + dx, playerY))
+ dy = 0;
+ else
+ dx = 0;
+ }
+ else
+ {
+ if (mMap->getWalk(playerX, playerY + dy))
+ dx = 0;
+ else
+ dy = 0;
+ }
}
else
{
- if (dx && dy)
+ // try avoid vertical or horisontal collision
+ if (!dx)
{
- // try avoid diagonal collision
- if (x2 > y2)
- {
- if (mMap->getWalk(playerX + dx, playerY))
- dy = 0;
- else
- dx = 0;
- }
- else
- {
- if (mMap->getWalk(playerX, playerY + dy))
- dx = 0;
- else
- dy = 0;
- }
+ if (mMap->getWalk(playerX + 1, playerY + dy))
+ dx = 1;
+ if (mMap->getWalk(playerX - 1, playerY + dy))
+ dx = -1;
}
- else
+ if (!dy)
{
- // try avoid vertical or horisontal collision
- if (!dx)
- {
- if (mMap->getWalk(playerX + 1, playerY + dy))
- dx = 1;
- if (mMap->getWalk(playerX - 1, playerY + dy))
- dx = -1;
- }
- if (!dy)
- {
- if (mMap->getWalk(playerX + dx, playerY + 1))
- dy = 1;
- if (mMap->getWalk(playerX + dx, playerY - 1))
- dy = -1;
- }
+ if (mMap->getWalk(playerX + dx, playerY + 1))
+ dy = 1;
+ if (mMap->getWalk(playerX + dx, playerY - 1))
+ dy = -1;
}
- player_node->navigateTo(playerX + dx, playerY + dy);
}
+ player_node->navigateTo(playerX + dx, playerY + dy);
}
- else
+ }
+ else
+ {
+ const int destX = (event.getX() + mPixelViewX)
+ / static_cast<float>(mMap->getTileWidth());
+ const int destY = (event.getY() + mPixelViewY)
+ / static_cast<float>(mMap->getTileHeight());
+ if (playerX != destX || playerY != destY)
{
- const int destX = (event.getX() + mPixelViewX)
- / static_cast<float>(mMap->getTileWidth());
- const int destY = (event.getY() + mPixelViewY)
- / static_cast<float>(mMap->getTileHeight());
- if (playerX != destX || playerY != destY)
+ if (!player_node->navigateTo(destX, destY))
{
- if (!player_node->navigateTo(destX, destY))
- {
- if (playerX > destX)
- playerX --;
- else if (playerX < destX)
- playerX ++;
- if (playerY > destY)
- playerY --;
- else if (playerY < destY)
- playerY ++;
- if (mMap->getWalk(playerX, playerY, 0))
- player_node->navigateTo(playerX, playerY);
- }
+ if (playerX > destX)
+ playerX --;
+ else if (playerX < destX)
+ playerX ++;
+ if (playerY > destY)
+ playerY --;
+ else if (playerY < destY)
+ playerY ++;
+ if (mMap->getWalk(playerX, playerY, 0))
+ player_node->navigateTo(playerX, playerY);
}
}
}
@@ -688,7 +647,6 @@ void Viewport::mouseDragged(MouseEvent &event)
void Viewport::mouseReleased(MouseEvent &event A_UNUSED)
{
mPlayerFollowMouse = false;
- // Only useful for eAthena but doesn't hurt under ManaServ
mLocalWalkTime = -1;
}