[2] | 1 | /* |
---|
[102] | 2 | * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/> |
---|
| 3 | * |
---|
[44] | 4 | * Copyright (C) 2008 Trinity <http://www.trinitycore.org/> |
---|
[2] | 5 | * |
---|
| 6 | * This program is free software; you can redistribute it and/or modify |
---|
| 7 | * it under the terms of the GNU General Public License as published by |
---|
| 8 | * the Free Software Foundation; either version 2 of the License, or |
---|
| 9 | * (at your option) any later version. |
---|
| 10 | * |
---|
| 11 | * This program is distributed in the hope that it will be useful, |
---|
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
[44] | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
[2] | 14 | * GNU General Public License for more details. |
---|
| 15 | * |
---|
| 16 | * You should have received a copy of the GNU General Public License |
---|
| 17 | * along with this program; if not, write to the Free Software |
---|
[44] | 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
[2] | 19 | */ |
---|
| 20 | |
---|
[44] | 21 | #ifndef TRINITY_BAG_H |
---|
| 22 | #define TRINITY_BAG_H |
---|
[2] | 23 | |
---|
| 24 | // Maximum 36 Slots ( (CONTAINER_END - CONTAINER_FIELD_SLOT_1)/2 |
---|
| 25 | #define MAX_BAG_SIZE 36 // 2.0.12 |
---|
| 26 | |
---|
| 27 | #include "Object.h" |
---|
| 28 | #include "ItemPrototype.h" |
---|
| 29 | #include "Unit.h" |
---|
| 30 | #include "Creature.h" |
---|
| 31 | #include "Item.h" |
---|
| 32 | |
---|
| 33 | class Bag : public Item |
---|
| 34 | { |
---|
| 35 | public: |
---|
| 36 | |
---|
| 37 | Bag(); |
---|
| 38 | ~Bag(); |
---|
| 39 | |
---|
| 40 | void AddToWorld(); |
---|
| 41 | void RemoveFromWorld(); |
---|
| 42 | |
---|
| 43 | bool Create(uint32 guidlow, uint32 itemid, Player const* owner); |
---|
| 44 | |
---|
| 45 | void Clear(); |
---|
| 46 | void StoreItem( uint8 slot, Item *pItem, bool update ); |
---|
| 47 | void RemoveItem( uint8 slot, bool update ); |
---|
| 48 | |
---|
| 49 | Item* GetItemByPos( uint8 slot ) const; |
---|
| 50 | uint32 GetItemCount( uint32 item, Item* eItem = NULL ) const; |
---|
| 51 | |
---|
| 52 | uint8 GetSlotByItemGUID(uint64 guid) const; |
---|
| 53 | bool IsEmpty() const; |
---|
| 54 | uint32 GetFreeSlots() const; |
---|
| 55 | |
---|
| 56 | // DB operations |
---|
| 57 | // overwrite virtual Item::SaveToDB |
---|
| 58 | void SaveToDB(); |
---|
| 59 | // overwrite virtual Item::LoadFromDB |
---|
| 60 | bool LoadFromDB(uint32 guid, uint64 owner_guid, QueryResult *result = NULL); |
---|
| 61 | // overwrite virtual Item::DeleteFromDB |
---|
| 62 | void DeleteFromDB(); |
---|
| 63 | |
---|
| 64 | void BuildCreateUpdateBlockForPlayer(UpdateData *data, Player *target) const; |
---|
| 65 | |
---|
| 66 | protected: |
---|
| 67 | |
---|
| 68 | // Bag Storage space |
---|
| 69 | Item* m_bagslot[MAX_BAG_SIZE]; |
---|
| 70 | }; |
---|
| 71 | |
---|
| 72 | inline Item* NewItemOrBag(ItemPrototype const * proto) |
---|
| 73 | { |
---|
| 74 | return (proto->InventoryType == INVTYPE_BAG) ? new Bag : new Item; |
---|
| 75 | } |
---|
| 76 | #endif |
---|