summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2009-02-26 22:22:22 +0100
committerIra Rice <irarice@gmail.com>2009-03-05 17:22:19 -0700
commit448d9076137fc5dde666a90820992a34a945cbf7 (patch)
treeee8d478fbced980a0ea868e9a7810ca56c49fe97 /src/gui
parenta79d05b01d4a2dc639e6d3a5b7ddd508e64d3511 (diff)
downloadmana-448d9076137fc5dde666a90820992a34a945cbf7.tar.gz
mana-448d9076137fc5dde666a90820992a34a945cbf7.tar.bz2
mana-448d9076137fc5dde666a90820992a34a945cbf7.tar.xz
mana-448d9076137fc5dde666a90820992a34a945cbf7.zip
Got rid of Sint{8,16,32} and Uint32 for being ID
Using unsigned rarely makes sense, especially when the server doesn't use it either. Other uses of unsigned should be reviewed. In all other cases, int is the fastest integer type on any architecture. Using 8 or 16 bits can basically only be a memory optimization.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/inventorywindow.cpp1
-rw-r--r--src/gui/inventorywindow.h2
-rw-r--r--src/gui/popupmenu.cpp66
-rw-r--r--src/gui/popupmenu.h2
4 files changed, 42 insertions, 29 deletions
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp
index e8457337..347c36ac 100644
--- a/src/gui/inventorywindow.cpp
+++ b/src/gui/inventorywindow.cpp
@@ -39,6 +39,7 @@
#include "../inventory.h"
#include "../item.h"
+#include "../localplayer.h"
#include "../resources/iteminfo.h"
diff --git a/src/gui/inventorywindow.h b/src/gui/inventorywindow.h
index a46a3fbb..83e98687 100644
--- a/src/gui/inventorywindow.h
+++ b/src/gui/inventorywindow.h
@@ -28,7 +28,7 @@
#include "window.h"
-#include "../localplayer.h"
+#include "../inventory.h"
class Item;
class ItemContainer;
diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp
index 7f82d1b5..ebaba977 100644
--- a/src/gui/popupmenu.cpp
+++ b/src/gui/popupmenu.cpp
@@ -30,6 +30,7 @@
#include "windowcontainer.h"
#include "../being.h"
+#include "../beingmanager.h"
#include "../floor_item.h"
#include "../item.h"
#include "../localplayer.h"
@@ -48,7 +49,7 @@ extern std::string tradePartnerName;
PopupMenu::PopupMenu():
Window(),
- mBeing(NULL),
+ mBeingId(0),
mFloorItem(NULL),
mItem(NULL)
{
@@ -66,16 +67,16 @@ PopupMenu::PopupMenu():
void PopupMenu::showPopup(int x, int y, Being *being)
{
- mBeing = being;
+ mBeingId = being->getId();
mBrowserBox->clearRows();
- switch (mBeing->getType())
+ switch (being->getType())
{
case Being::PLAYER:
{
- // Players can be traded with. Later also attack, follow and
+ // Players can be traded with. Later also follow and
// add as buddy will be options in this menu.
- const std::string &name = mBeing->getName();
+ const std::string &name = being->getName();
mBrowserBox->addRow(strprintf(_("@@trade|Trade With %s@@"), name.c_str()));
mBrowserBox->addRow(strprintf(_("@@attack|Attack %s@@"), name.c_str()));
@@ -144,45 +145,56 @@ void PopupMenu::showPopup(int x, int y, FloorItem *floorItem)
void PopupMenu::handleLink(const std::string& link)
{
+ Being *being = beingManager->findBeing(mBeingId);
+
+ if (!being)
+ {
+ mBeingId = 0;
+ mFloorItem = NULL;
+ mItem = NULL;
+ setVisible(false);
+ return;
+ }
+
// Talk To action
- if (link == "talk" && mBeing && mBeing->getType() == Being::NPC &&
+ if (link == "talk" && being && being->getType() == Being::NPC &&
current_npc == 0)
{
- dynamic_cast<NPC*>(mBeing)->talk();
+ dynamic_cast<NPC*>(being)->talk();
}
// Trade action
- else if (link == "trade" && mBeing && mBeing->getType() == Being::PLAYER)
+ else if (link == "trade" && being && being->getType() == Being::PLAYER)
{
- player_node->trade(mBeing);
- tradePartnerName = mBeing->getName();
+ player_node->trade(being);
+ tradePartnerName = being->getName();
}
// Attack action
- else if (link == "attack" && mBeing && mBeing->getType() == Being::PLAYER)
+ else if (link == "attack" && being && being->getType() == Being::PLAYER)
{
- player_node->attack(mBeing, true);
+ player_node->attack(being, true);
}
- else if (link == "unignore" && mBeing && mBeing->getType() == Being::PLAYER)
+ else if (link == "unignore" && being && being->getType() == Being::PLAYER)
{
- player_relations.setRelation(mBeing->getName(), PlayerRelation::NEUTRAL);
+ player_relations.setRelation(being->getName(), PlayerRelation::NEUTRAL);
}
- else if (link == "ignore" && mBeing && mBeing->getType() == Being::PLAYER)
+ else if (link == "ignore" && being && being->getType() == Being::PLAYER)
{
- player_relations.setRelation(mBeing->getName(), PlayerRelation::IGNORED);
+ player_relations.setRelation(being->getName(), PlayerRelation::IGNORED);
}
- else if (link == "disregard" && mBeing &&
- mBeing->getType() == Being::PLAYER)
+ else if (link == "disregard" && being &&
+ being->getType() == Being::PLAYER)
{
- player_relations.setRelation(mBeing->getName(), PlayerRelation::DISREGARDED);
+ player_relations.setRelation(being->getName(), PlayerRelation::DISREGARDED);
}
- else if (link == "friend" && mBeing && mBeing->getType() == Being::PLAYER)
+ else if (link == "friend" && being && being->getType() == Being::PLAYER)
{
- player_relations.setRelation(mBeing->getName(), PlayerRelation::FRIEND);
+ player_relations.setRelation(being->getName(), PlayerRelation::FRIEND);
}
/*
@@ -193,12 +205,12 @@ void PopupMenu::handleLink(const std::string& link)
/*
// Add Buddy action
- else if ((link == "buddy") && mBeing && mBeing->isPlayer())
+ else if ((link == "buddy") && being && being->isPlayer())
{
if (!buddyWindow->isVisible())
buddyWindow->setVisible(true);
- buddyWindow->addBuddy(mBeing->getName());
+ buddyWindow->addBuddy(being->getName());
}*/
// Pick Up Floor Item action
@@ -241,12 +253,12 @@ void PopupMenu::handleLink(const std::string& link)
{
new ItemAmountWindow(AMOUNT_ITEM_DROP, inventoryWindow, mItem);
}
- else if (link == "party-invite" && mBeing &&
- mBeing->getType() == Being::PLAYER)
+ else if (link == "party-invite" && being &&
+ being->getType() == Being::PLAYER)
{
MessageOut outMsg(player_node->getNetwork());
outMsg.writeInt16(CMSG_PARTY_INVITE);
- outMsg.writeInt32(mBeing->getId());
+ outMsg.writeInt32(being->getId());
}
// Unknown actions
@@ -257,7 +269,7 @@ void PopupMenu::handleLink(const std::string& link)
setVisible(false);
- mBeing = NULL;
+ mBeingId = 0;
mFloorItem = NULL;
mItem = NULL;
}
diff --git a/src/gui/popupmenu.h b/src/gui/popupmenu.h
index c62014f9..89152751 100644
--- a/src/gui/popupmenu.h
+++ b/src/gui/popupmenu.h
@@ -67,7 +67,7 @@ class PopupMenu : public Window, public LinkHandler
private:
BrowserBox* mBrowserBox;
- Being* mBeing;
+ int mBeingId;
FloorItem* mFloorItem;
Item *mItem;