From 0c72883009c254e6a13353ec98f78f9a4a30775d Mon Sep 17 00:00:00 2001 From: Foereaper Date: Mon, 22 Sep 2014 19:34:43 +0200 Subject: [PATCH] Changed AddItem to return item object --- PlayerMethods.h | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/PlayerMethods.h b/PlayerMethods.h index 3b8cd1b..01b5267 100644 --- a/PlayerMethods.h +++ b/PlayerMethods.h @@ -1972,10 +1972,23 @@ namespace LuaPlayer { uint32 itemId = Eluna::CHECKVAL(L, 2); uint32 itemCount = Eluna::CHECKVAL(L, 3); + #ifndef TRINITY - Eluna::Push(L, player->StoreNewItemInInventorySlot(itemId, itemCount) ? true : false); + Eluna::Push(L, player->StoreNewItemInInventorySlot(itemId, itemCount)); #else - Eluna::Push(L, player->AddItem(itemId, itemCount)); + uint32 noSpaceForCount = 0; + ItemPosCountVec dest; + InventoryResult msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemId, itemCount, &noSpaceForCount); + if (msg != EQUIP_ERR_OK) + itemCount -= noSpaceForCount; + + if (itemCount == 0 || dest.empty()) + return 1; + + Item* item = player->StoreNewItem(dest, itemId, true, Item::GenerateItemRandomPropertyId(itemId)); + if (item) + player->SendNewItem(item, itemCount, true, false); + Eluna::Push(L, item); #endif return 1; }