feat(core): Ensure that all actions are compared to fixed point in time (#1236) (#1458)

i.e. world update start
This commit is contained in:
Viste(Кирилл)
2019-02-14 21:22:17 +03:00
committed by Francesco Borzì
parent 1b7522ff0e
commit 51b8773528
108 changed files with 933 additions and 509 deletions

View File

@@ -18,6 +18,7 @@
#include "Item.h"
#include "Language.h"
#include "Logging/Log.h"
#include "GameTime.h"
#include <vector>
#include "AvgDiffTracker.h"
#include "AsyncAuctionListing.h"
@@ -424,7 +425,7 @@ bool AuctionHouseObject::RemoveAuction(AuctionEntry* auction)
void AuctionHouseObject::Update()
{
time_t checkTime = sWorld->GetGameTime() + 60;
time_t checkTime = GameTime::GetGameTime() + 60;
///- Handle expired auctions
// If storage is empty, no need to update. next == NULL in this case.
@@ -522,7 +523,7 @@ bool AuctionHouseObject::BuildListAuctionItems(WorldPacket& data, Player* player
return true;
}
time_t curTime = sWorld->GetGameTime();
time_t curTime = GameTime::GetGameTime();
int loc_idx = player->GetSession()->GetSessionDbLocaleIndex();
int locdbc_idx = player->GetSession()->GetSessionDbcLocale();
@@ -531,7 +532,7 @@ bool AuctionHouseObject::BuildListAuctionItems(WorldPacket& data, Player* player
{
if (AsyncAuctionListingMgr::IsAuctionListingAllowed() == false) // pussywizard: World::Update is waiting for us...
if ((itrcounter++) % 100 == 0) // check condition every 100 iterations
if (avgDiffTracker.getAverage() >= 30 || getMSTimeDiff(World::GetGameTimeMS(), getMSTime()) >= 10) // pussywizard: stop immediately if diff is high or waiting too long
if (avgDiffTracker.getAverage() >= 30 || getMSTimeDiff(GameTime::GetGameTimeMS(), getMSTime()) >= 10) // pussywizard: stop immediately if diff is high or waiting too long
return false;
AuctionEntry* Aentry = itr->second;
@@ -669,7 +670,7 @@ bool AuctionEntry::BuildAuctionInfo(WorldPacket& data) const
data << uint32(bid ? GetAuctionOutBid() : 0);
// Minimal outbid
data << uint32(buyout); // Auction->buyout
data << uint32((expire_time - time(NULL)) * IN_MILLISECONDS); // time left
data << uint32((expire_time - GameTime::GetGameTime()) * IN_MILLISECONDS); // time left
data << uint64(bidder); // auction->bidder current
data << uint32(bid); // current bid
return true;