[2771] Applied MaNGOS coding style (see trunk/bcpp.cfg).
[mangos-git.git] / src / game / AuctionHouseObject.h
blob5f3607a85c1d32ad2bf5dbf607c120e058e794b9
1 /*
2 * Copyright (C) 2005,2006 MaNGOS <http://www.mangosproject.org/>
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 AuctionHouse
20 #define AuctionHouse
22 enum AuctionError {
23 AUCTION_OK = 0,
24 AUCTION_INTERNAL_ERROR = 2
27 enum AuctionAction {
28 AUCTION_SELL_ITEM = 0,
29 AUCTION_CANCEL = 1,
30 AUCTION_PLACE_BID = 2
33 struct AuctionEntry
35 uint32 Id;
36 uint32 auctioneer;
37 uint32 item_guid;
38 uint32 item_template;
39 uint32 owner;
40 uint32 startbid;
41 uint32 bid;
42 uint32 buyout;
43 time_t time;
44 uint32 bidder;
45 uint32 deposit; //deposit can be calculated only when creating auction
46 uint32 location;
49 //this class is used as auctionhouse instance
50 class AuctionHouseObject
52 public:
53 AuctionHouseObject() {}
54 ~AuctionHouseObject()
56 for (AuctionEntryMap::iterator itr = AuctionsMap.begin(); itr != AuctionsMap.end(); ++itr)
57 delete itr->second;
60 typedef std::map<uint32, AuctionEntry*> AuctionEntryMap;
62 uint32 Getcount() { return AuctionsMap.size(); }
64 AuctionEntryMap::iterator GetAuctionsBegin() {return AuctionsMap.begin();}
65 AuctionEntryMap::iterator GetAuctionsEnd() {return AuctionsMap.end();}
68 void AddAuction(AuctionEntry *ah)
70 ASSERT( ah );
71 AuctionsMap[ah->Id] = ah;
74 AuctionEntry* GetAuction(uint32 id) const
76 AuctionEntryMap::const_iterator itr = AuctionsMap.find( id );
77 if( itr != AuctionsMap.end() )
78 return itr->second;
79 return NULL;
82 bool RemoveAuction(uint32 id)
84 AuctionEntryMap::iterator i = AuctionsMap.find(id);
85 if (i == AuctionsMap.end())
87 return false;
89 AuctionsMap.erase(i);
90 return true;
93 private:
94 AuctionEntryMap AuctionsMap;
97 #endif