本文整理汇总了C++中Auction::SaveToDB方法的典型用法代码示例。如果您正苦于以下问题:C++ Auction::SaveToDB方法的具体用法?C++ Auction::SaveToDB怎么用?C++ Auction::SaveToDB使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Auction
的用法示例。
在下文中一共展示了Auction::SaveToDB方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleAuctionSellItem
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);
}
示例2: HandleAuctionSellItem
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);
}
示例3: HandleAuctionSellItem
//.........这里部分代码省略.........
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));
item = _player->GetItemInterface()->SafeRemoveAndRetreiveItemByGuid(itemGUIDs[i], false);
if (!item)
{
_player->SendAuctionCommandResult(NULL, AUCTION_CREATE, ERR_AUCTION_ITEM_NOT_FOUND);
return;
};
if (item->IsInWorld())
{
item->RemoveFromWorld();
}
item->SetOwner(NULL);
item->m_isDirty = true;
item->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 = item;
auct->Deleted = false;
auct->DeletedReason = 0;
auct->DepositAmount = item_deposit;
// Add and save auction to DB
ah->AddAuction(auct);
auct->SaveToDB(ah->GetID());
// Send result packet
_player->SendAuctionCommandResult(NULL, AUCTION_CREATE, ERR_AUCTION_OK);
}
ah->SendOwnerListPacket(_player, &recv_data);
}