root/trunk/src/game/Bag.h @ 18

Revision 2, 2.2 kB (checked in by yumileroy, 17 years ago)

[svn] * Proper SVN structure

Original author: Neo2003
Date: 2008-10-02 16:23:55-05:00

Line 
1/*
2 * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
3 *
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.
8 *
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.
13 *
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
17 */
18
19#ifndef MANGOS_BAG_H
20#define MANGOS_BAG_H
21
22// Maximum 36 Slots ( (CONTAINER_END - CONTAINER_FIELD_SLOT_1)/2
23#define MAX_BAG_SIZE 36                                     // 2.0.12
24
25#include "Object.h"
26#include "ItemPrototype.h"
27#include "Unit.h"
28#include "Creature.h"
29#include "Item.h"
30
31class Bag : public Item
32{
33    public:
34
35        Bag();
36        ~Bag();
37
38        void AddToWorld();
39        void RemoveFromWorld();
40
41        bool Create(uint32 guidlow, uint32 itemid, Player const* owner);
42
43        void Clear();
44        void StoreItem( uint8 slot, Item *pItem, bool update );
45        void RemoveItem( uint8 slot, bool update );
46
47        Item* GetItemByPos( uint8 slot ) const;
48        uint32 GetItemCount( uint32 item, Item* eItem = NULL ) const;
49
50        uint8 GetSlotByItemGUID(uint64 guid) const;
51        bool IsEmpty() const;
52        uint32 GetFreeSlots() const;
53
54        // DB operations
55        // overwrite virtual Item::SaveToDB
56        void SaveToDB();
57        // overwrite virtual Item::LoadFromDB
58        bool LoadFromDB(uint32 guid, uint64 owner_guid, QueryResult *result = NULL);
59        // overwrite virtual Item::DeleteFromDB
60        void DeleteFromDB();
61
62        void BuildCreateUpdateBlockForPlayer(UpdateData *data, Player *target) const;
63
64    protected:
65
66        // Bag Storage space
67        Item* m_bagslot[MAX_BAG_SIZE];
68};
69
70inline Item* NewItemOrBag(ItemPrototype const * proto)
71{
72    return (proto->InventoryType == INVTYPE_BAG) ? new Bag : new Item;
73}
74#endif
Note: See TracBrowser for help on using the browser.