diff options
author | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2010-01-18 09:14:36 +0100 |
---|---|---|
committer | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2010-01-18 09:14:36 +0100 |
commit | b823889f1747bbceb61273f7a7383580c4b034e3 (patch) | |
tree | e86c37728c0fdd991ed18f101092c07b03b7e918 /src/gui/viewport.cpp | |
parent | 6eb2e01ef6943e4f8ef7cc32ec325e3c22b1f5ec (diff) | |
download | mana-b823889f1747bbceb61273f7a7383580c4b034e3.tar.gz mana-b823889f1747bbceb61273f7a7383580c4b034e3.tar.bz2 mana-b823889f1747bbceb61273f7a7383580c4b034e3.tar.xz mana-b823889f1747bbceb61273f7a7383580c4b034e3.zip |
Unified BeingManager::findNearestLivingBeing for eAthena and manaserv
It now always works with pixels.
Diffstat (limited to 'src/gui/viewport.cpp')
-rw-r--r-- | src/gui/viewport.cpp | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index ec8cf341..db995ab0 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -307,10 +307,10 @@ void Viewport::mousePressed(gcn::MouseEvent &event) mPlayerFollowMouse = false; - const int pixelx = event.getX() + (int) mPixelViewX; - const int pixely = event.getY() + (int) mPixelViewY; - const int tilex = pixelx / mMap->getTileWidth(); - const int tiley = pixely / mMap->getTileHeight(); + const int pixelX = event.getX() + (int) mPixelViewX; + const int pixelY = event.getY() + (int) mPixelViewY; + const int tileX = pixelX / mMap->getTileWidth(); + const int tileY = pixelY / mMap->getTileHeight(); // Right click might open a popup if (event.getButton() == gcn::MouseEvent::RIGHT) @@ -318,14 +318,14 @@ void Viewport::mousePressed(gcn::MouseEvent &event) Being *being; FloorItem *floorItem; - if ((being = beingManager->findBeingByPixel(pixelx, pixely)) && + if ((being = beingManager->findBeingByPixel(pixelX, pixelY)) && being != player_node) { mPopupMenu->showPopup(event.getX(), event.getY(), being); return; } - else if ((floorItem = floorItemManager->findByCoordinates(tilex, - tiley))) + else if ((floorItem = floorItemManager->findByCoordinates(tileX, + tileY))) { mPopupMenu->showPopup(event.getX(), event.getY(), floorItem); return; @@ -346,7 +346,7 @@ void Viewport::mousePressed(gcn::MouseEvent &event) Being *being; // Interact with some being - if ((being = beingManager->findBeingByPixel(pixelx, pixely))) + if ((being = beingManager->findBeingByPixel(pixelX, pixelY))) { switch (being->getType()) { @@ -378,7 +378,7 @@ void Viewport::mousePressed(gcn::MouseEvent &event) } // Picks up a item if we clicked on one } - else if ((item = floorItemManager->findByCoordinates(tilex, tiley))) + else if ((item = floorItemManager->findByCoordinates(tileX, tileY))) { player_node->pickUp(item); } @@ -401,8 +401,7 @@ void Viewport::mousePressed(gcn::MouseEvent &event) { // Find the being nearest to the clicked position Being *target = beingManager->findNearestLivingBeing( - tilex, tiley, - 20, Being::MONSTER); + pixelX, pixelY, 20, Being::MONSTER); if (target) player_node->setTarget(target); |