From 671ae4cd0e26618c0662123d4b9c0d1c63acb4f6 Mon Sep 17 00:00:00 2001 From: Stefan Dombrowski Date: Sun, 3 Oct 2010 22:53:09 +0200 Subject: Fixing segmentation fault and updating the cursor type after mouse press Until now the being was only set after a mouse move. If the mouse was pressed after the being was out of sight or dead, then a segmentation fault happened. Furthermore, pressing the mouse now updates the cursor type and sets the being popup invisible. Reviewed-by: Thorbjorn --- src/gui/viewport.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/gui/viewport.cpp') diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 99325db8..ce506ba1 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -349,10 +349,18 @@ void Viewport::mousePressed(gcn::MouseEvent &event) return; mPlayerFollowMouse = false; + mBeingPopup->setVisible(false); const int pixelX = event.getX() + (int) mPixelViewX; const int pixelY = event.getY() + (int) mPixelViewY; + mHoverBeing = beingManager->findBeingByPixel(pixelX, pixelY); + mHoverItem = floorItemManager-> + findByCoordinates(pixelX / mMap->getTileWidth(), + pixelY / mMap->getTileHeight()); + + updateCursorType(); + // Right click might open a popup if (event.getButton() == gcn::MouseEvent::RIGHT) { @@ -517,6 +525,11 @@ void Viewport::mouseMoved(gcn::MouseEvent &event) mHoverItem = floorItemManager->findByCoordinates(x / mMap->getTileWidth(), y / mMap->getTileHeight()); + updateCursorType(); +} + +void Viewport::updateCursorType() +{ if (mHoverBeing) { switch (mHoverBeing->getType()) -- cgit v1.2.3-70-g09d2