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
19 #ifndef _AUCTION_HOUSE_MGR_H
20 #define _AUCTION_HOUSE_MGR_H
22 #include "SharedDefines.h"
23 #include "Policies/Singleton.h"
29 #define MIN_AUCTION_TIME (12*HOUR)
34 AUCTION_INTERNAL_ERROR
= 2,
35 AUCTION_NOT_ENOUGHT_MONEY
= 3,
36 AUCTION_ITEM_NOT_FOUND
= 4,
37 CANNOT_BID_YOUR_AUCTION_ERROR
= 10
42 AUCTION_SELL_ITEM
= 0,
50 uint32 auctioneer
; // creature low guid
54 uint32 startbid
; //maybe useless
59 uint32 deposit
; //deposit can be calculated only when creating auction
60 AuctionHouseEntry
const* auctionHouseEntry
; // in AuctionHouse.dbc
63 uint32
GetHouseId() const { return auctionHouseEntry
->houseId
; }
64 uint32
GetHouseFaction() const { return auctionHouseEntry
->faction
; }
65 uint32
GetAuctionCut() const;
66 uint32
GetAuctionOutBid() const;
67 bool BuildAuctionInfo(WorldPacket
& data
) const;
68 void DeleteFromDB() const;
69 void SaveToDB() const;
72 //this class is used as auctionhouse instance
73 class AuctionHouseObject
76 AuctionHouseObject() {}
79 for (AuctionEntryMap::iterator itr
= AuctionsMap
.begin(); itr
!= AuctionsMap
.end(); ++itr
)
83 typedef std::map
<uint32
, AuctionEntry
*> AuctionEntryMap
;
85 uint32
Getcount() { return AuctionsMap
.size(); }
87 void AddAuction(AuctionEntry
*ah
)
90 AuctionsMap
[ah
->Id
] = ah
;
93 AuctionEntry
* GetAuction(uint32 id
) const
95 AuctionEntryMap::const_iterator itr
= AuctionsMap
.find( id
);
96 return itr
!= AuctionsMap
.end() ? itr
->second
: NULL
;
99 bool RemoveAuction(uint32 id
)
101 return AuctionsMap
.erase(id
) ? true : false;
106 void BuildListBidderItems(WorldPacket
& data
, Player
* player
, uint32
& count
, uint32
& totalcount
);
107 void BuildListOwnerItems(WorldPacket
& data
, Player
* player
, uint32
& count
, uint32
& totalcount
);
108 void BuildListAuctionItems(WorldPacket
& data
, Player
* player
,
109 std::wstring
const& searchedname
, uint32 listfrom
, uint32 levelmin
, uint32 levelmax
, uint32 usable
,
110 uint32 inventoryType
, uint32 itemClass
, uint32 itemSubClass
, uint32 quality
,
111 uint32
& count
, uint32
& totalcount
);
114 AuctionEntryMap AuctionsMap
;
117 class AuctionHouseMgr
123 typedef UNORDERED_MAP
<uint32
, Item
*> ItemMap
;
125 AuctionHouseObject
* GetAuctionsMap( uint32 factionTemplateId
);
127 Item
* GetAItem(uint32 id
)
129 ItemMap::const_iterator itr
= mAitems
.find(id
);
130 if (itr
!= mAitems
.end())
138 void SendAuctionWonMail( AuctionEntry
* auction
);
139 void SendAuctionSalePendingMail( AuctionEntry
* auction
);
140 void SendAuctionSuccessfulMail( AuctionEntry
* auction
);
141 void SendAuctionExpiredMail( AuctionEntry
* auction
);
142 static uint32
GetAuctionDeposit(AuctionHouseEntry
const* entry
, uint32 time
, Item
*pItem
);
143 static AuctionHouseEntry
const* GetAuctionHouseEntry(uint32 factionTemplateId
);
146 //load first auction items, because of check if item exists, when loading
147 void LoadAuctionItems();
150 void AddAItem(Item
* it
);
151 bool RemoveAItem(uint32 id
);
156 AuctionHouseObject mHordeAuctions
;
157 AuctionHouseObject mAllianceAuctions
;
158 AuctionHouseObject mNeutralAuctions
;
163 #define auctionmgr MaNGOS::Singleton<AuctionHouseMgr>::Instance()