2 * Copyright (C) 2005-2009 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
26 #define MAIL_BODY_ITEM_TEMPLATE 8383 // - plain letter, A Dusty Unsent Letter: 889
27 #define MAX_MAIL_ITEMS 12
31 MAIL_CHECK_MASK_NONE
= 0,
32 MAIL_CHECK_MASK_READ
= 1,
33 MAIL_CHECK_MASK_AUCTION
= 4,
34 MAIL_CHECK_MASK_COD_PAYMENT
= 8,
35 MAIL_CHECK_MASK_RETURNED
= 16
42 MAIL_CREATURE
= 3, // client send CMSG_CREATURE_QUERY on this mailmessagetype
43 MAIL_GAMEOBJECT
= 4, // client send CMSG_GAMEOBJECT_QUERY on this mailmessagetype
44 MAIL_ITEM
= 5, // client send CMSG_ITEM_QUERY on this mailmessagetype
49 MAIL_STATE_UNCHANGED
= 1,
50 MAIL_STATE_CHANGED
= 2,
51 MAIL_STATE_DELETED
= 3
54 enum MailAuctionAnswers
56 AUCTION_OUTBIDDED
= 0,
58 AUCTION_SUCCESSFUL
= 2,
60 AUCTION_CANCELLED_TO_BIDDER
= 4,
62 AUCTION_SALE_PENDING
= 6
65 // gathered from Stationery.dbc
68 MAIL_STATIONERY_UNKNOWN
= 0x01,
69 MAIL_STATIONERY_NORMAL
= 0x29,
70 MAIL_STATIONERY_GM
= 0x3D,
71 MAIL_STATIONERY_AUCTION
= 0x3E,
72 MAIL_STATIONERY_VAL
= 0x40,
73 MAIL_STATIONERY_CHR
= 0x41
84 MailItem() : item_slot(0), item_guidlow(0), item_template(0), item(NULL
) {}
86 uint8 item_slot
; // slot in mail
87 uint32 item_guidlow
; // item guid (low part)
88 uint32 item_template
; // item entry
89 Item
*item
; // item pointer
91 void deleteItem(bool inDB
= false);
94 typedef std::map
<uint32
, MailItem
> MailItemMap
;
99 MailItemMap::const_iterator
begin() const { return i_MailItemMap
.begin(); }
100 MailItemMap::const_iterator
end() const { return i_MailItemMap
.end(); }
101 MailItemMap::iterator
begin() { return i_MailItemMap
.begin(); }
102 MailItemMap::iterator
end() { return i_MailItemMap
.end(); }
104 void AddItem(uint32 guidlow
, uint32 _template
, Item
*item
, uint8 slot
= 0)
107 mailItem
.item_slot
= slot
;
108 mailItem
.item_guidlow
= guidlow
;
109 mailItem
.item_template
= _template
;
110 mailItem
.item
= item
;
111 i_MailItemMap
[guidlow
] = mailItem
;
114 void AddItem(uint32 guidlow
, uint8 slot
= 0)
117 mailItem
.item_guidlow
= guidlow
;
118 mailItem
.item_slot
= slot
;
119 i_MailItemMap
[guidlow
] = mailItem
;
122 uint8
size() const { return i_MailItemMap
.size(); }
123 bool empty() const { return i_MailItemMap
.empty(); }
125 void deleteIncludedItems(bool inDB
= false)
127 for(MailItemMap::iterator mailItemIter
= begin(); mailItemIter
!= end(); ++mailItemIter
)
129 MailItem
& mailItem
= mailItemIter
->second
;
130 mailItem
.deleteItem(inDB
);
134 MailItemMap i_MailItemMap
; // Keep the items in a map to avoid duplicate guids (which can happen), store only low part of guid
142 uint16 mailTemplateId
;
147 std::vector
<MailItemInfo
> items
;
148 std::vector
<uint32
> removedItems
;
156 void AddItem(uint32 itemGuidLow
, uint32 item_template
)
159 mii
.item_guid
= itemGuidLow
;
160 mii
.item_template
= item_template
;
161 items
.push_back(mii
);
164 void AddAllItems(MailItemsInfo
& pMailItemsInfo
)
166 for(MailItemMap::iterator mailItemIter
= pMailItemsInfo
.begin(); mailItemIter
!= pMailItemsInfo
.end(); ++mailItemIter
)
168 MailItem
& mailItem
= mailItemIter
->second
;
169 AddItem(mailItem
.item_guidlow
, mailItem
.item_template
);
173 bool RemoveItem(uint32 item_guid
)
175 for(std::vector
<MailItemInfo
>::iterator itr
= items
.begin(); itr
!= items
.end(); ++itr
)
177 if(itr
->item_guid
== item_guid
)
186 bool HasItems() const { return !items
.empty(); }