summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBertram <bertram@cegetel.net>2010-03-02 23:55:54 +0100
committerBertram <yohanndotferreiraatorange.fr>2010-04-12 23:50:22 +0200
commite87a2a533eb892c6e8b00cc483eed7c69032bf7a (patch)
tree9bbf3f6c7137dbe8246ea3453934e6b1f75bc4dc
parentdd2b559ea0d467db7fec522a63a66a82c1415b36 (diff)
downloadmana-e87a2a533eb892c6e8b00cc483eed7c69032bf7a.tar.gz
mana-e87a2a533eb892c6e8b00cc483eed7c69032bf7a.tar.bz2
mana-e87a2a533eb892c6e8b00cc483eed7c69032bf7a.tar.xz
mana-e87a2a533eb892c6e8b00cc483eed7c69032bf7a.zip
Added a more trusty path debug view for ManaServ.
-rw-r--r--src/gui/viewport.cpp70
-rw-r--r--src/gui/viewport.h3
2 files changed, 58 insertions, 15 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);
}
}
diff --git a/src/gui/viewport.h b/src/gui/viewport.h
index e67cc6d3..9658f934 100644
--- a/src/gui/viewport.h
+++ b/src/gui/viewport.h
@@ -174,7 +174,8 @@ class Viewport : public WindowContainer, public gcn::MouseListener,
/**
* Draws the given path.
*/
- void _drawPath(Graphics *graphics, const Path &path);
+ void _drawPath(Graphics *graphics, const Path &path,
+ gcn::Color color = gcn::Color(255, 0, 0));
/**
* Make the player go to the mouse position.