root/trunk/src/game/AuctionHouseObject.h @ 18

Revision 2, 2.8 kB (checked in by yumileroy, 17 years ago)

[svn] * Proper SVN structure

Original author: Neo2003
Date: 2008-10-02 16:23:55-05:00

Line 
1/*
2 * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
3 *
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.
8 *
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.
13 *
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
17 */
18
19#ifndef _AUCTION_HOUSE_H
20#define _AUCTION_HOUSE_H
21
22#include "SharedDefines.h"
23
24#define MIN_AUCTION_TIME (12*HOUR)
25
26enum AuctionError
27{
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
33};
34
35enum AuctionAction
36{
37    AUCTION_SELL_ITEM = 0,
38    AUCTION_CANCEL = 1,
39    AUCTION_PLACE_BID = 2
40};
41
42struct AuctionEntry
43{
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;
56};
57
58//this class is used as auctionhouse instance
59class AuctionHouseObject
60{
61    public:
62        AuctionHouseObject() {}
63        ~AuctionHouseObject()
64        {
65            for (AuctionEntryMap::iterator itr = AuctionsMap.begin(); itr != AuctionsMap.end(); ++itr)
66                delete itr->second;
67        }
68
69        typedef std::map<uint32, AuctionEntry*> AuctionEntryMap;
70
71        uint32 Getcount() { return AuctionsMap.size(); }
72
73        AuctionEntryMap::iterator GetAuctionsBegin() {return AuctionsMap.begin();}
74        AuctionEntryMap::iterator GetAuctionsEnd() {return AuctionsMap.end();}
75
76        void AddAuction(AuctionEntry *ah)
77        {
78            ASSERT( ah );
79            AuctionsMap[ah->Id] = ah;
80        }
81
82        AuctionEntry* GetAuction(uint32 id) const
83        {
84            AuctionEntryMap::const_iterator itr = AuctionsMap.find( id );
85            if( itr != AuctionsMap.end() )
86                return itr->second;
87            return NULL;
88        }
89
90        bool RemoveAuction(uint32 id)
91        {
92            AuctionEntryMap::iterator i = AuctionsMap.find(id);
93            if (i == AuctionsMap.end())
94            {
95                return false;
96            }
97            AuctionsMap.erase(i);
98            return true;
99        }
100
101    private:
102        AuctionEntryMap AuctionsMap;
103};
104#endif
Note: See TracBrowser for help on using the browser.