summaryrefslogtreecommitdiff
path: root/src/inventory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/inventory.cpp')
-rw-r--r--src/inventory.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/inventory.cpp b/src/inventory.cpp
index e476857f..6795fbec 100644
--- a/src/inventory.cpp
+++ b/src/inventory.cpp
@@ -24,8 +24,10 @@
#include "inventory.h"
#include <algorithm>
+#include <cassert>
#include "item.h"
+#include "log.h"
struct SlotUsed : public std::unary_function<Item, bool>
{
@@ -64,6 +66,11 @@ void Inventory::addItem(int id, int quantity, bool equipment)
void Inventory::addItem(int index, int id, int quantity, bool equipment)
{
+ if (index < 0 || index >= INVENTORY_SIZE) {
+ logger->log("Warning: invalid inventory index: %d", index);
+ return;
+ }
+
mItems[index].setId(id);
mItems[index].increaseQuantity(quantity);
mItems[index].setEquipment(equipment);