From dc13551309d1ae1b56c94bab4c05f5ebe0ca67de Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 5 May 2011 02:37:08 +0300 Subject: Fix debug path drawing after previous commit. Draw path with color from settings. Remove unneeded debug lines/fills. --- src/gui/viewport.cpp | 63 ++++++++++++++++------------------------------------ 1 file changed, 19 insertions(+), 44 deletions(-) (limited to 'src') diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index ba40adfc5..b064419ac 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -286,42 +286,37 @@ void Viewport::_followMouse() void Viewport::_drawDebugPath(Graphics *graphics) { + if (!player_node || !userPalette || !actorSpriteManager) + return; + // Get the current mouse position SDL_GetMouseState(&mMouseX, &mMouseY); // Prepare the walkmask corresponding to the protocol - unsigned char walkMask = 0; - switch (Net::getNetworkType()) - { - case ServerInfo::TMWATHENA: - walkMask = Map::BLOCKMASK_WALL | Map::BLOCKMASK_CHARACTER; - break; - case ServerInfo::MANASERV: - default: - walkMask = Map::BLOCKMASK_WALL; - break; - } + unsigned char walkMask = Map::BLOCKMASK_WALL; static Path debugPath; static Vector lastMouseDestination = Vector(0.0f, 0.0f); - Vector mouseDestination(mMouseX + (int) mPixelViewX, - mMouseY + (int) mPixelViewY); + const int mousePosX = mMouseX + static_cast(mPixelViewX); + const int mousePosY = mMouseY + static_cast(mPixelViewY); + Vector mouseDestination(mousePosX, mousePosY); if (mouseDestination.x != lastMouseDestination.x || mouseDestination.y != lastMouseDestination.y) { const Vector &playerPos = player_node->getPosition(); - debugPath = mMap->findPath((int) playerPos.x, - (int) playerPos.y, - mouseDestination.x, - mouseDestination.y, - walkMask); + debugPath = mMap->findPath( + static_cast(playerPos.x - 16) / 32, + static_cast(playerPos.y - 32) / 32, + mousePosX / 32, mousePosY / 32, 0, 500); + lastMouseDestination = mouseDestination; } + _drawPath(graphics, debugPath, userPalette->getColorWithAlpha( + UserPalette::ROAD_POINT)); // We draw the path proposed by mouse - _drawPath(graphics, debugPath, gcn::Color(128, 0, 128, 150)); // Draw the path debug information for every beings. ActorSpritesConstIterator it, it_end; @@ -329,36 +324,14 @@ void Viewport::_drawDebugPath(Graphics *graphics) for (it = actors.begin(), it_end = actors.end() ; it != it_end; it++) { Being *being = dynamic_cast(*it); - if (being) + if (being && being != player_node) { const Vector &beingPos = being->getPosition(); int radius = being->getCollisionRadius(); Path beingPath = being->getPath(); - // Draw being collision rectangle - graphics->setColor(gcn::Color(128, 128, 0, 150)); - graphics->fillRectangle(gcn::Rectangle( - (int) beingPos.x - - (int) mPixelViewX - radius, - (int) beingPos.y - (int) mPixelViewY - - radius, - radius * 2, radius * 2)); - - _drawPath(graphics, - beingPath, - gcn::Color(0, 0, 255, 150)); - - // Draw also the absolute x, y position using a cross. - graphics->setColor(gcn::Color(0, 0, 255, 255)); - graphics->drawLine((int) beingPos.x - (int) mPixelViewX - 4, - (int) beingPos.y - (int) mPixelViewY - 4, - (int) beingPos.x - (int) mPixelViewX + 4, - (int) beingPos.y - (int) mPixelViewY + 4); - graphics->drawLine((int) beingPos.x - (int) mPixelViewX + 4, - (int) beingPos.y - (int) mPixelViewY - 4, - (int) beingPos.x - (int) mPixelViewX - 4, - (int) beingPos.y - (int) mPixelViewY + 4); - + _drawPath(graphics, beingPath, userPalette->getColorWithAlpha( + UserPalette::ROAD_POINT)); } } } @@ -368,7 +341,9 @@ void Viewport::_drawPath(Graphics *graphics, const Path &path, { graphics->setColor(color); +#ifdef MANASERV_SUPPORT if (Net::getNetworkType() == ServerInfo::TMWATHENA) +#endif { for (Path::const_iterator i = path.begin(); i != path.end(); ++i) { -- cgit v1.2.3-60-g2f50