diff options
author | maximius <none@none> | 2009-10-12 18:54:43 -0700 |
---|---|---|
committer | maximius <none@none> | 2009-10-12 18:54:43 -0700 |
commit | 404dacaaa56762d9f0eb005126c35cd39d09e1c4 (patch) | |
tree | 2ff3f768b9ff325cfe30a2191ac6955563dac686 | |
parent | 8d59bf8179fcc936e9296910c680429a70347c77 (diff) |
*Select only expired auctions when updating, by Paradox
*Remove some useless code from AHBot, by Paradox
--HG--
branch : trunk
-rw-r--r-- | src/game/AuctionHouseBot.cpp | 6 | ||||
-rw-r--r-- | src/game/AuctionHouseBot.h | 23 | ||||
-rw-r--r-- | src/game/AuctionHouseMgr.cpp | 103 |
3 files changed, 60 insertions, 72 deletions
diff --git a/src/game/AuctionHouseBot.cpp b/src/game/AuctionHouseBot.cpp index 663e2f24089..cef09af8252 100644 --- a/src/game/AuctionHouseBot.cpp +++ b/src/game/AuctionHouseBot.cpp @@ -1,17 +1,12 @@ #include "ObjectMgr.h" #include "AuctionHouseMgr.h" #include "AuctionHouseBot.h" -#if CLIENT_VER > 300 -#else if CLIENT_VER > 100 #include <vector> -#endif #include "Policies/SingletonImp.h" INSTANTIATE_SINGLETON_1(AuctionHouseBot); using namespace std; -#if CLIENT_VER > 300 -#else if CLIENT_VER > 100 vector<uint32> npcItems; vector<uint32> lootItems; vector<uint32> greyTradeGoodsBin; @@ -28,7 +23,6 @@ vector<uint32> blueItemsBin; vector<uint32> purpleItemsBin; vector<uint32> orangeItemsBin; vector<uint32> yellowItemsBin; -#endif AuctionHouseBot::AuctionHouseBot() { debug_Out = false; diff --git a/src/game/AuctionHouseBot.h b/src/game/AuctionHouseBot.h index f996a45bb9a..d135af5c479 100644 --- a/src/game/AuctionHouseBot.h +++ b/src/game/AuctionHouseBot.h @@ -4,11 +4,6 @@ #include "World.h" #include "Config/ConfigEnv.h" #include "ItemPrototype.h" -#if CLIENT_VER > 300 -#include "ace/Vector_T.h" -#else if CLIENT_VER > 100 -#include <vector> -#endif #define AHB_GREY 0 #define AHB_WHITE 1 @@ -1131,24 +1126,6 @@ public: class AuctionHouseBot { private: -#if CLIENT_VER > 300 - ACE_Vector<uint32> npcItems; - ACE_Vector<uint32> lootItems; - ACE_Vector<uint32> greyTradeGoodsBin; - ACE_Vector<uint32> whiteTradeGoodsBin; - ACE_Vector<uint32> greenTradeGoodsBin; - ACE_Vector<uint32> blueTradeGoodsBin; - ACE_Vector<uint32> purpleTradeGoodsBin; - ACE_Vector<uint32> orangeTradeGoodsBin; - ACE_Vector<uint32> yellowTradeGoodsBin; - ACE_Vector<uint32> greyItemsBin; - ACE_Vector<uint32> whiteItemsBin; - ACE_Vector<uint32> greenItemsBin; - ACE_Vector<uint32> blueItemsBin; - ACE_Vector<uint32> purpleItemsBin; - ACE_Vector<uint32> orangeItemsBin; - ACE_Vector<uint32> yellowItemsBin; -#endif bool debug_Out; bool debug_Out_Filters; diff --git a/src/game/AuctionHouseMgr.cpp b/src/game/AuctionHouseMgr.cpp index 4fb8398e694..635d56e4bf5 100644 --- a/src/game/AuctionHouseMgr.cpp +++ b/src/game/AuctionHouseMgr.cpp @@ -33,10 +33,13 @@ #include "Language.h" #include "Log.h" #include "ProgressBar.h" +#include <vector> INSTANTIATE_SINGLETON_1(AuctionHouseMgr); +using namespace std; + AuctionHouseMgr::AuctionHouseMgr() { } @@ -71,13 +74,10 @@ uint32 AuctionHouseMgr::GetAuctionDeposit(AuctionHouseEntry const* entry, uint32 uint32 timeHr = (((time / 60) / 60) / 12); if (MSV > 0) - { deposit = (int32)floor((double)MSV * (((double)(entry->depositPercent * 3) / 100.0f * (double)sWorld.getRate(RATE_AUCTION_DEPOSIT) * (double)pItem->GetCount()))) * timeHr; - } else - { deposit = 0; - } + sLog.outDebug("SellPrice:\t\t%u", MSV); sLog.outDebug("Deposit Percent:\t%f", ((double)entry->depositPercent / 100.0f)); sLog.outDebug("Auction Time1:\t\t%u", time); @@ -309,8 +309,7 @@ void AuctionHouseMgr::LoadAuctionItems() AddAItem(item); ++count; - } - while(result->NextRow()); + } while (result->NextRow()); delete result; sLog.outString(); @@ -433,9 +432,8 @@ bool AuctionHouseMgr::RemoveAItem(uint32 id) { ItemMap::iterator i = mAitems.find(id); if (i == mAitems.end()) - { return false; - } + mAitems.erase(i); return true; } @@ -508,49 +506,66 @@ void AuctionHouseObject::Update() if (AuctionsMap.empty()) return; - // reset next if at end of map - if (next == AuctionsMap.end()) - next = AuctionsMap.begin(); + QueryResult* result = CharacterDatabase.PQuery("SELECT id FROM auctionhouse WHERE time <= %u ORDER BY TIME ASC", (uint32)curTime); + + if (!result) + { + delete result; + return; + } - ASSERT(next != AuctionsMap.end()); + if (result->GetRowCount() == 0) + { + delete result; + return; + } - uint32 loopBreaker = 0; + vector<uint32> expiredAuctions; - // 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) + do { - 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); - } + uint32 tmpdata = result->Fetch()->GetUInt32(); + expiredAuctions.push_back(tmpdata); + } while (result->NextRow()); + delete result; - ///- 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); + vector<uint32>::iterator iter = expiredAuctions.begin(); + for (uint32 count = 1;count <= 50;++count) + { + // Do we have any expired auctions? If not, stop here. + if (expiredAuctions.empty()) + { + count = 50; + continue; } - // only check 50 items per update to not peg the CPU - ++loopBreaker; + // from auctionhousehandler.cpp, creates auction pointer & player pointer + AuctionEntry* auction = GetAuction(*iter); - if (loopBreaker > 50) - break; + // Erase the auction from the vector. + expiredAuctions.erase(iter); + + if (!auction) + continue; + + ///- Either cancel the auction if there was no bidder + if (auction->bidder == 0) + auctionmgr.SendAuctionExpiredMail(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 + auctionmgr.SendAuctionSuccessfulMail(auction); + auctionmgr.SendAuctionWonMail(auction); + } + + ///- In any case clear the auction + auction->DeleteFromDB(); + uint32 item_template = auction->item_template; + auctionmgr.RemoveAItem(auction->item_guidlow); + RemoveAuction(auction, item_template); } } @@ -563,6 +578,7 @@ void AuctionHouseObject::BuildListBidderItems(WorldPacket& data, Player* player, { if (itr->second->BuildAuctionInfo(data)) ++count; + ++totalcount; } } @@ -577,6 +593,7 @@ void AuctionHouseObject::BuildListOwnerItems(WorldPacket& data, Player* player, { if (Aentry->BuildAuctionInfo(data)) ++count; + ++totalcount; } } |