summaryrefslogtreecommitdiff
path: root/src/gui/viewport.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/viewport.cpp')
-rw-r--r--src/gui/viewport.cpp70
1 files changed, 56 insertions, 14 deletions
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index cd94a52d..1c0959d7 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -259,30 +259,72 @@ void Viewport::_drawDebugPath(Graphics *graphics)
// Get the current mouse position
SDL_GetMouseState(&mMouseX, &mMouseY);
- const int mouseTileX = (mMouseX + (int) mPixelViewX) / 32;
- const int mouseTileY = (mMouseY + (int) mPixelViewY) / 32;
- const Vector &playerPos = player_node->getPosition();
+ Path debugPath;
+
+ if (Net::getNetworkType() == ServerInfo::EATHENA)
+ {
+ const int mouseTileX = (mMouseX + (int) mPixelViewX) / 32;
+ const int mouseTileY = (mMouseY + (int) mPixelViewY) / 32;
+ const Vector &playerPos = player_node->getPosition();
- Path debugPath = mMap->findPath(
+ debugPath = mMap->findPath(
(int) (playerPos.x - 16) / 32,
(int) (playerPos.y - 32) / 32,
mouseTileX, mouseTileY, 0xFF);
- _drawPath(graphics, debugPath);
+ _drawPath(graphics, debugPath);
+ }
+ else if (Net::getNetworkType() == ServerInfo::MANASERV)
+ {
+ const Vector &playerPos = player_node->getPosition();
+
+ debugPath = mMap->findPixelPath(
+ (int) playerPos.x,
+ (int) playerPos.y,
+ mMouseX + (int) mPixelViewX,
+ mMouseY + (int) mPixelViewY,
+ player_node->getWidth() / 2, 0xFF);
+
+ // We draw the path proposed by mouse
+ _drawPath(graphics, debugPath, gcn::Color(255, 0, 255));
+
+ // But also the one currently walked on.
+ _drawPath(graphics, player_node->getPath(), gcn::Color(0, 0, 255));
+ }
}
-void Viewport::_drawPath(Graphics *graphics, const Path &path)
+void Viewport::_drawPath(Graphics *graphics, const Path &path,
+ gcn::Color color)
{
- graphics->setColor(gcn::Color(255, 0, 0));
- for (Path::const_iterator i = path.begin(); i != path.end(); ++i)
+ graphics->setColor(color);
+
+ if (Net::getNetworkType() == ServerInfo::EATHENA)
+ {
+ for (Path::const_iterator i = path.begin(); i != path.end(); ++i)
+ {
+ int squareX = i->x * 32 - (int) mPixelViewX + 12;
+ int squareY = i->y * 32 - (int) mPixelViewY + 12;
+
+ graphics->fillRectangle(gcn::Rectangle(squareX, squareY, 8, 8));
+ graphics->drawText(
+ toString(mMap->getMetaTile(i->x, i->y)->Gcost),
+ squareX + 4, squareY + 12, gcn::Graphics::CENTER);
+ }
+ }
+ else if (Net::getNetworkType() == ServerInfo::MANASERV)
{
- int squareX = i->x * 32 - (int) mPixelViewX + 12;
- int squareY = i->y * 32 - (int) mPixelViewY + 12;
+ for (Path::const_iterator i = path.begin(); i != path.end(); ++i)
+ {
+ int squareX = i->x - (int) mPixelViewX;
+ int squareY = i->y - (int) mPixelViewY;
+
+ graphics->fillRectangle(gcn::Rectangle(squareX - 4, squareY - 4,
+ 8, 8));
+ graphics->drawText(
+ toString(mMap->getMetaTile(i->x / 32, i->y / 32)->Gcost),
+ squareX + 4, squareY + 12, gcn::Graphics::CENTER);
+ }
- graphics->fillRectangle(gcn::Rectangle(squareX, squareY, 8, 8));
- graphics->drawText(
- toString(mMap->getMetaTile(i->x, i->y)->Gcost),
- squareX + 4, squareY + 12, gcn::Graphics::CENTER);
}
}