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
34 MAIL_RETURNED_TO_SENDER
= 3,
36 MAIL_MADE_PERMANENT
= 5
41 MAIL_ERR_BAG_FULL
= 1,
42 MAIL_ERR_CANNOT_SEND_TO_SELF
= 2,
43 MAIL_ERR_NOT_ENOUGH_MONEY
= 3,
44 MAIL_ERR_RECIPIENT_NOT_FOUND
= 4,
45 MAIL_ERR_NOT_YOUR_TEAM
= 5,
46 MAIL_ERR_INTERNAL_ERROR
= 6,
47 MAIL_ERR_DISABLED_FOR_TRIAL_ACC
= 14,
48 MAIL_ERR_RECIPIENT_CAP_REACHED
= 15,
49 MAIL_ERR_CANT_SEND_WRAPPED_COD
= 16,
50 MAIL_ERR_MAIL_AND_CHAT_SUSPENDED
= 17
55 MAIL_CHECK_MASK_NONE
= 0,
56 MAIL_CHECK_MASK_READ
= 1,
57 MAIL_CHECK_MASK_AUCTION
= 4,
58 MAIL_CHECK_MASK_COD_PAYMENT
= 8,
59 MAIL_CHECK_MASK_RETURNED
= 16
66 MAIL_CREATURE
= 3, // client send CMSG_CREATURE_QUERY on this mailmessagetype
67 MAIL_GAMEOBJECT
= 4, // client send CMSG_GAMEOBJECT_QUERY on this mailmessagetype
68 MAIL_ITEM
= 5, // client send CMSG_ITEM_QUERY on this mailmessagetype
73 MAIL_STATE_UNCHANGED
= 1,
74 MAIL_STATE_CHANGED
= 2,
75 MAIL_STATE_DELETED
= 3
78 enum MailAuctionAnswers
80 AUCTION_OUTBIDDED
= 0,
82 AUCTION_SUCCESSFUL
= 2,
84 AUCTION_CANCELLED_TO_BIDDER
= 4,
86 AUCTION_SALE_PENDING
= 6
89 // gathered from Stationery.dbc
92 MAIL_STATIONERY_UNKNOWN
= 0x01,
93 MAIL_STATIONERY_NORMAL
= 0x29,
94 MAIL_STATIONERY_GM
= 0x3D,
95 MAIL_STATIONERY_AUCTION
= 0x3E,
96 MAIL_STATIONERY_VAL
= 0x40,
97 MAIL_STATIONERY_CHR
= 0x41
103 uint32 item_template
;
108 MailItem() : item_slot(0), item_guidlow(0), item_template(0), item(NULL
) {}
110 uint8 item_slot
; // slot in mail
111 uint32 item_guidlow
; // item guid (low part)
112 uint32 item_template
; // item entry
113 Item
*item
; // item pointer
115 void deleteItem(bool inDB
= false);
118 typedef std::map
<uint32
, MailItem
> MailItemMap
;
123 MailItemMap::const_iterator
begin() const { return i_MailItemMap
.begin(); }
124 MailItemMap::const_iterator
end() const { return i_MailItemMap
.end(); }
125 MailItemMap::iterator
begin() { return i_MailItemMap
.begin(); }
126 MailItemMap::iterator
end() { return i_MailItemMap
.end(); }
128 void AddItem(uint32 guidlow
, uint32 _template
, Item
*item
, uint8 slot
= 0)
131 mailItem
.item_slot
= slot
;
132 mailItem
.item_guidlow
= guidlow
;
133 mailItem
.item_template
= _template
;
134 mailItem
.item
= item
;
135 i_MailItemMap
[guidlow
] = mailItem
;
138 void AddItem(uint32 guidlow
, uint8 slot
= 0)
141 mailItem
.item_guidlow
= guidlow
;
142 mailItem
.item_slot
= slot
;
143 i_MailItemMap
[guidlow
] = mailItem
;
146 uint8
size() const { return i_MailItemMap
.size(); }
147 bool empty() const { return i_MailItemMap
.empty(); }
149 void deleteIncludedItems(bool inDB
= false)
151 for(MailItemMap::iterator mailItemIter
= begin(); mailItemIter
!= end(); ++mailItemIter
)
153 MailItem
& mailItem
= mailItemIter
->second
;
154 mailItem
.deleteItem(inDB
);
158 MailItemMap i_MailItemMap
; // Keep the items in a map to avoid duplicate guids (which can happen), store only low part of guid
166 uint16 mailTemplateId
;
171 std::vector
<MailItemInfo
> items
;
172 std::vector
<uint32
> removedItems
;
180 void AddItem(uint32 itemGuidLow
, uint32 item_template
)
183 mii
.item_guid
= itemGuidLow
;
184 mii
.item_template
= item_template
;
185 items
.push_back(mii
);
188 void AddAllItems(MailItemsInfo
& pMailItemsInfo
)
190 for(MailItemMap::iterator mailItemIter
= pMailItemsInfo
.begin(); mailItemIter
!= pMailItemsInfo
.end(); ++mailItemIter
)
192 MailItem
& mailItem
= mailItemIter
->second
;
193 AddItem(mailItem
.item_guidlow
, mailItem
.item_template
);
197 bool RemoveItem(uint32 itemId
)
199 for(std::vector
<MailItemInfo
>::iterator itr
= items
.begin(); itr
!= items
.end(); ++itr
)
201 if(itr
->item_guid
== itemId
)
210 bool HasItems() const { return !items
.empty(); }