[6982] Implemented gmlevel-based command security
[getmangos.git] / src / game / AuctionHouseObject.h
blob5cc51692ca0c4e29a923023b9f2cc0f81641d161
1 /*
2 * Copyright (C) 2005-2008 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_H
20 #define _AUCTION_HOUSE_H
22 #include "SharedDefines.h"
24 #define MIN_AUCTION_TIME (12*HOUR)
26 enum AuctionError
28 AUCTION_OK = 0,
29 AUCTION_INTERNAL_ERROR = 2,
30 AUCTION_NOT_ENOUGHT_MONEY = 3,
31 AUCTION_ITEM_NOT_FOUND = 4,
32 CANNOT_BID_YOUR_AUCTION_ERROR = 10
35 enum AuctionAction
37 AUCTION_SELL_ITEM = 0,
38 AUCTION_CANCEL = 1,
39 AUCTION_PLACE_BID = 2
42 struct AuctionEntry
44 uint32 Id;
45 uint32 auctioneer;
46 uint32 item_guidlow;
47 uint32 item_template;
48 uint32 owner;
49 uint32 startbid; //maybe useless
50 uint32 bid;
51 uint32 buyout;
52 time_t time;
53 uint32 bidder;
54 uint32 deposit; //deposit can be calculated only when creating auction
55 uint32 location;
58 //this class is used as auctionhouse instance
59 class AuctionHouseObject
61 public:
62 AuctionHouseObject() {}
63 ~AuctionHouseObject()
65 for (AuctionEntryMap::iterator itr = AuctionsMap.begin(); itr != AuctionsMap.end(); ++itr)
66 delete itr->second;
69 typedef std::map<uint32, AuctionEntry*> AuctionEntryMap;
71 uint32 Getcount() { return AuctionsMap.size(); }
73 AuctionEntryMap::iterator GetAuctionsBegin() {return AuctionsMap.begin();}
74 AuctionEntryMap::iterator GetAuctionsEnd() {return AuctionsMap.end();}
76 void AddAuction(AuctionEntry *ah)
78 ASSERT( ah );
79 AuctionsMap[ah->Id] = ah;
82 AuctionEntry* GetAuction(uint32 id) const
84 AuctionEntryMap::const_iterator itr = AuctionsMap.find( id );
85 if( itr != AuctionsMap.end() )
86 return itr->second;
87 return NULL;
90 bool RemoveAuction(uint32 id)
92 AuctionEntryMap::iterator i = AuctionsMap.find(id);
93 if (i == AuctionsMap.end())
95 return false;
97 AuctionsMap.erase(i);
98 return true;
101 private:
102 AuctionEntryMap AuctionsMap;
104 #endif