[10041] Use for spell 49145 and ranks for decrease SPELL_DIRECT_DAMAGE damage.
[getmangos.git] / src / game / Bag.h
blob160128648bfc54573310bdf2ca2033dfe904f58f
1 /*
2 * Copyright (C) 2005-2010 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
19 #ifndef MANGOS_BAG_H
20 #define MANGOS_BAG_H
22 // Maximum 36 Slots ( (CONTAINER_END - CONTAINER_FIELD_SLOT_1)/2
23 #define MAX_BAG_SIZE 36 // 2.0.12
25 #include "ItemPrototype.h"
26 #include "Item.h"
28 class Bag : public Item
30 public:
32 Bag();
33 ~Bag();
35 void AddToWorld();
36 void RemoveFromWorld();
38 bool Create(uint32 guidlow, uint32 itemid, Player const* owner);
40 void Clear();
41 void StoreItem( uint8 slot, Item *pItem, bool update );
42 void RemoveItem( uint8 slot, bool update );
44 Item* GetItemByPos( uint8 slot ) const;
45 Item* GetItemByEntry( uint32 item ) const;
46 Item* GetItemByLimitedCategory(uint32 limitedCategory) const;
47 uint32 GetItemCount( uint32 item, Item* eItem = NULL ) const;
48 uint32 GetItemCountWithLimitCategory(uint32 limitCategory) const;
50 uint8 GetSlotByItemGUID(uint64 guid) const;
51 bool IsEmpty() const;
52 uint32 GetFreeSlots() const;
53 uint32 GetBagSize() const { return GetUInt32Value(CONTAINER_FIELD_NUM_SLOTS); }
55 // DB operations
56 // overwrite virtual Item::SaveToDB
57 void SaveToDB();
58 // overwrite virtual Item::LoadFromDB
59 bool LoadFromDB(uint32 guid, uint64 owner_guid, QueryResult *result);
60 // overwrite virtual Item::DeleteFromDB
61 void DeleteFromDB();
63 void BuildCreateUpdateBlockForPlayer(UpdateData *data, Player *target) const;
65 protected:
67 // Bag Storage space
68 Item* m_bagslot[MAX_BAG_SIZE];
71 inline Item* NewItemOrBag(ItemPrototype const * proto)
73 return (proto->InventoryType == INVTYPE_BAG) ? new Bag : new Item;
75 #endif