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 From 94218cc8e93ed7087c4036312fb469d0070802e3 Mon Sep 17 00:00:00 2001 From: Stefan Dombrowski Date: Wed, 6 Oct 2010 16:06:49 +0200 Subject: Fixing movement with the mouse When a player clicked on a tile in order to go to it, then he went to the wrong tile. Trivial fix. --- src/gui/viewport.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/gui/viewport.cpp') diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index ce506ba1..0b7cc0f8 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -471,10 +471,8 @@ void Viewport::mouseDragged(gcn::MouseEvent &event) if (mLocalWalkTime != player_node->getWalkTime()) { mLocalWalkTime = player_node->getWalkTime(); - int destX = (event.getX() + mPixelViewX + 16) / - mMap->getTileWidth(); - int destY = (event.getY() + mPixelViewY + 16) / - mMap->getTileHeight(); + int destX = (event.getX() + mPixelViewX) / mMap->getTileWidth(); + int destY = (event.getY() + mPixelViewY) / mMap->getTileHeight(); player_node->setDestination(destX, destY); } } -- cgit v1.2.3-70-g09d2 From 574bd5fa1ee45a7452d2e85941fa33f946b63eae Mon Sep 17 00:00:00 2001 From: Stefan Dombrowski Date: Fri, 8 Oct 2010 23:19:12 +0200 Subject: Remove the following system Removed due to unresolved social issues. In master it had been already removed by Kage in commit 89f192b9039f9c000515f0a12f4bb9fb55c4691c. --- src/game.cpp | 4 ---- src/gui/popupmenu.cpp | 9 --------- src/gui/viewport.cpp | 1 - src/localplayer.cpp | 2 -- src/localplayer.h | 28 ---------------------------- src/net/tmwa/beinghandler.cpp | 21 --------------------- 6 files changed, 65 deletions(-) (limited to 'src/gui/viewport.cpp') diff --git a/src/game.cpp b/src/game.cpp index 8e856dc0..66b6e3c4 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -778,26 +778,22 @@ void Game::handleInput() (joystick && joystick->isUp())) { direction |= Being::UP; - player_node->cancelFollow(); } else if (keyboard.isKeyActive(keyboard.KEY_MOVE_DOWN) || (joystick && joystick->isDown())) { direction |= Being::DOWN; - player_node->cancelFollow(); } if (keyboard.isKeyActive(keyboard.KEY_MOVE_LEFT) || (joystick && joystick->isLeft())) { direction |= Being::LEFT; - player_node->cancelFollow(); } else if (keyboard.isKeyActive(keyboard.KEY_MOVE_RIGHT) || (joystick && joystick->isRight())) { direction |= Being::RIGHT; - player_node->cancelFollow(); } if (keyboard.isKeyActive(keyboard.KEY_EMOTE) && direction != 0) diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index 01870e62..409a0eda 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -125,9 +125,6 @@ void PopupMenu::showPopup(int x, int y, Being *being) break; } - mBrowserBox->addRow(strprintf("@@follow|%s@@", - strprintf(_("Follow %s"), - name.c_str()).c_str())); if (player_node->getNumberOfGuilds()) mBrowserBox->addRow(strprintf("@@guild|%s@@", strprintf(_("Invite %s to join your guild"), @@ -249,12 +246,6 @@ void PopupMenu::handleLink(const std::string &link) player_node->inviteToGuild(being); } - // Follow Player action - else if (link == "follow" && being) - { - player_node->setFollow(being->getName()); - } - // Pick Up Floor Item action else if ((link == "pickup") && mFloorItem) { diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 0b7cc0f8..b18b9b0b 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -431,7 +431,6 @@ void Viewport::mousePressed(gcn::MouseEvent &event) else { player_node->stopAttack(); - player_node->cancelFollow(); mPlayerFollowMouse = true; // Make the player go to the mouse position diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 50a9462f..74ca5f0d 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -96,7 +96,6 @@ LocalPlayer::LocalPlayer(int id, int subtype): mHp(1), mMaxHp(1), mSkillPoints(0), mTarget(NULL), - mPlayerFollowed(""), mPickUpTarget(NULL), mTrading(false), mGoingToTarget(false), mKeepAttacking(false), mLastAction(-1), @@ -1432,7 +1431,6 @@ void LocalPlayer::changeAwayMode() mAfkTime = 0; if (mAwayMode) { - cancelFollow(); mAwayDialog = new OkDialog(_("Away"), config.getValue("afkMessage", "I am away from keyboard")); mAwayDialog->addActionListener(mAwayListener); diff --git a/src/localplayer.h b/src/localplayer.h index 2c06dfb5..03fec1f8 100644 --- a/src/localplayer.h +++ b/src/localplayer.h @@ -379,29 +379,6 @@ class LocalPlayer : public Player */ void optionChanged(const std::string &value); - /** - * set a following player by right clicking. - */ - void setFollow(std::string player) { mPlayerFollowed = player; } - - /** - * setting the next destination of the following, in case of warp - */ - void setNextDest(int x, int y) { mNextDestX = x; mNextDestY = y; } - - int getNextDestX() const { return mNextDestX; } - int getNextDestY() const { return mNextDestY; } - - /** - * Stop following a player. - */ - void cancelFollow() { mPlayerFollowed = ""; } - - /** - * Get the playername followed by the current player. - */ - std::string getFollow() const { return mPlayerFollowed; } - /** * Tells the engine wether to check * if the Player Name is to be displayed. @@ -458,11 +435,6 @@ class LocalPlayer : public Player Being *mTarget; - /** Follow system **/ - std::string mPlayerFollowed; - int mNextDestX; - int mNextDestY; - FloorItem *mPickUpTarget; bool mTrading; diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp index 889f8777..2fe962c7 100644 --- a/src/net/tmwa/beinghandler.cpp +++ b/src/net/tmwa/beinghandler.cpp @@ -115,7 +115,6 @@ void BeingHandler::handleMessage(Net::MessageIn &msg) Being *srcBeing, *dstBeing; Player *player = 0; int hairStyle, hairColor, flag; - std::string player_followed; switch (msg.getId()) { @@ -280,16 +279,6 @@ void BeingHandler::handleMessage(Net::MessageIn &msg) if (!dstBeing) break; - player_followed = player_node->getFollow(); - - if (!player_followed.empty()) - { - if (dstBeing->getName() == player_followed) - { - player_node->setDestination(player_node->getNextDestX(), player_node->getNextDestY()); - } - } - // If this is player's current target, clear it. if (dstBeing == player_node->getTarget()) player_node->stopAttack(); @@ -595,16 +584,6 @@ void BeingHandler::handleMessage(Net::MessageIn &msg) msg.readCoordinatePair(srcX, srcY, dstX, dstY); dstBeing->setTileCoords(srcX, srcY); dstBeing->setDestination(dstX, dstY); - - player_followed = player_node->getFollow(); - if (!player_followed.empty()) - { - if (dstBeing->getName() == player_followed) - { - player_node->setNextDest(dstX, dstY); - player_node->setDestination(srcX, srcY); - } - } } else { -- cgit v1.2.3-70-g09d2