/*
* Ascent MMORPG Server
* Copyright (C) 2005-2007 Ascent Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
*/
#ifndef AUCTIONHOUSE_H
#define AUCTIONHOUSE_H
#include "../shared/Threading/RWLock.h"
enum AuctionRemoveType
{
AUCTION_REMOVE_EXPIRED,
AUCTION_REMOVE_WON,
AUCTION_REMOVE_CANCELLED,
};
enum AUCTIONRESULT
{
AUCTION_CREATE,// = 1
AUCTION_CANCEL,// = 2
AUCTION_BID,
AUCTION_BUYOUT,
};
enum AuctionMailResult
{
AUCTION_OUTBID,
AUCTION_WON,
AUCTION_SOLD,
AUCTION_EXPIRED,
AUCTION_EXPIRED2,
AUCTION_CANCELLED,
};
struct Auction
{
uint32 Id;
uint32 Owner;
uint32 HighestBidder;
uint32 HighestBid;
uint32 BuyoutPrice;
uint32 DepositAmount;
uint32 ExpiryTime;
Item * pItem;
void DeleteFromDB();
void SaveToDB(uint32 AuctionHouseId);
void UpdateInDB();
void AddToPacket(WorldPacket & data);
bool Deleted;
uint32 DeletedReason;
};
class AuctionHouse
{
public:
AuctionHouse(uint32 ID);
~AuctionHouse();
inline uint32 GetID() { return dbc->id; }
void LoadAuctions();
void UpdateAuctions();
void UpdateDeletionQueue();
void RemoveAuction(Auction * auct);
void AddAuction(Auction * auct);
Auction * GetAuction(uint32 Id);
void QueueDeletion(Auction * auct, uint32 Reason);
void SendOwnerListPacket(Player * plr, WorldPacket * packet);
void SendBidListPacket(Player * plr, WorldPacket * packet);
void SendAuctionNotificationPacket(Player * plr, Auction * auct);
void SendAuctionList(Player * plr, WorldPacket * packet);
private:
RWLock itemLock;
HM_NAMESPACE::hash_map auctionedItems;
RWLock auctionLock;
HM_NAMESPACE::hash_map auctions;
Mutex removalLock;
list removalList;
AuctionHouseDBC * dbc;
public:
float cut_percent;
float deposit_percent;
};
#endif