summaryrefslogtreecommitdiff
path: root/src/inventory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/inventory.cpp')
-rw-r--r--src/inventory.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/inventory.cpp b/src/inventory.cpp
index bc4bd1c0..807e1223 100644
--- a/src/inventory.cpp
+++ b/src/inventory.cpp
@@ -26,6 +26,7 @@
#include <algorithm>
#include "item.h"
+#include "log.h"
struct SlotUsed : public std::unary_function<Item*, bool>
{
@@ -64,6 +65,11 @@ void Inventory::addItem(int id, int quantity)
void Inventory::setItem(int index, int id, int quantity)
{
+ if (index < 0 || index >= INVENTORY_SIZE) {
+ logger->log("Warning: invalid inventory index: %d", index);
+ return;
+ }
+
if (!mItems[index] && id > 0) {
mItems[index] = new Item(id, quantity);
mItems[index]->setInvIndex(index);