summaryrefslogtreecommitdiff
path: root/src/gui/equipmentwindow.cpp
diff options
context:
space:
mode:
authorIra Rice <irarice@gmail.com>2008-11-06 17:44:35 +0000
committerIra Rice <irarice@gmail.com>2008-11-06 17:44:35 +0000
commit0db6dce98d9c07b569dd29207979818f114f7a32 (patch)
tree3ae317c611a6e1d530b7d5e2b693ffc554aaa920 /src/gui/equipmentwindow.cpp
parentcb81caa6ddbe1861d7b276d48f337dd8841d68c1 (diff)
downloadmana-client-0db6dce98d9c07b569dd29207979818f114f7a32.tar.gz
mana-client-0db6dce98d9c07b569dd29207979818f114f7a32.tar.bz2
mana-client-0db6dce98d9c07b569dd29207979818f114f7a32.tar.xz
mana-client-0db6dce98d9c07b569dd29207979818f114f7a32.zip
Ported a patch by Peavey on TMW to keep all item pointers inside of
inventory. For us, this should get rid of the arrow crashing bug, if it still exists (been a few weeks since I've heard of it happening now).
Diffstat (limited to 'src/gui/equipmentwindow.cpp')
-rw-r--r--src/gui/equipmentwindow.cpp21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp
index 564486aa..727ac732 100644
--- a/src/gui/equipmentwindow.cpp
+++ b/src/gui/equipmentwindow.cpp
@@ -25,7 +25,9 @@
#include "../equipment.h"
#include "../graphics.h"
+#include "../inventory.h"
#include "../item.h"
+#include "../localplayer.h"
#include "../log.h"
#include "../resources/iteminfo.h"
@@ -40,6 +42,7 @@ EquipmentWindow::EquipmentWindow(Equipment *equipment):
setCloseButton(true);
setDefaultSize(5, 230, 200, 120);
loadWindowState();
+ inventory = player_node->getInventory();
}
EquipmentWindow::~EquipmentWindow()
@@ -61,22 +64,28 @@ void EquipmentWindow::draw(gcn::Graphics *graphics)
graphics->drawRectangle(gcn::Rectangle(10 + 36 * (i % 4),
36 * (i / 4) + 25, 32, 32));
- if (!(item = mEquipment->getEquipment(i)))
+ if (!(item = inventory->getItem(mEquipment->getEquipment(i))))
continue;
image = item->getImage();
- static_cast<Graphics*>(graphics)->drawImage(
- image, 36 * (i % 4) + 10, 36 * (i / 4) + 25);
+ if (image)
+ {
+ static_cast<Graphics*>(graphics)->drawImage(
+ image, 36 * (i % 4) + 10, 36 * (i / 4) + 25);
+ }
}
graphics->drawRectangle(gcn::Rectangle(160, 25, 32, 32));
- if (!(item = mEquipment->getArrows()))
+ if (!(item = inventory->getItem(mEquipment->getArrows())))
return;
image = item->getImage();
- static_cast<Graphics*>(graphics)->drawImage(image, 160, 25);
+ if (image)
+ {
+ static_cast<Graphics*>(graphics)->drawImage(image, 160, 25);
+ }
graphics->drawText(toString(item->getQuantity()), 170, 62,
- gcn::Graphics::CENTER);
+ gcn::Graphics::CENTER);
}