Update GameTime Methods
This commit is contained in:
@@ -55,7 +55,7 @@ namespace Game
|
||||
mNeutralAuctions = new AuctionHouseObject(1);
|
||||
mGoblinAuctions = new AuctionHouseObject(7);
|
||||
_replicateIdGenerator = 0;
|
||||
_playerThrottleObjectsCleanupTime = GameTime.GetGameTimeSteadyPoint() + TimeSpan.FromHours(1);
|
||||
_playerThrottleObjectsCleanupTime = GameTime.Now() + TimeSpan.FromHours(1);
|
||||
}
|
||||
|
||||
public AuctionHouseObject GetAuctionsMap(uint factionTemplateId)
|
||||
@@ -348,7 +348,7 @@ namespace Game
|
||||
PendingAuctionInfo pendingAuction = playerPendingAuctions.Auctions[auctionIndex];
|
||||
AuctionPosting auction = GetAuctionsById(pendingAuction.AuctionHouseId).GetAuction(pendingAuction.AuctionId);
|
||||
if (auction != null)
|
||||
auction.EndTime = GameTime.GetGameTimeSystemPoint();
|
||||
auction.EndTime = GameTime.GetSystemTime();
|
||||
|
||||
PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.UPD_AUCTION_EXPIRATION);
|
||||
stmt.AddValue(0, (uint)GameTime.GetGameTime());
|
||||
@@ -388,7 +388,7 @@ namespace Game
|
||||
{
|
||||
AuctionPosting auction = GetAuctionsById(pendingAuction.AuctionHouseId).GetAuction(pendingAuction.AuctionId);
|
||||
if (auction != null)
|
||||
auction.EndTime = GameTime.GetGameTimeSystemPoint();
|
||||
auction.EndTime = GameTime.GetSystemTime();
|
||||
|
||||
PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.UPD_AUCTION_EXPIRATION);
|
||||
stmt.AddValue(0, (uint)GameTime.GetGameTime());
|
||||
@@ -408,7 +408,7 @@ namespace Game
|
||||
mNeutralAuctions.Update();
|
||||
mGoblinAuctions.Update();
|
||||
|
||||
DateTime now = GameTime.GetGameTimeSteadyPoint();
|
||||
DateTime now = GameTime.Now();
|
||||
if (now >= _playerThrottleObjectsCleanupTime)
|
||||
{
|
||||
foreach (var pair in _playerThrottleObjects.ToList())
|
||||
@@ -428,7 +428,7 @@ namespace Game
|
||||
|
||||
public AuctionThrottleResult CheckThrottle(Player player, bool addonTainted, AuctionCommand command = AuctionCommand.SellItem)
|
||||
{
|
||||
DateTime now = GameTime.GetGameTimeSteadyPoint();
|
||||
DateTime now = GameTime.Now();
|
||||
|
||||
if (!_playerThrottleObjects.ContainsKey(player.GetGUID()))
|
||||
_playerThrottleObjects[player.GetGUID()] = new PlayerThrottleObject();
|
||||
@@ -768,8 +768,8 @@ namespace Game
|
||||
|
||||
public void Update()
|
||||
{
|
||||
DateTime curTime = GameTime.GetGameTimeSystemPoint();
|
||||
DateTime curTimeSteady = GameTime.GetGameTimeSteadyPoint();
|
||||
DateTime curTime = GameTime.GetSystemTime();
|
||||
DateTime curTimeSteady = GameTime.Now();
|
||||
///- Handle expired auctions
|
||||
|
||||
// Clear expired throttled players
|
||||
@@ -1092,7 +1092,7 @@ namespace Game
|
||||
|
||||
public void BuildReplicate(AuctionReplicateResponse replicateResponse, Player player, uint global, uint cursor, uint tombstone, uint count)
|
||||
{
|
||||
DateTime curTime = GameTime.GetGameTimeSteadyPoint();
|
||||
DateTime curTime = GameTime.Now();
|
||||
|
||||
var throttleData = _replicateThrottleMap.LookupByKey(player.GetGUID());
|
||||
if (throttleData == null)
|
||||
@@ -1172,7 +1172,7 @@ namespace Game
|
||||
CommodityQuote quote = _commodityQuotes[player.GetGUID()];
|
||||
quote.TotalPrice = totalPrice;
|
||||
quote.Quantity = quantity;
|
||||
quote.ValidTo = GameTime.GetGameTimeSteadyPoint() + TimeSpan.FromSeconds(30);
|
||||
quote.ValidTo = GameTime.Now() + TimeSpan.FromSeconds(30);
|
||||
return quote;
|
||||
}
|
||||
|
||||
@@ -1698,7 +1698,7 @@ namespace Game
|
||||
}
|
||||
|
||||
// all (not optional<>)
|
||||
auctionItem.DurationLeft = (int)Math.Max((EndTime - GameTime.GetGameTimeSystemPoint()).ToMilliseconds(), 0L);
|
||||
auctionItem.DurationLeft = (int)Math.Max((EndTime - GameTime.GetSystemTime()).ToMilliseconds(), 0L);
|
||||
auctionItem.DeleteReason = 0;
|
||||
|
||||
// SMSG_AUCTION_LIST_ITEMS_RESULT (only if owned)
|
||||
|
||||
@@ -3881,7 +3881,7 @@ namespace Game.Entities
|
||||
if (pItem.GetTemplate().HasFlag(ItemFlags.NoEquipCooldown))
|
||||
return;
|
||||
|
||||
DateTime now = GameTime.GetGameTimeSteadyPoint();
|
||||
DateTime now = GameTime.Now();
|
||||
foreach (ItemEffectRecord effectData in pItem.GetEffects())
|
||||
{
|
||||
SpellInfo effectSpellInfo = Global.SpellMgr.GetSpellInfo((uint)effectData.SpellID, Difficulty.None);
|
||||
|
||||
@@ -1487,7 +1487,7 @@ namespace Game.Entities
|
||||
|
||||
void GetProcAurasTriggeredOnEvent(List<Tuple<uint, AuraApplication>> aurasTriggeringProc, List<AuraApplication> procAuras, ProcEventInfo eventInfo)
|
||||
{
|
||||
DateTime now = GameTime.GetGameTimeSteadyPoint();
|
||||
DateTime now = GameTime.Now();
|
||||
|
||||
// use provided list of auras which can proc
|
||||
if (procAuras != null)
|
||||
|
||||
@@ -658,7 +658,7 @@ namespace Game
|
||||
auction.OwnerAccount = GetAccountGUID();
|
||||
auction.BuyoutOrUnitPrice = sellCommodity.UnitPrice;
|
||||
auction.Deposit = deposit;
|
||||
auction.StartTime = GameTime.GetGameTimeSystemPoint();
|
||||
auction.StartTime = GameTime.GetSystemTime();
|
||||
auction.EndTime = auction.StartTime + auctionTime;
|
||||
|
||||
// keep track of what was cloned to undo/modify counts later
|
||||
@@ -853,7 +853,7 @@ namespace Game
|
||||
auction.BuyoutOrUnitPrice = sellItem.BuyoutPrice;
|
||||
auction.Deposit = deposit;
|
||||
auction.BidAmount = sellItem.MinBid;
|
||||
auction.StartTime = GameTime.GetGameTimeSystemPoint();
|
||||
auction.StartTime = GameTime.GetSystemTime();
|
||||
auction.EndTime = auction.StartTime + auctionTime;
|
||||
|
||||
if (HasPermission(RBACPermissions.LogGmTrade))
|
||||
@@ -951,7 +951,7 @@ namespace Game
|
||||
{
|
||||
commodityQuoteResult.TotalPrice = quote.TotalPrice;
|
||||
commodityQuoteResult.Quantity = quote.Quantity;
|
||||
commodityQuoteResult.QuoteDuration = (int)(quote.ValidTo - GameTime.GetGameTimeSteadyPoint()).TotalMilliseconds;
|
||||
commodityQuoteResult.QuoteDuration = (int)(quote.ValidTo - GameTime.Now()).TotalMilliseconds;
|
||||
}
|
||||
|
||||
commodityQuoteResult.ItemID = getCommodityQuote.ItemID;
|
||||
|
||||
@@ -1882,7 +1882,7 @@ namespace Game.Spells
|
||||
float ppm = m_spellInfo.CalcProcPPM(actor, GetCastItemLevel());
|
||||
float averageProcInterval = 60.0f / ppm;
|
||||
|
||||
var currentTime = GameTime.GetGameTimeSteadyPoint();
|
||||
var currentTime = GameTime.Now();
|
||||
float secondsSinceLastAttempt = Math.Min((float)(currentTime - m_lastProcAttemptTime).TotalSeconds, 10.0f);
|
||||
float secondsSinceLastProc = Math.Min((float)(currentTime - m_lastProcSuccessTime).TotalSeconds, 1000.0f);
|
||||
|
||||
|
||||
@@ -166,7 +166,7 @@ namespace Game.Spells
|
||||
|
||||
public void Update()
|
||||
{
|
||||
DateTime now = GameTime.GetGameTimeSystemPoint();
|
||||
DateTime now = GameTime.GetSystemTime();
|
||||
foreach (var pair in _categoryCooldowns.ToList())
|
||||
{
|
||||
if (pair.Value.CategoryEnd < now)
|
||||
@@ -240,7 +240,7 @@ namespace Game.Spells
|
||||
|
||||
public void WritePacket(SendSpellHistory sendSpellHistory)
|
||||
{
|
||||
DateTime now = GameTime.GetGameTimeSystemPoint();
|
||||
DateTime now = GameTime.GetSystemTime();
|
||||
foreach (var p in _spellCooldowns)
|
||||
{
|
||||
SpellHistoryEntry historyEntry = new();
|
||||
@@ -272,7 +272,7 @@ namespace Game.Spells
|
||||
|
||||
public void WritePacket(SendSpellCharges sendSpellCharges)
|
||||
{
|
||||
DateTime now = GameTime.GetGameTimeSystemPoint();
|
||||
DateTime now = GameTime.GetSystemTime();
|
||||
foreach (var key in _categoryCharges.Keys)
|
||||
{
|
||||
var list = _categoryCharges[key];
|
||||
@@ -293,7 +293,7 @@ namespace Game.Spells
|
||||
|
||||
public void WritePacket(PetSpells petSpells)
|
||||
{
|
||||
DateTime now = GameTime.GetGameTimeSystemPoint();
|
||||
DateTime now = GameTime.GetSystemTime();
|
||||
|
||||
foreach (var pair in _spellCooldowns)
|
||||
{
|
||||
@@ -344,7 +344,7 @@ namespace Game.Spells
|
||||
TimeSpan cooldown = TimeSpan.Zero;
|
||||
TimeSpan categoryCooldown = TimeSpan.Zero;
|
||||
|
||||
DateTime curTime = GameTime.GetGameTimeSystemPoint();
|
||||
DateTime curTime = GameTime.GetSystemTime();
|
||||
DateTime catrecTime;
|
||||
DateTime recTime;
|
||||
bool needsCooldownPacket = false;
|
||||
@@ -428,7 +428,7 @@ namespace Game.Spells
|
||||
|
||||
SpellCategoryRecord categoryEntry = CliDB.SpellCategoryStorage.LookupByKey(categoryId);
|
||||
if (categoryEntry.Flags.HasAnyFlag(SpellCategoryFlags.CooldownExpiresAtDailyReset))
|
||||
categoryCooldown = Time.UnixTimeToDateTime(Global.WorldMgr.GetNextDailyQuestsResetTime()) - GameTime.GetGameTimeSystemPoint();
|
||||
categoryCooldown = Time.UnixTimeToDateTime(Global.WorldMgr.GetNextDailyQuestsResetTime()) - GameTime.GetSystemTime();
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -496,7 +496,7 @@ namespace Game.Spells
|
||||
|
||||
public void AddCooldown(uint spellId, uint itemId, TimeSpan cooldownDuration)
|
||||
{
|
||||
DateTime now = GameTime.GetGameTimeSystemPoint();
|
||||
DateTime now = GameTime.GetSystemTime();
|
||||
AddCooldown(spellId, itemId, now + cooldownDuration, 0, now);
|
||||
}
|
||||
|
||||
@@ -525,7 +525,7 @@ namespace Game.Spells
|
||||
if (offset.TotalMilliseconds == 0 || cooldownEntry == null)
|
||||
return;
|
||||
|
||||
DateTime now = GameTime.GetGameTimeSystemPoint();
|
||||
DateTime now = GameTime.GetSystemTime();
|
||||
|
||||
cooldownEntry.CooldownEnd += offset;
|
||||
|
||||
@@ -670,7 +670,7 @@ namespace Game.Spells
|
||||
end = cooldownEntry.CategoryEnd;
|
||||
}
|
||||
|
||||
DateTime now = GameTime.GetGameTimeSystemPoint();
|
||||
DateTime now = GameTime.GetSystemTime();
|
||||
if (end < now)
|
||||
return TimeSpan.Zero;
|
||||
|
||||
@@ -687,7 +687,7 @@ namespace Game.Spells
|
||||
|
||||
end = cooldownEntry.CategoryEnd;
|
||||
|
||||
DateTime now = GameTime.GetGameTimeSystemPoint();
|
||||
DateTime now = GameTime.GetSystemTime();
|
||||
if (end < now)
|
||||
return TimeSpan.Zero;
|
||||
|
||||
@@ -702,7 +702,7 @@ namespace Game.Spells
|
||||
|
||||
public void LockSpellSchool(SpellSchoolMask schoolMask, TimeSpan lockoutTime)
|
||||
{
|
||||
DateTime now = GameTime.GetGameTimeSystemPoint();
|
||||
DateTime now = GameTime.GetSystemTime();
|
||||
DateTime lockoutEnd = now + lockoutTime;
|
||||
for (int i = 0; i < (int)SpellSchools.Max; ++i)
|
||||
if (Convert.ToBoolean((SpellSchoolMask)(1 << i) & schoolMask))
|
||||
@@ -761,7 +761,7 @@ namespace Game.Spells
|
||||
|
||||
public bool IsSchoolLocked(SpellSchoolMask schoolMask)
|
||||
{
|
||||
DateTime now = GameTime.GetGameTimeSystemPoint();
|
||||
DateTime now = GameTime.GetSystemTime();
|
||||
for (int i = 0; i < (int)SpellSchools.Max; ++i)
|
||||
if (Convert.ToBoolean((SpellSchoolMask)(1 << i) & schoolMask))
|
||||
if (_schoolLockouts[i] > now)
|
||||
@@ -781,7 +781,7 @@ namespace Game.Spells
|
||||
DateTime recoveryStart;
|
||||
var charges = _categoryCharges.LookupByKey(chargeCategoryId);
|
||||
if (charges.Empty())
|
||||
recoveryStart = GameTime.GetGameTimeSystemPoint();
|
||||
recoveryStart = GameTime.GetSystemTime();
|
||||
else
|
||||
recoveryStart = charges.Last().RechargeEnd;
|
||||
|
||||
@@ -802,7 +802,7 @@ namespace Game.Spells
|
||||
if (chargeList == null || chargeList.Empty())
|
||||
return;
|
||||
|
||||
var now = GameTime.GetGameTimeSystemPoint();
|
||||
var now = GameTime.GetSystemTime();
|
||||
|
||||
for (var i = 0; i < chargeList.Count; ++i)
|
||||
{
|
||||
@@ -910,12 +910,12 @@ namespace Game.Spells
|
||||
|
||||
public bool HasGlobalCooldown(SpellInfo spellInfo)
|
||||
{
|
||||
return _globalCooldowns.ContainsKey(spellInfo.StartRecoveryCategory) && _globalCooldowns[spellInfo.StartRecoveryCategory] > GameTime.GetGameTimeSystemPoint();
|
||||
return _globalCooldowns.ContainsKey(spellInfo.StartRecoveryCategory) && _globalCooldowns[spellInfo.StartRecoveryCategory] > GameTime.GetSystemTime();
|
||||
}
|
||||
|
||||
public void AddGlobalCooldown(SpellInfo spellInfo, TimeSpan durationMs)
|
||||
{
|
||||
_globalCooldowns[spellInfo.StartRecoveryCategory] = GameTime.GetGameTimeSystemPoint() + durationMs;
|
||||
_globalCooldowns[spellInfo.StartRecoveryCategory] = GameTime.GetSystemTime() + durationMs;
|
||||
}
|
||||
|
||||
public void CancelGlobalCooldown(SpellInfo spellInfo)
|
||||
@@ -1032,7 +1032,7 @@ namespace Game.Spells
|
||||
|
||||
foreach (var c in _spellCooldowns)
|
||||
{
|
||||
DateTime now = GameTime.GetGameTimeSystemPoint();
|
||||
DateTime now = GameTime.GetSystemTime();
|
||||
uint cooldownDuration = c.Value.CooldownEnd > now ? (uint)(c.Value.CooldownEnd - now).TotalMilliseconds : 0;
|
||||
|
||||
// cooldownDuration must be between 0 and 10 minutes in order to avoid any visual bugs
|
||||
|
||||
@@ -27,12 +27,12 @@ public class GameTime
|
||||
return _gameMSTime;
|
||||
}
|
||||
|
||||
public static DateTime GetGameTimeSystemPoint()
|
||||
public static DateTime GetSystemTime()
|
||||
{
|
||||
return _gameTimeSystemPoint;
|
||||
}
|
||||
|
||||
public static DateTime GetGameTimeSteadyPoint()
|
||||
public static DateTime Now()
|
||||
{
|
||||
return _gameTimeSteadyPoint;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user