void AuctionHouseObject::Update() { time_t curTime = sWorld.GetGameTime(); ///- Handle expired auctions AuctionEntryMap::iterator next; for (AuctionEntryMap::iterator itr = AuctionsMap.begin(); itr != AuctionsMap.end(); itr = next) { next = itr; ++next; if (itr->second->moneyDeliveryTime) { if (curTime > itr->second->moneyDeliveryTime) { sAuctionMgr.SendAuctionSuccessfulMail(itr->second); itr->second->DeleteFromDB(); sAuctionMgr.RemoveAItem(itr->second->itemGuidLow); delete itr->second; RemoveAuction(itr->first); } } else { if (curTime > itr->second->expireTime) { ///- Either cancel the auction if there was no bidder if (itr->second->bidder == 0) { sAuctionMgr.SendAuctionExpiredMail(itr->second); } ///- Or perform the transaction else { itr->second->moneyDeliveryTime = time(NULL) + HOUR; sAuctionMgr.SendAuctionWonMail(itr->second); continue; } ///- In any case clear the auction itr->second->DeleteFromDB(); sAuctionMgr.RemoveAItem(itr->second->itemGuidLow); delete itr->second; RemoveAuction(itr->first); } } } }
void AuctionHouseObject::Update() { time_t curTime = sWorld.GetGameTime(); ///- Handle expired auctions AuctionEntryMap::iterator next; for (AuctionEntryMap::iterator itr = AuctionsMap.begin(); itr != AuctionsMap.end(); itr = next) { next = itr; ++next; if (curTime > (itr->second->expireTime)) { ///- Either cancel the auction if there was no bidder if (itr->second->bidder == 0) { sAuctionMgr.SendAuctionExpiredMail(itr->second); } ///- Or perform the transaction else { //we should send an "item sold" message if the seller is online //we send the item to the winner //we send the money to the seller sAuctionMgr.SendAuctionSuccessfulMail(itr->second); sAuctionMgr.SendAuctionWonMail(itr->second); } ///- In any case clear the auction itr->second->DeleteFromDB(); sAuctionMgr.RemoveAItem(itr->second->itemGuidLow); delete itr->second; RemoveAuction(itr->first); } } }
void AuctionHouseObject::Update() { time_t curTime = GameTime::GetGameTime(); ///- Handle expired auctions // If storage is empty, no need to update. next == NULL in this case. if (AuctionsMap.empty()) return; // Clear expired throttled players for (PlayerGetAllThrottleMap::const_iterator itr = GetAllThrottleMap.begin(); itr != GetAllThrottleMap.end();) { if (itr->second <= curTime) itr = GetAllThrottleMap.erase(itr); else ++itr; } SQLTransaction trans = CharacterDatabase.BeginTransaction(); for (AuctionEntryMap::iterator it = AuctionsMap.begin(); it != AuctionsMap.end();) { // from auctionhousehandler.cpp, creates auction pointer & player pointer AuctionEntry* auction = it->second; // Increment iterator due to AuctionEntry deletion ++it; ///- filter auctions expired on next update if (auction->expire_time > curTime + 60) continue; ///- Either cancel the auction if there was no bidder if (auction->bidder == 0 && auction->bid == 0) { sAuctionMgr->SendAuctionExpiredMail(auction, trans); sScriptMgr->OnAuctionExpire(this, auction); } ///- Or perform the transaction else { //we should send an "item sold" message if the seller is online //we send the item to the winner //we send the money to the seller sAuctionMgr->SendAuctionSuccessfulMail(auction, trans); sAuctionMgr->SendAuctionWonMail(auction, trans); sScriptMgr->OnAuctionSuccessful(this, auction); } ///- In any case clear the auction auction->DeleteFromDB(trans); sAuctionMgr->RemoveAItem(auction->itemGUIDLow); RemoveAuction(auction); } // Run DB changes CharacterDatabase.CommitTransaction(trans); }
void AuctionHouseObject::Update() { time_t curTime = sWorld.GetGameTime(); ///- Handle expired auctions AuctionEntryMap::iterator next; for (AuctionEntryMap::iterator itr = AuctionsMap.begin(); itr != AuctionsMap.end(); itr = next) { next = itr; ++next; if (itr->second->moneyDeliveryTime) { if (curTime > itr->second->moneyDeliveryTime) { sAuctionMgr.SendAuctionSuccessfulMail(itr->second); itr->second->DeleteFromDB(); MANGOS_ASSERT(!itr->second->itemGuidLow); // already removed or send in mail at won delete itr->second; RemoveAuction(itr->first); } } else { if (curTime > itr->second->expireTime) { ///- perform the transaction if there was bidder if (itr->second->bid) itr->second->AuctionBidWinning(); ///- cancel the auction if there was no bidder and clear the auction else { sAuctionMgr.SendAuctionExpiredMail(itr->second); itr->second->DeleteFromDB(); delete itr->second; RemoveAuction(itr->first); } } } } }
void AuctionHouseObject::Update() { time_t curTime = sWorld->GetGameTime(); ///- Handle expired auctions // If storage is empty, no need to update. next == NULL in this case. if (AuctionsMap.empty()) return; PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_AUCTION_BY_TIME); stmt->setUInt32(0, (uint32)curTime+60); PreparedQueryResult result = CharacterDatabase.Query(stmt); if (!result) return; do { // from auctionhousehandler.cpp, creates auction pointer & player pointer AuctionEntry* auction = GetAuction(result->Fetch()->GetUInt32()); if (!auction) continue; SQLTransaction trans = CharacterDatabase.BeginTransaction(); ///- Either cancel the auction if there was no bidder if (auction->bidder == 0) { sAuctionMgr->SendAuctionExpiredMail(auction, trans); sScriptMgr->OnAuctionExpire(this, auction); } ///- Or perform the transaction else { //we should send an "item sold" message if the seller is online //we send the item to the winner //we send the money to the seller sAuctionMgr->SendAuctionSuccessfulMail(auction, trans); sAuctionMgr->SendAuctionWonMail(auction, trans); sScriptMgr->OnAuctionSuccessful(this, auction); } uint32 itemEntry = auction->itemEntry; ///- In any case clear the auction auction->DeleteFromDB(trans); CharacterDatabase.CommitTransaction(trans); sAuctionMgr->RemoveAItem(auction->itemGUIDLow); RemoveAuction(auction, itemEntry); } while (result->NextRow()); }
void AuctionHouseObject::Update() { time_t curTime = sWorld.GetGameTime(); ///- Handle expired auctions // If storage is empty, no need to update. next == NULL in this case. if (AuctionsMap.empty()) return; // reset next if at end of map if (next == AuctionsMap.end()) next = AuctionsMap.begin(); ASSERT(next != AuctionsMap.end()); uint32 loopBreaker = 0; // Initialize itr with next. next is stored for future calls to Update() after // 50 items are checked for (AuctionEntryMap::const_iterator itr = next; itr != AuctionsMap.end(); itr = next) { next = itr; ++next; if (curTime > (itr->second->expire_time)) { ///- Either cancel the auction if there was no bidder if (itr->second->bidder == 0) { auctionmgr.SendAuctionExpiredMail(itr->second); } ///- Or perform the transaction else { //we should send an "item sold" message if the seller is online //we send the item to the winner //we send the money to the seller auctionmgr.SendAuctionSuccessfulMail(itr->second); auctionmgr.SendAuctionWonMail(itr->second); } ///- In any case clear the auction itr->second->DeleteFromDB(); uint32 item_template = itr->second->item_template; auctionmgr.RemoveAItem(itr->second->item_guidlow); RemoveAuction(itr->second, item_template); } // only check 50 items per update to not peg the CPU ++loopBreaker; if (loopBreaker > 50) break; } }
void AuctionHouse::UpdateDeletionQueue() { removalLock.Acquire(); Auction * auct; list<Auction*>::iterator it = removalList.begin(); for(; it != removalList.end(); ++it) { auct = *it; assert(auct->Deleted); RemoveAuction(auct); } removalList.clear(); removalLock.Release(); }