summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/game.cpp3
-rw-r--r--src/gui/itemcontainer.cpp8
-rw-r--r--src/gui/itemcontainer.h5
3 files changed, 16 insertions, 0 deletions
diff --git a/src/game.cpp b/src/game.cpp
index 7f3ff7eb..b145190a 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -775,7 +775,10 @@ void do_parse() {
break;
// Get the items
+ // Only called on map load / warp
case 0x01ee:
+ // Reset all items to not load them twice on map change
+ inventoryWindow->items->resetItems();
for (int loop = 0; loop < (RFIFOW(2) - 4) / 18; loop++) {
inventoryWindow->addItem(RFIFOW(4 + loop * 18),
RFIFOW(4 + loop * 18 + 2),
diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp
index 3ee6bfb4..d76fc3d9 100644
--- a/src/gui/itemcontainer.cpp
+++ b/src/gui/itemcontainer.cpp
@@ -135,6 +135,14 @@ void ItemContainer::addItem(int index, int id, int quantity, bool equipment)
items[index].equipment = equipment;
}
+void ItemContainer::resetItems()
+{
+ for (int i = 0; i < INVENTORY_SIZE; i++) {
+ items[i].id = -1;
+ items[i].quantity = 0;
+ }
+}
+
void ItemContainer::removeItem(int id)
{
for (int i = 0; i < INVENTORY_SIZE; i++) {
diff --git a/src/gui/itemcontainer.h b/src/gui/itemcontainer.h
index 3dbc3b7c..cbf08cf1 100644
--- a/src/gui/itemcontainer.h
+++ b/src/gui/itemcontainer.h
@@ -109,6 +109,11 @@ class ItemContainer : public gcn::Widget
void addItem(int index, int id, int quantity, bool equipment);
/**
+ * Reset all item slots.
+ */
+ void resetItems();
+
+ /**
* Remove a item from the inventory.
*/
void removeItem(int id);