本文整理汇总了C++中AuctionHouse类的典型用法代码示例。如果您正苦于以下问题:C++ AuctionHouse类的具体用法?C++ AuctionHouse怎么用?C++ AuctionHouse使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AuctionHouse类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SendAuctionList
void WorldSession::SendAuctionList(Creature* auctioneer)
{
AuctionHouse* AH = sAuctionMgr.GetAuctionHouse(auctioneer->GetEntry());
if(!AH)
{
sChatHandler.BlueSystemMessage(this, "Report to devs: Unbound auction house npc %u.", auctioneer->GetEntry());
return;
}
WorldPacket data(MSG_AUCTION_HELLO, 12);
data << uint64(auctioneer->GetGUID());
data << uint32(AH->GetID());
data << uint8(AH->enabled ? 1 : 0); // Alleycat - Need to correct this properly.
SendPacket(&data);
}
示例2: SendAuctionList
void WorldSession::SendAuctionList(Creature* auctioneer)
{
AuctionHouse* AH = sAuctionMgr.GetAuctionHouse(auctioneer->GetEntry());
if(!AH)
{
sChatHandler.BlueSystemMessage(this, "Report to devs: Unbound auction house npc %u.", auctioneer->GetEntry());
return;
}
WorldPacket data(MSG_AUCTION_HELLO, 12);
data << auctioneer->GetGUID();
data << uint32(AH->GetID());
SendPacket( &data );
}
示例3: MAX
void AuctionMgr::LoadAuctionHouses()
{
Log.Notice("AuctionMgr", "Loading Auction Houses...");
QueryResult* res = CharacterDatabase.Query("SELECT MAX(auctionId) FROM auctions");
if(res)
{
maxId.SetVal(res->Fetch()[0].GetUInt32());
delete res;
}
res = WorldDatabase.Query("SELECT DISTINCT ahgroup FROM auctionhouse");
AuctionHouse* ah;
map<uint32, AuctionHouse*> tempmap;
if(res)
{
uint32 period = (res->GetRowCount() / 20) + 1;
uint32 c = 0;
do
{
ah = new AuctionHouse(res->Fetch()[0].GetUInt32());
ah->LoadAuctions();
auctionHouses.push_back(ah);
tempmap.insert(make_pair(res->Fetch()[0].GetUInt32(), ah));
if(!((++c) % period))
Log.Notice("AuctionHouse", "Done %u/%u, %u%% complete.", c, res->GetRowCount(), c * 100 / res->GetRowCount());
}
while(res->NextRow());
delete res;
}
res = WorldDatabase.Query("SELECT creature_entry, ahgroup FROM auctionhouse");
if(res)
{
do
{
auctionHouseEntryMap.insert(make_pair(res->Fetch()[0].GetUInt32(), tempmap[res->Fetch()[1].GetUInt32()]));
}
while(res->NextRow());
delete res;
}
}
示例4: MAX
void AuctionMgr::LoadAuctionHouses()
{
sLog.outString("Loading Auction Houses...");
QueryResult * res = CharacterDatabase.Query("SELECT MAX(auctionId) FROM auctions");
if(res)
{
maxId = res->Fetch()[0].GetUInt32();
delete res;
}
res = WorldDatabase.Query("SELECT DISTINCT AHid FROM auctionhouse ORDER BY AHid");
AuctionHouse * ah;
map<uint32, AuctionHouse*> tempmap;
if(res)
{
do
{
ah = new AuctionHouse(res->Fetch()[0].GetUInt32());
ah->LoadAuctions();
auctionHouses.push_back(ah);
tempmap.insert( make_pair( res->Fetch()[0].GetUInt32(), ah ) );
}while(res->NextRow());
delete res;
}
res = WorldDatabase.Query("SELECT auctioneer, AHid FROM auctionhouse");
if(res)
{
do
{
auctionHouseEntryMap.insert( make_pair( res->Fetch()[0].GetUInt32(), tempmap[res->Fetch()[1].GetUInt32()] ) );
} while(res->NextRow());
delete res;
}
}
示例5: MAX
void AuctionMgr::LoadAuctionHouses()
{
Log.Notice("AuctionMgr", "Loading Auction Houses...");
QueryResult * res = CharacterDatabase.Query("SELECT MAX(auctionId) FROM auctions");
if(res)
{
maxId = res->Fetch()[0].GetUInt32();
delete res;
}
res = WorldDatabase.Query("SELECT DISTINCT `group` FROM auctionhouse");
AuctionHouse * ah;
map<uint32, AuctionHouse*> tempmap;
if(res)
{
do
{
ah = new AuctionHouse(res->Fetch()[0].GetUInt32());
ah->LoadAuctions();
auctionHouses.push_back(ah);
tempmap.insert( make_pair( res->Fetch()[0].GetUInt32(), ah ) );
}while(res->NextRow());
delete res;
}
res = WorldDatabase.Query("SELECT creature_entry, `group` FROM auctionhouse");
if(res)
{
do
{
auctionHouseEntryMap.insert( make_pair( res->Fetch()[0].GetUInt32(), tempmap[res->Fetch()[1].GetUInt32()] ) );
} while(res->NextRow());
delete res;
}
}
示例6: sStackWolrdPacket
void WorldSession::HandleAuctionSellItem( WorldPacket & recv_data )
{
if (!_player->IsInWorld())
{
return;
}
uint64 guid,item;
uint32 bid, buyout, etime, unk1, unk2; // etime is in minutes
recv_data >> guid >> unk1 >> item;
recv_data >> unk2;
recv_data >> bid >> buyout >> etime;
Creature * pCreature = _player->GetMapMgr()->GetCreature( guid );
if( !pCreature || !pCreature->auctionHouse )
return; // NPC doesnt exist or isnt an auctioneer
// Get item
Item * pItem = _player->GetItemInterface()->GetItemByGUID(item);
if( !pItem || pItem->IsSoulbound() || pItem->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_CONJURED ) )
{
sStackWolrdPacket( data,SMSG_AUCTION_COMMAND_RESULT, 50);
data << uint32(0);
data << uint32(AUCTION_CREATE);
data << uint32(AUCTION_ERROR_ITEM);
SendPacket(&data);
return;
};
AuctionHouse * ah = pCreature->auctionHouse;
uint32 item_worth = pItem->GetProto()->SellPrice * pItem->GetUInt32Value(ITEM_FIELD_STACK_COUNT);
uint32 item_deposit = (uint32)(item_worth * ah->deposit_percent) * (uint32)(etime / 240.0f); // deposit is per 4 hours
if (_player->GetGold() < item_deposit) // player cannot afford deposit
{
sStackWolrdPacket( data,SMSG_AUCTION_COMMAND_RESULT, 50);
data << uint32(0);
data << uint32(AUCTION_CREATE);
data << uint32(AUCTION_ERROR_MONEY);
SendPacket(&data);
return;
}
pItem = _player->GetItemInterface()->SafeRemoveAndRetreiveItemByGuid(item, false);
if (!pItem){
sStackWolrdPacket( data, SMSG_AUCTION_COMMAND_RESULT, 50);
data << uint32(0);
data << uint32(AUCTION_CREATE);
data << uint32(AUCTION_ERROR_ITEM);
SendPacket(&data);
return;
};
if( pItem->IsInWorld() )
{
pItem->RemoveFromWorld();
}
pItem->SetOwner(NULL);
pItem->m_isDirty = true;
pItem->SaveToDB(INVENTORY_SLOT_NOT_SET, 0, true, NULL);
// Create auction
Auction * auct = new Auction;
auct->BuyoutPrice = buyout;
auct->ExpiryTime = (uint32)UNIXTIME + (etime * 60);
auct->StartingPrice = bid;
auct->HighestBid = 0;
auct->HighestBidder = 0; // hm
auct->Id = sAuctionMgr.GenerateAuctionId();
auct->Owner = _player->GetLowGUID();
auct->pItem = pItem;
auct->Deleted = false;
auct->DeletedReason = 0;
auct->DepositAmount = item_deposit;
// remove deposit
_player->ModGold(-(int32)item_deposit);
// Add and save auction to DB
ah->AddAuction(auct);
auct->SaveToDB(ah->GetID());
// Send result packet
sStackWolrdPacket( data,SMSG_AUCTION_COMMAND_RESULT, 50);
data << auct->Id;
data << uint32(AUCTION_CREATE);
data << uint32(AUCTION_ERROR_NONE);
SendPacket(&data);
}
示例7: HandleAuctionPlaceBid
void WorldSession::HandleAuctionPlaceBid( WorldPacket & recv_data )
{
if(!_player->IsInWorld())
{
return;
}
uint64 guid;
recv_data >> guid;
uint32 auction_id, price;
recv_data >> auction_id >> price;
Creature * pCreature = _player->GetMapMgr()->GetCreature( guid );
if(!pCreature || !pCreature->auctionHouse)
{
return;
}
// Find Item
AuctionHouse * ah = pCreature->auctionHouse;
Auction * auct = ah->GetAuction(auction_id);
if(auct == 0 || !auct->Owner || !_player)
{
SendAuctionPlaceBidResultPacket(0, AUCTION_ERROR_INTERNAL);
return;
}
if(auct->Owner == _player->GetGUID())
{
SendAuctionPlaceBidResultPacket(0, AUCTION_ERROR_BID_OWN_AUCTION);
return;
}
if(auct->HighestBid > price && price != auct->BuyoutPrice)
{
//HACK: Don't know the correct error code...
SendAuctionPlaceBidResultPacket(0, AUCTION_ERROR_INTERNAL);
return;
}
if(_player->GetGold() < price)
{
SendAuctionPlaceBidResultPacket(0, AUCTION_ERROR_MONEY);
return;
}
_player->ModGold( -((int32)price));
if(auct->HighestBidder != 0)
{
// Return the money to the last highest bidder.
char subject[100];
snprintf(subject, 100, "%u:0:0", (int)auct->pItem->GetEntry());
sMailSystem.SendAutomatedMessage(AUCTION, ah->GetID(), auct->HighestBidder, subject, "", auct->HighestBid, 0, 0, MAIL_STATIONERY_AUCTION );
// Do not send out bid notification, when current highest bidder and new bidder are the same player..
if(auct->HighestBidder != (uint32)_player->GetLowGUID())
ah->SendAuctionOutBidNotificationPacket(auct, _player->GetGUID(), price);
}
if(auct->BuyoutPrice == price)
{
auct->HighestBidder = _player->GetLowGUID();
auct->HighestBid = price;
// we used buyout on the item.
ah->QueueDeletion(auct, AUCTION_REMOVE_WON);
SendAuctionPlaceBidResultPacket(auct->Id, AUCTION_ERROR_NONE);
ah->SendAuctionBuyOutNotificationPacket(auct);
}
else
{
// update most recent bid
auct->HighestBidder = _player->GetLowGUID();
auct->HighestBid = price;
auct->UpdateInDB();
SendAuctionPlaceBidResultPacket(auct->Id, AUCTION_ERROR_NONE);
}
}
示例8: data
void WorldSession::HandleAuctionSellItem( WorldPacket & recv_data )
{
if (!_player->IsInWorld())
return;
uint64 guid,item;
uint32 bid, buyout, etime, unk1, unk2; // etime is in minutes
recv_data >> guid >> unk1 >> item;
recv_data >> unk2;
recv_data >> bid >> buyout >> etime;
Creature * pCreature = _player->GetMapMgr()->GetCreature(GET_LOWGUID_PART(guid));
if( !pCreature || !pCreature->auctionHouse )
return; // NPC doesn't exist or isn't an auctioneer
// Get item
Item * pItem = _player->GetItemInterface()->GetItemByGUID(item);
if( !pItem || pItem->IsSoulbound() || pItem->IsConjured() )
{
WorldPacket data(SMSG_AUCTION_COMMAND_RESULT, 8);
data << uint32(0);
data << uint32(AUCTION_CREATE);
data << uint32(AUCTION_ERROR_ITEM);
SendPacket(&data);
return;
};
if (m_gmData->rank > RANK_NO_RANK && m_gmData->rank < RANK_COADMIN)
{
SystemMessage("GMs cannot post auctions");
WorldPacket data(SMSG_AUCTION_COMMAND_RESULT, 8);
data << uint32(0);
data << uint32(AUCTION_CREATE);
data << uint32(AUCTION_ERROR_ITEM);
SendPacket(&data);
return;
};
AuctionHouse * ah = pCreature->auctionHouse;
uint32 item_worth = pItem->GetProto()->SellPrice * pItem->GetStackCount();
uint32 item_deposit = (uint32)(item_worth * ah->deposit_percent) * (uint32)(etime / 240.0f); // deposit is per 4 hours
if( !_player->HasGold(item_deposit) ) // player cannot afford deposit
{
WorldPacket data(SMSG_AUCTION_COMMAND_RESULT, 8);
data << uint32(0);
data << uint32(AUCTION_CREATE);
data << uint32(AUCTION_ERROR_MONEY);
SendPacket(&data);
return;
}
pItem = _player->GetItemInterface()->SafeRemoveAndRetreiveItemByGuid(item, false);
if (!pItem){
WorldPacket data(SMSG_AUCTION_COMMAND_RESULT, 8);
data << uint32(0);
data << uint32(AUCTION_CREATE);
data << uint32(AUCTION_ERROR_ITEM);
SendPacket(&data);
return;
};
if( pItem->IsInWorld() )
{
pItem->RemoveFromWorld();
}
pItem->SetOwner(NULL);
pItem->m_isDirty = true;
pItem->SaveToDB(INVENTORY_SLOT_NOT_SET, 0, true, NULL);
// Create auction
Auction * auct = new Auction;
auct->BuyoutPrice = buyout;
auct->ExpiryTime = (uint32)UNIXTIME + (etime * 60);
auct->HighestBid = bid;
auct->HighestBidder = 0; // hm
auct->Id = sAuctionMgr.GenerateAuctionId();
auct->Owner = _player->GetLowGUID();
auct->pItem = pItem;
auct->Deleted = false;
auct->DeletedReason = 0;
auct->DepositAmount = item_deposit;
// remove deposit
_player->ModGold( -(int32)item_deposit );
// Add and save auction to DB
ah->AddAuction(auct);
auct->SaveToDB(ah->GetID());
// Send result packet
WorldPacket data(SMSG_AUCTION_COMMAND_RESULT, 8);
data << auct->Id;
data << uint32(AUCTION_CREATE);
data << uint32(AUCTION_ERROR_NONE);
SendPacket(&data);
}
示例9: switch
void WorldSession::HandleAuctionSellItem(WorldPacket& recv_data)
{
CHECK_INWORLD_RETURN
uint64 auctioneer, bid, buyout;
uint32 itemsCount, etime;
recv_data >> auctioneer;
recv_data >> itemsCount;
uint64 itemGUIDs[MAX_AUCTION_ITEMS]; // 160 slot = 4x 36 slot bag + backpack 16 slot
uint32 count[MAX_AUCTION_ITEMS];
for (uint32 i = 0; i < itemsCount; ++i)
{
recv_data >> itemGUIDs[i];
recv_data >> count[i];
if (!itemGUIDs[i] || !count[i] || count[i] > 1000)
return;
}
recv_data >> bid;
recv_data >> buyout;
recv_data >> etime;
if (!bid || !etime)
return;
Creature* pCreature = _player->GetMapMgr()->GetCreature(GET_LOWGUID_PART(auctioneer));
if (!pCreature || !pCreature->auctionHouse)
return; // NPC doesn't exist or isn't an auctioneer
AuctionHouse* ah = pCreature->auctionHouse;
etime *= MINUTE;
switch (etime)
{
case 1 * MIN_AUCTION_TIME:
case 2 * MIN_AUCTION_TIME:
case 4 * MIN_AUCTION_TIME:
break;
default:
return;
}
Item* items[MAX_AUCTION_ITEMS];
uint32 finalCount = 0;
for (uint32 i = 0; i < itemsCount; ++i)
{
Item* item = _player->GetItemInterface()->GetItemByGUID(itemGUIDs[i]);
if (!item)
{
_player->SendAuctionCommandResult(NULL, AUCTION_CREATE, ERR_AUCTION_ITEM_NOT_FOUND);
return;
}
items[i] = item;
finalCount += count[i];
}
if (!finalCount)
{
_player->SendAuctionCommandResult(NULL, AUCTION_CREATE, ERR_AUCTION_DATABASE_ERROR);
return;
}
for (uint32 i = 0; i < itemsCount; ++i)
{
Item* item = items[i];
if (item->GetStackCount() < finalCount)
{
_player->SendAuctionCommandResult(NULL, AUCTION_CREATE, ERR_AUCTION_DATABASE_ERROR);
return;
}
}
for (uint32 i = 0; i < itemsCount; ++i)
{
Item* item = items[i];
uint32 auctionTime = uint32(etime);
AuctionHouse* ah = pCreature->auctionHouse;
uint32 item_worth = item->GetProto()->SellPrice * item->GetStackCount();
uint32 item_deposit = (uint32)(item_worth * ah->deposit_percent) * (uint32)(etime / 240.0f); // deposit is per 4 hours
if (!_player->HasGold((uint64)item_deposit))
{
_player->SendAuctionCommandResult(NULL, AUCTION_CREATE, ERR_AUCTION_NOT_ENOUGHT_MONEY);
return;
}
_player->TakeGold(-int32(item_deposit));
//.........这里部分代码省略.........
示例10: atol
bool AHBot::AHBotUnLoadAH(string args, BaseConsole * pConsole, WorldSession *m_session)
{
char msg[200];
uint32 AHid = 0;
if(args.length() > 0)
AHid = atol(args.c_str());
// Default to AH 1
if(AHid == 0)
AHid = 1;
Player * plr = NULL;
if ( m_session )
plr = m_session->GetPlayer();
// Get an auctioneer for the Auction House reference
uint32 auctioneer = GetAnAuctioneer(plr, AHid);
if(auctioneer == 0)
{
snprintf(msg, 200, "Unable to access an auctioneer for auction house '%u'.", AHid);
if ( m_session )
sChatHandler.RedSystemMessage(m_session, msg);
else
{pConsole->Write(msg); pConsole->Write("\n");}
return true;
}
// Create a reference to the Auction House
AuctionHouse * ah = sAuctionMgr.GetAuctionHouse(auctioneer);
if(!ah)
{
snprintf(msg, 200, "Unable to access auction house '%u' using auctioneer '%u'.", AHid, auctioneer);
if ( m_session )
sChatHandler.RedSystemMessage(m_session, msg);
else
{pConsole->Write(msg); pConsole->Write("\n");}
return true;
}
if(sLog.m_fileLogLevel >= 1)
{
if ( m_session )
snprintf(msg, 200, "Player %s initiated an unload for ah '%u'.", plr->GetName(), ah->GetID());
else
snprintf(msg, 200, "Player %s initiated an unload for ah '%u'.", "[Console]", ah->GetID());
{pConsole->Write(msg); pConsole->Write("\n");}
}
sAHBotMgr.plr = plr;
sAHBotMgr.ah = ah;
sAHBotMgr.m_ThreadTask = AHBOT_UNLOAD;
snprintf(msg, 200, "Queued the un-loading of auction house '%u'.", ah->GetID());
if ( m_session )
sChatHandler.BlueSystemMessage(m_session, msg);
else
{pConsole->Write(msg); pConsole->Write("\n");}
return true;
}
示例11: snprintf
bool AHBot::AHBotLoadAH(string args, BaseConsole * pConsole, WorldSession *m_session)
{
char msg[200];
if(args.length() == 0)
{
snprintf(msg, 200, "You must at least specify a number of items to add to an auction house.");
if ( m_session )
sChatHandler.RedSystemMessage(m_session, msg);
else
{pConsole->Write(msg); pConsole->Write("\n");}
return false;
}
uint32 itemsToAdd = 0;
uint32 AHid = 0;
if(sscanf(args.c_str(), "%u %u", &itemsToAdd, &AHid) < 1)
{
snprintf(msg, 200, "You must at least specify a number of items to add to an auction house.");
if ( m_session )
sChatHandler.RedSystemMessage(m_session, msg);
else
{pConsole->Write(msg); pConsole->Write("\n");}
return true;
}
Player * plr = NULL;
if ( m_session )
plr = m_session->GetPlayer();
// Get an auctioneer for the Auction House reference
uint32 auctioneer = GetAnAuctioneer(plr, AHid);
if(auctioneer == 0)
{
snprintf(msg, 200, "Unable to access an auctioneer for auction house '%u'.", AHid);
if ( m_session )
sChatHandler.RedSystemMessage(m_session, msg);
else
{pConsole->Write(msg); pConsole->Write("\n");}
return true;
}
// Create a reference to the Auction House
AuctionHouse * ah = sAuctionMgr.GetAuctionHouse(auctioneer);
if(!ah)
{
snprintf(msg, 200, "Unable to access auction house '%u' using auctioneer '%u'.", AHid, auctioneer);
if ( m_session )
sChatHandler.RedSystemMessage(m_session, msg);
else
{pConsole->Write(msg); pConsole->Write("\n");}
return true;
}
if(sLog.m_fileLogLevel >= 1)
{
if ( m_session )
snprintf(msg, 200, "Player %s initiated an AH load of '%u' items for ah '%u'.", plr->GetName(), itemsToAdd, ah->GetID());
else
snprintf(msg, 200, "Player %s initiated an AH load of '%u' items for ah '%u'.", "[Console]", itemsToAdd, ah->GetID());
{pConsole->Write(msg); pConsole->Write("\n");}
}
sAHBotMgr.plr = plr;
sAHBotMgr.ah = ah;
sAHBotMgr.itemsToAdd = itemsToAdd;
sAHBotMgr.m_ThreadTask = AHBOT_LOAD;
snprintf(msg, 200, "Queued the loading of AH `%u` with `%u` items using `%u`.", ah->GetID(), itemsToAdd, auctioneer);
if ( m_session )
sChatHandler.BlueSystemMessage(m_session, msg);
else
{pConsole->Write(msg); pConsole->Write("\n");}
return true;
}