mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 22:37:03 +00:00
[11396] Auction: server side sorting and get all auctions feature.
This commit is contained in:
parent
0f7aaa865a
commit
66ba7d2c49
5 changed files with 394 additions and 186 deletions
|
|
@ -34,7 +34,7 @@
|
||||||
// post-incrementation is always slower than pre-incrementation !
|
// post-incrementation is always slower than pre-incrementation !
|
||||||
|
|
||||||
// void called when player click on auctioneer npc
|
// void called when player click on auctioneer npc
|
||||||
void WorldSession::HandleAuctionHelloOpcode( WorldPacket & recv_data )
|
void WorldSession::HandleAuctionHelloOpcode(WorldPacket & recv_data)
|
||||||
{
|
{
|
||||||
ObjectGuid auctioneerGuid; // NPC guid
|
ObjectGuid auctioneerGuid; // NPC guid
|
||||||
recv_data >> auctioneerGuid;
|
recv_data >> auctioneerGuid;
|
||||||
|
|
@ -47,7 +47,7 @@ void WorldSession::HandleAuctionHelloOpcode( WorldPacket & recv_data )
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove fake death
|
// remove fake death
|
||||||
if(GetPlayer()->hasUnitState(UNIT_STAT_DIED))
|
if (GetPlayer()->hasUnitState(UNIT_STAT_DIED))
|
||||||
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
|
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
|
||||||
|
|
||||||
SendAuctionHello(unit);
|
SendAuctionHello(unit);
|
||||||
|
|
@ -59,7 +59,7 @@ void WorldSession::SendAuctionHello(Unit* unit)
|
||||||
// always return pointer
|
// always return pointer
|
||||||
AuctionHouseEntry const* ahEntry = AuctionHouseMgr::GetAuctionHouseEntry(unit);
|
AuctionHouseEntry const* ahEntry = AuctionHouseMgr::GetAuctionHouseEntry(unit);
|
||||||
|
|
||||||
WorldPacket data( MSG_AUCTION_HELLO, 12 );
|
WorldPacket data(MSG_AUCTION_HELLO, 12);
|
||||||
data << unit->GetObjectGuid();
|
data << unit->GetObjectGuid();
|
||||||
data << uint32(ahEntry->houseId);
|
data << uint32(ahEntry->houseId);
|
||||||
data << uint8(1); // 3.3.3: 1 - AH enabled, 0 - AH disabled
|
data << uint8(1); // 3.3.3: 1 - AH enabled, 0 - AH disabled
|
||||||
|
|
@ -67,17 +67,17 @@ void WorldSession::SendAuctionHello(Unit* unit)
|
||||||
}
|
}
|
||||||
|
|
||||||
// call this method when player bids, creates, or deletes auction
|
// call this method when player bids, creates, or deletes auction
|
||||||
void WorldSession::SendAuctionCommandResult(AuctionEntry *auc, AuctionAction Action, AuctionError ErrorCode, InventoryResult invError )
|
void WorldSession::SendAuctionCommandResult(AuctionEntry *auc, AuctionAction Action, AuctionError ErrorCode, InventoryResult invError)
|
||||||
{
|
{
|
||||||
WorldPacket data( SMSG_AUCTION_COMMAND_RESULT, 16 );
|
WorldPacket data(SMSG_AUCTION_COMMAND_RESULT, 16);
|
||||||
data << uint32(auc ? auc->Id : 0);
|
data << uint32(auc ? auc->Id : 0);
|
||||||
data << uint32(Action);
|
data << uint32(Action);
|
||||||
data << uint32(ErrorCode);
|
data << uint32(ErrorCode);
|
||||||
|
|
||||||
switch(ErrorCode)
|
switch (ErrorCode)
|
||||||
{
|
{
|
||||||
case AUCTION_OK:
|
case AUCTION_OK:
|
||||||
if(Action == AUCTION_BID_PLACED)
|
if (Action == AUCTION_BID_PLACED)
|
||||||
data << uint32(auc->GetAuctionOutBid()); // new AuctionOutBid?
|
data << uint32(auc->GetAuctionOutBid()); // new AuctionOutBid?
|
||||||
break;
|
break;
|
||||||
case AUCTION_ERR_INVENTORY:
|
case AUCTION_ERR_INVENTORY:
|
||||||
|
|
@ -125,7 +125,7 @@ void WorldSession::SendAuctionOwnerNotification(AuctionEntry* auction)
|
||||||
data << uint32(auction->GetAuctionOutBid()); // AuctionOutBid?
|
data << uint32(auction->GetAuctionOutBid()); // AuctionOutBid?
|
||||||
|
|
||||||
ObjectGuid guid = ObjectGuid();
|
ObjectGuid guid = ObjectGuid();
|
||||||
if(!auction->moneyDeliveryTime) // not sold yet
|
if (!auction->moneyDeliveryTime) // not sold yet
|
||||||
guid = ObjectGuid(HIGHGUID_PLAYER, auction->bidder);// bidder==0 and moneyDeliveryTime==0 for expired auctions, so it will show error message properly
|
guid = ObjectGuid(HIGHGUID_PLAYER, auction->bidder);// bidder==0 and moneyDeliveryTime==0 for expired auctions, so it will show error message properly
|
||||||
|
|
||||||
// if guid!=0, client updates auctions with new bid, outbid and bidderGuid, else it shows error messages as described above
|
// if guid!=0, client updates auctions with new bid, outbid and bidderGuid, else it shows error messages as described above
|
||||||
|
|
@ -170,7 +170,7 @@ void WorldSession::SendAuctionOutbiddedMail(AuctionEntry *auction)
|
||||||
oldBidder_accId = sObjectMgr.GetPlayerAccountIdByGUID(oldBidder_guid);
|
oldBidder_accId = sObjectMgr.GetPlayerAccountIdByGUID(oldBidder_guid);
|
||||||
|
|
||||||
// old bidder exist
|
// old bidder exist
|
||||||
if(oldBidder || oldBidder_accId)
|
if (oldBidder || oldBidder_accId)
|
||||||
{
|
{
|
||||||
std::ostringstream msgAuctionOutbiddedSubject;
|
std::ostringstream msgAuctionOutbiddedSubject;
|
||||||
msgAuctionOutbiddedSubject << auction->itemTemplate << ":0:" << AUCTION_OUTBIDDED << ":0:0";
|
msgAuctionOutbiddedSubject << auction->itemTemplate << ":0:" << AUCTION_OUTBIDDED << ":0:0";
|
||||||
|
|
@ -185,22 +185,22 @@ void WorldSession::SendAuctionOutbiddedMail(AuctionEntry *auction)
|
||||||
}
|
}
|
||||||
|
|
||||||
// this function sends mail, when auction is cancelled to old bidder
|
// this function sends mail, when auction is cancelled to old bidder
|
||||||
void WorldSession::SendAuctionCancelledToBidderMail( AuctionEntry* auction )
|
void WorldSession::SendAuctionCancelledToBidderMail(AuctionEntry* auction)
|
||||||
{
|
{
|
||||||
ObjectGuid bidder_guid = ObjectGuid(HIGHGUID_PLAYER, auction->bidder);
|
ObjectGuid bidder_guid = ObjectGuid(HIGHGUID_PLAYER, auction->bidder);
|
||||||
Player *bidder = sObjectMgr.GetPlayer(bidder_guid);
|
Player *bidder = sObjectMgr.GetPlayer(bidder_guid);
|
||||||
|
|
||||||
uint32 bidder_accId = 0;
|
uint32 bidder_accId = 0;
|
||||||
if(!bidder)
|
if (!bidder)
|
||||||
bidder_accId = sObjectMgr.GetPlayerAccountIdByGUID(bidder_guid);
|
bidder_accId = sObjectMgr.GetPlayerAccountIdByGUID(bidder_guid);
|
||||||
|
|
||||||
// bidder exist
|
// bidder exist
|
||||||
if(bidder || bidder_accId)
|
if (bidder || bidder_accId)
|
||||||
{
|
{
|
||||||
std::ostringstream msgAuctionCancelledSubject;
|
std::ostringstream msgAuctionCancelledSubject;
|
||||||
msgAuctionCancelledSubject << auction->itemTemplate << ":0:" << AUCTION_CANCELLED_TO_BIDDER << ":0:0";
|
msgAuctionCancelledSubject << auction->itemTemplate << ":0:" << AUCTION_CANCELLED_TO_BIDDER << ":0:0";
|
||||||
|
|
||||||
if(bidder)
|
if (bidder)
|
||||||
bidder->GetSession()->SendAuctionRemovedNotification(auction);
|
bidder->GetSession()->SendAuctionRemovedNotification(auction);
|
||||||
|
|
||||||
MailDraft(msgAuctionCancelledSubject.str(), "") // TODO: fix body
|
MailDraft(msgAuctionCancelledSubject.str(), "") // TODO: fix body
|
||||||
|
|
@ -242,7 +242,7 @@ AuctionHouseEntry const* WorldSession::GetCheckedAuctionHouseForAuctioneer(Objec
|
||||||
}
|
}
|
||||||
|
|
||||||
// this void creates new auction and adds auction to some auctionhouse
|
// this void creates new auction and adds auction to some auctionhouse
|
||||||
void WorldSession::HandleAuctionSellItem( WorldPacket & recv_data )
|
void WorldSession::HandleAuctionSellItem(WorldPacket & recv_data)
|
||||||
{
|
{
|
||||||
DEBUG_LOG("WORLD: HandleAuctionSellItem");
|
DEBUG_LOG("WORLD: HandleAuctionSellItem");
|
||||||
|
|
||||||
|
|
@ -254,7 +254,7 @@ void WorldSession::HandleAuctionSellItem( WorldPacket & recv_data )
|
||||||
recv_data >> auctioneerGuid;
|
recv_data >> auctioneerGuid;
|
||||||
recv_data >> itemCount;
|
recv_data >> itemCount;
|
||||||
|
|
||||||
if(itemCount > MAX_BAG_SIZE * 5)
|
if (itemCount > MAX_BAG_SIZE * 5)
|
||||||
{
|
{
|
||||||
recv_data.rpos(recv_data.wpos()); // should not happen
|
recv_data.rpos(recv_data.wpos()); // should not happen
|
||||||
return;
|
return;
|
||||||
|
|
@ -263,7 +263,7 @@ void WorldSession::HandleAuctionSellItem( WorldPacket & recv_data )
|
||||||
guids.resize(itemCount);
|
guids.resize(itemCount);
|
||||||
stackSizes.resize(itemCount);
|
stackSizes.resize(itemCount);
|
||||||
|
|
||||||
for(uint32 i = 0; i < itemCount; ++i)
|
for (uint32 i = 0; i < itemCount; ++i)
|
||||||
{
|
{
|
||||||
recv_data >> guids[i]; // item guid
|
recv_data >> guids[i]; // item guid
|
||||||
recv_data >> stackSizes[i]; // stack size
|
recv_data >> stackSizes[i]; // stack size
|
||||||
|
|
@ -289,7 +289,7 @@ void WorldSession::HandleAuctionSellItem( WorldPacket & recv_data )
|
||||||
etime *= MINUTE;
|
etime *= MINUTE;
|
||||||
|
|
||||||
// client understand only 3 auction time
|
// client understand only 3 auction time
|
||||||
switch(etime)
|
switch (etime)
|
||||||
{
|
{
|
||||||
case 1*MIN_AUCTION_TIME:
|
case 1*MIN_AUCTION_TIME:
|
||||||
case 2*MIN_AUCTION_TIME:
|
case 2*MIN_AUCTION_TIME:
|
||||||
|
|
@ -300,14 +300,14 @@ void WorldSession::HandleAuctionSellItem( WorldPacket & recv_data )
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove fake death
|
// remove fake death
|
||||||
if(GetPlayer()->hasUnitState(UNIT_STAT_DIED))
|
if (GetPlayer()->hasUnitState(UNIT_STAT_DIED))
|
||||||
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
|
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
|
||||||
|
|
||||||
for(uint32 i = 0; i < itemCount; ++i)
|
for (uint32 i = 0; i < itemCount; ++i)
|
||||||
{
|
{
|
||||||
ObjectGuid itemGuid = guids[i];
|
ObjectGuid itemGuid = guids[i];
|
||||||
|
|
||||||
if(itemGuid.IsEmpty())
|
if (itemGuid.IsEmpty())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
uint32 stackSize = stackSizes[i];
|
uint32 stackSize = stackSizes[i];
|
||||||
|
|
@ -323,13 +323,13 @@ void WorldSession::HandleAuctionSellItem( WorldPacket & recv_data )
|
||||||
}
|
}
|
||||||
|
|
||||||
// prevent sending bag with items (cheat: can be placed in bag after adding equipped empty bag to auction)
|
// prevent sending bag with items (cheat: can be placed in bag after adding equipped empty bag to auction)
|
||||||
if(!it)
|
if (!it)
|
||||||
{
|
{
|
||||||
SendAuctionCommandResult(NULL, AUCTION_STARTED, AUCTION_ERR_INVENTORY, EQUIP_ERR_ITEM_NOT_FOUND);
|
SendAuctionCommandResult(NULL, AUCTION_STARTED, AUCTION_ERR_INVENTORY, EQUIP_ERR_ITEM_NOT_FOUND);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!it->CanBeTraded())
|
if (!it->CanBeTraded())
|
||||||
{
|
{
|
||||||
SendAuctionCommandResult(NULL, AUCTION_STARTED, AUCTION_ERR_INVENTORY, EQUIP_ERR_CANNOT_TRADE_THAT);
|
SendAuctionCommandResult(NULL, AUCTION_STARTED, AUCTION_ERR_INVENTORY, EQUIP_ERR_CANNOT_TRADE_THAT);
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -342,33 +342,33 @@ void WorldSession::HandleAuctionSellItem( WorldPacket & recv_data )
|
||||||
}
|
}
|
||||||
|
|
||||||
// check money for deposit
|
// check money for deposit
|
||||||
uint32 deposit = AuctionHouseMgr::GetAuctionDeposit( auctionHouseEntry, etime, it );
|
uint32 deposit = AuctionHouseMgr::GetAuctionDeposit(auctionHouseEntry, etime, it);
|
||||||
if ( pl->GetMoney() < deposit )
|
if (pl->GetMoney() < deposit)
|
||||||
{
|
{
|
||||||
SendAuctionCommandResult(NULL, AUCTION_STARTED, AUCTION_ERR_NOT_ENOUGH_MONEY);
|
SendAuctionCommandResult(NULL, AUCTION_STARTED, AUCTION_ERR_NOT_ENOUGH_MONEY);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_BOOL_GM_LOG_TRADE) )
|
if (GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_BOOL_GM_LOG_TRADE))
|
||||||
{
|
{
|
||||||
sLog.outCommand(GetAccountId(),"GM %s (Account: %u) create auction: %s (Entry: %u Count: %u)",
|
sLog.outCommand(GetAccountId(),"GM %s (Account: %u) create auction: %s (Entry: %u Count: %u)",
|
||||||
GetPlayerName(), GetAccountId(), it->GetProto()->Name1, it->GetEntry(), it->GetCount());
|
GetPlayerName(), GetAccountId(), it->GetProto()->Name1, it->GetEntry(), it->GetCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(stackSize == 0)
|
if (stackSize == 0)
|
||||||
stackSize = 1;
|
stackSize = 1;
|
||||||
|
|
||||||
if(stackSize > it->GetMaxStackCount()) // too big stack size
|
if (stackSize > it->GetMaxStackCount()) // too big stack size
|
||||||
stackSize = it->GetMaxStackCount();
|
stackSize = it->GetMaxStackCount();
|
||||||
|
|
||||||
if(!pl->HasItemCount(it->GetEntry(), stackSize)) // not enough items
|
if (!pl->HasItemCount(it->GetEntry(), stackSize)) // not enough items
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Item *newItem = it->CloneItem(stackSize, pl);
|
Item *newItem = it->CloneItem(stackSize, pl);
|
||||||
|
|
||||||
pl->DestroyItemCount(it, stackSize, true);
|
pl->DestroyItemCount(it, stackSize, true);
|
||||||
|
|
||||||
pl->ModifyMoney( -int32(deposit) );
|
pl->ModifyMoney(-int32(deposit));
|
||||||
|
|
||||||
uint32 auction_time = uint32(etime * sWorld.getConfig(CONFIG_FLOAT_RATE_AUCTION_TIME));
|
uint32 auction_time = uint32(etime * sWorld.getConfig(CONFIG_FLOAT_RATE_AUCTION_TIME));
|
||||||
|
|
||||||
|
|
@ -405,7 +405,7 @@ void WorldSession::HandleAuctionSellItem( WorldPacket & recv_data )
|
||||||
}
|
}
|
||||||
|
|
||||||
// this function is called when client bids or buys out auction
|
// this function is called when client bids or buys out auction
|
||||||
void WorldSession::HandleAuctionPlaceBid( WorldPacket & recv_data )
|
void WorldSession::HandleAuctionPlaceBid(WorldPacket & recv_data)
|
||||||
{
|
{
|
||||||
DEBUG_LOG("WORLD: HandleAuctionPlaceBid");
|
DEBUG_LOG("WORLD: HandleAuctionPlaceBid");
|
||||||
|
|
||||||
|
|
@ -426,16 +426,16 @@ void WorldSession::HandleAuctionPlaceBid( WorldPacket & recv_data )
|
||||||
AuctionHouseObject* auctionHouse = sAuctionMgr.GetAuctionsMap(auctionHouseEntry);
|
AuctionHouseObject* auctionHouse = sAuctionMgr.GetAuctionsMap(auctionHouseEntry);
|
||||||
|
|
||||||
// remove fake death
|
// remove fake death
|
||||||
if(GetPlayer()->hasUnitState(UNIT_STAT_DIED))
|
if (GetPlayer()->hasUnitState(UNIT_STAT_DIED))
|
||||||
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
|
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
|
||||||
|
|
||||||
AuctionEntry *auction = auctionHouse->GetAuction(auctionId);
|
AuctionEntry *auction = auctionHouse->GetAuction(auctionId);
|
||||||
Player *pl = GetPlayer();
|
Player *pl = GetPlayer();
|
||||||
|
|
||||||
if( !auction || auction->owner == pl->GetGUIDLow() )
|
if (!auction || auction->owner == pl->GetGUIDLow())
|
||||||
{
|
{
|
||||||
// you cannot bid your own auction:
|
// you cannot bid your own auction:
|
||||||
SendAuctionCommandResult( NULL, AUCTION_BID_PLACED, AUCTION_ERR_BID_OWN );
|
SendAuctionCommandResult(NULL, AUCTION_BID_PLACED, AUCTION_ERR_BID_OWN);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -446,12 +446,12 @@ void WorldSession::HandleAuctionPlaceBid( WorldPacket & recv_data )
|
||||||
if (!auction_owner && sObjectMgr.GetPlayerAccountIdByGUID(ownerGuid) == pl->GetSession()->GetAccountId())
|
if (!auction_owner && sObjectMgr.GetPlayerAccountIdByGUID(ownerGuid) == pl->GetSession()->GetAccountId())
|
||||||
{
|
{
|
||||||
// you cannot bid your another character auction:
|
// you cannot bid your another character auction:
|
||||||
SendAuctionCommandResult( NULL, AUCTION_BID_PLACED, AUCTION_ERR_BID_OWN );
|
SendAuctionCommandResult(NULL, AUCTION_BID_PLACED, AUCTION_ERR_BID_OWN);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// cheating
|
// cheating
|
||||||
if(price <= auction->bid || price < auction->startbid)
|
if (price <= auction->bid || price < auction->startbid)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// price too low for next bid if not buyout
|
// price too low for next bid if not buyout
|
||||||
|
|
@ -485,7 +485,7 @@ void WorldSession::HandleAuctionPlaceBid( WorldPacket & recv_data )
|
||||||
auction->bidder = pl->GetGUIDLow();
|
auction->bidder = pl->GetGUIDLow();
|
||||||
auction->bid = price;
|
auction->bid = price;
|
||||||
|
|
||||||
if(auction_owner)
|
if (auction_owner)
|
||||||
auction_owner->GetSession()->SendAuctionOwnerNotification(auction);
|
auction_owner->GetSession()->SendAuctionOwnerNotification(auction);
|
||||||
|
|
||||||
GetPlayer()->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_BID, price);
|
GetPlayer()->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_BID, price);
|
||||||
|
|
@ -527,7 +527,7 @@ void WorldSession::HandleAuctionPlaceBid( WorldPacket & recv_data )
|
||||||
}
|
}
|
||||||
|
|
||||||
// this void is called when auction_owner cancels his auction
|
// this void is called when auction_owner cancels his auction
|
||||||
void WorldSession::HandleAuctionRemoveItem( WorldPacket & recv_data )
|
void WorldSession::HandleAuctionRemoveItem(WorldPacket & recv_data)
|
||||||
{
|
{
|
||||||
DEBUG_LOG("WORLD: HandleAuctionRemoveItem");
|
DEBUG_LOG("WORLD: HandleAuctionRemoveItem");
|
||||||
|
|
||||||
|
|
@ -535,7 +535,7 @@ void WorldSession::HandleAuctionRemoveItem( WorldPacket & recv_data )
|
||||||
uint32 auctionId;
|
uint32 auctionId;
|
||||||
recv_data >> auctioneerGuid;
|
recv_data >> auctioneerGuid;
|
||||||
recv_data >> auctionId;
|
recv_data >> auctionId;
|
||||||
//DEBUG_LOG( "Cancel AUCTION AuctionID: %u", auctionId);
|
//DEBUG_LOG("Cancel AUCTION AuctionID: %u", auctionId);
|
||||||
|
|
||||||
AuctionHouseEntry const* auctionHouseEntry = GetCheckedAuctionHouseForAuctioneer(auctioneerGuid);
|
AuctionHouseEntry const* auctionHouseEntry = GetCheckedAuctionHouseForAuctioneer(auctioneerGuid);
|
||||||
if (!auctionHouseEntry)
|
if (!auctionHouseEntry)
|
||||||
|
|
@ -545,7 +545,7 @@ void WorldSession::HandleAuctionRemoveItem( WorldPacket & recv_data )
|
||||||
AuctionHouseObject* auctionHouse = sAuctionMgr.GetAuctionsMap(auctionHouseEntry);
|
AuctionHouseObject* auctionHouse = sAuctionMgr.GetAuctionsMap(auctionHouseEntry);
|
||||||
|
|
||||||
// remove fake death
|
// remove fake death
|
||||||
if(GetPlayer()->hasUnitState(UNIT_STAT_DIED))
|
if (GetPlayer()->hasUnitState(UNIT_STAT_DIED))
|
||||||
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
|
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
|
||||||
|
|
||||||
AuctionEntry *auction = auctionHouse->GetAuction(auctionId);
|
AuctionEntry *auction = auctionHouse->GetAuction(auctionId);
|
||||||
|
|
@ -559,11 +559,11 @@ void WorldSession::HandleAuctionRemoveItem( WorldPacket & recv_data )
|
||||||
if (auction->bidder > 0) // If we have a bidder, we have to send him the money he paid
|
if (auction->bidder > 0) // If we have a bidder, we have to send him the money he paid
|
||||||
{
|
{
|
||||||
uint32 auctionCut = auction->GetAuctionCut();
|
uint32 auctionCut = auction->GetAuctionCut();
|
||||||
if ( pl->GetMoney() < auctionCut ) // player doesn't have enough money, maybe message needed
|
if (pl->GetMoney() < auctionCut) // player doesn't have enough money, maybe message needed
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SendAuctionCancelledToBidderMail( auction );
|
SendAuctionCancelledToBidderMail(auction);
|
||||||
pl->ModifyMoney( -int32(auctionCut) );
|
pl->ModifyMoney(-int32(auctionCut));
|
||||||
}
|
}
|
||||||
// Return the item by mail
|
// Return the item by mail
|
||||||
std::ostringstream msgAuctionCanceledOwner;
|
std::ostringstream msgAuctionCanceledOwner;
|
||||||
|
|
@ -577,32 +577,32 @@ void WorldSession::HandleAuctionRemoveItem( WorldPacket & recv_data )
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sLog.outError("Auction id: %u has nonexistent item (item guid : %u)!!!", auction->Id, auction->itemGuidLow);
|
sLog.outError("Auction id: %u has nonexistent item (item guid : %u)!!!", auction->Id, auction->itemGuidLow);
|
||||||
SendAuctionCommandResult( NULL, AUCTION_REMOVED, AUCTION_ERR_INVENTORY, EQUIP_ERR_ITEM_NOT_FOUND );
|
SendAuctionCommandResult(NULL, AUCTION_REMOVED, AUCTION_ERR_INVENTORY, EQUIP_ERR_ITEM_NOT_FOUND);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SendAuctionCommandResult( NULL, AUCTION_REMOVED, AUCTION_ERR_DATABASE );
|
SendAuctionCommandResult(NULL, AUCTION_REMOVED, AUCTION_ERR_DATABASE);
|
||||||
// this code isn't possible ... maybe there should be ASSERT
|
// this code isn't possible ... maybe there should be ASSERT
|
||||||
sLog.outError("CHEATER : %u, he tried to cancel auction (id: %u) of another player, or auction is NULL", pl->GetGUIDLow(), auctionId);
|
sLog.outError("CHEATER : %u, he tried to cancel auction (id: %u) of another player, or auction is NULL", pl->GetGUIDLow(), auctionId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// inform player, that auction is removed
|
// inform player, that auction is removed
|
||||||
SendAuctionCommandResult(auction, AUCTION_REMOVED, AUCTION_OK );
|
SendAuctionCommandResult(auction, AUCTION_REMOVED, AUCTION_OK);
|
||||||
// Now remove the auction
|
// Now remove the auction
|
||||||
CharacterDatabase.BeginTransaction();
|
CharacterDatabase.BeginTransaction();
|
||||||
auction->DeleteFromDB();
|
auction->DeleteFromDB();
|
||||||
pl->SaveInventoryAndGoldToDB();
|
pl->SaveInventoryAndGoldToDB();
|
||||||
CharacterDatabase.CommitTransaction();
|
CharacterDatabase.CommitTransaction();
|
||||||
sAuctionMgr.RemoveAItem( auction->itemGuidLow );
|
sAuctionMgr.RemoveAItem(auction->itemGuidLow);
|
||||||
auctionHouse->RemoveAuction( auction->Id );
|
auctionHouse->RemoveAuction(auction->Id);
|
||||||
delete auction;
|
delete auction;
|
||||||
}
|
}
|
||||||
|
|
||||||
// called when player lists his bids
|
// called when player lists his bids
|
||||||
void WorldSession::HandleAuctionListBidderItems( WorldPacket & recv_data )
|
void WorldSession::HandleAuctionListBidderItems(WorldPacket & recv_data)
|
||||||
{
|
{
|
||||||
DEBUG_LOG("WORLD: HandleAuctionListBidderItems");
|
DEBUG_LOG("WORLD: HandleAuctionListBidderItems");
|
||||||
|
|
||||||
|
|
@ -613,9 +613,9 @@ void WorldSession::HandleAuctionListBidderItems( WorldPacket & recv_data )
|
||||||
recv_data >> auctioneerGuid;
|
recv_data >> auctioneerGuid;
|
||||||
recv_data >> listfrom; // not used in fact (this list not have page control in client)
|
recv_data >> listfrom; // not used in fact (this list not have page control in client)
|
||||||
recv_data >> outbiddedCount;
|
recv_data >> outbiddedCount;
|
||||||
if (recv_data.size() != (16 + outbiddedCount * 4 ))
|
if (recv_data.size() != (16 + outbiddedCount * 4))
|
||||||
{
|
{
|
||||||
sLog.outError("Client sent bad opcode!!! with count: %u and size : %lu (must be: %u)", outbiddedCount, (unsigned long)recv_data.size(),(16 + outbiddedCount * 4 ));
|
sLog.outError("Client sent bad opcode!!! with count: %u and size : %u (must be: %u)", outbiddedCount, (uint32)recv_data.size(), (16 + outbiddedCount * 4));
|
||||||
outbiddedCount = 0;
|
outbiddedCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -627,21 +627,21 @@ void WorldSession::HandleAuctionListBidderItems( WorldPacket & recv_data )
|
||||||
AuctionHouseObject* auctionHouse = sAuctionMgr.GetAuctionsMap(auctionHouseEntry);
|
AuctionHouseObject* auctionHouse = sAuctionMgr.GetAuctionsMap(auctionHouseEntry);
|
||||||
|
|
||||||
// remove fake death
|
// remove fake death
|
||||||
if(GetPlayer()->hasUnitState(UNIT_STAT_DIED))
|
if (GetPlayer()->hasUnitState(UNIT_STAT_DIED))
|
||||||
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
|
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
|
||||||
|
|
||||||
WorldPacket data( SMSG_AUCTION_BIDDER_LIST_RESULT, (4+4+4) );
|
WorldPacket data(SMSG_AUCTION_BIDDER_LIST_RESULT, (4+4+4));
|
||||||
Player *pl = GetPlayer();
|
Player *pl = GetPlayer();
|
||||||
data << uint32(0); // add 0 as count
|
data << uint32(0); // add 0 as count
|
||||||
uint32 count = 0;
|
uint32 count = 0;
|
||||||
uint32 totalcount = 0;
|
uint32 totalcount = 0;
|
||||||
while ( outbiddedCount > 0) // add all data, which client requires
|
while (outbiddedCount > 0) // add all data, which client requires
|
||||||
{
|
{
|
||||||
--outbiddedCount;
|
--outbiddedCount;
|
||||||
uint32 outbiddedAuctionId;
|
uint32 outbiddedAuctionId;
|
||||||
recv_data >> outbiddedAuctionId;
|
recv_data >> outbiddedAuctionId;
|
||||||
AuctionEntry * auction = auctionHouse->GetAuction( outbiddedAuctionId );
|
AuctionEntry *auction = auctionHouse->GetAuction(outbiddedAuctionId);
|
||||||
if ( auction && auction->BuildAuctionInfo(data))
|
if (auction && auction->BuildAuctionInfo(data))
|
||||||
{
|
{
|
||||||
++totalcount;
|
++totalcount;
|
||||||
++count;
|
++count;
|
||||||
|
|
@ -649,14 +649,14 @@ void WorldSession::HandleAuctionListBidderItems( WorldPacket & recv_data )
|
||||||
}
|
}
|
||||||
|
|
||||||
auctionHouse->BuildListBidderItems(data, pl, count, totalcount);
|
auctionHouse->BuildListBidderItems(data, pl, count, totalcount);
|
||||||
data.put<uint32>( 0, count ); // add count to placeholder
|
data.put<uint32>(0, count); // add count to placeholder
|
||||||
data << uint32(totalcount);
|
data << uint32(totalcount);
|
||||||
data << uint32(300); // unk 2.3.0 delay for next list request?
|
data << uint32(300); // unk 2.3.0 delay for next isFull request?
|
||||||
SendPacket(&data);
|
SendPacket(&data);
|
||||||
}
|
}
|
||||||
|
|
||||||
// this void sends player info about his auctions
|
// this void sends player info about his auctions
|
||||||
void WorldSession::HandleAuctionListOwnerItems( WorldPacket & recv_data )
|
void WorldSession::HandleAuctionListOwnerItems(WorldPacket & recv_data)
|
||||||
{
|
{
|
||||||
DEBUG_LOG("WORLD: HandleAuctionListOwnerItems");
|
DEBUG_LOG("WORLD: HandleAuctionListOwnerItems");
|
||||||
|
|
||||||
|
|
@ -674,11 +674,11 @@ void WorldSession::HandleAuctionListOwnerItems( WorldPacket & recv_data )
|
||||||
AuctionHouseObject* auctionHouse = sAuctionMgr.GetAuctionsMap(auctionHouseEntry);
|
AuctionHouseObject* auctionHouse = sAuctionMgr.GetAuctionsMap(auctionHouseEntry);
|
||||||
|
|
||||||
// remove fake death
|
// remove fake death
|
||||||
if(GetPlayer()->hasUnitState(UNIT_STAT_DIED))
|
if (GetPlayer()->hasUnitState(UNIT_STAT_DIED))
|
||||||
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
|
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
|
||||||
|
|
||||||
WorldPacket data( SMSG_AUCTION_OWNER_LIST_RESULT, (4+4+4) );
|
WorldPacket data(SMSG_AUCTION_OWNER_LIST_RESULT, (4+4+4));
|
||||||
data << (uint32) 0; // amount place holder
|
data << uint32(0); // amount place holder
|
||||||
|
|
||||||
uint32 count = 0;
|
uint32 count = 0;
|
||||||
uint32 totalcount = 0;
|
uint32 totalcount = 0;
|
||||||
|
|
@ -686,12 +686,12 @@ void WorldSession::HandleAuctionListOwnerItems( WorldPacket & recv_data )
|
||||||
auctionHouse->BuildListOwnerItems(data, _player, count, totalcount);
|
auctionHouse->BuildListOwnerItems(data, _player, count, totalcount);
|
||||||
data.put<uint32>(0, count);
|
data.put<uint32>(0, count);
|
||||||
data << uint32(totalcount);
|
data << uint32(totalcount);
|
||||||
data << uint32(300); // 2.3.0 delay for next list request?
|
data << uint32(300); // 2.3.0 delay for next isFull request?
|
||||||
SendPacket(&data);
|
SendPacket(&data);
|
||||||
}
|
}
|
||||||
|
|
||||||
// this void is called when player clicks on search button
|
// this void is called when player clicks on search button
|
||||||
void WorldSession::HandleAuctionListItems( WorldPacket & recv_data )
|
void WorldSession::HandleAuctionListItems(WorldPacket & recv_data)
|
||||||
{
|
{
|
||||||
DEBUG_LOG("WORLD: HandleAuctionListItems");
|
DEBUG_LOG("WORLD: HandleAuctionListItems");
|
||||||
|
|
||||||
|
|
@ -708,11 +708,23 @@ void WorldSession::HandleAuctionListItems( WorldPacket & recv_data )
|
||||||
recv_data >> auctionSlotID >> auctionMainCategory >> auctionSubCategory >> quality;
|
recv_data >> auctionSlotID >> auctionMainCategory >> auctionSubCategory >> quality;
|
||||||
recv_data >> usable >> isFull >> sortCount;
|
recv_data >> usable >> isFull >> sortCount;
|
||||||
|
|
||||||
|
if (sortCount >= MAX_AUCTION_SORT)
|
||||||
|
return;
|
||||||
|
|
||||||
|
uint8 Sort[MAX_AUCTION_SORT];
|
||||||
|
memset(Sort, MAX_AUCTION_SORT, MAX_AUCTION_SORT);
|
||||||
|
|
||||||
// auction columns sorting
|
// auction columns sorting
|
||||||
for(uint32 i = 0; i < sortCount; ++i)
|
for (uint32 i = 0; i < sortCount; ++i)
|
||||||
{
|
{
|
||||||
recv_data.read_skip<uint8>(); // column?
|
uint8 column, reversed;
|
||||||
recv_data.read_skip<uint8>(); // direction?
|
recv_data >> column;
|
||||||
|
|
||||||
|
if (column >= MAX_AUCTION_SORT)
|
||||||
|
return;
|
||||||
|
|
||||||
|
recv_data >> reversed;
|
||||||
|
Sort[i] = (reversed > 0) ? (column |= AUCTION_SORT_REVERSED) : column;
|
||||||
}
|
}
|
||||||
|
|
||||||
AuctionHouseEntry const* auctionHouseEntry = GetCheckedAuctionHouseForAuctioneer(auctioneerGuid);
|
AuctionHouseEntry const* auctionHouseEntry = GetCheckedAuctionHouseForAuctioneer(auctioneerGuid);
|
||||||
|
|
@ -722,37 +734,43 @@ void WorldSession::HandleAuctionListItems( WorldPacket & recv_data )
|
||||||
// always return pointer
|
// always return pointer
|
||||||
AuctionHouseObject* auctionHouse = sAuctionMgr.GetAuctionsMap(auctionHouseEntry);
|
AuctionHouseObject* auctionHouse = sAuctionMgr.GetAuctionsMap(auctionHouseEntry);
|
||||||
|
|
||||||
|
// Sort
|
||||||
|
AuctionHouseObject::AuctionEntryMap *aucs = auctionHouse->GetAuctions();
|
||||||
|
std::list<AuctionEntry*> auctions;
|
||||||
|
for (AuctionHouseObject::AuctionEntryMap::const_iterator itr = aucs->begin(); itr != aucs->end(); ++itr)
|
||||||
|
auctions.push_back(itr->second);
|
||||||
|
AuctionSorter sorter(Sort);
|
||||||
|
auctions.sort(sorter);
|
||||||
|
|
||||||
// remove fake death
|
// remove fake death
|
||||||
if(GetPlayer()->hasUnitState(UNIT_STAT_DIED))
|
if (GetPlayer()->hasUnitState(UNIT_STAT_DIED))
|
||||||
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
|
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
|
||||||
|
|
||||||
//DEBUG_LOG("Auctionhouse search %s list from: %u, searchedname: %s, levelmin: %u, levelmax: %u, auctionSlotID: %u, auctionMainCategory: %u, auctionSubCategory: %u, quality: %u, usable: %u",
|
//DEBUG_LOG("Auctionhouse search %s list from: %u, searchedname: %s, levelmin: %u, levelmax: %u, auctionSlotID: %u, auctionMainCategory: %u, auctionSubCategory: %u, quality: %u, usable: %u",
|
||||||
// auctioneerGuid.GetString().c_str(), listfrom, searchedname.c_str(), levelmin, levelmax, auctionSlotID, auctionMainCategory, auctionSubCategory, quality, usable);
|
// auctioneerGuid.GetString().c_str(), listfrom, searchedname.c_str(), levelmin, levelmax, auctionSlotID, auctionMainCategory, auctionSubCategory, quality, usable);
|
||||||
|
|
||||||
WorldPacket data( SMSG_AUCTION_LIST_RESULT, (4+4+4) );
|
WorldPacket data(SMSG_AUCTION_LIST_RESULT, (4+4+4));
|
||||||
uint32 count = 0;
|
uint32 count = 0;
|
||||||
uint32 totalcount = 0;
|
uint32 totalcount = 0;
|
||||||
data << uint32(0);
|
data << uint32(0);
|
||||||
|
|
||||||
// converting string that we try to find to lower case
|
// converting string that we try to find to lower case
|
||||||
std::wstring wsearchedname;
|
std::wstring wsearchedname;
|
||||||
if(!Utf8toWStr(searchedname,wsearchedname))
|
if (!Utf8toWStr(searchedname, wsearchedname))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wstrToLower(wsearchedname);
|
wstrToLower(wsearchedname);
|
||||||
|
|
||||||
auctionHouse->BuildListAuctionItems(data, _player,
|
BuildListAuctionItems(auctions, data, wsearchedname, listfrom, levelmin, levelmax, usable,
|
||||||
wsearchedname, listfrom, levelmin, levelmax, usable,
|
auctionSlotID, auctionMainCategory, auctionSubCategory, quality, count, totalcount, isFull);
|
||||||
auctionSlotID, auctionMainCategory, auctionSubCategory, quality,
|
|
||||||
count, totalcount);
|
|
||||||
|
|
||||||
data.put<uint32>(0, count);
|
data.put<uint32>(0, count);
|
||||||
data << uint32(totalcount);
|
data << uint32(totalcount);
|
||||||
data << uint32(300); // 2.3.0 delay for next list request?
|
data << uint32(300); // 2.3.0 delay for next isFull request?
|
||||||
SendPacket(&data);
|
SendPacket(&data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldSession::HandleAuctionListPendingSales( WorldPacket & recv_data )
|
void WorldSession::HandleAuctionListPendingSales(WorldPacket & recv_data)
|
||||||
{
|
{
|
||||||
DEBUG_LOG("CMSG_AUCTION_LIST_PENDING_SALES");
|
DEBUG_LOG("CMSG_AUCTION_LIST_PENDING_SALES");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@
|
||||||
|
|
||||||
#include "Policies/SingletonImp.h"
|
#include "Policies/SingletonImp.h"
|
||||||
|
|
||||||
INSTANTIATE_SINGLETON_1( AuctionHouseMgr );
|
INSTANTIATE_SINGLETON_1(AuctionHouseMgr);
|
||||||
|
|
||||||
AuctionHouseMgr::AuctionHouseMgr()
|
AuctionHouseMgr::AuctionHouseMgr()
|
||||||
{
|
{
|
||||||
|
|
@ -64,7 +64,7 @@ AuctionHouseObject * AuctionHouseMgr::GetAuctionsMap(AuctionHouseEntry const* ho
|
||||||
|
|
||||||
uint32 AuctionHouseMgr::GetAuctionDeposit(AuctionHouseEntry const* entry, uint32 time, Item *pItem)
|
uint32 AuctionHouseMgr::GetAuctionDeposit(AuctionHouseEntry const* entry, uint32 time, Item *pItem)
|
||||||
{
|
{
|
||||||
float deposit = float(pItem->GetProto()->SellPrice * pItem->GetCount() * (time / MIN_AUCTION_TIME ));
|
float deposit = float(pItem->GetProto()->SellPrice * pItem->GetCount() * (time / MIN_AUCTION_TIME));
|
||||||
|
|
||||||
deposit = deposit * entry->depositPercent * 3.0f / 100.0f;
|
deposit = deposit * entry->depositPercent * 3.0f / 100.0f;
|
||||||
|
|
||||||
|
|
@ -77,10 +77,10 @@ uint32 AuctionHouseMgr::GetAuctionDeposit(AuctionHouseEntry const* entry, uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
// does not clear ram
|
// does not clear ram
|
||||||
void AuctionHouseMgr::SendAuctionWonMail( AuctionEntry *auction )
|
void AuctionHouseMgr::SendAuctionWonMail(AuctionEntry *auction)
|
||||||
{
|
{
|
||||||
Item *pItem = GetAItem(auction->itemGuidLow);
|
Item *pItem = GetAItem(auction->itemGuidLow);
|
||||||
if(!pItem)
|
if (!pItem)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ObjectGuid bidder_guid = ObjectGuid(HIGHGUID_PLAYER, auction->bidder);
|
ObjectGuid bidder_guid = ObjectGuid(HIGHGUID_PLAYER, auction->bidder);
|
||||||
|
|
@ -89,7 +89,7 @@ void AuctionHouseMgr::SendAuctionWonMail( AuctionEntry *auction )
|
||||||
uint32 bidder_accId = 0;
|
uint32 bidder_accId = 0;
|
||||||
|
|
||||||
// data for gm.log
|
// data for gm.log
|
||||||
if( sWorld.getConfig(CONFIG_BOOL_GM_LOG_TRADE) )
|
if (sWorld.getConfig(CONFIG_BOOL_GM_LOG_TRADE))
|
||||||
{
|
{
|
||||||
uint32 bidder_security = 0;
|
uint32 bidder_security = 0;
|
||||||
std::string bidder_name;
|
std::string bidder_name;
|
||||||
|
|
@ -104,7 +104,7 @@ void AuctionHouseMgr::SendAuctionWonMail( AuctionEntry *auction )
|
||||||
bidder_accId = sObjectMgr.GetPlayerAccountIdByGUID(bidder_guid);
|
bidder_accId = sObjectMgr.GetPlayerAccountIdByGUID(bidder_guid);
|
||||||
bidder_security = sAccountMgr.GetSecurity(bidder_accId);
|
bidder_security = sAccountMgr.GetSecurity(bidder_accId);
|
||||||
|
|
||||||
if (bidder_security > SEC_PLAYER ) // not do redundant DB requests
|
if (bidder_security > SEC_PLAYER) // not do redundant DB requests
|
||||||
{
|
{
|
||||||
if (!sObjectMgr.GetPlayerNameByGUID(bidder_guid, bidder_name))
|
if (!sObjectMgr.GetPlayerNameByGUID(bidder_guid, bidder_name))
|
||||||
bidder_name = sObjectMgr.GetMangosStringForDBCLocale(LANG_UNKNOWN);
|
bidder_name = sObjectMgr.GetMangosStringForDBCLocale(LANG_UNKNOWN);
|
||||||
|
|
@ -115,7 +115,7 @@ void AuctionHouseMgr::SendAuctionWonMail( AuctionEntry *auction )
|
||||||
{
|
{
|
||||||
ObjectGuid owner_guid = ObjectGuid(HIGHGUID_PLAYER, auction->owner);
|
ObjectGuid owner_guid = ObjectGuid(HIGHGUID_PLAYER, auction->owner);
|
||||||
std::string owner_name;
|
std::string owner_name;
|
||||||
if(!sObjectMgr.GetPlayerNameByGUID(owner_guid, owner_name))
|
if (!sObjectMgr.GetPlayerNameByGUID(owner_guid, owner_name))
|
||||||
owner_name = sObjectMgr.GetMangosStringForDBCLocale(LANG_UNKNOWN);
|
owner_name = sObjectMgr.GetMangosStringForDBCLocale(LANG_UNKNOWN);
|
||||||
|
|
||||||
uint32 owner_accid = sObjectMgr.GetPlayerAccountIdByGUID(owner_guid);
|
uint32 owner_accid = sObjectMgr.GetPlayerAccountIdByGUID(owner_guid);
|
||||||
|
|
@ -129,11 +129,11 @@ void AuctionHouseMgr::SendAuctionWonMail( AuctionEntry *auction )
|
||||||
|
|
||||||
ObjectGuid ownerGuid = ObjectGuid(HIGHGUID_PLAYER, auction->owner);
|
ObjectGuid ownerGuid = ObjectGuid(HIGHGUID_PLAYER, auction->owner);
|
||||||
Player* auction_owner = sObjectMgr.GetPlayer(ownerGuid);
|
Player* auction_owner = sObjectMgr.GetPlayer(ownerGuid);
|
||||||
if(auction_owner)
|
if (auction_owner)
|
||||||
auction_owner->GetSession()->SendAuctionOwnerNotification( auction );
|
auction_owner->GetSession()->SendAuctionOwnerNotification(auction);
|
||||||
|
|
||||||
// receiver exist
|
// receiver exist
|
||||||
if(bidder || bidder_accId)
|
if (bidder || bidder_accId)
|
||||||
{
|
{
|
||||||
std::ostringstream msgAuctionWonSubject;
|
std::ostringstream msgAuctionWonSubject;
|
||||||
msgAuctionWonSubject << auction->itemTemplate << ":0:" << AUCTION_WON;
|
msgAuctionWonSubject << auction->itemTemplate << ":0:" << AUCTION_WON;
|
||||||
|
|
@ -142,7 +142,7 @@ void AuctionHouseMgr::SendAuctionWonMail( AuctionEntry *auction )
|
||||||
msgAuctionWonBody.width(16);
|
msgAuctionWonBody.width(16);
|
||||||
msgAuctionWonBody << std::right << std::hex << auction->owner;
|
msgAuctionWonBody << std::right << std::hex << auction->owner;
|
||||||
msgAuctionWonBody << std::dec << ":" << auction->bid << ":" << auction->buyout;
|
msgAuctionWonBody << std::dec << ":" << auction->bid << ":" << auction->buyout;
|
||||||
DEBUG_LOG( "AuctionWon body string : %s", msgAuctionWonBody.str().c_str() );
|
DEBUG_LOG("AuctionWon body string : %s", msgAuctionWonBody.str().c_str());
|
||||||
|
|
||||||
// set owner to bidder (to prevent delete item with sender char deleting)
|
// set owner to bidder (to prevent delete item with sender char deleting)
|
||||||
// owner in `data` will set at mail receive and item extracting
|
// owner in `data` will set at mail receive and item extracting
|
||||||
|
|
@ -172,13 +172,13 @@ void AuctionHouseMgr::SendAuctionWonMail( AuctionEntry *auction )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AuctionHouseMgr::SendAuctionSalePendingMail( AuctionEntry * auction )
|
void AuctionHouseMgr::SendAuctionSalePendingMail(AuctionEntry * auction)
|
||||||
{
|
{
|
||||||
ObjectGuid owner_guid = ObjectGuid(HIGHGUID_PLAYER, auction->owner);
|
ObjectGuid owner_guid = ObjectGuid(HIGHGUID_PLAYER, auction->owner);
|
||||||
Player *owner = sObjectMgr.GetPlayer(owner_guid);
|
Player *owner = sObjectMgr.GetPlayer(owner_guid);
|
||||||
|
|
||||||
// owner exist (online or offline)
|
// owner exist (online or offline)
|
||||||
if(owner || sObjectMgr.GetPlayerAccountIdByGUID(owner_guid))
|
if (owner || sObjectMgr.GetPlayerAccountIdByGUID(owner_guid))
|
||||||
{
|
{
|
||||||
std::ostringstream msgAuctionSalePendingSubject;
|
std::ostringstream msgAuctionSalePendingSubject;
|
||||||
msgAuctionSalePendingSubject << auction->itemTemplate << ":0:" << AUCTION_SALE_PENDING;
|
msgAuctionSalePendingSubject << auction->itemTemplate << ":0:" << AUCTION_SALE_PENDING;
|
||||||
|
|
@ -202,17 +202,17 @@ void AuctionHouseMgr::SendAuctionSalePendingMail( AuctionEntry * auction )
|
||||||
}
|
}
|
||||||
|
|
||||||
// call this method to send mail to auction owner, when auction is successful, it does not clear ram
|
// call this method to send mail to auction owner, when auction is successful, it does not clear ram
|
||||||
void AuctionHouseMgr::SendAuctionSuccessfulMail( AuctionEntry * auction )
|
void AuctionHouseMgr::SendAuctionSuccessfulMail(AuctionEntry * auction)
|
||||||
{
|
{
|
||||||
ObjectGuid owner_guid = ObjectGuid(HIGHGUID_PLAYER, auction->owner);
|
ObjectGuid owner_guid = ObjectGuid(HIGHGUID_PLAYER, auction->owner);
|
||||||
Player *owner = sObjectMgr.GetPlayer(owner_guid);
|
Player *owner = sObjectMgr.GetPlayer(owner_guid);
|
||||||
|
|
||||||
uint32 owner_accId = 0;
|
uint32 owner_accId = 0;
|
||||||
if(!owner)
|
if (!owner)
|
||||||
owner_accId = sObjectMgr.GetPlayerAccountIdByGUID(owner_guid);
|
owner_accId = sObjectMgr.GetPlayerAccountIdByGUID(owner_guid);
|
||||||
|
|
||||||
// owner exist
|
// owner exist
|
||||||
if(owner || owner_accId)
|
if (owner || owner_accId)
|
||||||
{
|
{
|
||||||
std::ostringstream msgAuctionSuccessfulSubject;
|
std::ostringstream msgAuctionSuccessfulSubject;
|
||||||
msgAuctionSuccessfulSubject << auction->itemTemplate << ":0:" << AUCTION_SUCCESSFUL;
|
msgAuctionSuccessfulSubject << auction->itemTemplate << ":0:" << AUCTION_SUCCESSFUL;
|
||||||
|
|
@ -243,10 +243,10 @@ void AuctionHouseMgr::SendAuctionSuccessfulMail( AuctionEntry * auction )
|
||||||
}
|
}
|
||||||
|
|
||||||
// does not clear ram
|
// does not clear ram
|
||||||
void AuctionHouseMgr::SendAuctionExpiredMail( AuctionEntry * auction )
|
void AuctionHouseMgr::SendAuctionExpiredMail(AuctionEntry * auction)
|
||||||
{ // return an item in auction to its owner by mail
|
{ // return an item in auction to its owner by mail
|
||||||
Item *pItem = GetAItem(auction->itemGuidLow);
|
Item *pItem = GetAItem(auction->itemGuidLow);
|
||||||
if(!pItem)
|
if (!pItem)
|
||||||
{
|
{
|
||||||
sLog.outError("Auction item (GUID: %u) not found, and lost.", auction->itemGuidLow);
|
sLog.outError("Auction item (GUID: %u) not found, and lost.", auction->itemGuidLow);
|
||||||
return;
|
return;
|
||||||
|
|
@ -256,17 +256,17 @@ void AuctionHouseMgr::SendAuctionExpiredMail( AuctionEntry * auction )
|
||||||
Player *owner = sObjectMgr.GetPlayer(owner_guid);
|
Player *owner = sObjectMgr.GetPlayer(owner_guid);
|
||||||
|
|
||||||
uint32 owner_accId = 0;
|
uint32 owner_accId = 0;
|
||||||
if(!owner)
|
if (!owner)
|
||||||
owner_accId = sObjectMgr.GetPlayerAccountIdByGUID(owner_guid);
|
owner_accId = sObjectMgr.GetPlayerAccountIdByGUID(owner_guid);
|
||||||
|
|
||||||
// owner exist
|
// owner exist
|
||||||
if(owner || owner_accId)
|
if (owner || owner_accId)
|
||||||
{
|
{
|
||||||
std::ostringstream subject;
|
std::ostringstream subject;
|
||||||
subject << auction->itemGuidLow << ":0:" << AUCTION_EXPIRED << ":0:0";
|
subject << auction->itemGuidLow << ":0:" << AUCTION_EXPIRED << ":0:0";
|
||||||
|
|
||||||
if ( owner )
|
if (owner)
|
||||||
owner->GetSession()->SendAuctionOwnerNotification( auction );
|
owner->GetSession()->SendAuctionOwnerNotification(auction);
|
||||||
else
|
else
|
||||||
RemoveAItem(pItem->GetGUIDLow()); // we have to remove the item, before we delete it !!
|
RemoveAItem(pItem->GetGUIDLow()); // we have to remove the item, before we delete it !!
|
||||||
|
|
||||||
|
|
@ -287,9 +287,9 @@ void AuctionHouseMgr::SendAuctionExpiredMail( AuctionEntry * auction )
|
||||||
void AuctionHouseMgr::LoadAuctionItems()
|
void AuctionHouseMgr::LoadAuctionItems()
|
||||||
{
|
{
|
||||||
// data needs to be at first place for Item::LoadFromDB 0 1 2 3
|
// data needs to be at first place for Item::LoadFromDB 0 1 2 3
|
||||||
QueryResult *result = CharacterDatabase.Query( "SELECT data,text,itemguid,item_template FROM auction JOIN item_instance ON itemguid = guid" );
|
QueryResult *result = CharacterDatabase.Query("SELECT data,text,itemguid,item_template FROM auction JOIN item_instance ON itemguid = guid");
|
||||||
|
|
||||||
if( !result )
|
if (!result)
|
||||||
{
|
{
|
||||||
barGoLink bar(1);
|
barGoLink bar(1);
|
||||||
bar.step();
|
bar.step();
|
||||||
|
|
@ -298,7 +298,7 @@ void AuctionHouseMgr::LoadAuctionItems()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
barGoLink bar( (int)result->GetRowCount() );
|
barGoLink bar((int)result->GetRowCount());
|
||||||
|
|
||||||
uint32 count = 0;
|
uint32 count = 0;
|
||||||
|
|
||||||
|
|
@ -313,15 +313,15 @@ void AuctionHouseMgr::LoadAuctionItems()
|
||||||
|
|
||||||
ItemPrototype const *proto = ObjectMgr::GetItemPrototype(item_template);
|
ItemPrototype const *proto = ObjectMgr::GetItemPrototype(item_template);
|
||||||
|
|
||||||
if(!proto)
|
if (!proto)
|
||||||
{
|
{
|
||||||
sLog.outError( "AuctionHouseMgr::LoadAuctionItems: Unknown item (GUID: %u id: #%u) in auction, skipped.", item_guid,item_template);
|
sLog.outError("AuctionHouseMgr::LoadAuctionItems: Unknown item (GUID: %u id: #%u) in auction, skipped.", item_guid,item_template);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Item *item = NewItemOrBag(proto);
|
Item *item = NewItemOrBag(proto);
|
||||||
|
|
||||||
if(!item->LoadFromDB(item_guid, fields))
|
if (!item->LoadFromDB(item_guid, fields))
|
||||||
{
|
{
|
||||||
delete item;
|
delete item;
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -330,17 +330,17 @@ void AuctionHouseMgr::LoadAuctionItems()
|
||||||
|
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
while( result->NextRow() );
|
while (result->NextRow());
|
||||||
delete result;
|
delete result;
|
||||||
|
|
||||||
sLog.outString();
|
sLog.outString();
|
||||||
sLog.outString( ">> Loaded %u auction items", count );
|
sLog.outString(">> Loaded %u auction items", count);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AuctionHouseMgr::LoadAuctions()
|
void AuctionHouseMgr::LoadAuctions()
|
||||||
{
|
{
|
||||||
QueryResult *result = CharacterDatabase.Query("SELECT COUNT(*) FROM auction");
|
QueryResult *result = CharacterDatabase.Query("SELECT COUNT(*) FROM auction");
|
||||||
if( !result )
|
if (!result)
|
||||||
{
|
{
|
||||||
barGoLink bar(1);
|
barGoLink bar(1);
|
||||||
bar.step();
|
bar.step();
|
||||||
|
|
@ -353,7 +353,7 @@ void AuctionHouseMgr::LoadAuctions()
|
||||||
uint32 AuctionCount=fields[0].GetUInt32();
|
uint32 AuctionCount=fields[0].GetUInt32();
|
||||||
delete result;
|
delete result;
|
||||||
|
|
||||||
if(!AuctionCount)
|
if (!AuctionCount)
|
||||||
{
|
{
|
||||||
barGoLink bar(1);
|
barGoLink bar(1);
|
||||||
bar.step();
|
bar.step();
|
||||||
|
|
@ -362,8 +362,8 @@ void AuctionHouseMgr::LoadAuctions()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = CharacterDatabase.Query( "SELECT id,houseid,itemguid,item_template,itemowner,buyoutprice,time,moneyTime,buyguid,lastbid,startbid,deposit FROM auction" );
|
result = CharacterDatabase.Query("SELECT id,houseid,itemguid,item_template,itemowner,buyoutprice,time,moneyTime,buyguid,lastbid,startbid,deposit FROM auction");
|
||||||
if( !result )
|
if (!result)
|
||||||
{
|
{
|
||||||
barGoLink bar(1);
|
barGoLink bar(1);
|
||||||
bar.step();
|
bar.step();
|
||||||
|
|
@ -372,7 +372,7 @@ void AuctionHouseMgr::LoadAuctions()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
barGoLink bar( AuctionCount );
|
barGoLink bar(AuctionCount);
|
||||||
|
|
||||||
AuctionEntry *auction;
|
AuctionEntry *auction;
|
||||||
|
|
||||||
|
|
@ -437,17 +437,17 @@ void AuctionHouseMgr::LoadAuctions()
|
||||||
delete result;
|
delete result;
|
||||||
|
|
||||||
sLog.outString();
|
sLog.outString();
|
||||||
sLog.outString( ">> Loaded %u auctions", AuctionCount );
|
sLog.outString(">> Loaded %u auctions", AuctionCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AuctionHouseMgr::AddAItem( Item* it )
|
void AuctionHouseMgr::AddAItem(Item* it)
|
||||||
{
|
{
|
||||||
MANGOS_ASSERT( it );
|
MANGOS_ASSERT(it);
|
||||||
MANGOS_ASSERT( mAitems.find(it->GetGUIDLow()) == mAitems.end());
|
MANGOS_ASSERT(mAitems.find(it->GetGUIDLow()) == mAitems.end());
|
||||||
mAitems[it->GetGUIDLow()] = it;
|
mAitems[it->GetGUIDLow()] = it;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AuctionHouseMgr::RemoveAItem( uint32 id )
|
bool AuctionHouseMgr::RemoveAItem(uint32 id)
|
||||||
{
|
{
|
||||||
ItemMap::iterator i = mAitems.find(id);
|
ItemMap::iterator i = mAitems.find(id);
|
||||||
if (i == mAitems.end())
|
if (i == mAitems.end())
|
||||||
|
|
@ -470,7 +470,7 @@ uint32 AuctionHouseMgr::GetAuctionHouseTeam(AuctionHouseEntry const* house)
|
||||||
// auction houses have faction field pointing to PLAYER,* factions,
|
// auction houses have faction field pointing to PLAYER,* factions,
|
||||||
// but player factions not have filled team field, and hard go from faction value to faction_template value,
|
// but player factions not have filled team field, and hard go from faction value to faction_template value,
|
||||||
// so more easy just sort by auction house ids
|
// so more easy just sort by auction house ids
|
||||||
switch(house->houseId)
|
switch (house->houseId)
|
||||||
{
|
{
|
||||||
case 1: case 2: case 3:
|
case 1: case 2: case 3:
|
||||||
return ALLIANCE;
|
return ALLIANCE;
|
||||||
|
|
@ -486,7 +486,7 @@ AuctionHouseEntry const* AuctionHouseMgr::GetAuctionHouseEntry(Unit* unit)
|
||||||
{
|
{
|
||||||
uint32 houseid = 1; // dwarf auction house (used for normal cut/etc percents)
|
uint32 houseid = 1; // dwarf auction house (used for normal cut/etc percents)
|
||||||
|
|
||||||
if(!sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_AUCTION))
|
if (!sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_AUCTION))
|
||||||
{
|
{
|
||||||
if (unit->GetTypeId() == TYPEID_UNIT)
|
if (unit->GetTypeId() == TYPEID_UNIT)
|
||||||
{
|
{
|
||||||
|
|
@ -494,7 +494,7 @@ AuctionHouseEntry const* AuctionHouseMgr::GetAuctionHouseEntry(Unit* unit)
|
||||||
// AuctionHouse.dbc have faction field with _player_ factions associated with auction house races.
|
// AuctionHouse.dbc have faction field with _player_ factions associated with auction house races.
|
||||||
// but no easy way convert creature faction to player race faction for specific city
|
// but no easy way convert creature faction to player race faction for specific city
|
||||||
uint32 factionTemplateId = unit->getFaction();
|
uint32 factionTemplateId = unit->getFaction();
|
||||||
switch(factionTemplateId)
|
switch (factionTemplateId)
|
||||||
{
|
{
|
||||||
case 12: houseid = 1; break; // human
|
case 12: houseid = 1; break; // human
|
||||||
case 29: houseid = 6; break; // orc, and generic for horde
|
case 29: houseid = 6; break; // orc, and generic for horde
|
||||||
|
|
@ -511,11 +511,11 @@ AuctionHouseEntry const* AuctionHouseMgr::GetAuctionHouseEntry(Unit* unit)
|
||||||
default: // for unknown case
|
default: // for unknown case
|
||||||
{
|
{
|
||||||
FactionTemplateEntry const* u_entry = sFactionTemplateStore.LookupEntry(factionTemplateId);
|
FactionTemplateEntry const* u_entry = sFactionTemplateStore.LookupEntry(factionTemplateId);
|
||||||
if(!u_entry)
|
if (!u_entry)
|
||||||
houseid = 7; // goblin auction house
|
houseid = 7; // goblin auction house
|
||||||
else if(u_entry->ourMask & FACTION_MASK_ALLIANCE)
|
else if (u_entry->ourMask & FACTION_MASK_ALLIANCE)
|
||||||
houseid = 1; // human auction house
|
houseid = 1; // human auction house
|
||||||
else if(u_entry->ourMask & FACTION_MASK_HORDE)
|
else if (u_entry->ourMask & FACTION_MASK_HORDE)
|
||||||
houseid = 6; // orc auction house
|
houseid = 6; // orc auction house
|
||||||
else
|
else
|
||||||
houseid = 7; // goblin auction house
|
houseid = 7; // goblin auction house
|
||||||
|
|
@ -556,7 +556,7 @@ void AuctionHouseObject::Update()
|
||||||
{
|
{
|
||||||
if (curTime > itr->second->moneyDeliveryTime)
|
if (curTime > itr->second->moneyDeliveryTime)
|
||||||
{
|
{
|
||||||
sAuctionMgr.SendAuctionSuccessfulMail( itr->second );
|
sAuctionMgr.SendAuctionSuccessfulMail(itr->second);
|
||||||
|
|
||||||
itr->second->DeleteFromDB();
|
itr->second->DeleteFromDB();
|
||||||
sAuctionMgr.RemoveAItem(itr->second->itemGuidLow);
|
sAuctionMgr.RemoveAItem(itr->second->itemGuidLow);
|
||||||
|
|
@ -571,13 +571,13 @@ void AuctionHouseObject::Update()
|
||||||
///- Either cancel the auction if there was no bidder
|
///- Either cancel the auction if there was no bidder
|
||||||
if (itr->second->bidder == 0)
|
if (itr->second->bidder == 0)
|
||||||
{
|
{
|
||||||
sAuctionMgr.SendAuctionExpiredMail( itr->second );
|
sAuctionMgr.SendAuctionExpiredMail(itr->second);
|
||||||
}
|
}
|
||||||
///- Or perform the transaction
|
///- Or perform the transaction
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
itr->second->moneyDeliveryTime = time(NULL) + HOUR;
|
itr->second->moneyDeliveryTime = time(NULL) + HOUR;
|
||||||
sAuctionMgr.SendAuctionWonMail( itr->second );
|
sAuctionMgr.SendAuctionWonMail(itr->second);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -596,9 +596,9 @@ void AuctionHouseObject::BuildListBidderItems(WorldPacket& data, Player* player,
|
||||||
for (AuctionEntryMap::const_iterator itr = AuctionsMap.begin();itr != AuctionsMap.end();++itr)
|
for (AuctionEntryMap::const_iterator itr = AuctionsMap.begin();itr != AuctionsMap.end();++itr)
|
||||||
{
|
{
|
||||||
AuctionEntry *Aentry = itr->second;
|
AuctionEntry *Aentry = itr->second;
|
||||||
if(Aentry->moneyDeliveryTime)
|
if (Aentry->moneyDeliveryTime)
|
||||||
continue;
|
continue;
|
||||||
if( Aentry && Aentry->bidder == player->GetGUIDLow() )
|
if (Aentry && Aentry->bidder == player->GetGUIDLow())
|
||||||
{
|
{
|
||||||
if (itr->second->BuildAuctionInfo(data))
|
if (itr->second->BuildAuctionInfo(data))
|
||||||
++count;
|
++count;
|
||||||
|
|
@ -609,79 +609,255 @@ void AuctionHouseObject::BuildListBidderItems(WorldPacket& data, Player* player,
|
||||||
|
|
||||||
void AuctionHouseObject::BuildListOwnerItems(WorldPacket& data, Player* player, uint32& count, uint32& totalcount)
|
void AuctionHouseObject::BuildListOwnerItems(WorldPacket& data, Player* player, uint32& count, uint32& totalcount)
|
||||||
{
|
{
|
||||||
for (AuctionEntryMap::const_iterator itr = AuctionsMap.begin();itr != AuctionsMap.end();++itr)
|
for (AuctionEntryMap::const_iterator itr = AuctionsMap.begin(); itr != AuctionsMap.end(); ++itr)
|
||||||
{
|
{
|
||||||
AuctionEntry *Aentry = itr->second;
|
AuctionEntry *Aentry = itr->second;
|
||||||
if(Aentry->moneyDeliveryTime)
|
if (Aentry->moneyDeliveryTime)
|
||||||
continue;
|
continue;
|
||||||
if( Aentry && Aentry->owner == player->GetGUIDLow() )
|
if (Aentry && Aentry->owner == player->GetGUIDLow())
|
||||||
{
|
{
|
||||||
if(Aentry->BuildAuctionInfo(data))
|
if (Aentry->BuildAuctionInfo(data))
|
||||||
++count;
|
++count;
|
||||||
++totalcount;
|
++totalcount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AuctionHouseObject::BuildListAuctionItems(WorldPacket& data, Player* player,
|
bool AuctionEntry::CompareAuctionEntry(uint32 column, const AuctionEntry *auc) const
|
||||||
std::wstring const& wsearchedname, uint32 listfrom, uint32 levelmin, uint32 levelmax, uint32 usable,
|
|
||||||
uint32 inventoryType, uint32 itemClass, uint32 itemSubClass, uint32 quality,
|
|
||||||
uint32& count, uint32& totalcount)
|
|
||||||
{
|
{
|
||||||
int loc_idx = player->GetSession()->GetSessionDbLocaleIndex();
|
Item *item1 = sAuctionMgr.GetAItem(itemGuidLow);
|
||||||
|
Item *item2 = sAuctionMgr.GetAItem(auc->itemGuidLow);
|
||||||
|
Player *pl1 = NULL;
|
||||||
|
Player *pl2 = NULL;
|
||||||
|
int res = 0;
|
||||||
|
time_t currentTime = time(NULL);
|
||||||
|
|
||||||
for (AuctionEntryMap::const_iterator itr = AuctionsMap.begin();itr != AuctionsMap.end();++itr)
|
switch (column)
|
||||||
{
|
{
|
||||||
AuctionEntry *Aentry = itr->second;
|
case 0: // level = 0
|
||||||
if(Aentry->moneyDeliveryTime)
|
if (!item1 || !item2)
|
||||||
|
break;
|
||||||
|
if (item1->GetProto()->RequiredLevel < item2->GetProto()->RequiredLevel)
|
||||||
|
return true;
|
||||||
|
else if (item1->GetProto()->RequiredLevel > item2->GetProto()->RequiredLevel)
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
case 1: // quality = 1
|
||||||
|
if (!item1 || !item2)
|
||||||
|
break;
|
||||||
|
if (item1->GetProto()->Quality < item2->GetProto()->Quality)
|
||||||
|
return true;
|
||||||
|
else if (item1->GetProto()->Quality > item2->GetProto()->Quality)
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
case 2: // buyoutthenbid = 2
|
||||||
|
if (buyout)
|
||||||
|
{
|
||||||
|
if (buyout < auc->buyout)
|
||||||
|
return true;
|
||||||
|
else if (buyout > auc->buyout)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (bid < auc->bid)
|
||||||
|
return true;
|
||||||
|
else if (bid > auc->bid)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 3: // duration = 3
|
||||||
|
if ((expireTime - currentTime) < (auc->expireTime - currentTime))
|
||||||
|
return true;
|
||||||
|
else if ((expireTime - currentTime) > (auc->expireTime - currentTime))
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
case 4: // status = 4
|
||||||
|
if (bidder < auc->bidder)
|
||||||
|
return true;
|
||||||
|
else if (bidder > auc->bidder)
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
case 5: // name = 5
|
||||||
|
if (!item1 || !item2)
|
||||||
|
break;
|
||||||
|
res = strcmp(item1->GetProto()->Name1, item2->GetProto()->Name1);
|
||||||
|
if (res < 0)
|
||||||
|
return true;
|
||||||
|
else if (res > 0)
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
case 6: // minbidbuyout = 6
|
||||||
|
if (bid)
|
||||||
|
{
|
||||||
|
if (bid < auc->bid)
|
||||||
|
return true;
|
||||||
|
else if (bid > auc->bid)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (startbid)
|
||||||
|
{
|
||||||
|
if (startbid < auc->startbid)
|
||||||
|
return true;
|
||||||
|
else if (startbid > auc->startbid)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (buyout < auc->buyout)
|
||||||
|
return true;
|
||||||
|
else if (buyout > auc->buyout)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 7: // seller = 7
|
||||||
|
pl1 = sObjectMgr.GetPlayer(ObjectGuid(HIGHGUID_PLAYER, owner));
|
||||||
|
pl2 = sObjectMgr.GetPlayer(ObjectGuid(HIGHGUID_PLAYER, auc->owner));
|
||||||
|
if (!pl1 || !pl2)
|
||||||
|
break;
|
||||||
|
res = strcmp(pl1->GetName(), pl2->GetName());
|
||||||
|
if (res < 0)
|
||||||
|
return true;
|
||||||
|
else if (res > 0)
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
case 8: // bid = 8
|
||||||
|
if (bid)
|
||||||
|
{
|
||||||
|
if (bid < auc->bid)
|
||||||
|
return true;
|
||||||
|
else if (bid > auc->bid)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (startbid < auc->startbid)
|
||||||
|
return true;
|
||||||
|
else if (startbid > auc->startbid)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 9: // quantity = 9
|
||||||
|
if (!item1 || !item2)
|
||||||
|
break;
|
||||||
|
if (item1->GetCount() < item2->GetCount())
|
||||||
|
return true;
|
||||||
|
else if (item1->GetCount() > item2->GetCount())
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
case 10: // buyout = 10
|
||||||
|
if (buyout < auc->buyout)
|
||||||
|
return true;
|
||||||
|
else if (buyout > auc->buyout)
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
case 11: // unused = 11
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Id < auc->Id)
|
||||||
|
return true;
|
||||||
|
else if (Id > auc->Id)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AuctionSorter::operator()(const AuctionEntry *auc1, const AuctionEntry *auc2) const
|
||||||
|
{
|
||||||
|
bool result = false;
|
||||||
|
uint32 column = 0;
|
||||||
|
|
||||||
|
for (uint32 i = 0; i < MAX_AUCTION_SORT; ++i)
|
||||||
|
{
|
||||||
|
if (m_sort[i] == MAX_AUCTION_SORT) // end of sort
|
||||||
|
{
|
||||||
|
column = m_sort[0]; // use main column
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
column = m_sort[i];
|
||||||
|
|
||||||
|
result = auc1->CompareAuctionEntry(column & ~AUCTION_SORT_REVERSED, auc2);
|
||||||
|
|
||||||
|
if (result)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (column & AUCTION_SORT_REVERSED) // reversed flag
|
||||||
|
result = !result;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WorldSession::BuildListAuctionItems(std::list<AuctionEntry*> &auctions, WorldPacket& data, std::wstring const& wsearchedname, uint32 listfrom, uint32 levelmin,
|
||||||
|
uint32 levelmax, uint32 usable, uint32 inventoryType, uint32 itemClass, uint32 itemSubClass, uint32 quality, uint32& count, uint32& totalcount, bool isFull)
|
||||||
|
{
|
||||||
|
int loc_idx = _player->GetSession()->GetSessionDbLocaleIndex();
|
||||||
|
|
||||||
|
for (std::list<AuctionEntry*>::const_iterator itr = auctions.begin(); itr != auctions.end();++itr)
|
||||||
|
{
|
||||||
|
AuctionEntry *Aentry = *itr;
|
||||||
|
if (Aentry->moneyDeliveryTime)
|
||||||
continue;
|
continue;
|
||||||
Item *item = sAuctionMgr.GetAItem(Aentry->itemGuidLow);
|
Item *item = sAuctionMgr.GetAItem(Aentry->itemGuidLow);
|
||||||
if (!item)
|
if (!item)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ItemPrototype const *proto = item->GetProto();
|
if (isFull)
|
||||||
|
|
||||||
if (itemClass != 0xffffffff && proto->Class != itemClass)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (itemSubClass != 0xffffffff && proto->SubClass != itemSubClass)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (inventoryType != 0xffffffff && proto->InventoryType != inventoryType)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (quality != 0xffffffff && proto->Quality < quality)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (levelmin != 0x00 && (proto->RequiredLevel < levelmin || (levelmax != 0x00 && proto->RequiredLevel > levelmax)))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (usable != 0x00 && player->CanUseItem( item ) != EQUIP_ERR_OK)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
std::string name = proto->Name1;
|
|
||||||
if(name.empty())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// local name
|
|
||||||
if ( loc_idx >= 0 )
|
|
||||||
{
|
|
||||||
ItemLocale const *il = sObjectMgr.GetItemLocale(proto->ItemId);
|
|
||||||
if (il)
|
|
||||||
{
|
|
||||||
if (il->Name.size() > size_t(loc_idx) && !il->Name[loc_idx].empty())
|
|
||||||
name = il->Name[loc_idx];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!wsearchedname.empty() && !Utf8FitTo(name, wsearchedname) )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (count < 50 && totalcount >= listfrom)
|
|
||||||
{
|
{
|
||||||
++count;
|
++count;
|
||||||
Aentry->BuildAuctionInfo(data);
|
Aentry->BuildAuctionInfo(data);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ItemPrototype const *proto = item->GetProto();
|
||||||
|
|
||||||
|
if (itemClass != 0xffffffff && proto->Class != itemClass)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (itemSubClass != 0xffffffff && proto->SubClass != itemSubClass)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (inventoryType != 0xffffffff && proto->InventoryType != inventoryType)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (quality != 0xffffffff && proto->Quality < quality)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (levelmin != 0x00 && (proto->RequiredLevel < levelmin || (levelmax != 0x00 && proto->RequiredLevel > levelmax)))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (usable != 0x00 && _player->CanUseItem(item) != EQUIP_ERR_OK)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
std::string name = proto->Name1;
|
||||||
|
if (name.empty())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// local name
|
||||||
|
if (loc_idx >= 0)
|
||||||
|
{
|
||||||
|
ItemLocale const *il = sObjectMgr.GetItemLocale(proto->ItemId);
|
||||||
|
if (il)
|
||||||
|
{
|
||||||
|
if (il->Name.size() > size_t(loc_idx) && !il->Name[loc_idx].empty())
|
||||||
|
name = il->Name[loc_idx];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!wsearchedname.empty() && !Utf8FitTo(name, wsearchedname))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (count < 50 && totalcount >= listfrom)
|
||||||
|
{
|
||||||
|
++count;
|
||||||
|
Aentry->BuildAuctionInfo(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
++totalcount;
|
++totalcount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -691,9 +867,9 @@ void AuctionHouseObject::BuildListPendingSales(WorldPacket& data, Player* player
|
||||||
for (AuctionEntryMap::const_iterator itr = AuctionsMap.begin(); itr != AuctionsMap.end(); ++itr)
|
for (AuctionEntryMap::const_iterator itr = AuctionsMap.begin(); itr != AuctionsMap.end(); ++itr)
|
||||||
{
|
{
|
||||||
AuctionEntry *Aentry = itr->second;
|
AuctionEntry *Aentry = itr->second;
|
||||||
if(!Aentry->moneyDeliveryTime)
|
if (!Aentry->moneyDeliveryTime)
|
||||||
continue;
|
continue;
|
||||||
if( Aentry && Aentry->owner == player->GetGUIDLow() )
|
if (Aentry && Aentry->owner == player->GetGUIDLow())
|
||||||
{
|
{
|
||||||
Item *pItem = sAuctionMgr.GetAItem(Aentry->itemGuidLow);
|
Item *pItem = sAuctionMgr.GetAItem(Aentry->itemGuidLow);
|
||||||
if (!pItem)
|
if (!pItem)
|
||||||
|
|
@ -772,7 +948,7 @@ uint32 AuctionEntry::GetAuctionOutBid() const
|
||||||
void AuctionEntry::DeleteFromDB() const
|
void AuctionEntry::DeleteFromDB() const
|
||||||
{
|
{
|
||||||
//No SQL injection (Id is integer)
|
//No SQL injection (Id is integer)
|
||||||
CharacterDatabase.PExecute("DELETE FROM auction WHERE id = '%u'",Id);
|
CharacterDatabase.PExecute("DELETE FROM auction WHERE id = '%u'", Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AuctionEntry::SaveToDB() const
|
void AuctionEntry::SaveToDB() const
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,8 @@ class Unit;
|
||||||
class WorldPacket;
|
class WorldPacket;
|
||||||
|
|
||||||
#define MIN_AUCTION_TIME (12*HOUR)
|
#define MIN_AUCTION_TIME (12*HOUR)
|
||||||
|
#define MAX_AUCTION_SORT 12
|
||||||
|
#define AUCTION_SORT_REVERSED 0x10
|
||||||
|
|
||||||
enum AuctionError
|
enum AuctionError
|
||||||
{
|
{
|
||||||
|
|
@ -74,6 +76,7 @@ struct AuctionEntry
|
||||||
bool BuildAuctionInfo(WorldPacket & data) const;
|
bool BuildAuctionInfo(WorldPacket & data) const;
|
||||||
void DeleteFromDB() const;
|
void DeleteFromDB() const;
|
||||||
void SaveToDB() const;
|
void SaveToDB() const;
|
||||||
|
bool CompareAuctionEntry(uint32 column, const AuctionEntry *auc) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
//this class is used as auctionhouse instance
|
//this class is used as auctionhouse instance
|
||||||
|
|
@ -89,7 +92,9 @@ class AuctionHouseObject
|
||||||
|
|
||||||
typedef std::map<uint32, AuctionEntry*> AuctionEntryMap;
|
typedef std::map<uint32, AuctionEntry*> AuctionEntryMap;
|
||||||
|
|
||||||
uint32 Getcount() { return AuctionsMap.size(); }
|
uint32 GetCount() { return AuctionsMap.size(); }
|
||||||
|
|
||||||
|
AuctionEntryMap *GetAuctions() { return &AuctionsMap; }
|
||||||
|
|
||||||
void AddAuction(AuctionEntry *ah)
|
void AddAuction(AuctionEntry *ah)
|
||||||
{
|
{
|
||||||
|
|
@ -113,15 +118,21 @@ class AuctionHouseObject
|
||||||
void BuildListBidderItems(WorldPacket& data, Player* player, uint32& count, uint32& totalcount);
|
void BuildListBidderItems(WorldPacket& data, Player* player, uint32& count, uint32& totalcount);
|
||||||
void BuildListOwnerItems(WorldPacket& data, Player* player, uint32& count, uint32& totalcount);
|
void BuildListOwnerItems(WorldPacket& data, Player* player, uint32& count, uint32& totalcount);
|
||||||
void BuildListPendingSales(WorldPacket& data, Player* player, uint32& count);
|
void BuildListPendingSales(WorldPacket& data, Player* player, uint32& count);
|
||||||
void BuildListAuctionItems(WorldPacket& data, Player* player,
|
|
||||||
std::wstring const& searchedname, uint32 listfrom, uint32 levelmin, uint32 levelmax, uint32 usable,
|
|
||||||
uint32 inventoryType, uint32 itemClass, uint32 itemSubClass, uint32 quality,
|
|
||||||
uint32& count, uint32& totalcount);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AuctionEntryMap AuctionsMap;
|
AuctionEntryMap AuctionsMap;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class AuctionSorter
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AuctionSorter(uint8 *sort) : m_sort(sort) {}
|
||||||
|
bool operator()(const AuctionEntry *auc1, const AuctionEntry *auc2) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint8* m_sort;
|
||||||
|
};
|
||||||
|
|
||||||
class AuctionHouseMgr
|
class AuctionHouseMgr
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -356,6 +356,9 @@ class MANGOS_DLL_SPEC WorldSession
|
||||||
void SendAuctionRemovedNotification(AuctionEntry* auction);
|
void SendAuctionRemovedNotification(AuctionEntry* auction);
|
||||||
void SendAuctionOutbiddedMail(AuctionEntry *auction);
|
void SendAuctionOutbiddedMail(AuctionEntry *auction);
|
||||||
void SendAuctionCancelledToBidderMail(AuctionEntry *auction);
|
void SendAuctionCancelledToBidderMail(AuctionEntry *auction);
|
||||||
|
void BuildListAuctionItems(std::list<AuctionEntry*> &auctions, WorldPacket& data, std::wstring const& searchedname, uint32 listfrom, uint32 levelmin,
|
||||||
|
uint32 levelmax, uint32 usable, uint32 inventoryType, uint32 itemClass, uint32 itemSubClass, uint32 quality, uint32& count, uint32& totalcount, bool isFull);
|
||||||
|
|
||||||
AuctionHouseEntry const* GetCheckedAuctionHouseForAuctioneer(ObjectGuid guid);
|
AuctionHouseEntry const* GetCheckedAuctionHouseForAuctioneer(ObjectGuid guid);
|
||||||
|
|
||||||
//Item Enchantment
|
//Item Enchantment
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "11395"
|
#define REVISION_NR "11396"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue