diff options
author | maximius <none@none> | 2009-09-19 16:01:08 -0700 |
---|---|---|
committer | maximius <none@none> | 2009-09-19 16:01:08 -0700 |
commit | ec054272e1ded02f7dadfa84b5f0f93e53f52fc8 (patch) | |
tree | d04ba34739a7cf7eaed4fb4e2f98b8f5ef8711a8 /src/game/AuctionHouseMgr.cpp | |
parent | 22869c7a47315c9f1568b14c4d960bf1d3f345c4 (diff) |
*GO - Southfury Moonstone script, from SD2, patch by manuel
*Fix Auctionhouse CPU usage during item expire check, by MrSmite
--HG--
branch : trunk
Diffstat (limited to 'src/game/AuctionHouseMgr.cpp')
-rw-r--r-- | src/game/AuctionHouseMgr.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/game/AuctionHouseMgr.cpp b/src/game/AuctionHouseMgr.cpp index 85bc815efd1..2edaa3f374c 100644 --- a/src/game/AuctionHouseMgr.cpp +++ b/src/game/AuctionHouseMgr.cpp @@ -537,8 +537,16 @@ 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) + + // reset next if at end of map + if (next == AuctionsMap.end()) + next = AuctionsMap.begin(); + + 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; @@ -565,6 +573,12 @@ void AuctionHouseObject::Update() delete itr->second; RemoveAuction(itr->first); } + + // only check 50 items per update to not peg the CPU + ++loopBreaker; + + if (loopBreaker > 50) + break; } } |