2 * Copyright (C) 2005-2013 MaNGOS <http://getmangos.com/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "ItemPrototype.h"
26 // Maximum 36 Slots ( (CONTAINER_END - CONTAINER_FIELD_SLOT_1)/2
27 #define MAX_BAG_SIZE 36 // 2.0.12
29 class Bag
: public Item
36 void AddToWorld() override
;
37 void RemoveFromWorld() override
;
39 bool Create(uint32 guidlow
, uint32 itemid
, Player
const* owner
) override
;
42 void StoreItem(uint8 slot
, Item
* pItem
, bool update
);
43 void RemoveItem(uint8 slot
, bool update
);
45 Item
* GetItemByPos(uint8 slot
) const;
46 Item
* GetItemByEntry(uint32 item
) const;
47 Item
* GetItemByLimitedCategory(uint32 limitedCategory
) const;
48 uint32
GetItemCount(uint32 item
, Item
* eItem
= NULL
) const;
49 uint32
GetItemCountWithLimitCategory(uint32 limitCategory
, Item
* eItem
= NULL
) const;
51 uint8
GetSlotByItemGUID(ObjectGuid guid
) const;
53 uint32
GetFreeSlots() const;
54 uint32
GetBagSize() const { return GetUInt32Value(CONTAINER_FIELD_NUM_SLOTS
); }
57 // overwrite virtual Item::SaveToDB
58 void SaveToDB() override
;
59 // overwrite virtual Item::LoadFromDB
60 bool LoadFromDB(uint32 guidLow
, Field
* fields
, ObjectGuid ownerGuid
= ObjectGuid()) override
;
61 // overwrite virtual Item::DeleteFromDB
62 void DeleteFromDB() override
;
64 void BuildCreateUpdateBlockForPlayer(UpdateData
* data
, Player
* target
) const override
;
69 Item
* m_bagslot
[MAX_BAG_SIZE
];
72 inline Item
* NewItemOrBag(ItemPrototype
const* proto
)
74 if (proto
->InventoryType
== INVTYPE_BAG
)