diff options
Diffstat (limited to 'src/game-server')
-rw-r--r-- | src/game-server/inventory.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/game-server/inventory.cpp b/src/game-server/inventory.cpp index 0eddfd04..1fe09001 100644 --- a/src/game-server/inventory.cpp +++ b/src/game-server/inventory.cpp @@ -148,7 +148,13 @@ unsigned Inventory::insert(unsigned itemId, unsigned amount) return 0; MessageOut invMsg(GPMSG_INVENTORY); - unsigned maxPerSlot = itemManager->getItem(itemId)->getMaxPerSlot(); + ItemClass *item = itemManager->getItem(itemId); + if (!item) { + LOG_ERROR("Inventory: Trying to insert invalid item id " << itemId + << " (amount: " << amount << ")"); + return amount; + } + unsigned maxPerSlot = item->getMaxPerSlot(); LOG_DEBUG("Inventory: Inserting " << amount << " item(s) Id: " << itemId << " for character '" << mCharacter->getName() << "'."); @@ -210,6 +216,8 @@ unsigned Inventory::insert(unsigned itemId, unsigned amount) break; } + item->useTrigger(mCharacter, ITT_IN_INVY); + // Send that first, before checking potential removals if (invMsg.getLength() > 2) gameHandler->sendTo(mCharacter, invMsg); |