From 7cf5cb58865bc5f3951a6f4e40cf892ede96fc5a Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 5 Jan 2012 18:35:21 +0300 Subject: Update copyrights year. --- src/gui/popupmenu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gui/popupmenu.h') diff --git a/src/gui/popupmenu.h b/src/gui/popupmenu.h index 2db565ab7..17a985a4f 100644 --- a/src/gui/popupmenu.h +++ b/src/gui/popupmenu.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * -- cgit v1.2.3-70-g09d2 From dea21e405d0cda6c21e2a25841ec0db2f3ace34a Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 18 Jan 2012 16:41:46 +0300 Subject: Fix crash if pickup items. --- src/gui/popupmenu.cpp | 46 ++++++++++++++++++++++++++++------------------ src/gui/popupmenu.h | 2 +- 2 files changed, 29 insertions(+), 19 deletions(-) (limited to 'src/gui/popupmenu.h') diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index f31d01cfa..cd3a4c5ad 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -85,7 +85,7 @@ std::string tradePartnerName(""); PopupMenu::PopupMenu(): Popup("PopupMenu", "popupmenu.xml"), mBeingId(0), - mFloorItem(nullptr), + mFloorItemId(0), mItem(nullptr), mItemId(0), mItemColor(1), @@ -529,7 +529,7 @@ void PopupMenu::showPopup(int x, int y, FloorItem *floorItem) if (!floorItem) return; - mFloorItem = floorItem; + mFloorItemId = floorItem->getId(); mX = x; mY = y; const ItemInfo &info = floorItem->getInfo(); @@ -871,7 +871,7 @@ void PopupMenu::showChangePos(int x, int y) else { mBeingId = 0; - mFloorItem = nullptr; + mFloorItemId = 0; mItem = nullptr; mMapItem = nullptr; mNick = ""; @@ -1038,10 +1038,14 @@ void PopupMenu::handleLink(const std::string &link, player_node->setImitate(mNick); } // Pick Up Floor Item action - else if ((link == "pickup") && mFloorItem) + else if ((link == "pickup") && mFloorItemId) { - if (player_node) - player_node->pickUp(mFloorItem); + if (player_node && actorSpriteManager) + { + FloorItem *item = actorSpriteManager->findItem(mFloorItemId); + if (item) + player_node->pickUp(item); + } } // Look To action else if (link == "look") @@ -1106,16 +1110,21 @@ void PopupMenu::handleLink(const std::string &link, chatWindow->addItemText(mItem->getInfo().getName()); } } - else if (mFloorItem) + else if (mFloorItemId && actorSpriteManager) { - if (serverVersion > 0) - { - chatWindow->addItemText(mFloorItem->getInfo().getName( - mFloorItem->getColor())); - } - else + FloorItem *item = actorSpriteManager->findItem(mFloorItemId); + + if (item) { - chatWindow->addItemText(mFloorItem->getInfo().getName()); + if (serverVersion > 0) + { + chatWindow->addItemText(item->getInfo().getName( + item->getColor())); + } + else + { + chatWindow->addItemText(item->getInfo().getName()); + } } } } @@ -1706,10 +1715,11 @@ void PopupMenu::handleLink(const std::string &link, int id = atoi(link.substr(10).c_str()); if (id) { - mFloorItem = actorSpriteManager->findItem(id); - if (mFloorItem) + FloorItem *item = actorSpriteManager->findItem(id); + if (item) { - showPopup(getX(), getY(), mFloorItem); + mFloorItemId = item->getId(); + showPopup(getX(), getY(), item); return; } } @@ -1744,7 +1754,7 @@ void PopupMenu::handleLink(const std::string &link, setVisible(false); mBeingId = 0; - mFloorItem = nullptr; + mFloorItemId = 0; mItem = nullptr; mItemId = 0; mItemColor = 1; diff --git a/src/gui/popupmenu.h b/src/gui/popupmenu.h index 17a985a4f..8b9107300 100644 --- a/src/gui/popupmenu.h +++ b/src/gui/popupmenu.h @@ -160,7 +160,7 @@ class PopupMenu : public Popup, public LinkHandler BrowserBox* mBrowserBox; int mBeingId; - FloorItem* mFloorItem; + int mFloorItemId; Item *mItem; int mItemId; unsigned char mItemColor; -- cgit v1.2.3-70-g09d2