summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Dombrowski <stefan@uni-bonn.de>2010-10-03 22:53:09 +0200
committerStefan Dombrowski <stefan@uni-bonn.de>2010-10-03 22:53:09 +0200
commit671ae4cd0e26618c0662123d4b9c0d1c63acb4f6 (patch)
tree4f1c89f92838e2f2468eaf06a1306d7bb1b66c0d
parente6acf6e2f17b4177f3f8292f52d83b46822ab9c5 (diff)
downloadmana-client-671ae4cd0e26618c0662123d4b9c0d1c63acb4f6.tar.gz
mana-client-671ae4cd0e26618c0662123d4b9c0d1c63acb4f6.tar.bz2
mana-client-671ae4cd0e26618c0662123d4b9c0d1c63acb4f6.tar.xz
mana-client-671ae4cd0e26618c0662123d4b9c0d1c63acb4f6.zip
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
-rw-r--r--src/gui/viewport.cpp13
-rw-r--r--src/gui/viewport.h5
2 files changed, 18 insertions, 0 deletions
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())
diff --git a/src/gui/viewport.h b/src/gui/viewport.h
index 9658f934..616b88be 100644
--- a/src/gui/viewport.h
+++ b/src/gui/viewport.h
@@ -182,6 +182,11 @@ class Viewport : public WindowContainer, public gcn::MouseListener,
*/
void _followMouse();
+ /**
+ * Updates the cursor type
+ */
+ void updateCursorType();
+
Map *mMap; /**< The current map. */
int mScrollRadius;