diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2007-12-21 14:56:38 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2007-12-21 14:56:38 +0000 |
commit | 0c531de47eae77ab9fb2ec7a1fd6fc2be1462ef4 (patch) | |
tree | f85809e3a6a4771e2c157e1fb1577877741b81b5 /src/inventory.cpp | |
parent | 539af2ea0ce3245c41b4a4be989da35788f7b992 (diff) | |
download | mana-0c531de47eae77ab9fb2ec7a1fd6fc2be1462ef4.tar.gz mana-0c531de47eae77ab9fb2ec7a1fd6fc2be1462ef4.tar.bz2 mana-0c531de47eae77ab9fb2ec7a1fd6fc2be1462ef4.tar.xz mana-0c531de47eae77ab9fb2ec7a1fd6fc2be1462ef4.zip |
Fixed inventory size not matching the size assumed by eAthena and related
memory corruption and increased default chat log length.
Diffstat (limited to 'src/inventory.cpp')
-rw-r--r-- | src/inventory.cpp | 7 |
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); |